summaryrefslogtreecommitdiffstats
path: root/libcxx/test/strings/basic.string/string.ops/string_rfind
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2013-06-28 16:59:19 +0000
committerHoward Hinnant <hhinnant@apple.com>2013-06-28 16:59:19 +0000
commiteec721826cc35a0c08dc5bc54db9a51dbd4fa361 (patch)
treebe3ea93c71256a122174477e4e8b0024bca43ee7 /libcxx/test/strings/basic.string/string.ops/string_rfind
parente852add40ed7d93da626d4e2286c840afb9d98d8 (diff)
downloadbcm5719-llvm-eec721826cc35a0c08dc5bc54db9a51dbd4fa361.tar.gz
bcm5719-llvm-eec721826cc35a0c08dc5bc54db9a51dbd4fa361.zip
Implement full support for non-pointer pointers in custom allocators for string. This completes the custom pointer support for the entire library.
llvm-svn: 185167
Diffstat (limited to 'libcxx/test/strings/basic.string/string.ops/string_rfind')
-rw-r--r--libcxx/test/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp37
-rw-r--r--libcxx/test/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp20
-rw-r--r--libcxx/test/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp28
-rw-r--r--libcxx/test/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp20
4 files changed, 89 insertions, 16 deletions
diff --git a/libcxx/test/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp b/libcxx/test/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp
index 932e3530fa6..8db67d9fa95 100644
--- a/libcxx/test/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp
@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
+#include "../../min_allocator.h"
+
template <class S>
void
test(const S& s, typename S::value_type c, typename S::size_type pos,
@@ -33,10 +35,39 @@ test(const S& s, typename S::value_type c, typename S::size_type x)
assert(x + 1 <= s.size());
}
-typedef std::string S;
-
int main()
{
+ {
+ typedef std::string S;
+ test(S(""), 'b', 0, S::npos);
+ test(S(""), 'b', 1, S::npos);
+ test(S("abcde"), 'b', 0, S::npos);
+ test(S("abcde"), 'b', 1, 1);
+ test(S("abcde"), 'b', 2, 1);
+ test(S("abcde"), 'b', 4, 1);
+ test(S("abcde"), 'b', 5, 1);
+ test(S("abcde"), 'b', 6, 1);
+ test(S("abcdeabcde"), 'b', 0, S::npos);
+ test(S("abcdeabcde"), 'b', 1, 1);
+ test(S("abcdeabcde"), 'b', 5, 1);
+ test(S("abcdeabcde"), 'b', 9, 6);
+ test(S("abcdeabcde"), 'b', 10, 6);
+ test(S("abcdeabcde"), 'b', 11, 6);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 0, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 10, 6);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 19, 16);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 20, 16);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 21, 16);
+
+ test(S(""), 'b', S::npos);
+ test(S("abcde"), 'b', 1);
+ test(S("abcdeabcde"), 'b', 6);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 16);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), 'b', 0, S::npos);
test(S(""), 'b', 1, S::npos);
test(S("abcde"), 'b', 0, S::npos);
@@ -62,4 +93,6 @@ int main()
test(S("abcde"), 'b', 1);
test(S("abcdeabcde"), 'b', 6);
test(S("abcdeabcdeabcdeabcde"), 'b', 16);
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp b/libcxx/test/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp
index 4424fdf4a95..2b1efd336dc 100644
--- a/libcxx/test/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp
@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
+#include "../../min_allocator.h"
+
template <class S>
void
test(const S& s, const typename S::value_type* str, typename S::size_type pos,
@@ -40,8 +42,7 @@ test(const S& s, const typename S::value_type* str, typename S::size_type x)
}
}
-typedef std::string S;
-
+template <class S>
void test0()
{
test(S(""), "", 0, 0);
@@ -126,6 +127,7 @@ void test0()
test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0);
}
+template <class S>
void test1()
{
test(S(""), "", 0);
@@ -148,6 +150,16 @@ void test1()
int main()
{
- test0();
- test1();
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp b/libcxx/test/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp
index 8ba26f126ee..5699cabfbeb 100644
--- a/libcxx/test/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp
@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
+#include "../../min_allocator.h"
+
template <class S>
void
test(const S& s, const typename S::value_type* str, typename S::size_type pos,
@@ -24,8 +26,7 @@ test(const S& s, const typename S::value_type* str, typename S::size_type pos,
assert(x <= pos && x + n <= s.size());
}
-typedef std::string S;
-
+template <class S>
void test0()
{
test(S(""), "", 0, 0, 0);
@@ -130,6 +131,7 @@ void test0()
test(S("abcde"), "abcde", 5, 2, 0);
}
+template <class S>
void test1()
{
test(S("abcde"), "abcde", 5, 4, 0);
@@ -234,6 +236,7 @@ void test1()
test(S("abcdeabcde"), "abcdeabcde", 10, 1, 5);
}
+template <class S>
void test2()
{
test(S("abcdeabcde"), "abcdeabcde", 10, 5, 5);
@@ -338,6 +341,7 @@ void test2()
test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20);
}
+template <class S>
void test3()
{
test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 1, 15);
@@ -364,8 +368,20 @@ void test3()
int main()
{
- test0();
- test1();
- test2();
- test3();
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp b/libcxx/test/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp
index 0c69f3c089a..d7c2e8503a6 100644
--- a/libcxx/test/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp
@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
+#include "../../min_allocator.h"
+
template <class S>
void
test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
@@ -32,8 +34,7 @@ test(const S& s, const S& str, typename S::size_type x)
assert(0 <= x && x + str.size() <= s.size());
}
-typedef std::string S;
-
+template <class S>
void test0()
{
test(S(""), S(""), 0, 0);
@@ -118,6 +119,7 @@ void test0()
test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 21, 0);
}
+template <class S>
void test1()
{
test(S(""), S(""), 0);
@@ -140,6 +142,16 @@ void test1()
int main()
{
- test0();
- test1();
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ }
+#endif
}
OpenPOWER on IntegriCloud