aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNicolas Catania <niko@google.com>2010-01-13 15:40:14 -0800
committerNicolas Catania <niko@google.com>2010-01-13 15:56:46 -0800
commit91ea6c037471a1acd97b03c3097223777906f748 (patch)
treed3ec27e8df9433193a35a71fcc93a321abba0ce3 /tests
parentdfec9fcb74ce3381af05f54e6ebc2667a6bfb6b8 (diff)
downloadastl-91ea6c037471a1acd97b03c3097223777906f748.tar.gz
Basic implementation of iterators.
Added basic iterator support for strings.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_string.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test_string.cpp b/tests/test_string.cpp
index bd69a46..60c02aa 100644
--- a/tests/test_string.cpp
+++ b/tests/test_string.cpp
@@ -867,6 +867,31 @@ bool testErase()
return true;
}
+// Checks an iterator can be cast to a const one.
+bool testConstIterator()
+{
+ string s("a string");
+ string::iterator i = s.begin();
+ string::const_iterator ci = s.begin();
+ return true;
+}
+
+bool testForwardIterator()
+{
+ string s("a string");
+ char chars[] = "a string";
+ string::iterator iter = s.begin();
+ for (int i = 0; iter != s.end(); ++i) {
+ EXPECT_TRUE(*iter == chars[i]);
+ ++iter;
+ }
+ EXPECT_TRUE(iter == s.end());
+
+ string empty;
+ EXPECT_TRUE(empty.begin() == empty.end());
+ return true;
+}
+
} // namespace android
int main(int argc, char **argv)
@@ -891,5 +916,7 @@ int main(int argc, char **argv)
FAIL_UNLESS(testCapacity);
FAIL_UNLESS(testClear);
FAIL_UNLESS(testErase);
+ FAIL_UNLESS(testConstIterator);
+ FAIL_UNLESS(testForwardIterator);
return kPassed;
}