aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Mark Loeser <halcy0n@gentoo.org> 2006-01-30 05:41:57 +0000
committerAvatar Mark Loeser <halcy0n@gentoo.org> 2006-01-30 05:41:57 +0000
commit977f008d1b829c823e5e30d3274b4d47ea5b6022 (patch)
treee29ceb713c068ae7277e97d35b62b35e697fe8bb
parenta87e65c033bf425cd4644838ffee21ea64cbf677 (diff)
downloadpaludis-977f008d1b829c823e5e30d3274b4d47ea5b6022.tar.gz
paludis-977f008d1b829c823e5e30d3274b4d47ea5b6022.tar.xz
Some simple tests for iterator_utilities
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/iterator_utilities_TEST.cc83
2 files changed, 84 insertions, 1 deletions
diff --git a/paludis/files.m4 b/paludis/files.m4
index 4007263..f7e2982 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -44,7 +44,7 @@ add(`indirect_iterator', `hh', `cc', `test')
add(`instantiation_policy', `hh', `cc', `test')
add(`is_const', `hh', `cc', `test')
add(`is_file_with_extension', `hh', `cc', `test', `testscript')
-add(`iterator_utilities', `hh', `cc')
+add(`iterator_utilities', `hh', `cc', `test')
add(`join', `hh', `cc', `test')
add(`key_value_config_file', `hh', `cc', `test')
add(`keyword_name', `hh', `cc')
diff --git a/paludis/iterator_utilities_TEST.cc b/paludis/iterator_utilities_TEST.cc
new file mode 100644
index 0000000..4fd6642
--- /dev/null
+++ b/paludis/iterator_utilities_TEST.cc
@@ -0,0 +1,83 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Mark Loeser <halcy0n@gentoo.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "iterator_utilities.hh"
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+#include <string>
+#include <vector>
+
+using namespace test;
+using namespace paludis;
+
+/** \file
+ * Test cases for iterator_utilities.hh .
+ *
+ * \ingroup Test
+ */
+
+namespace test_cases
+{
+ /**
+ * \test Test iterator_utilities next()
+ *
+ * \ingroup Test
+ */
+ struct IteratorNextTest : public TestCase
+ {
+ IteratorNextTest() : TestCase("iterator next()") { }
+
+ void run()
+ {
+ std::vector<int> v;
+ v.push_back(1);
+ v.push_back(2);
+ std::vector<int>::iterator iter(v.begin());
+
+ TEST_CHECK(*(next(iter)) == 2);
+ TEST_CHECK(next(next(iter)) == v.end());
+ iter = next(iter);
+ TEST_CHECK(++iter == v.end());
+ }
+ } test_iterator_next;
+
+ /**
+ * \test Test iterator_utilities previous()
+ *
+ * \ingroup Test
+ */
+ struct IteratorpreviousTest : public TestCase
+ {
+ IteratorpreviousTest() : TestCase("iterator previous()") { }
+
+ void run()
+ {
+ std::vector<int> v;
+ v.push_back(1);
+ v.push_back(2);
+ std::vector<int>::iterator iter(v.end());
+
+ TEST_CHECK(*(previous(iter)) == 2);
+ TEST_CHECK(previous(previous(iter)) == v.begin());
+ iter = previous(iter);
+ TEST_CHECK(--iter == v.begin());
+ }
+ } test_iterator_previous;
+}
+