aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 20:35:26 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 20:35:26 +0000
commit737aa23d23897fecf794e9ad4b4e620ce8bf3d71 (patch)
tree48a6c40c24428bac372625b78ae3bb8dcf1eee95
parent264ff74a1af6fb3a2466de40611e2c2c104e1fe7 (diff)
downloadpaludis-737aa23d23897fecf794e9ad4b4e620ce8bf3d71.tar.gz
paludis-737aa23d23897fecf794e9ad4b4e620ce8bf3d71.tar.xz
gtest more
-rw-r--r--paludis/repositories/e/Makefile.am4
-rw-r--r--paludis/repositories/e/source_uri_finder_TEST.cc115
2 files changed, 55 insertions, 64 deletions
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index c0aa9c2..d508509 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -416,13 +416,15 @@ fetch_visitor_TEST_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
source_uri_finder_TEST_SOURCES = source_uri_finder_TEST.cc
source_uri_finder_TEST_LDADD = \
- $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/test/libtest.a \
$(DYNAMIC_LD_LIBS)
source_uri_finder_TEST_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+source_uri_finder_TEST_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
fix_locked_dependencies_TEST_SOURCES = fix_locked_dependencies_TEST.cc
fix_locked_dependencies_TEST_LDADD = \
diff --git a/paludis/repositories/e/source_uri_finder_TEST.cc b/paludis/repositories/e/source_uri_finder_TEST.cc
index 693a875..089941d 100644
--- a/paludis/repositories/e/source_uri_finder_TEST.cc
+++ b/paludis/repositories/e/source_uri_finder_TEST.cc
@@ -18,15 +18,17 @@
*/
#include <paludis/repositories/e/source_uri_finder.hh>
+
#include <paludis/environments/test/test_environment.hh>
+
#include <paludis/repositories/fake/fake_repository.hh>
+
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/sequence.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
-using namespace test;
+#include <gtest/gtest.h>
+
using namespace paludis;
using namespace paludis::erepository;
@@ -44,83 +46,70 @@ namespace
}
}
-namespace test_cases
+TEST(SourceURIFinder, Works)
{
- struct SourceURIFinderTest : TestCase
- {
- SourceURIFinderTest() : TestCase("source uri finder") { }
+ TestEnvironment env;
+ const std::shared_ptr<FakeRepository> repo(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("repo")
+ )));
+ env.add_repository(1, repo);
- void run()
- {
- TestEnvironment env;
- const std::shared_ptr<FakeRepository> repo(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("repo")
- )));
- env.add_repository(1, repo);
+ SourceURIFinder f(&env, repo.get(), "http://example.com/path/input", "output", "monkey",
+ get_mirrors_fn);
+ URIMirrorsThenListedLabel label("mirrors-then-listed");
+ label.accept(f);
- SourceURIFinder f(&env, repo.get(), "http://example.com/path/input", "output", "monkey",
- get_mirrors_fn);
- URIMirrorsThenListedLabel label("mirrors-then-listed");
- label.accept(f);
+ SourceURIFinder::ConstIterator i(f.begin());
- SourceURIFinder::ConstIterator i(f.begin());
+ ASSERT_TRUE(i != f.end());
+ EXPECT_EQ("http://example.com/path/input", i->first);
+ EXPECT_EQ("output", i->second);
- TEST_CHECK(i != f.end());
- TEST_CHECK_EQUAL(i->first, "http://example.com/path/input");
- TEST_CHECK_EQUAL(i->second, "output");
+ ++i;
- ++i;
-
- TEST_CHECK(i == f.end());
- }
- } test_source_uri_finder;
-
- struct SourceURIMirrorFinderTest : TestCase
- {
- SourceURIMirrorFinderTest() : TestCase("source uri mirror finder") { }
+ ASSERT_TRUE(i == f.end());
+}
- void run()
- {
- TestEnvironment env;
- const std::shared_ptr<FakeRepository> repo(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("repo")
- )));
- env.add_repository(1, repo);
+TEST(SourceURIFinder, Mirrors)
+{
+ TestEnvironment env;
+ const std::shared_ptr<FakeRepository> repo(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("repo")
+ )));
+ env.add_repository(1, repo);
- SourceURIFinder f(&env, repo.get(), "mirror://example/path/input", "output", "repo", get_mirrors_fn);
- URIMirrorsThenListedLabel label("mirrors-then-listed");
- label.accept(f);
+ SourceURIFinder f(&env, repo.get(), "mirror://example/path/input", "output", "repo", get_mirrors_fn);
+ URIMirrorsThenListedLabel label("mirrors-then-listed");
+ label.accept(f);
- SourceURIFinder::ConstIterator i(f.begin());
+ SourceURIFinder::ConstIterator i(f.begin());
- TEST_CHECK(i != f.end());
- TEST_CHECK_EQUAL(i->first, "http://fake-repo/fake-repo/output");
- TEST_CHECK_EQUAL(i->second, "output");
+ ASSERT_TRUE(i != f.end());
+ EXPECT_EQ("http://fake-repo/fake-repo/output", i->first);
+ EXPECT_EQ("output", i->second);
- ++i;
+ ++i;
- TEST_CHECK(i != f.end());
- TEST_CHECK_EQUAL(i->first, "http://example-mirror-1/example-mirror-1/path/input");
- TEST_CHECK_EQUAL(i->second, "output");
+ ASSERT_TRUE(i != f.end());
+ EXPECT_EQ("http://example-mirror-1/example-mirror-1/path/input", i->first);
+ EXPECT_EQ("output", i->second);
- ++i;
+ ++i;
- TEST_CHECK(i != f.end());
- TEST_CHECK_EQUAL(i->first, "http://example-mirror-2/example-mirror-2/path/input");
- TEST_CHECK_EQUAL(i->second, "output");
+ ASSERT_TRUE(i != f.end());
+ EXPECT_EQ("http://example-mirror-2/example-mirror-2/path/input", i->first);
+ EXPECT_EQ("output", i->second);
- ++i;
+ ++i;
- TEST_CHECK(i != f.end());
- TEST_CHECK_EQUAL(i->first, "http://fake-example/fake-example/path/input");
- TEST_CHECK_EQUAL(i->second, "output");
+ ASSERT_TRUE(i != f.end());
+ EXPECT_EQ("http://fake-example/fake-example/path/input", i->first);
+ EXPECT_EQ("output", i->second);
- ++i;
+ ++i;
- TEST_CHECK(i == f.end());
- }
- } test_source_uri_mirror_finder;
+ ASSERT_TRUE(i == f.end());
}