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.capacity | |
parent | e852add40ed7d93da626d4e2286c840afb9d98d8 (diff) | |
download | bcm5719-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.capacity')
10 files changed, 182 insertions, 0 deletions
diff --git a/libcxx/test/strings/basic.string/string.capacity/capacity.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/capacity.pass.cpp index 67ef152a5ef..22ca1f3be14 100644 --- a/libcxx/test/strings/basic.string/string.capacity/capacity.pass.cpp +++ b/libcxx/test/strings/basic.string/string.capacity/capacity.pass.cpp @@ -15,6 +15,7 @@ #include <cassert> #include "../test_allocator.h" +#include "../min_allocator.h" template <class S> void @@ -36,6 +37,7 @@ test(S s) int main() { + { typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > S; S s; test(s); @@ -45,4 +47,12 @@ int main() s.assign(100, 'a'); s.erase(50); test(s); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S s; + assert(s.capacity() > 0); + } +#endif } diff --git a/libcxx/test/strings/basic.string/string.capacity/clear.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/clear.pass.cpp index 5f8cf6f09e2..ba8ba245d29 100644 --- a/libcxx/test/strings/basic.string/string.capacity/clear.pass.cpp +++ b/libcxx/test/strings/basic.string/string.capacity/clear.pass.cpp @@ -14,6 +14,8 @@ #include <string> #include <cassert> +#include "../min_allocator.h" + template <class S> void test(S s) @@ -24,6 +26,7 @@ test(S s) int main() { + { typedef std::string S; S s; test(s); @@ -35,4 +38,20 @@ int main() s.assign(100, 'a'); s.erase(50); test(s); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S s; + test(s); + + s.assign(10, 'a'); + s.erase(5); + test(s); + + s.assign(100, 'a'); + s.erase(50); + test(s); + } +#endif } diff --git a/libcxx/test/strings/basic.string/string.capacity/empty.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/empty.pass.cpp index c79ac77788b..29f62cdf76b 100644 --- a/libcxx/test/strings/basic.string/string.capacity/empty.pass.cpp +++ b/libcxx/test/strings/basic.string/string.capacity/empty.pass.cpp @@ -14,6 +14,8 @@ #include <string> #include <cassert> +#include "../min_allocator.h" + template <class S> void test(const S& s) @@ -23,8 +25,18 @@ test(const S& s) int main() { + { typedef std::string S; test(S()); test(S("123")); test(S("12345678901234567890123456789012345678901234567890")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S()); + test(S("123")); + test(S("12345678901234567890123456789012345678901234567890")); + } +#endif } diff --git a/libcxx/test/strings/basic.string/string.capacity/length.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/length.pass.cpp index 756c1412c0e..5ddb5c1e0cc 100644 --- a/libcxx/test/strings/basic.string/string.capacity/length.pass.cpp +++ b/libcxx/test/strings/basic.string/string.capacity/length.pass.cpp @@ -14,6 +14,8 @@ #include <string> #include <cassert> +#include "../min_allocator.h" + template <class S> void test(const S& s) @@ -23,8 +25,18 @@ test(const S& s) int main() { + { typedef std::string S; test(S()); test(S("123")); test(S("12345678901234567890123456789012345678901234567890")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S()); + test(S("123")); + test(S("12345678901234567890123456789012345678901234567890")); + } +#endif } diff --git a/libcxx/test/strings/basic.string/string.capacity/max_size.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/max_size.pass.cpp index 59387c63dcc..e016bba56f6 100644 --- a/libcxx/test/strings/basic.string/string.capacity/max_size.pass.cpp +++ b/libcxx/test/strings/basic.string/string.capacity/max_size.pass.cpp @@ -14,6 +14,8 @@ #include <string> #include <cassert> +#include "../min_allocator.h" + template <class S> void test(const S& s) @@ -23,8 +25,18 @@ test(const S& s) int main() { + { typedef std::string S; test(S()); test(S("123")); test(S("12345678901234567890123456789012345678901234567890")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S()); + test(S("123")); + test(S("12345678901234567890123456789012345678901234567890")); + } +#endif } diff --git a/libcxx/test/strings/basic.string/string.capacity/reserve.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/reserve.pass.cpp index 0689a8b406e..6fdb457e3f8 100644 --- a/libcxx/test/strings/basic.string/string.capacity/reserve.pass.cpp +++ b/libcxx/test/strings/basic.string/string.capacity/reserve.pass.cpp @@ -15,6 +15,8 @@ #include <stdexcept> #include <cassert> +#include "../min_allocator.h" + template <class S> void test(S s) @@ -50,6 +52,7 @@ test(S s, typename S::size_type res_arg) int main() { + { typedef std::string S; { S s; @@ -78,4 +81,37 @@ int main() test(s, 100); test(s, S::npos); } + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + { + S s; + test(s); + + s.assign(10, 'a'); + s.erase(5); + test(s); + + s.assign(100, 'a'); + s.erase(50); + test(s); + } + { + S s; + test(s, 5); + test(s, 10); + test(s, 50); + } + { + S s(100, 'a'); + s.erase(50); + test(s, 5); + test(s, 10); + test(s, 50); + test(s, 100); + test(s, S::npos); + } + } +#endif } diff --git a/libcxx/test/strings/basic.string/string.capacity/resize_size.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/resize_size.pass.cpp index 723c1256a73..d1b66a41bab 100644 --- a/libcxx/test/strings/basic.string/string.capacity/resize_size.pass.cpp +++ b/libcxx/test/strings/basic.string/string.capacity/resize_size.pass.cpp @@ -15,6 +15,8 @@ #include <stdexcept> #include <cassert> +#include "../min_allocator.h" + template <class S> void test(S s, typename S::size_type n, S expected) @@ -34,6 +36,7 @@ test(S s, typename S::size_type n, S expected) int main() { + { typedef std::string S; test(S(), 0, S()); test(S(), 1, S(1, '\0')); @@ -51,4 +54,26 @@ int main() test(S("12345678901234567890123456789012345678901234567890"), 60, S("12345678901234567890123456789012345678901234567890\0\0\0\0\0\0\0\0\0\0", 60)); test(S(), S::npos, S("not going to happen")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(), 0, S()); + test(S(), 1, S(1, '\0')); + test(S(), 10, S(10, '\0')); + test(S(), 100, S(100, '\0')); + test(S("12345"), 0, S()); + test(S("12345"), 2, S("12")); + test(S("12345"), 5, S("12345")); + test(S("12345"), 15, S("12345\0\0\0\0\0\0\0\0\0\0", 15)); + test(S("12345678901234567890123456789012345678901234567890"), 0, S()); + test(S("12345678901234567890123456789012345678901234567890"), 10, + S("1234567890")); + test(S("12345678901234567890123456789012345678901234567890"), 50, + S("12345678901234567890123456789012345678901234567890")); + test(S("12345678901234567890123456789012345678901234567890"), 60, + S("12345678901234567890123456789012345678901234567890\0\0\0\0\0\0\0\0\0\0", 60)); + test(S(), S::npos, S("not going to happen")); + } +#endif } diff --git a/libcxx/test/strings/basic.string/string.capacity/resize_size_char.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/resize_size_char.pass.cpp index f21776568ee..9fb0c8cc7a6 100644 --- a/libcxx/test/strings/basic.string/string.capacity/resize_size_char.pass.cpp +++ b/libcxx/test/strings/basic.string/string.capacity/resize_size_char.pass.cpp @@ -15,6 +15,8 @@ #include <stdexcept> #include <cassert> +#include "../min_allocator.h" + template <class S> void test(S s, typename S::size_type n, typename S::value_type c, S expected) @@ -34,6 +36,7 @@ test(S s, typename S::size_type n, typename S::value_type c, S expected) int main() { + { typedef std::string S; test(S(), 0, 'a', S()); test(S(), 1, 'a', S("a")); @@ -51,4 +54,26 @@ int main() test(S("12345678901234567890123456789012345678901234567890"), 60, 'a', S("12345678901234567890123456789012345678901234567890aaaaaaaaaa")); test(S(), S::npos, 'a', S("not going to happen")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(), 0, 'a', S()); + test(S(), 1, 'a', S("a")); + test(S(), 10, 'a', S(10, 'a')); + test(S(), 100, 'a', S(100, 'a')); + test(S("12345"), 0, 'a', S()); + test(S("12345"), 2, 'a', S("12")); + test(S("12345"), 5, 'a', S("12345")); + test(S("12345"), 15, 'a', S("12345aaaaaaaaaa")); + test(S("12345678901234567890123456789012345678901234567890"), 0, 'a', S()); + test(S("12345678901234567890123456789012345678901234567890"), 10, 'a', + S("1234567890")); + test(S("12345678901234567890123456789012345678901234567890"), 50, 'a', + S("12345678901234567890123456789012345678901234567890")); + test(S("12345678901234567890123456789012345678901234567890"), 60, 'a', + S("12345678901234567890123456789012345678901234567890aaaaaaaaaa")); + test(S(), S::npos, 'a', S("not going to happen")); + } +#endif } diff --git a/libcxx/test/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp index e756f3c173b..310cceca45e 100644 --- a/libcxx/test/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp +++ b/libcxx/test/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp @@ -14,6 +14,8 @@ #include <string> #include <cassert> +#include "../min_allocator.h" + template <class S> void test(S s) @@ -29,6 +31,7 @@ test(S s) int main() { + { typedef std::string S; S s; test(s); @@ -40,4 +43,20 @@ int main() s.assign(100, 'a'); s.erase(50); test(s); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S s; + test(s); + + s.assign(10, 'a'); + s.erase(5); + test(s); + + s.assign(100, 'a'); + s.erase(50); + test(s); + } +#endif } diff --git a/libcxx/test/strings/basic.string/string.capacity/size.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/size.pass.cpp index 0acbefbabb6..9d51ca1705a 100644 --- a/libcxx/test/strings/basic.string/string.capacity/size.pass.cpp +++ b/libcxx/test/strings/basic.string/string.capacity/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::size_type c) @@ -23,8 +25,18 @@ test(const S& s, typename S::size_type c) int main() { + { typedef std::string S; test(S(), 0); test(S("123"), 3); test(S("12345678901234567890123456789012345678901234567890"), 50); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(), 0); + test(S("123"), 3); + test(S("12345678901234567890123456789012345678901234567890"), 50); + } +#endif } |