diff options
| author | Howard Hinnant <hhinnant@apple.com> | 2013-06-28 16:59:19 +0000 |
|---|---|---|
| committer | Howard Hinnant <hhinnant@apple.com> | 2013-06-28 16:59:19 +0000 |
| commit | eec721826cc35a0c08dc5bc54db9a51dbd4fa361 (patch) | |
| tree | be3ea93c71256a122174477e4e8b0024bca43ee7 /libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp | |
| parent | e852add40ed7d93da626d4e2286c840afb9d98d8 (diff) | |
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.modifiers/string_replace/iter_iter_string.pass.cpp')
| -rw-r--r-- | libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp b/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp index 12df01154c81..76db558c2e50 100644 --- a/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp +++ b/libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp @@ -18,22 +18,24 @@ #include <algorithm> #include <cassert> -typedef std::string S; +#include "../../min_allocator.h" +template <class S> void -test(S s, S::size_type pos1, S::size_type n1, S str, S expected) +test(S s, typename S::size_type pos1, typename S::size_type n1, S str, S expected) { - S::size_type old_size = s.size(); - S::const_iterator first = s.begin() + pos1; - S::const_iterator last = s.begin() + pos1 + n1; + typename S::size_type old_size = s.size(); + typename S::const_iterator first = s.begin() + pos1; + typename S::const_iterator last = s.begin() + pos1 + n1; s.replace(first, last, str); assert(s.__invariants()); assert(s == expected); - S::size_type xlen = last - first; - S::size_type rlen = str.size(); + typename S::size_type xlen = last - first; + typename S::size_type rlen = str.size(); assert(s.size() == old_size - xlen + rlen); } +template <class S> void test0() { test(S(""), 0, 0, S(""), S("")); @@ -138,6 +140,7 @@ void test0() test(S("abcdefghij"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghij")); } +template <class S> void test1() { test(S("abcdefghij"), 1, 4, S(""), S("afghij")); @@ -242,6 +245,7 @@ void test1() test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), S("abcdefghij12345678901234567890t")); } +template <class S> void test2() { test(S("abcdefghijklmnopqrst"), 10, 10, S(""), S("abcdefghij")); @@ -264,7 +268,18 @@ void test2() int main() { - test0(); - test1(); - test2(); + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#endif } |
