summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/strings/basic.string/string.iterators
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2014-12-20 01:40:03 +0000
committerEric Fiselier <eric@efcs.ca>2014-12-20 01:40:03 +0000
commit5a83710e371fe68a06e6e3876c6a2c8b820a8976 (patch)
treeafde4c82ad6704681781c5cd49baa3fbd05c85db /libcxx/test/std/strings/basic.string/string.iterators
parentf11e8eab527fba316c64112f6e05de1a79693a3e (diff)
downloadbcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.tar.gz
bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.zip
Move test into test/std subdirectory.
llvm-svn: 224658
Diffstat (limited to 'libcxx/test/std/strings/basic.string/string.iterators')
-rw-r--r--libcxx/test/std/strings/basic.string/string.iterators/begin.pass.cpp48
-rw-r--r--libcxx/test/std/strings/basic.string/string.iterators/cbegin.pass.cpp45
-rw-r--r--libcxx/test/std/strings/basic.string/string.iterators/cend.pass.cpp41
-rw-r--r--libcxx/test/std/strings/basic.string/string.iterators/crbegin.pass.cpp45
-rw-r--r--libcxx/test/std/strings/basic.string/string.iterators/crend.pass.cpp41
-rw-r--r--libcxx/test/std/strings/basic.string/string.iterators/db_iterators_2.pass.cpp52
-rw-r--r--libcxx/test/std/strings/basic.string/string.iterators/db_iterators_3.pass.cpp52
-rw-r--r--libcxx/test/std/strings/basic.string/string.iterators/db_iterators_4.pass.cpp54
-rw-r--r--libcxx/test/std/strings/basic.string/string.iterators/db_iterators_5.pass.cpp58
-rw-r--r--libcxx/test/std/strings/basic.string/string.iterators/db_iterators_6.pass.cpp56
-rw-r--r--libcxx/test/std/strings/basic.string/string.iterators/db_iterators_7.pass.cpp56
-rw-r--r--libcxx/test/std/strings/basic.string/string.iterators/db_iterators_8.pass.cpp52
-rw-r--r--libcxx/test/std/strings/basic.string/string.iterators/end.pass.cpp50
-rw-r--r--libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp73
-rw-r--r--libcxx/test/std/strings/basic.string/string.iterators/rbegin.pass.cpp48
-rw-r--r--libcxx/test/std/strings/basic.string/string.iterators/rend.pass.cpp50
16 files changed, 821 insertions, 0 deletions
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/begin.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/begin.pass.cpp
new file mode 100644
index 00000000000..55f2eb30f80
--- /dev/null
+++ b/libcxx/test/std/strings/basic.string/string.iterators/begin.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator begin();
+// const_iterator begin() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+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"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ }
+#endif
+}
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/cbegin.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/cbegin.pass.cpp
new file mode 100644
index 00000000000..d0c6ddbb950
--- /dev/null
+++ b/libcxx/test/std/strings/basic.string/string.iterators/cbegin.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_iterator cbegin() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+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"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ }
+#endif
+}
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/cend.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/cend.pass.cpp
new file mode 100644
index 00000000000..6b86d263245
--- /dev/null
+++ b/libcxx/test/std/strings/basic.string/string.iterators/cend.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_iterator cend() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+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"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ }
+#endif
+}
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/crbegin.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/crbegin.pass.cpp
new file mode 100644
index 00000000000..6f29f433f31
--- /dev/null
+++ b/libcxx/test/std/strings/basic.string/string.iterators/crbegin.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_reverse_iterator crbegin() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+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"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ }
+#endif
+}
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/crend.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/crend.pass.cpp
new file mode 100644
index 00000000000..1fb422c080a
--- /dev/null
+++ b/libcxx/test/std/strings/basic.string/string.iterators/crend.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_reverse_iterator crend() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+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"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ }
+#endif
+}
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_2.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_2.pass.cpp
new file mode 100644
index 00000000000..6cac1875ce8
--- /dev/null
+++ b/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_2.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Compare iterators from different containers with <.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string S;
+ S s1;
+ S s2;
+ bool b = s1.begin() < s2.begin();
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s1;
+ S s2;
+ bool b = s1.begin() < s2.begin();
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_3.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_3.pass.cpp
new file mode 100644
index 00000000000..d90387e3a46
--- /dev/null
+++ b/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_3.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Subtract iterators from different containers with <.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string S;
+ S s1;
+ S s2;
+ int i = s1.begin() - s2.begin();
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s1;
+ S s2;
+ int i = s1.begin() - s2.begin();
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_4.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_4.pass.cpp
new file mode 100644
index 00000000000..c4a2d0a4baf
--- /dev/null
+++ b/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_4.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Index iterator out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string C;
+ C c(1, '\0');
+ C::iterator i = c.begin();
+ assert(i[0] == 0);
+ assert(i[1] == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
+ C c(1, '\0');
+ C::iterator i = c.begin();
+ assert(i[0] == 0);
+ assert(i[1] == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_5.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_5.pass.cpp
new file mode 100644
index 00000000000..ce44cb1ba5b
--- /dev/null
+++ b/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_5.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Add to iterator out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string C;
+ C c(1, '\0');
+ C::iterator i = c.begin();
+ i += 1;
+ assert(i == c.end());
+ i = c.begin();
+ i += 2;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
+ C c(1, '\0');
+ C::iterator i = c.begin();
+ i += 1;
+ assert(i == c.end());
+ i = c.begin();
+ i += 2;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_6.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_6.pass.cpp
new file mode 100644
index 00000000000..8fab8babc61
--- /dev/null
+++ b/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_6.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Decrement iterator prior to begin.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string C;
+ C c(1, '\0');
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ --i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
+ C c(1, '\0');
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ --i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_7.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_7.pass.cpp
new file mode 100644
index 00000000000..d1cac07e222
--- /dev/null
+++ b/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_7.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string C;
+ C c(1, '\0');
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
+ C c(1, '\0');
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_8.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_8.pass.cpp
new file mode 100644
index 00000000000..914c77d48c5
--- /dev/null
+++ b/libcxx/test/std/strings/basic.string/string.iterators/db_iterators_8.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string C;
+ C c(1, '\0');
+ C::iterator i = c.end();
+ char j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
+ C c(1, '\0');
+ C::iterator i = c.end();
+ char j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/end.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/end.pass.cpp
new file mode 100644
index 00000000000..02180bbd73d
--- /dev/null
+++ b/libcxx/test/std/strings/basic.string/string.iterators/end.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator end();
+// const_iterator end() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+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"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ }
+#endif
+}
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp
new file mode 100644
index 00000000000..386cededa53
--- /dev/null
+++ b/libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator begin();
+// iterator end();
+// const_iterator begin() const;
+// const_iterator end() const;
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::string C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+ assert ( ii1 == cii );
+ assert ( !(ii1 != ii2 ));
+ assert ( !(ii1 != cii ));
+ }
+
+ { // N3644 testing
+ typedef std::wstring C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+ assert ( ii1 == cii );
+ assert ( !(ii1 != ii2 ));
+ assert ( !(ii1 != cii ));
+ }
+
+ { // N3644 testing
+ typedef std::u16string C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+ assert ( ii1 == cii );
+ assert ( !(ii1 != ii2 ));
+ assert ( !(ii1 != cii ));
+ }
+
+ { // N3644 testing
+ typedef std::u32string C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+ assert ( ii1 == cii );
+ assert ( !(ii1 != ii2 ));
+ assert ( !(ii1 != cii ));
+ }
+#endif
+}
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/rbegin.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/rbegin.pass.cpp
new file mode 100644
index 00000000000..0111ad11363
--- /dev/null
+++ b/libcxx/test/std/strings/basic.string/string.iterators/rbegin.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+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"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ }
+#endif
+}
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/rend.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/rend.pass.cpp
new file mode 100644
index 00000000000..750173dc342
--- /dev/null
+++ b/libcxx/test/std/strings/basic.string/string.iterators/rend.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// reverse_iterator rend();
+// const_reverse_iterator rend() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+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"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ }
+#endif
+}
OpenPOWER on IntegriCloud