summaryrefslogtreecommitdiffstats
path: root/libcxx/test/strings/basic.string/string.iterators
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2010-05-11 19:42:16 +0000
committerHoward Hinnant <hhinnant@apple.com>2010-05-11 19:42:16 +0000
commit3e519524c118651123eecf60c2bbc5d65ad9bac3 (patch)
treeb2dd4168cfe448920a602cd7d2e40f95da187153 /libcxx/test/strings/basic.string/string.iterators
parent9132c59d43b6c590c9bb33496eebf9f192d6857a (diff)
downloadbcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.tar.gz
bcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.zip
libcxx initial import
llvm-svn: 103490
Diffstat (limited to 'libcxx/test/strings/basic.string/string.iterators')
-rw-r--r--libcxx/test/strings/basic.string/string.iterators/begin.pass.cpp37
-rw-r--r--libcxx/test/strings/basic.string/string.iterators/cbegin.pass.cpp34
-rw-r--r--libcxx/test/strings/basic.string/string.iterators/cend.pass.cpp30
-rw-r--r--libcxx/test/strings/basic.string/string.iterators/crbegin.pass.cpp34
-rw-r--r--libcxx/test/strings/basic.string/string.iterators/crend.pass.cpp30
-rw-r--r--libcxx/test/strings/basic.string/string.iterators/end.pass.cpp39
-rw-r--r--libcxx/test/strings/basic.string/string.iterators/rbegin.pass.cpp37
-rw-r--r--libcxx/test/strings/basic.string/string.iterators/rend.pass.cpp39
8 files changed, 280 insertions, 0 deletions
diff --git a/libcxx/test/strings/basic.string/string.iterators/begin.pass.cpp b/libcxx/test/strings/basic.string/string.iterators/begin.pass.cpp
new file mode 100644
index 00000000000..2d54de45d00
--- /dev/null
+++ b/libcxx/test/strings/basic.string/string.iterators/begin.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator begin();
+// const_iterator begin() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+ const S& cs = s;
+ typename S::iterator b = s.begin();
+ typename S::const_iterator cb = cs.begin();
+ if (!s.empty())
+ {
+ assert(*b == s[0]);
+ }
+ assert(b == cb);
+}
+
+int main()
+{
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+}
diff --git a/libcxx/test/strings/basic.string/string.iterators/cbegin.pass.cpp b/libcxx/test/strings/basic.string/string.iterators/cbegin.pass.cpp
new file mode 100644
index 00000000000..f794a460967
--- /dev/null
+++ b/libcxx/test/strings/basic.string/string.iterators/cbegin.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_iterator cbegin() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s)
+{
+ typename S::const_iterator cb = s.cbegin();
+ if (!s.empty())
+ {
+ assert(*cb == s[0]);
+ }
+ assert(cb == s.begin());
+}
+
+int main()
+{
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+}
diff --git a/libcxx/test/strings/basic.string/string.iterators/cend.pass.cpp b/libcxx/test/strings/basic.string/string.iterators/cend.pass.cpp
new file mode 100644
index 00000000000..5d5801fad27
--- /dev/null
+++ b/libcxx/test/strings/basic.string/string.iterators/cend.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_iterator cend() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s)
+{
+ typename S::const_iterator ce = s.cend();
+ assert(ce == s.end());
+}
+
+int main()
+{
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+}
diff --git a/libcxx/test/strings/basic.string/string.iterators/crbegin.pass.cpp b/libcxx/test/strings/basic.string/string.iterators/crbegin.pass.cpp
new file mode 100644
index 00000000000..707272f7a74
--- /dev/null
+++ b/libcxx/test/strings/basic.string/string.iterators/crbegin.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_reverse_iterator crbegin() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s)
+{
+ typename S::const_reverse_iterator cb = s.crbegin();
+ if (!s.empty())
+ {
+ assert(*cb == s.back());
+ }
+ assert(cb == s.rbegin());
+}
+
+int main()
+{
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+}
diff --git a/libcxx/test/strings/basic.string/string.iterators/crend.pass.cpp b/libcxx/test/strings/basic.string/string.iterators/crend.pass.cpp
new file mode 100644
index 00000000000..290854df24c
--- /dev/null
+++ b/libcxx/test/strings/basic.string/string.iterators/crend.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_reverse_iterator crend() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s)
+{
+ typename S::const_reverse_iterator ce = s.crend();
+ assert(ce == s.rend());
+}
+
+int main()
+{
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+}
diff --git a/libcxx/test/strings/basic.string/string.iterators/end.pass.cpp b/libcxx/test/strings/basic.string/string.iterators/end.pass.cpp
new file mode 100644
index 00000000000..cf43bdd7bf6
--- /dev/null
+++ b/libcxx/test/strings/basic.string/string.iterators/end.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator end();
+// const_iterator end() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+ const S& cs = s;
+ typename S::iterator e = s.end();
+ typename S::const_iterator ce = cs.end();
+ if (s.empty())
+ {
+ assert(e == s.begin());
+ assert(ce == cs.begin());
+ }
+ assert(e - s.begin() == s.size());
+ assert(ce - cs.begin() == cs.size());
+}
+
+int main()
+{
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+}
diff --git a/libcxx/test/strings/basic.string/string.iterators/rbegin.pass.cpp b/libcxx/test/strings/basic.string/string.iterators/rbegin.pass.cpp
new file mode 100644
index 00000000000..1653136891a
--- /dev/null
+++ b/libcxx/test/strings/basic.string/string.iterators/rbegin.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+ const S& cs = s;
+ typename S::reverse_iterator b = s.rbegin();
+ typename S::const_reverse_iterator cb = cs.rbegin();
+ if (!s.empty())
+ {
+ assert(*b == s.back());
+ }
+ assert(b == cb);
+}
+
+int main()
+{
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+}
diff --git a/libcxx/test/strings/basic.string/string.iterators/rend.pass.cpp b/libcxx/test/strings/basic.string/string.iterators/rend.pass.cpp
new file mode 100644
index 00000000000..5daed016127
--- /dev/null
+++ b/libcxx/test/strings/basic.string/string.iterators/rend.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// reverse_iterator rend();
+// const_reverse_iterator rend() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+ const S& cs = s;
+ typename S::reverse_iterator e = s.rend();
+ typename S::const_reverse_iterator ce = cs.rend();
+ if (s.empty())
+ {
+ assert(e == s.rbegin());
+ assert(ce == cs.rbegin());
+ }
+ assert(e - s.rbegin() == s.size());
+ assert(ce - cs.rbegin() == cs.size());
+}
+
+int main()
+{
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+}
OpenPOWER on IntegriCloud