aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 19:14:31 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 19:14:31 +0000
commit00bb119b64c3be3113b2b4274653a2e9261f3313 (patch)
tree66cb8156a4ac1b335739d88b8b04ec4be314e0ab
parent06bd9765c5444f1a0eaf19f3fd5f19a5469c3277 (diff)
downloadpaludis-00bb119b64c3be3113b2b4274653a2e9261f3313.tar.gz
paludis-00bb119b64c3be3113b2b4274653a2e9261f3313.tar.xz
gtest more
-rw-r--r--paludis/util/files.m42
-rw-r--r--paludis/util/join_TEST.cc159
2 files changed, 56 insertions, 105 deletions
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 83a08cf..87c75ef 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -46,7 +46,7 @@ add(`hashes', `hh', `cc', `test')
add(`iterator_funcs', `hh', `test')
add(`indirect_iterator', `hh', `fwd', `impl', `test')
add(`is_file_with_extension', `hh', `cc', `se', `test', `testscript')
-add(`join', `hh', `test')
+add(`join', `hh', `gtest')
add(`log', `hh', `cc', `se', `gtest')
add(`make_named_values', `hh', `cc')
add(`make_null_shared_ptr', `hh')
diff --git a/paludis/util/join_TEST.cc b/paludis/util/join_TEST.cc
index 3038c8d..4cf2177 100644
--- a/paludis/util/join_TEST.cc
+++ b/paludis/util/join_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 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
@@ -17,19 +17,14 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <list>
#include <paludis/util/join.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
+
+#include <list>
#include <vector>
-using namespace paludis;
-using namespace test;
+#include <gtest/gtest.h>
-/** \file
- * Test cases for join.hh .
- *
- */
+using namespace paludis;
namespace
{
@@ -39,104 +34,60 @@ namespace
}
}
-namespace test_cases
+TEST(Join, Vector)
{
- /**
- * \test Test join on a vector.
- *
- */
- struct JoinVectorTest : TestCase
- {
- JoinVectorTest() : TestCase("join vector") { }
-
- void run()
- {
- std::vector<std::string> v;
- v.push_back("one");
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), "/"), "one");
- v.push_back("two");
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), "/"), "one/two");
- v.push_back("three");
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), "/"), "one/two/three");
- }
- } test_join_vector;
-
- /**
- * \test Test join on a list.
- *
- */
- struct JoinListTest : TestCase
- {
- JoinListTest() : TestCase("join list") { }
-
- void run()
- {
- std::list<std::string> v;
- v.push_back("one");
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), "/"), "one");
- v.push_back("two");
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), "/"), "one/two");
- v.push_back("three");
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), "/"), "one/two/three");
- }
- } test_join_list;
-
- /**
- * \test Test join on a list of ints.
- *
- */
- struct JoinListIntTest : TestCase
- {
- JoinListIntTest() : TestCase("join list int") { }
-
- void run()
- {
- std::list<int> v;
- v.push_back(1);
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), "/"), "1");
- v.push_back(2);
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), "/"), "1/2");
- v.push_back(3);
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), "/"), "1/2/3");
- }
- } test_join_list_int;
+ std::vector<std::string> v;
+ v.push_back("one");
+ EXPECT_EQ("one", join(v.begin(), v.end(), "/"));
+ v.push_back("two");
+ EXPECT_EQ("one/two", join(v.begin(), v.end(), "/"));
+ v.push_back("three");
+ EXPECT_EQ("one/two/three", join(v.begin(), v.end(), "/"));
+}
- /**
- * \test Test join with empty things.
- *
- */
- struct JoinEmptyTest : TestCase
- {
- JoinEmptyTest() : TestCase("join empty") { }
+TEST(Join, List)
+{
+ std::list<std::string> v;
+ v.push_back("one");
+ EXPECT_EQ("one", join(v.begin(), v.end(), "/"));
+ v.push_back("two");
+ EXPECT_EQ("one/two", join(v.begin(), v.end(), "/"));
+ v.push_back("three");
+ EXPECT_EQ("one/two/three", join(v.begin(), v.end(), "/"));
+}
- void run()
- {
- std::list<std::string> v;
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), ""), "");
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), "*"), "");
- v.push_back("");
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), ""), "");
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), "*"), "");
- v.push_back("");
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), ""), "");
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), "*"), "*");
- }
- } test_join_empty;
+TEST(Join, IntList)
+{
+ std::list<int> v;
+ v.push_back(1);
+ EXPECT_EQ("1", join(v.begin(), v.end(), "/"));
+ v.push_back(2);
+ EXPECT_EQ("1/2", join(v.begin(), v.end(), "/"));
+ v.push_back(3);
+ EXPECT_EQ("1/2/3", join(v.begin(), v.end(), "/"));
+}
- struct JoinFunctionTest : TestCase
- {
- JoinFunctionTest() : TestCase("join function") { }
+TEST(Join, Empty)
+{
+ std::list<std::string> v;
+ EXPECT_EQ("", join(v.begin(), v.end(), ""));
+ EXPECT_EQ("", join(v.begin(), v.end(), "*"));
+ v.push_back("");
+ EXPECT_EQ("", join(v.begin(), v.end(), ""));
+ EXPECT_EQ("", join(v.begin(), v.end(), "*"));
+ v.push_back("");
+ EXPECT_EQ("", join(v.begin(), v.end(), ""));
+ EXPECT_EQ("*", join(v.begin(), v.end(), "*"));
+}
- void run()
- {
- std::list<int> v;
- v.push_back(1);
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), "/", &make_purdy), "<1>");
- v.push_back(2);
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), "/", &make_purdy), "<1>/<2>");
- v.push_back(3);
- TEST_CHECK_EQUAL(join(v.begin(), v.end(), "/", &make_purdy), "<1>/<2>/<3>");
- }
- } test_join_function;
+TEST(Join, Function)
+{
+ std::list<int> v;
+ v.push_back(1);
+ EXPECT_EQ("<1>", join(v.begin(), v.end(), "/", &make_purdy));
+ v.push_back(2);
+ EXPECT_EQ("<1>/<2>", join(v.begin(), v.end(), "/", &make_purdy));
+ v.push_back(3);
+ EXPECT_EQ("<1>/<2>/<3>", join(v.begin(), v.end(), "/", &make_purdy));
}