From eec721826cc35a0c08dc5bc54db9a51dbd4fa361 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Fri, 28 Jun 2013 16:59:19 +0000 Subject: 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 --- .../string.ops/string_find/char_size.pass.cpp | 37 ++++++++++++++++++++-- .../string.ops/string_find/pointer_size.pass.cpp | 20 +++++++++--- .../string_find/pointer_size_size.pass.cpp | 28 ++++++++++++---- .../string.ops/string_find/string_size.pass.cpp | 20 +++++++++--- 4 files changed, 89 insertions(+), 16 deletions(-) (limited to 'libcxx/test/strings/basic.string/string.ops/string_find') diff --git a/libcxx/test/strings/basic.string/string.ops/string_find/char_size.pass.cpp b/libcxx/test/strings/basic.string/string.ops/string_find/char_size.pass.cpp index c08ee53c9af..3c48a77045d 100644 --- a/libcxx/test/strings/basic.string/string.ops/string_find/char_size.pass.cpp +++ b/libcxx/test/strings/basic.string/string.ops/string_find/char_size.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../min_allocator.h" + template 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(0 <= x && x + 1 <= s.size()); } -typedef std::string S; - int main() { + { + typedef std::string S; + test(S(""), 'c', 0, S::npos); + test(S(""), 'c', 1, S::npos); + test(S("abcde"), 'c', 0, 2); + test(S("abcde"), 'c', 1, 2); + test(S("abcde"), 'c', 2, 2); + test(S("abcde"), 'c', 4, S::npos); + test(S("abcde"), 'c', 5, S::npos); + test(S("abcde"), 'c', 6, S::npos); + test(S("abcdeabcde"), 'c', 0, 2); + test(S("abcdeabcde"), 'c', 1, 2); + test(S("abcdeabcde"), 'c', 5, 7); + test(S("abcdeabcde"), 'c', 9, S::npos); + test(S("abcdeabcde"), 'c', 10, S::npos); + test(S("abcdeabcde"), 'c', 11, S::npos); + test(S("abcdeabcdeabcdeabcde"), 'c', 0, 2); + test(S("abcdeabcdeabcdeabcde"), 'c', 1, 2); + test(S("abcdeabcdeabcdeabcde"), 'c', 10, 12); + test(S("abcdeabcdeabcdeabcde"), 'c', 19, S::npos); + test(S("abcdeabcdeabcdeabcde"), 'c', 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), 'c', 21, S::npos); + + test(S(""), 'c', S::npos); + test(S("abcde"), 'c', 2); + test(S("abcdeabcde"), 'c', 2); + test(S("abcdeabcdeabcdeabcde"), 'c', 2); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; test(S(""), 'c', 0, S::npos); test(S(""), 'c', 1, S::npos); test(S("abcde"), 'c', 0, 2); @@ -62,4 +93,6 @@ int main() test(S("abcde"), 'c', 2); test(S("abcdeabcde"), 'c', 2); test(S("abcdeabcdeabcdeabcde"), 'c', 2); + } +#endif } diff --git a/libcxx/test/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp b/libcxx/test/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp index dde0f50118f..c3ea07976bf 100644 --- a/libcxx/test/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp +++ b/libcxx/test/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../min_allocator.h" + template void test(const S& s, const typename S::value_type* str, typename S::size_type pos, @@ -39,8 +41,7 @@ test(const S& s, const typename S::value_type* str, typename S::size_type x) } } -typedef std::string S; - +template void test0() { test(S(""), "", 0, 0); @@ -125,6 +126,7 @@ void test0() test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, S::npos); } +template void test1() { test(S(""), "", 0); @@ -147,6 +149,16 @@ void test1() int main() { - test0(); - test1(); + { + typedef std::string S; + test0(); + test1(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + } +#endif } diff --git a/libcxx/test/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp b/libcxx/test/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp index 14db59ea864..f936651eb20 100644 --- a/libcxx/test/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp +++ b/libcxx/test/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../min_allocator.h" + template 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(pos <= x && x + n <= s.size()); } -typedef std::string S; - +template void test0() { test(S(""), "", 0, 0, 0); @@ -130,6 +131,7 @@ void test0() test(S("abcde"), "abcde", 5, 2, S::npos); } +template void test1() { test(S("abcde"), "abcde", 5, 4, S::npos); @@ -234,6 +236,7 @@ void test1() test(S("abcdeabcde"), "abcdeabcde", 10, 1, S::npos); } +template void test2() { test(S("abcdeabcde"), "abcdeabcde", 10, 5, S::npos); @@ -338,6 +341,7 @@ void test2() test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20); } +template void test3() { test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 1, S::npos); @@ -364,8 +368,20 @@ void test3() int main() { - test0(); - test1(); - test2(); - test3(); + { + typedef std::string S; + test0(); + test1(); + test2(); + test3(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + test3(); + } +#endif } diff --git a/libcxx/test/strings/basic.string/string.ops/string_find/string_size.pass.cpp b/libcxx/test/strings/basic.string/string.ops/string_find/string_size.pass.cpp index 375a6f398ba..dc280d0aca2 100644 --- a/libcxx/test/strings/basic.string/string.ops/string_find/string_size.pass.cpp +++ b/libcxx/test/strings/basic.string/string.ops/string_find/string_size.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../min_allocator.h" + template 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 void test0() { test(S(""), S(""), 0, 0); @@ -118,6 +119,7 @@ void test0() test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 21, S::npos); } +template void test1() { test(S(""), S(""), 0); @@ -140,6 +142,16 @@ void test1() int main() { - test0(); - test1(); + { + typedef std::string S; + test0(); + test1(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + } +#endif } -- cgit v1.2.3