aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-24 23:41:15 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-24 23:41:15 +0000
commit1221d7496174c24427b9958a29ee83d895d64bb0 (patch)
tree1eb079c5c6261fd22e30c70f744d8ec334c1bb82
parent7d3d34aefc05a3081ae075476230f9a69a7934d5 (diff)
downloadpaludis-1221d7496174c24427b9958a29ee83d895d64bb0.tar.gz
paludis-1221d7496174c24427b9958a29ee83d895d64bb0.tar.xz
gtest more
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/name_TEST.cc447
2 files changed, 152 insertions, 297 deletions
diff --git a/paludis/files.m4 b/paludis/files.m4
index e8de1a9..232dd63 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -67,7 +67,7 @@ add(`merger', `hh', `cc', `se', `fwd')
add(`merger_entry_type', `hh', `cc', `se')
add(`metadata_key', `hh', `cc', `se', `fwd')
add(`metadata_key_holder', `hh', `cc', `fwd')
-add(`name', `hh', `cc', `fwd', `test')
+add(`name', `hh', `cc', `fwd', `gtest')
add(`ndbam', `hh', `cc', `fwd')
add(`ndbam_merger', `hh', `cc')
add(`ndbam_unmerger', `hh', `cc')
diff --git a/paludis/name_TEST.cc b/paludis/name_TEST.cc
index 9813b38..386bd61 100644
--- a/paludis/name_TEST.cc
+++ b/paludis/name_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 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,320 +18,175 @@
*/
#include <paludis/name.hh>
+
#include <paludis/util/exception.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-using namespace test;
-using namespace paludis;
+#include <gtest/gtest.h>
-/** \file
- * Test cases for QualifiedPackageName.
- *
- */
+using namespace paludis;
-namespace test_cases
+TEST(QualifiedPackageName, Create)
{
- /**
- * \test Basic QualifiedPackageName tests.
- *
- */
- struct QualifiedPackageNameTest : TestCase
- {
- QualifiedPackageNameTest() : TestCase("basic") { }
-
- void run()
- {
- QualifiedPackageName a("foo/bar1");
- TEST_CHECK(true);
- }
- } test_qualified_package_name;
-
- /**
- * \test Validate QualifiedPackageName tests.
- *
- */
- struct QualifiedPackageNameValidateTest : TestCase
- {
- QualifiedPackageNameValidateTest() : TestCase("validate") { }
-
- void run()
- {
- QualifiedPackageName a("foo/bar");
- TEST_CHECK_THROWS(a = QualifiedPackageName("moo"), NameError);
- TEST_CHECK_THROWS(a = QualifiedPackageName("foo/bar!"), NameError);
- TEST_CHECK_THROWS(a = QualifiedPackageName("foo/bar/baz"), NameError);
- }
- } test_qualified_package_name_validate;
-
- /**
- * \test Compare QualifiedPackageName tests.
- *
- */
- struct QualifiedPackageNameCompareTest : TestCase
- {
- QualifiedPackageNameCompareTest() : TestCase("compare") { }
-
- void run()
- {
- QualifiedPackageName foo1_bar1("foo1/bar1");
- QualifiedPackageName foo1_bar2("foo1/bar2");
- QualifiedPackageName foo2_bar1("foo2/bar1");
-
- TEST_CHECK( (foo1_bar1 < foo1_bar2));
- TEST_CHECK( (foo1_bar1 <= foo1_bar2));
- TEST_CHECK(!(foo1_bar1 == foo1_bar2));
- TEST_CHECK( (foo1_bar1 != foo1_bar2));
- TEST_CHECK(!(foo1_bar1 >= foo1_bar2));
- TEST_CHECK(!(foo1_bar1 > foo1_bar2));
-
- TEST_CHECK(!(foo2_bar1 < foo1_bar2));
- TEST_CHECK(!(foo2_bar1 <= foo1_bar2));
- TEST_CHECK(!(foo2_bar1 == foo1_bar2));
- TEST_CHECK( (foo2_bar1 != foo1_bar2));
- TEST_CHECK( (foo2_bar1 >= foo1_bar2));
- TEST_CHECK( (foo2_bar1 > foo1_bar2));
- }
- } test_qualified_package_name_compare;
-
- /**
- * \test Test CategoryNamePart creation.
- *
- */
- struct CategoryNamePartCreationTest : public TestCase
- {
- CategoryNamePartCreationTest() : TestCase("creation") { }
-
- void run()
- {
- CategoryNamePart p("foo");
- TEST_CHECK(true);
- }
- } category_package_name_part_creation;
-
- /**
- * \test Test CategoryNamePart validation
- *
- */
- struct CategoryNamePartValidationTest : public TestCase
- {
- CategoryNamePartValidationTest() : TestCase("validation") {}
-
- void run()
- {
- CategoryNamePart p = CategoryNamePart("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+_");
-
- TEST_CHECK_THROWS(p = CategoryNamePart(""), CategoryNamePartError);
- TEST_CHECK_THROWS(p = CategoryNamePart("*"), CategoryNamePartError);
- TEST_CHECK_THROWS(p = CategoryNamePart("foo bar"), CategoryNamePartError);
- }
- } category_package_name_part_validation;
-
- /**
- * \test Test PackageNamePart creation.
- *
- */
- struct PackageNamePartCreationTest : public TestCase
- {
- PackageNamePartCreationTest() : TestCase("creation") { }
-
- void run()
- {
- PackageNamePart p("foo");
- TEST_CHECK(true);
- }
- } test_package_name_part_creation;
-
- /**
- * \test Test PackageNamePart validation.
- *
- */
- struct PackageNamePartValidationTest : public TestCase
- {
- PackageNamePartValidationTest() : TestCase("validation") { }
-
- void run()
- {
- PackageNamePart p("foo-200dpi");
- TEST_CHECK_THROWS(p = PackageNamePart(""), NameError);
- TEST_CHECK_THROWS(p = PackageNamePart("!!!"), NameError);
- TEST_CHECK_THROWS(p = PackageNamePart("foo-2"), NameError);
- TEST_CHECK_THROWS(p = PackageNamePart("foo-200"), NameError);
- }
- } test_package_name_part_validation;
-
- /**
- * \test Test PackageNamePart comparison.
- *
- */
- struct PackageNamePartComparisonTest : public TestCase
- {
- PackageNamePartComparisonTest() : TestCase("comparison") { }
-
- void run()
- {
- PackageNamePart p1("p1");
- PackageNamePart p2("p2");
-
- TEST_CHECK( (p1 < p2));
- TEST_CHECK( (p1 <= p2));
- TEST_CHECK(!(p1 == p2));
- TEST_CHECK(!(p1 > p2));
- TEST_CHECK(!(p1 >= p2));
- TEST_CHECK( (p1 != p2));
-
- TEST_CHECK(!(p2 < p2));
- TEST_CHECK( (p2 <= p2));
- TEST_CHECK( (p2 == p2));
- TEST_CHECK(!(p2 > p2));
- TEST_CHECK( (p2 >= p2));
- TEST_CHECK(!(p2 != p2));
+ QualifiedPackageName a("foo/bar1");
+}
- TEST_CHECK(!(p2 < p1));
- TEST_CHECK(!(p2 <= p1));
- TEST_CHECK(!(p2 == p1));
- TEST_CHECK( (p2 > p1));
- TEST_CHECK( (p2 >= p1));
- TEST_CHECK( (p2 != p1));
- }
- } test_package_name_part_comparison;
+TEST(QualifiedPackageName, Validation)
+{
+ QualifiedPackageName a("foo/bar");
+ EXPECT_THROW(a = QualifiedPackageName("moo"), NameError);
+ EXPECT_THROW(a = QualifiedPackageName("foo/bar!"), NameError);
+ EXPECT_THROW(a = QualifiedPackageName("foo/bar/baz"), NameError);
+}
- /**
- * \test Test RepositoryName creation.
- *
- */
- struct RepositoryNameCreationTest : public TestCase
- {
- RepositoryNameCreationTest() : TestCase("creation") { }
+TEST(QualifiedPackageName, Compare)
+{
+ QualifiedPackageName foo1_bar1("foo1/bar1");
+ QualifiedPackageName foo1_bar2("foo1/bar2");
+ QualifiedPackageName foo2_bar1("foo2/bar1");
+
+ EXPECT_TRUE( (foo1_bar1 < foo1_bar2));
+ EXPECT_TRUE( (foo1_bar1 <= foo1_bar2));
+ EXPECT_TRUE(!(foo1_bar1 == foo1_bar2));
+ EXPECT_TRUE( (foo1_bar1 != foo1_bar2));
+ EXPECT_TRUE(!(foo1_bar1 >= foo1_bar2));
+ EXPECT_TRUE(!(foo1_bar1 > foo1_bar2));
+
+ EXPECT_TRUE(!(foo2_bar1 < foo1_bar2));
+ EXPECT_TRUE(!(foo2_bar1 <= foo1_bar2));
+ EXPECT_TRUE(!(foo2_bar1 == foo1_bar2));
+ EXPECT_TRUE( (foo2_bar1 != foo1_bar2));
+ EXPECT_TRUE( (foo2_bar1 >= foo1_bar2));
+ EXPECT_TRUE( (foo2_bar1 > foo1_bar2));
+}
- void run()
- {
- RepositoryName r("foo");
- TEST_CHECK(true);
- }
- } test_repository_name_creation;
+TEST(CategoryNamePart, Create)
+{
+ CategoryNamePart p("foo");
+}
- /**
- * \test Test RepositoryName validation.
- *
- */
- struct RepositoryNameValidationTest : public TestCase
- {
- RepositoryNameValidationTest() : TestCase("validation") { }
+TEST(CategoryNamePart, Validate)
+{
+ CategoryNamePart p = CategoryNamePart("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+_");
- void run()
- {
- RepositoryName r("repo0_-");
- TEST_CHECK_THROWS(r = RepositoryName(""), NameError);
- TEST_CHECK_THROWS(r = RepositoryName("!!!"), NameError);
- TEST_CHECK_THROWS(r = RepositoryName("-foo"), NameError);
- TEST_CHECK_THROWS(r = RepositoryName("fo$o"), NameError);
- }
- } test_repository_name_validation;
+ EXPECT_THROW(p = CategoryNamePart(""), CategoryNamePartError);
+ EXPECT_THROW(p = CategoryNamePart("*"), CategoryNamePartError);
+ EXPECT_THROW(p = CategoryNamePart("foo bar"), CategoryNamePartError);
+}
- /**
- * \test Test SlotName creation.
- *
- */
- struct SlotNameCreationTest : public TestCase
- {
- SlotNameCreationTest() : TestCase("creation") { }
+TEST(PackageNamePart, Create)
+{
+ PackageNamePart p("foo");
+}
- void run()
- {
- SlotName s("foo");
- TEST_CHECK(true);
- }
- } test_slot_name_creation;
+TEST(PackageNamePart, Validate)
+{
+ PackageNamePart p("foo-200dpi");
+ EXPECT_THROW(p = PackageNamePart(""), NameError);
+ EXPECT_THROW(p = PackageNamePart("!!!"), NameError);
+ EXPECT_THROW(p = PackageNamePart("foo-2"), NameError);
+ EXPECT_THROW(p = PackageNamePart("foo-200"), NameError);
+}
- /**
- * \test Test SlotName validation.
- *
- */
- struct SlotNameValidationTest : public TestCase
- {
- SlotNameValidationTest() : TestCase("validation") { }
+TEST(PackageNamePart, Comparison)
+{
+ PackageNamePart p1("p1");
+ PackageNamePart p2("p2");
+
+ EXPECT_TRUE( (p1 < p2));
+ EXPECT_TRUE( (p1 <= p2));
+ EXPECT_TRUE(!(p1 == p2));
+ EXPECT_TRUE(!(p1 > p2));
+ EXPECT_TRUE(!(p1 >= p2));
+ EXPECT_TRUE( (p1 != p2));
+
+ EXPECT_TRUE(!(p2 < p2));
+ EXPECT_TRUE( (p2 <= p2));
+ EXPECT_TRUE( (p2 == p2));
+ EXPECT_TRUE(!(p2 > p2));
+ EXPECT_TRUE( (p2 >= p2));
+ EXPECT_TRUE(!(p2 != p2));
+
+ EXPECT_TRUE(!(p2 < p1));
+ EXPECT_TRUE(!(p2 <= p1));
+ EXPECT_TRUE(!(p2 == p1));
+ EXPECT_TRUE( (p2 > p1));
+ EXPECT_TRUE( (p2 >= p1));
+ EXPECT_TRUE( (p2 != p1));
+}
- void run()
- {
- SlotName s("slot0+_.-");
- TEST_CHECK_THROWS(s = SlotName(""), NameError);
- TEST_CHECK_THROWS(s = SlotName("!!!"), NameError);
- TEST_CHECK_THROWS(s = SlotName("-foo"), NameError);
- TEST_CHECK_THROWS(s = SlotName(".foo"), NameError);
- TEST_CHECK_THROWS(s = SlotName("fo$o"), NameError);
- }
- } test_slot_name_validation;
+TEST(RepositoryName, Create)
+{
+ RepositoryName r("foo");
+}
- /**
- * \test Test KeywordName creation.
- *
- */
- struct KeywordNameCreationTest : public TestCase
- {
- KeywordNameCreationTest() : TestCase("creation") { }
+TEST(RepositoryName, Validation)
+{
+ RepositoryName r("repo0_-");
+ EXPECT_THROW(r = RepositoryName(""), NameError);
+ EXPECT_THROW(r = RepositoryName("!!!"), NameError);
+ EXPECT_THROW(r = RepositoryName("-foo"), NameError);
+ EXPECT_THROW(r = RepositoryName("fo$o"), NameError);
+}
- void run()
- {
- KeywordName k("foo");
- TEST_CHECK(true);
- }
- } test_keyword_name_creation;
+TEST(SlotName, Creation)
+{
+ SlotName s("foo");
+}
- /**
- * \test Test KeywordName validation.
- *
- */
- struct KeywordNameValidationTest : public TestCase
- {
- KeywordNameValidationTest() : TestCase("validation") { }
+TEST(SlotName, Validation)
+{
+ SlotName s("slot0+_.-");
+ EXPECT_THROW(s = SlotName(""), NameError);
+ EXPECT_THROW(s = SlotName("!!!"), NameError);
+ EXPECT_THROW(s = SlotName("-foo"), NameError);
+ EXPECT_THROW(s = SlotName(".foo"), NameError);
+ EXPECT_THROW(s = SlotName("fo$o"), NameError);
+}
- void run()
- {
- KeywordName k("keyword0_-");
- KeywordName k1("~keyword0_-");
- KeywordName k2("-keyword0_-");
- KeywordName k3("*");
- KeywordName k4("-*");
- TEST_CHECK_THROWS(k = KeywordName(""), NameError);
- TEST_CHECK_THROWS(k = KeywordName("!!!"), NameError);
- TEST_CHECK_THROWS(k = KeywordName("~"), NameError);
- TEST_CHECK_THROWS(k = KeywordName("-"), NameError);
- TEST_CHECK_THROWS(k = KeywordName("@foo"), NameError);
- TEST_CHECK_THROWS(k = KeywordName("fo$o"), NameError);
- TEST_CHECK_THROWS(k = KeywordName("foo+"), NameError);
- }
- } test_keyword_name_validation;
+TEST(KeywordName, Create)
+{
+ KeywordName k("foo");
+}
- struct SetNameValidationTest : public TestCase
- {
- SetNameValidationTest() : TestCase("validation") { }
+TEST(KeywordName, Validation)
+{
+ KeywordName k("keyword0_-");
+ KeywordName k1("~keyword0_-");
+ KeywordName k2("-keyword0_-");
+ KeywordName k3("*");
+ KeywordName k4("-*");
+ EXPECT_THROW(k = KeywordName(""), NameError);
+ EXPECT_THROW(k = KeywordName("!!!"), NameError);
+ EXPECT_THROW(k = KeywordName("~"), NameError);
+ EXPECT_THROW(k = KeywordName("-"), NameError);
+ EXPECT_THROW(k = KeywordName("@foo"), NameError);
+ EXPECT_THROW(k = KeywordName("fo$o"), NameError);
+ EXPECT_THROW(k = KeywordName("foo+"), NameError);
+}
- void run()
- {
- SetName k("set0_-");
- SetName k1("set0_-");
- SetName k2("set0*");
- SetName k3("set::foo");
- SetName k4("set::foo*");
- TEST_CHECK_THROWS(k = SetName(""), NameError);
- TEST_CHECK_THROWS(k = SetName("!!!"), NameError);
- TEST_CHECK_THROWS(k = SetName("~"), NameError);
- TEST_CHECK_THROWS(k = SetName("-"), NameError);
- TEST_CHECK_THROWS(k = SetName("f?oo"), NameError);
- TEST_CHECK_THROWS(k = SetName("*"), NameError);
- TEST_CHECK_THROWS(k = SetName("?"), NameError);
- TEST_CHECK_THROWS(k = SetName("*set"), NameError);
- TEST_CHECK_THROWS(k = SetName("set**"), NameError);
- TEST_CHECK_THROWS(k = SetName("set*?"), NameError);
- TEST_CHECK_THROWS(k = SetName("set?"), NameError);
- TEST_CHECK_THROWS(k = SetName("set:::"), NameError);
- TEST_CHECK_THROWS(k = SetName("set::"), NameError);
- TEST_CHECK_THROWS(k = SetName("set:"), NameError);
- TEST_CHECK_THROWS(k = SetName("set:foo"), NameError);
- TEST_CHECK_THROWS(k = SetName("set:::foo"), NameError);
- TEST_CHECK_THROWS(k = SetName("set::foo::bar"), NameError);
- }
- } test_set_name_validator;
+TEST(SetName, Validation)
+{
+ SetName k("set0_-");
+ SetName k1("set0_-");
+ SetName k2("set0*");
+ SetName k3("set::foo");
+ SetName k4("set::foo*");
+ EXPECT_THROW(k = SetName(""), NameError);
+ EXPECT_THROW(k = SetName("!!!"), NameError);
+ EXPECT_THROW(k = SetName("~"), NameError);
+ EXPECT_THROW(k = SetName("-"), NameError);
+ EXPECT_THROW(k = SetName("f?oo"), NameError);
+ EXPECT_THROW(k = SetName("*"), NameError);
+ EXPECT_THROW(k = SetName("?"), NameError);
+ EXPECT_THROW(k = SetName("*set"), NameError);
+ EXPECT_THROW(k = SetName("set**"), NameError);
+ EXPECT_THROW(k = SetName("set*?"), NameError);
+ EXPECT_THROW(k = SetName("set?"), NameError);
+ EXPECT_THROW(k = SetName("set:::"), NameError);
+ EXPECT_THROW(k = SetName("set::"), NameError);
+ EXPECT_THROW(k = SetName("set:"), NameError);
+ EXPECT_THROW(k = SetName("set:foo"), NameError);
+ EXPECT_THROW(k = SetName("set:::foo"), NameError);
+ EXPECT_THROW(k = SetName("set::foo::bar"), NameError);
}