aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Mark Loeser <halcy0n@gentoo.org> 2006-01-28 08:13:53 +0000
committerAvatar Mark Loeser <halcy0n@gentoo.org> 2006-01-28 08:13:53 +0000
commit081bfb52479b562263b688b07f976baa3e068665 (patch)
tree0ebd8d253e9442d23e06704ed3d75b16f8cf04c8
parent627b6f31bbce4904f729e295795a2321c455aed5 (diff)
downloadpaludis-081bfb52479b562263b688b07f976baa3e068665.tar.gz
paludis-081bfb52479b562263b688b07f976baa3e068665.tar.xz
Some initial simple tests for DirIterator
-rw-r--r--paludis/dir_iterator_TEST.cc72
-rwxr-xr-xpaludis/dir_iterator_TEST_cleanup.sh9
-rwxr-xr-xpaludis/dir_iterator_TEST_setup.sh6
-rw-r--r--paludis/files.m42
4 files changed, 88 insertions, 1 deletions
diff --git a/paludis/dir_iterator_TEST.cc b/paludis/dir_iterator_TEST.cc
new file mode 100644
index 0000000..3b39749
--- /dev/null
+++ b/paludis/dir_iterator_TEST.cc
@@ -0,0 +1,72 @@
+/* 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 "dir_iterator.hh"
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+
+using namespace paludis;
+using namespace test;
+
+/** \file
+ * Test cases for dir_iterator.hh.
+ *
+ * \ingroup Test
+ */
+
+namespace test_cases
+{
+ /**
+ * \test Test DirIterator construction and manipulation.
+ */
+ struct DirIteratorManipulationTest : TestCase
+ {
+ DirIteratorManipulationTest() : TestCase("construction and manipulation") { }
+
+ void run()
+ {
+ TEST_CHECK_THROWS(DirIterator(FSEntry("/i/dont/exist/")), DirOpenError);
+
+ DirIterator iter(FSEntry("dir_iterator_TEST_dir"));
+ DirIterator iter1(iter);
+ TEST_CHECK(iter == iter1);
+ TEST_CHECK(!(iter != iter1));
+ }
+ } test_dir_iterator_manipulation;
+
+ /**
+ * \test Test DirIterator iterating abilities
+ */
+ struct DirIteratorIterateTest : TestCase
+ {
+ DirIteratorIterateTest() : TestCase("iterate") {}
+
+ void run()
+ {
+ DirIterator iter(FSEntry("dir_iterator_TEST_dir"));
+ DirIterator iter1(FSEntry("dir_iterator_TEST_dir"));
+
+ TEST_CHECK(*iter == FSEntry("dir_iterator_TEST_dir/all_perms"));
+ TEST_CHECK(*(iter++) == FSEntry("dir_iterator_TEST_dir/all_perms"));
+ TEST_CHECK(iter == DirIterator());
+
+ TEST_CHECK(++iter1 == DirIterator());
+ }
+ } test_dir_iterator_iterate;
+}
diff --git a/paludis/dir_iterator_TEST_cleanup.sh b/paludis/dir_iterator_TEST_cleanup.sh
new file mode 100755
index 0000000..8d6e8ba
--- /dev/null
+++ b/paludis/dir_iterator_TEST_cleanup.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d dir_iterator_TEST_dir ] ; then
+ rm -fr dir_iterator_TEST_dir
+else
+ true
+fi
+
diff --git a/paludis/dir_iterator_TEST_setup.sh b/paludis/dir_iterator_TEST_setup.sh
new file mode 100755
index 0000000..9fa425e
--- /dev/null
+++ b/paludis/dir_iterator_TEST_setup.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir dir_iterator_TEST_dir || exit 2
+cd dir_iterator_TEST_dir || exit 3
+touch all_perms || exit 4
diff --git a/paludis/files.m4 b/paludis/files.m4
index cc33947..6e6e4be 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -31,7 +31,7 @@ add(`dep_atom_visitor', `hh', `cc')
add(`dep_lexer', `hh', `cc', `test')
add(`dep_list', `hh', `cc', `test')
add(`dep_parser', `hh', `cc', `test')
-add(`dir_iterator', `hh', `cc')
+add(`dir_iterator', `hh', `cc', `test', `testscript')
add(`environment', `hh', `cc')
add(`exception', `hh', `cc')
add(`fake_repository', `hh', `cc')