aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-25 11:57:38 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-25 16:55:34 +0000
commitd304be1945067c24830c9210bc03638f4f4b3a12 (patch)
treef5d093fc169c4a2a8ca951836be234812ff0a46b
parentf9a3c30b1e96d8288068dbea0ea7c4447f3654bb (diff)
downloadpaludis-d304be1945067c24830c9210bc03638f4f4b3a12.tar.gz
paludis-d304be1945067c24830c9210bc03638f4f4b3a12.tar.xz
gtest more
-rw-r--r--paludis/repositories/unwritten/Makefile.am4
-rw-r--r--paludis/repositories/unwritten/unwritten_repository_TEST.cc138
2 files changed, 67 insertions, 75 deletions
diff --git a/paludis/repositories/unwritten/Makefile.am b/paludis/repositories/unwritten/Makefile.am
index 5e2a18d..9e606a4 100644
--- a/paludis/repositories/unwritten/Makefile.am
+++ b/paludis/repositories/unwritten/Makefile.am
@@ -30,13 +30,15 @@ libpaludisunwrittenrepository_la_SOURCES = \
unwritten_repository_TEST_SOURCES = unwritten_repository_TEST.cc
unwritten_repository_TEST_LDADD = \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
- $(top_builddir)/test/libtest.a \
$(DYNAMIC_LD_LIBS)
unwritten_repository_TEST_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+unwritten_repository_TEST_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
EXTRA_DIST = \
unwritten_repository_TEST.cc \
unwritten_repository_TEST_setup.sh \
diff --git a/paludis/repositories/unwritten/unwritten_repository_TEST.cc b/paludis/repositories/unwritten/unwritten_repository_TEST.cc
index 2d9aa17..0df4c71 100644
--- a/paludis/repositories/unwritten/unwritten_repository_TEST.cc
+++ b/paludis/repositories/unwritten/unwritten_repository_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2010 Ciaran McCreesh
+ * Copyright (c) 2008, 2010, 2011 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -18,13 +18,16 @@
*/
#include <paludis/repositories/unwritten/unwritten_repository.hh>
+
#include <paludis/environments/test/test_environment.hh>
+
#include <paludis/util/sequence.hh>
#include <paludis/util/join.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/map.hh>
+
#include <paludis/generator.hh>
#include <paludis/selection.hh>
#include <paludis/filtered_generator.hh>
@@ -32,13 +35,13 @@
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
#include <paludis/package_database.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
+
#include <memory>
+#include <gtest/gtest.h>
+
using namespace paludis;
using namespace paludis::unwritten_repository;
-using namespace test;
namespace
{
@@ -48,80 +51,67 @@ namespace
}
}
-namespace test_cases
+TEST(UnwrittenRepository, Creation)
{
- struct UnwrittenRepositoryCreationTest : TestCase
- {
- UnwrittenRepositoryCreationTest() : TestCase("creation") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<UnwrittenRepository> repo(std::make_shared<UnwrittenRepository>(
- make_named_values<UnwrittenRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath::cwd() / "unwritten_repository_TEST_dir" / "repo1",
- n::name() = RepositoryName("unwritten"),
- n::sync() = std::make_shared<Map<std::string, std::string> >(),
- n::sync_options() = std::make_shared<Map<std::string, std::string> >()
- )));
- env.package_database()->add_repository(1, repo);
- TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "unwritten");
- }
- } test_creation;
-
- struct UnwrittenRepositoryContentsTest : TestCase
- {
- UnwrittenRepositoryContentsTest() : TestCase("contents") { }
+ TestEnvironment env;
+ std::shared_ptr<UnwrittenRepository> repo(std::make_shared<UnwrittenRepository>(
+ make_named_values<UnwrittenRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath::cwd() / "unwritten_repository_TEST_dir" / "repo1",
+ n::name() = RepositoryName("unwritten"),
+ n::sync() = std::make_shared<Map<std::string, std::string> >(),
+ n::sync_options() = std::make_shared<Map<std::string, std::string> >()
+ )));
+ env.package_database()->add_repository(1, repo);
+ EXPECT_EQ("unwritten", stringify(repo->name()));
+}
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<UnwrittenRepository> repo(std::make_shared<UnwrittenRepository>(
- make_named_values<UnwrittenRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath::cwd() / "unwritten_repository_TEST_dir" / "repo2",
- n::name() = RepositoryName("unwritten"),
- n::sync() = std::make_shared<Map<std::string, std::string> >(),
- n::sync_options() = std::make_shared<Map<std::string, std::string> >()
- )));
- env.package_database()->add_repository(1, repo);
- TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "unwritten");
+TEST(UnwrittenRepository, Contents)
+{
+ TestEnvironment env;
+ std::shared_ptr<UnwrittenRepository> repo(std::make_shared<UnwrittenRepository>(
+ make_named_values<UnwrittenRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath::cwd() / "unwritten_repository_TEST_dir" / "repo2",
+ n::name() = RepositoryName("unwritten"),
+ n::sync() = std::make_shared<Map<std::string, std::string> >(),
+ n::sync_options() = std::make_shared<Map<std::string, std::string> >()
+ )));
+ env.package_database()->add_repository(1, repo);
+ EXPECT_EQ("unwritten", stringify(repo->name()));
- std::shared_ptr<const PackageIDSequence> contents(
- env[selection::AllVersionsSorted(generator::All())]);
- TEST_CHECK(bool(contents));
+ std::shared_ptr<const PackageIDSequence> contents(
+ env[selection::AllVersionsSorted(generator::All())]);
+ ASSERT_TRUE(bool(contents));
- TEST_CHECK_EQUAL(
- join(indirect_iterator(contents->begin()), indirect_iterator(contents->end()), " "),
- "cat-one/pkg-one-1:0::unwritten "
- "cat-one/pkg-one-2:0::unwritten "
- "cat-one/pkg-one-3:0::unwritten "
- "cat-one/pkg-three-1:1::unwritten "
- "cat-one/pkg-three-2:1::unwritten "
- "cat-one/pkg-three-3:1::unwritten "
- "cat-one/pkg-three-4:2::unwritten "
- "cat-one/pkg-three-5:2::unwritten "
- "cat-one/pkg-three-6:2::unwritten "
- "cat-one/pkg-two-1:1::unwritten "
- "cat-one/pkg-two-2:2::unwritten"
- );
+ EXPECT_EQ(
+ "cat-one/pkg-one-1:0::unwritten "
+ "cat-one/pkg-one-2:0::unwritten "
+ "cat-one/pkg-one-3:0::unwritten "
+ "cat-one/pkg-three-1:1::unwritten "
+ "cat-one/pkg-three-2:1::unwritten "
+ "cat-one/pkg-three-3:1::unwritten "
+ "cat-one/pkg-three-4:2::unwritten "
+ "cat-one/pkg-three-5:2::unwritten "
+ "cat-one/pkg-three-6:2::unwritten "
+ "cat-one/pkg-two-1:1::unwritten "
+ "cat-one/pkg-two-2:2::unwritten",
+ join(indirect_iterator(contents->begin()), indirect_iterator(contents->end()), " ")
+ );
- TEST_CHECK_EQUAL(
- join(indirect_iterator(contents->begin()), indirect_iterator(contents->end()), " ", visit),
- "Description for pkg-one-1:0 "
- "Description for pkg-one-2:0 "
- "Description for pkg-one-3:0 "
- "Description for pkg-three:1 "
- "Description for pkg-three:1 "
- "Description for pkg-three:1 "
- "Description for pkg-three:2 "
- "Description for pkg-three:2 "
- "Description for pkg-three:2 "
- "Description for pkg-two-1:1 "
- "Description for pkg-two-2:2"
- );
- }
- } test_contents;
+ EXPECT_EQ(
+ "Description for pkg-one-1:0 "
+ "Description for pkg-one-2:0 "
+ "Description for pkg-one-3:0 "
+ "Description for pkg-three:1 "
+ "Description for pkg-three:1 "
+ "Description for pkg-three:1 "
+ "Description for pkg-three:2 "
+ "Description for pkg-three:2 "
+ "Description for pkg-three:2 "
+ "Description for pkg-two-1:1 "
+ "Description for pkg-two-2:2",
+ join(indirect_iterator(contents->begin()), indirect_iterator(contents->end()), " ", visit)
+ );
}