aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-25 11:04:05 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-25 16:55:34 +0000
commitd95b2ec676cd49c2d31990a6316f4a14a0fec6aa (patch)
treec25542351f39876658149a90920d571a9aac481c
parent696a370f93de32f8fbb115c84733595e96ede8b4 (diff)
downloadpaludis-d95b2ec676cd49c2d31990a6316f4a14a0fec6aa.tar.gz
paludis-d95b2ec676cd49c2d31990a6316f4a14a0fec6aa.tar.xz
gtest more
-rw-r--r--paludis/repositories/unavailable/Makefile.am4
-rw-r--r--paludis/repositories/unavailable/unavailable_repository_TEST.cc162
2 files changed, 79 insertions, 87 deletions
diff --git a/paludis/repositories/unavailable/Makefile.am b/paludis/repositories/unavailable/Makefile.am
index 25857f1..1339c94 100644
--- a/paludis/repositories/unavailable/Makefile.am
+++ b/paludis/repositories/unavailable/Makefile.am
@@ -34,13 +34,15 @@ libpaludisunavailablerepository_la_SOURCES = \
unavailable_repository_TEST_SOURCES = unavailable_repository_TEST.cc
unavailable_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)
unavailable_repository_TEST_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+unavailable_repository_TEST_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
EXTRA_DIST = \
unavailable_repository_TEST.cc \
unavailable_repository_TEST_setup.sh \
diff --git a/paludis/repositories/unavailable/unavailable_repository_TEST.cc b/paludis/repositories/unavailable/unavailable_repository_TEST.cc
index 7be785a..5b78e78 100644
--- a/paludis/repositories/unavailable/unavailable_repository_TEST.cc
+++ b/paludis/repositories/unavailable/unavailable_repository_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009, 2010 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 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
@@ -19,109 +19,99 @@
#include <paludis/repositories/unavailable/unavailable_repository.hh>
#include <paludis/repositories/fake/fake_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>
#include <paludis/filter.hh>
#include <paludis/package_id.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::unavailable_repository;
-using namespace test;
-namespace test_cases
+TEST(UnavailableRepository, Creation)
{
- struct UnavailableRepositoryCreationTest : TestCase
- {
- UnavailableRepositoryCreationTest() : TestCase("creation") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<UnavailableRepository> repo(std::make_shared<UnavailableRepository>(
- make_named_values<UnavailableRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath::cwd() / "unavailable_repository_TEST_dir" / "repo1",
- n::name() = RepositoryName("unavailable"),
- 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(), "unavailable");
- }
- } test_creation;
-
- struct UnavailableRepositoryContentsTest : TestCase
- {
- UnavailableRepositoryContentsTest() : TestCase("contents") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<UnavailableRepository> repo(std::make_shared<UnavailableRepository>(
- make_named_values<UnavailableRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath::cwd() / "unavailable_repository_TEST_dir" / "repo2",
- n::name() = RepositoryName("unavailable"),
- 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(), "unavailable");
-
- std::shared_ptr<const PackageIDSequence> contents(
- env[selection::AllVersionsSorted(generator::All())]);
- TEST_CHECK(bool(contents));
-
- TEST_CHECK_EQUAL(
- join(indirect_iterator(contents->begin()), indirect_iterator(contents->end()), " "),
- "cat-one/pkg-one-1:0::unavailable (in ::bar) "
- "cat-one/pkg-one-1:0::unavailable (in ::foo) "
- "cat-one/pkg-one-2:0::unavailable (in ::foo) "
- "cat-one/pkg-one-3:0::unavailable (in ::foo) "
- "cat-one/pkg-one-3:3::unavailable (in ::bar) "
- "cat-one/pkg-six-3:0::unavailable (in ::bar) "
- "cat-one/pkg-two-1:1::unavailable (in ::foo) "
- "cat-one/pkg-two-2:2::unavailable (in ::foo) "
- "cat-two/pkg-six-1:0::unavailable (in ::bar) "
- "repository/bar-0::unavailable "
- "repository/foo-0::unavailable"
- );
-
- const std::shared_ptr<FakeRepository> hide_bar(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("bar")
- )));
- env.package_database()->add_repository(2, hide_bar);
- repo->invalidate();
-
- std::shared_ptr<const PackageIDSequence> contents_without_bar(
- env[selection::AllVersionsSorted(generator::All())]);
- TEST_CHECK(bool(contents));
-
- TEST_CHECK_EQUAL(
- join(indirect_iterator(contents_without_bar->begin()),
- indirect_iterator(contents_without_bar->end()), " "),
- "cat-one/pkg-one-1:0::unavailable (in ::foo) "
- "cat-one/pkg-one-2:0::unavailable (in ::foo) "
- "cat-one/pkg-one-3:0::unavailable (in ::foo) "
- "cat-one/pkg-two-1:1::unavailable (in ::foo) "
- "cat-one/pkg-two-2:2::unavailable (in ::foo) "
- "repository/bar-0::unavailable "
- "repository/foo-0::unavailable"
- );
- }
- } test_contents;
+ TestEnvironment env;
+ std::shared_ptr<UnavailableRepository> repo(std::make_shared<UnavailableRepository>(
+ make_named_values<UnavailableRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath::cwd() / "unavailable_repository_TEST_dir" / "repo1",
+ n::name() = RepositoryName("unavailable"),
+ 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("unavailable", stringify(repo->name()));
+}
+
+TEST(UnavailableRepository, Contents)
+{
+ TestEnvironment env;
+ std::shared_ptr<UnavailableRepository> repo(std::make_shared<UnavailableRepository>(
+ make_named_values<UnavailableRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath::cwd() / "unavailable_repository_TEST_dir" / "repo2",
+ n::name() = RepositoryName("unavailable"),
+ 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("unavailable", stringify(repo->name()));
+
+ std::shared_ptr<const PackageIDSequence> contents(
+ env[selection::AllVersionsSorted(generator::All())]);
+ ASSERT_TRUE(bool(contents));
+
+ EXPECT_EQ(
+ "cat-one/pkg-one-1:0::unavailable (in ::bar) "
+ "cat-one/pkg-one-1:0::unavailable (in ::foo) "
+ "cat-one/pkg-one-2:0::unavailable (in ::foo) "
+ "cat-one/pkg-one-3:0::unavailable (in ::foo) "
+ "cat-one/pkg-one-3:3::unavailable (in ::bar) "
+ "cat-one/pkg-six-3:0::unavailable (in ::bar) "
+ "cat-one/pkg-two-1:1::unavailable (in ::foo) "
+ "cat-one/pkg-two-2:2::unavailable (in ::foo) "
+ "cat-two/pkg-six-1:0::unavailable (in ::bar) "
+ "repository/bar-0::unavailable "
+ "repository/foo-0::unavailable",
+ join(indirect_iterator(contents->begin()), indirect_iterator(contents->end()), " ")
+ );
+
+ const std::shared_ptr<FakeRepository> hide_bar(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("bar")
+ )));
+ env.package_database()->add_repository(2, hide_bar);
+ repo->invalidate();
+
+ std::shared_ptr<const PackageIDSequence> contents_without_bar(
+ env[selection::AllVersionsSorted(generator::All())]);
+ ASSERT_TRUE(bool(contents));
+
+ EXPECT_EQ(
+ "cat-one/pkg-one-1:0::unavailable (in ::foo) "
+ "cat-one/pkg-one-2:0::unavailable (in ::foo) "
+ "cat-one/pkg-one-3:0::unavailable (in ::foo) "
+ "cat-one/pkg-two-1:1::unavailable (in ::foo) "
+ "cat-one/pkg-two-2:2::unavailable (in ::foo) "
+ "repository/bar-0::unavailable "
+ "repository/foo-0::unavailable",
+ join(indirect_iterator(contents_without_bar->begin()),
+ indirect_iterator(contents_without_bar->end()), " ")
+ );
}