aboutsummaryrefslogtreecommitdiff
path: root/tests/test_string.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_string.cpp')
-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;
}