aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-03 16:45:48 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-03 16:45:48 +0000
commit0ba2096aba6461243798f27020ab2c8b7f5af689 (patch)
treefd6f4d1c187d0f4382c6b3ca824ac2539fbcf047
parentc9897068b44e6399b3db5eeec51f010cddc9a340 (diff)
downloadpaludis-0ba2096aba6461243798f27020ab2c8b7f5af689.tar.gz
paludis-0ba2096aba6461243798f27020ab2c8b7f5af689.tar.xz
Fix some_dir_iterator != DirIterator() and DirIterator() != some_dir_iterator inconsistencies. Add testcase.
-rw-r--r--paludis/dir_iterator.cc3
-rw-r--r--paludis/dir_iterator_TEST.cc4
2 files changed, 7 insertions, 0 deletions
diff --git a/paludis/dir_iterator.cc b/paludis/dir_iterator.cc
index ce5eaaa..cfb69f6 100644
--- a/paludis/dir_iterator.cc
+++ b/paludis/dir_iterator.cc
@@ -116,6 +116,9 @@ DirIterator::operator== (const DirIterator & other) const
if (other._iter == other._items->end())
return _iter == _items->end();
+ if (_iter == _items->end())
+ return other._iter == other._items->end();
+
if (other._items != _items)
throw InternalError(PALUDIS_HERE,
"comparing two different DirIterators.");
diff --git a/paludis/dir_iterator_TEST.cc b/paludis/dir_iterator_TEST.cc
index 3b39749..6bad139 100644
--- a/paludis/dir_iterator_TEST.cc
+++ b/paludis/dir_iterator_TEST.cc
@@ -62,9 +62,13 @@ namespace test_cases
DirIterator iter(FSEntry("dir_iterator_TEST_dir"));
DirIterator iter1(FSEntry("dir_iterator_TEST_dir"));
+ TEST_CHECK(iter != DirIterator());
+ TEST_CHECK(DirIterator() != iter);
+
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(DirIterator() == iter);
TEST_CHECK(++iter1 == DirIterator());
}