aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-24 23:20:15 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-24 23:20:15 +0000
commitde20a3101ef1ce2ec66b3c7de3991a0be1e48fa3 (patch)
tree2e3ec2b7ccc2f446e31cae45d7150ef4593ebac3
parent3631299d2ec0cdad20ef63835dd43bba9d7f4d15 (diff)
downloadpaludis-de20a3101ef1ce2ec66b3c7de3991a0be1e48fa3.tar.gz
paludis-de20a3101ef1ce2ec66b3c7de3991a0be1e48fa3.tar.xz
gtest more
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/set_file_TEST.cc315
2 files changed, 145 insertions, 172 deletions
diff --git a/paludis/files.m4 b/paludis/files.m4
index b811141..7579574 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -92,7 +92,7 @@ add(`selection', `hh', `cc', `fwd', `test')
add(`selection_cache', `hh', `cc', `fwd')
add(`selection_handler', `hh', `cc', `fwd')
add(`serialise', `hh', `cc', `fwd', `impl')
-add(`set_file', `hh', `cc', `se', `test', `testscript')
+add(`set_file', `hh', `cc', `se', `gtest', `testscript')
add(`slot_requirement', `hh', `fwd', `cc')
add(`spec_tree', `hh', `fwd', `cc')
add(`standard_output_manager', `hh', `cc', `fwd')
diff --git a/paludis/set_file_TEST.cc b/paludis/set_file_TEST.cc
index 83b4856..0b016f3 100644
--- a/paludis/set_file_TEST.cc
+++ b/paludis/set_file_TEST.cc
@@ -18,20 +18,21 @@
*/
#include <paludis/set_file.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
+
#include <paludis/environments/test/test_environment.hh>
+
#include <paludis/util/make_named_values.hh>
#include <paludis/util/safe_ifstream.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/accept_visitor.hh>
-#include <paludis/dep_spec.hh>
-#include <paludis/user_dep_spec.hh>
-
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
+#include <paludis/util/stringify.hh>
#include <algorithm>
-using namespace test;
+#include <gtest/gtest.h>
+
using namespace paludis;
namespace
@@ -59,182 +60,154 @@ namespace
};
}
-namespace test_cases
+TEST(SetFile, Simple)
{
- struct SimpleTest : TestCase
+ using namespace std::placeholders;
+
+ TestEnvironment env;
+
+ SetFile f(make_named_values<SetFileParams>(
+ n::environment() = static_cast<Environment *>(0),
+ n::file_name() = FSPath("set_file_TEST_dir/simple1"),
+ n::parser() = std::bind(&parse_user_package_dep_spec, _1, &env, UserPackageDepSpecOptions(), filter::All()),
+ n::set_operator_mode() = sfsmo_natural,
+ n::type() = sft_simple
+ ));
+
{
- SimpleTest() : TestCase("simple set file") { }
+ SetSpecStringifier p;
+ f.contents()->top()->accept(p);
+ EXPECT_EQ("( foo/bar >=bar/baz-1.23 ) ", stringify(p.s.str()));
+ }
- void run()
- {
- using namespace std::placeholders;
-
- TestEnvironment env;
-
- SetFile f(make_named_values<SetFileParams>(
- n::environment() = static_cast<Environment *>(0),
- n::file_name() = FSPath("set_file_TEST_dir/simple1"),
- n::parser() = std::bind(&parse_user_package_dep_spec, _1, &env, UserPackageDepSpecOptions(), filter::All()),
- n::set_operator_mode() = sfsmo_natural,
- n::type() = sft_simple
- ));
-
- {
- SetSpecStringifier p;
- f.contents()->top()->accept(p);
- TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( foo/bar >=bar/baz-1.23 ) ");
- }
-
- f.add("foo/bar");
- f.add("moo/oink");
- {
- SetSpecStringifier p;
- f.contents()->top()->accept(p);
- TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( foo/bar >=bar/baz-1.23 moo/oink ) ");
- }
-
- f.rewrite();
-
- {
- SafeIFStream ff(FSPath("set_file_TEST_dir/simple1"));
- TEST_CHECK(ff);
- std::string g((std::istreambuf_iterator<char>(ff)), std::istreambuf_iterator<char>());
- TEST_CHECK_EQUAL(g, "# this is a comment\n\nfoo/bar\n>=bar/baz-1.23\n\n# the end\nmoo/oink\n");
- }
-
- TEST_CHECK(f.remove(">=bar/baz-1.23"));
- TEST_CHECK(! f.remove("bar/cow"));
-
- {
- SetSpecStringifier p;
- f.contents()->top()->accept(p);
- TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( foo/bar moo/oink ) ");
- }
-
- f.rewrite();
-
- {
- SafeIFStream ff(FSPath("set_file_TEST_dir/simple1"));
- TEST_CHECK(ff);
- std::string g((std::istreambuf_iterator<char>(ff)), std::istreambuf_iterator<char>());
- TEST_CHECK_EQUAL(g, "# this is a comment\n\nfoo/bar\n\n# the end\nmoo/oink\n");
- }
- }
+ f.add("foo/bar");
+ f.add("moo/oink");
+ {
+ SetSpecStringifier p;
+ f.contents()->top()->accept(p);
+ EXPECT_EQ("( foo/bar >=bar/baz-1.23 moo/oink ) ", stringify(p.s.str()));
+ }
- bool repeatable() const
- {
- return false;
- }
- } test_simple;
+ f.rewrite();
- struct PaludisConfTest : TestCase
{
- PaludisConfTest() : TestCase("paludis .conf set file") { }
+ SafeIFStream ff(FSPath("set_file_TEST_dir/simple1"));
+ ASSERT_TRUE(ff);
+ std::string g((std::istreambuf_iterator<char>(ff)), std::istreambuf_iterator<char>());
+ EXPECT_EQ("# this is a comment\n\nfoo/bar\n>=bar/baz-1.23\n\n# the end\nmoo/oink\n", g);
+ }
- void run()
- {
- using namespace std::placeholders;
-
- TestEnvironment env;
-
- SetFile f(make_named_values<SetFileParams>(
- n::environment() = static_cast<Environment *>(0),
- n::file_name() = FSPath("set_file_TEST_dir/paludisconf1"),
- n::parser() = std::bind(&parse_user_package_dep_spec, _1, &env, UserPackageDepSpecOptions(), filter::All()),
- n::set_operator_mode() = sfsmo_natural,
- n::type() = sft_paludis_conf
- ));
-
- {
- SetSpecStringifier p;
- f.contents()->top()->accept(p);
- TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( >=bar/baz-1.23 set ) ");
- }
-
- f.add("foo/bar");
- f.add("moo/oink");
- f.add("settee");
- f.add("couch");
- {
- SetSpecStringifier p;
- f.contents()->top()->accept(p);
- TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( >=bar/baz-1.23 set moo/oink couch ) ");
- }
-
- f.rewrite();
-
- {
- SafeIFStream ff(FSPath("set_file_TEST_dir/paludisconf1"));
- TEST_CHECK(ff);
- std::string g((std::istreambuf_iterator<char>(ff)), std::istreambuf_iterator<char>());
- TEST_CHECK_EQUAL(g, "# this is a comment\n\n? foo/bar\n* >=bar/baz-1.23\n\n* set\n? settee\n\n# the end\n* moo/oink\n* couch\n");
- }
-
- TEST_CHECK(f.remove(">=bar/baz-1.23"));
- TEST_CHECK(! f.remove("bar/cow"));
- TEST_CHECK(f.remove("set"));
-
- {
- SetSpecStringifier p;
- f.contents()->top()->accept(p);
- TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( moo/oink couch ) ");
- }
-
- f.rewrite();
-
- {
- SafeIFStream ff(FSPath("set_file_TEST_dir/paludisconf1"));
- TEST_CHECK(ff);
- std::string g((std::istreambuf_iterator<char>(ff)), std::istreambuf_iterator<char>());
- TEST_CHECK_EQUAL(g, "# this is a comment\n\n? foo/bar\n\n? settee\n\n# the end\n* moo/oink\n* couch\n");
- }
- }
+ EXPECT_TRUE(f.remove(">=bar/baz-1.23"));
+ EXPECT_TRUE(! f.remove("bar/cow"));
- bool repeatable() const
- {
- return false;
- }
- } test_paludis_conf;
+ {
+ SetSpecStringifier p;
+ f.contents()->top()->accept(p);
+ EXPECT_EQ("( foo/bar moo/oink ) ", stringify(p.s.str()));
+ }
+
+ f.rewrite();
- struct OverrideTest : TestCase
{
- OverrideTest() : TestCase("operator overrides") { }
+ SafeIFStream ff(FSPath("set_file_TEST_dir/simple1"));
+ ASSERT_TRUE(ff);
+ std::string g((std::istreambuf_iterator<char>(ff)), std::istreambuf_iterator<char>());
+ EXPECT_EQ("# this is a comment\n\nfoo/bar\n\n# the end\nmoo/oink\n", g);
+ }
+}
- void run()
- {
- using namespace std::placeholders;
-
- TestEnvironment env;
-
- SetFile f(make_named_values<SetFileParams>(
- n::environment() = static_cast<Environment *>(0),
- n::file_name() = FSPath("set_file_TEST_dir/override"),
- n::parser() = std::bind(&parse_user_package_dep_spec, _1, &env, UserPackageDepSpecOptions(), filter::All()),
- n::set_operator_mode() = sfsmo_natural,
- n::type() = sft_paludis_conf
- ));
-
- {
- SetSpecStringifier p;
- f.contents()->top()->accept(p);
- TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( >=bar/bar-1.23 set set2* ) ");
- }
-
- SetFile fstar(make_named_values<SetFileParams>(
- n::environment() = static_cast<Environment *>(0),
- n::file_name() = FSPath("set_file_TEST_dir/override"),
- n::parser() = std::bind(&parse_user_package_dep_spec, _1, &env, UserPackageDepSpecOptions(), filter::All()),
- n::set_operator_mode() = sfsmo_star,
- n::type() = sft_paludis_conf
- ));
-
- {
- SetSpecStringifier p;
- fstar.contents()->top()->accept(p);
- TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( foo/foo >=bar/bar-1.23 >=baz/baz-1.23 set* set2* ) ");
- }
+TEST(SetFile, PaludisConf)
+{
+ using namespace std::placeholders;
+
+ TestEnvironment env;
+
+ SetFile f(make_named_values<SetFileParams>(
+ n::environment() = static_cast<Environment *>(0),
+ n::file_name() = FSPath("set_file_TEST_dir/paludisconf1"),
+ n::parser() = std::bind(&parse_user_package_dep_spec, _1, &env, UserPackageDepSpecOptions(), filter::All()),
+ n::set_operator_mode() = sfsmo_natural,
+ n::type() = sft_paludis_conf
+ ));
+
+ {
+ SetSpecStringifier p;
+ f.contents()->top()->accept(p);
+ EXPECT_EQ("( >=bar/baz-1.23 set ) ", stringify(p.s.str()));
+ }
+
+ f.add("foo/bar");
+ f.add("moo/oink");
+ f.add("settee");
+ f.add("couch");
+ {
+ SetSpecStringifier p;
+ f.contents()->top()->accept(p);
+ EXPECT_EQ("( >=bar/baz-1.23 set moo/oink couch ) ", stringify(p.s.str()));
+ }
+
+ f.rewrite();
+
+ {
+ SafeIFStream ff(FSPath("set_file_TEST_dir/paludisconf1"));
+ ASSERT_TRUE(ff);
+ std::string g((std::istreambuf_iterator<char>(ff)), std::istreambuf_iterator<char>());
+ EXPECT_EQ("# this is a comment\n\n? foo/bar\n* >=bar/baz-1.23\n\n* set\n? settee\n\n# the end\n* moo/oink\n* couch\n", g);
+ }
+
+ EXPECT_TRUE(f.remove(">=bar/baz-1.23"));
+ EXPECT_TRUE(! f.remove("bar/cow"));
+ EXPECT_TRUE(f.remove("set"));
+
+ {
+ SetSpecStringifier p;
+ f.contents()->top()->accept(p);
+ EXPECT_EQ("( moo/oink couch ) ", stringify(p.s.str()));
+ }
+
+ f.rewrite();
+
+ {
+ SafeIFStream ff(FSPath("set_file_TEST_dir/paludisconf1"));
+ ASSERT_TRUE(ff);
+ std::string g((std::istreambuf_iterator<char>(ff)), std::istreambuf_iterator<char>());
+ EXPECT_EQ("# this is a comment\n\n? foo/bar\n\n? settee\n\n# the end\n* moo/oink\n* couch\n", g);
+ }
+}
+
+TEST(SetFile, Overrides)
+{
+ using namespace std::placeholders;
+
+ TestEnvironment env;
+
+ SetFile f(make_named_values<SetFileParams>(
+ n::environment() = static_cast<Environment *>(0),
+ n::file_name() = FSPath("set_file_TEST_dir/override"),
+ n::parser() = std::bind(&parse_user_package_dep_spec, _1, &env, UserPackageDepSpecOptions(), filter::All()),
+ n::set_operator_mode() = sfsmo_natural,
+ n::type() = sft_paludis_conf
+ ));
+
+ {
+ SetSpecStringifier p;
+ f.contents()->top()->accept(p);
+ EXPECT_EQ("( >=bar/bar-1.23 set set2* ) ", stringify(p.s.str()));
+ }
+
+ SetFile fstar(make_named_values<SetFileParams>(
+ n::environment() = static_cast<Environment *>(0),
+ n::file_name() = FSPath("set_file_TEST_dir/override"),
+ n::parser() = std::bind(&parse_user_package_dep_spec, _1, &env, UserPackageDepSpecOptions(), filter::All()),
+ n::set_operator_mode() = sfsmo_star,
+ n::type() = sft_paludis_conf
+ ));
+
+ {
+ SetSpecStringifier p;
+ fstar.contents()->top()->accept(p);
+ EXPECT_EQ("( foo/foo >=bar/bar-1.23 >=baz/baz-1.23 set* set2* ) ", stringify(p.s.str()));
+ }
- }
- } test_overrides;
}