aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 19:20:23 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 19:20:23 +0000
commitf475a230cc53eb170cdbdd7589250b253f24e37b (patch)
treec9fd829ddbe94f6c1dc7da61fbbf298017ad53b8
parent3c6d7ced8e8b31dd917c940e12b0ef11dd2ccaf4 (diff)
downloadpaludis-f475a230cc53eb170cdbdd7589250b253f24e37b.tar.gz
paludis-f475a230cc53eb170cdbdd7589250b253f24e37b.tar.xz
gtest more
-rw-r--r--paludis/util/files.m42
-rw-r--r--paludis/util/indirect_iterator_TEST.cc185
2 files changed, 73 insertions, 114 deletions
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 443bf7a..5024190 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -44,7 +44,7 @@ add(`fs_stat', `hh', `cc', `fwd', `test', `testscript'
add(`graph', `hh', `cc', `fwd', `impl', `test')
add(`hashes', `hh', `cc', `test')
add(`iterator_funcs', `hh', `test')
-add(`indirect_iterator', `hh', `fwd', `impl', `test')
+add(`indirect_iterator', `hh', `fwd', `impl', `gtest')
add(`is_file_with_extension', `hh', `cc', `se', `gtest', `testscript')
add(`join', `hh', `gtest')
add(`log', `hh', `cc', `se', `gtest')
diff --git a/paludis/util/indirect_iterator_TEST.cc b/paludis/util/indirect_iterator_TEST.cc
index d76fbdd..e848030 100644
--- a/paludis/util/indirect_iterator_TEST.cc
+++ b/paludis/util/indirect_iterator_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008, 2010 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2010, 2011 Ciaran McCreesh
* Copyright (c) 2007 David Leverton
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -21,13 +21,13 @@
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/join.hh>
#include <paludis/util/iterator_funcs.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
+
#include <algorithm>
#include <vector>
#include <list>
-using namespace test;
+#include <gtest/gtest.h>
+
using namespace paludis;
namespace
@@ -42,121 +42,80 @@ namespace
};
}
-namespace test_cases
+TEST(IndirectIterator, VectorSharedInt)
{
- struct IndirectIteratorVecCPIntTest : TestCase
- {
- IndirectIteratorVecCPIntTest() : TestCase("vector<std::shared_ptr<int> >") { }
-
- void run()
- {
- std::vector<std::shared_ptr<int> > v;
- v.push_back(std::shared_ptr<int>(std::make_shared<int>(5)));
- v.push_back(std::shared_ptr<int>(std::make_shared<int>(10)));
- IndirectIterator<std::vector<std::shared_ptr<int> >::iterator, int> vi(v.begin()), vi_end(v.end());
- TEST_CHECK(vi != vi_end);
- TEST_CHECK(vi < vi_end);
- TEST_CHECK(! (vi > vi_end));
- TEST_CHECK_EQUAL(*vi, 5);
- TEST_CHECK(++vi != vi_end);
- TEST_CHECK(vi < vi_end);
- TEST_CHECK(! (vi > vi_end));
- TEST_CHECK_EQUAL(*vi, 10);
- TEST_CHECK(++vi == vi_end);
- }
- } test_indirect_iterator_vec_cp_int;
-
- /**
- * \test Test IndirectIterator over a list of shared_ptr of int.
- *
- */
- struct IndirectIteratorListCPIntTest : TestCase
- {
- IndirectIteratorListCPIntTest() : TestCase("list<std::shared_ptr<int> >") { }
-
- void run()
- {
- std::list<std::shared_ptr<int> > v;
- v.push_back(std::shared_ptr<int>(std::make_shared<int>(5)));
- v.push_back(std::shared_ptr<int>(std::make_shared<int>(10)));
- IndirectIterator<std::list<std::shared_ptr<int> >::iterator> vi(v.begin()), vi_end(v.end());
- TEST_CHECK(vi != vi_end);
- TEST_CHECK_EQUAL(*vi, 5);
- TEST_CHECK(++vi != vi_end);
- TEST_CHECK_EQUAL(*vi, 10);
- TEST_CHECK(++vi == vi_end);
- }
- } test_indirect_iterator_list_cp_int;
-
- /**
- * \test Test IndirectIterator over a vector of int *.
- *
- */
- struct IndirectIteratorVecPIntTest : TestCase
- {
- IndirectIteratorVecPIntTest() : TestCase("vector<int *>") { }
-
- void run()
- {
- std::vector<int *> v;
- v.push_back(new int(5));
- v.push_back(new int(10));
- IndirectIterator<std::vector<int *>::iterator, int> vi(v.begin()), vi_end(v.end());
- TEST_CHECK(vi != vi_end);
- TEST_CHECK(vi < vi_end);
- TEST_CHECK(! (vi > vi_end));
- TEST_CHECK_EQUAL(*vi, 5);
- TEST_CHECK(++vi != vi_end);
- TEST_CHECK(vi < vi_end);
- TEST_CHECK(! (vi > vi_end));
- TEST_CHECK_EQUAL(*vi, 10);
- TEST_CHECK(++vi == vi_end);
-
- std::for_each(v.begin(), v.end(), Deleter());
- }
- } test_indirect_iterator_vec_p_int;
-
- /**
- * \test Test IndirectIterator over a list of int *.
- *
- */
- struct IndirectIteratorListPIntTest : TestCase
- {
- IndirectIteratorListPIntTest() : TestCase("list<int *>") { }
+ std::vector<std::shared_ptr<int> > v;
+ v.push_back(std::shared_ptr<int>(std::make_shared<int>(5)));
+ v.push_back(std::shared_ptr<int>(std::make_shared<int>(10)));
+ IndirectIterator<std::vector<std::shared_ptr<int> >::iterator, int> vi(v.begin()), vi_end(v.end());
+ ASSERT_TRUE(vi != vi_end);
+ ASSERT_TRUE(vi < vi_end);
+ ASSERT_TRUE(! (vi > vi_end));
+ EXPECT_EQ(5, *vi);
+ ASSERT_TRUE(++vi != vi_end);
+ ASSERT_TRUE(vi < vi_end);
+ ASSERT_TRUE(! (vi > vi_end));
+ EXPECT_EQ(10, *vi);
+ ASSERT_TRUE(++vi == vi_end);
+}
- void run()
- {
- std::list<int *> v;
- v.push_back(new int(5));
- v.push_back(new int(10));
- IndirectIterator<std::list<int *>::iterator, int> vi(v.begin()), vi_end(v.end());
- TEST_CHECK(vi != vi_end);
- TEST_CHECK_EQUAL(*vi, 5);
- TEST_CHECK(++vi != vi_end);
- TEST_CHECK_EQUAL(*vi, 10);
- TEST_CHECK(++vi == vi_end);
-
- std::for_each(v.begin(), v.end(), Deleter());
- }
- } test_indirect_iterator_list_p_int;
+TEST(IndirectIterator, ListSharedInt)
+{
+ std::list<std::shared_ptr<int> > v;
+ v.push_back(std::shared_ptr<int>(std::make_shared<int>(5)));
+ v.push_back(std::shared_ptr<int>(std::make_shared<int>(10)));
+ IndirectIterator<std::list<std::shared_ptr<int> >::iterator> vi(v.begin()), vi_end(v.end());
+ ASSERT_TRUE(vi != vi_end);
+ EXPECT_EQ(5, *vi);
+ ASSERT_TRUE(++vi != vi_end);
+ EXPECT_EQ(10, *vi);
+ ASSERT_TRUE(++vi == vi_end);
+}
- struct IndirectIteratorListListIterIntTest : TestCase
- {
- IndirectIteratorListListIterIntTest() : TestCase("list<list<int>::iterator>") { }
+TEST(IndirectIterator, VectorIntStar)
+{
+ std::vector<int *> v;
+ v.push_back(new int(5));
+ v.push_back(new int(10));
+ IndirectIterator<std::vector<int *>::iterator, int> vi(v.begin()), vi_end(v.end());
+ ASSERT_TRUE(vi != vi_end);
+ ASSERT_TRUE(vi < vi_end);
+ ASSERT_TRUE(! (vi > vi_end));
+ EXPECT_EQ(5, *vi);
+ ASSERT_TRUE(++vi != vi_end);
+ ASSERT_TRUE(vi < vi_end);
+ ASSERT_TRUE(! (vi > vi_end));
+ EXPECT_EQ(10, *vi);
+ ASSERT_TRUE(++vi == vi_end);
+
+ std::for_each(v.begin(), v.end(), Deleter());
+}
- void run()
- {
- std::list<int> v;
- v.push_back(5);
- v.push_back(10);
+TEST(IndirectIterator, ListIntStar)
+{
+ std::list<int *> v;
+ v.push_back(new int(5));
+ v.push_back(new int(10));
+ IndirectIterator<std::list<int *>::iterator, int> vi(v.begin()), vi_end(v.end());
+ ASSERT_TRUE(vi != vi_end);
+ EXPECT_EQ(5, *vi);
+ ASSERT_TRUE(++vi != vi_end);
+ EXPECT_EQ(10, *vi);
+ ASSERT_TRUE(++vi == vi_end);
+
+ std::for_each(v.begin(), v.end(), Deleter());
+}
- std::list<std::list<int>::iterator> w;
- w.push_back(v.begin());
- w.push_back(next(v.begin()));
+TEST(IndirectIterator, ListIntListIterator)
+{
+ std::list<int> v;
+ v.push_back(5);
+ v.push_back(10);
- TEST_CHECK_EQUAL(join(indirect_iterator(w.begin()), indirect_iterator(w.end()), ", "), "5, 10");
+ std::list<std::list<int>::iterator> w;
+ w.push_back(v.begin());
+ w.push_back(next(v.begin()));
- }
- } test_indirect_iterator_list_list_int_iter;
+ EXPECT_EQ("5, 10", join(indirect_iterator(w.begin()), indirect_iterator(w.end()), ", "));
}