summaryrefslogtreecommitdiffstats
path: root/libcxx/test/strings/basic.string/string.modifiers/string_assign
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.modifiers/string_assign
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.modifiers/string_assign')
-rw-r--r--libcxx/test/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp10
-rw-r--r--libcxx/test/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp63
-rw-r--r--libcxx/test/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp21
-rw-r--r--libcxx/test/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp25
-rw-r--r--libcxx/test/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp29
-rw-r--r--libcxx/test/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp21
-rw-r--r--libcxx/test/strings/basic.string/string.modifiers/string_assign/string.pass.cpp29
-rw-r--r--libcxx/test/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp30
8 files changed, 228 insertions, 0 deletions
diff --git a/libcxx/test/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp b/libcxx/test/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp
index e27f714a1fd..b2c083415da 100644
--- a/libcxx/test/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp
@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
+#include "../../min_allocator.h"
+
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
@@ -22,5 +24,13 @@ int main()
s.assign({'a', 'b', 'c'});
assert(s == "abc");
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s("123");
+ s.assign({'a', 'b', 'c'});
+ assert(s == "abc");
+ }
+#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}
diff --git a/libcxx/test/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp b/libcxx/test/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp
index 12d994cb58e..3eefb7b8cac 100644
--- a/libcxx/test/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp
@@ -16,6 +16,7 @@
#include <cassert>
#include "../../input_iterator.h"
+#include "../../min_allocator.h"
template <class S, class It>
void
@@ -28,6 +29,7 @@ test(S s, It first, It last, S expected)
int main()
{
+ {
typedef std::string S;
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
test(S(), s, s, S());
@@ -84,4 +86,65 @@ int main()
S("ABCDEFGHIJ"));
test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ test(S(), s, s, S());
+ test(S(), s, s+1, S("A"));
+ test(S(), s, s+10, S("ABCDEFGHIJ"));
+ test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345"), s, s, S());
+ test(S("12345"), s, s+1, S("A"));
+ test(S("12345"), s, s+10, S("ABCDEFGHIJ"));
+ test(S("12345"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("1234567890"), s, s, S());
+ test(S("1234567890"), s, s+1, S("A"));
+ test(S("1234567890"), s, s+10, S("ABCDEFGHIJ"));
+ test(S("1234567890"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345678901234567890"), s, s, S());
+ test(S("12345678901234567890"), s, s+1, S("A"));
+ test(S("12345678901234567890"), s, s+10, S("ABCDEFGHIJ"));
+ test(S("12345678901234567890"), s, s+52,
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s), S());
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("ABCDEFGHIJ"));
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+ S());
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+ S("A"));
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("ABCDEFGHIJ"));
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+ S());
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+ S("A"));
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("ABCDEFGHIJ"));
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+ S());
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+ S("A"));
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("ABCDEFGHIJ"));
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp b/libcxx/test/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp
index 9370666a817..f9d0614126e 100644
--- a/libcxx/test/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp
@@ -15,6 +15,8 @@
#include <stdexcept>
#include <cassert>
+#include "../../min_allocator.h"
+
template <class S>
void
test(S s, const typename S::value_type* str, S expected)
@@ -26,6 +28,7 @@ test(S s, const typename S::value_type* str, S expected)
int main()
{
+ {
typedef std::string S;
test(S(), "", S());
test(S(), "12345", S("12345"));
@@ -39,4 +42,22 @@ int main()
test(S("12345678901234567890"), "12345", S("12345"));
test(S("12345678901234567890"), "12345678901234567890",
S("12345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), "", S());
+ test(S(), "12345", S("12345"));
+ test(S(), "12345678901234567890", S("12345678901234567890"));
+
+ test(S("12345"), "", S());
+ test(S("12345"), "12345", S("12345"));
+ test(S("12345"), "1234567890", S("1234567890"));
+
+ test(S("12345678901234567890"), "", S());
+ test(S("12345678901234567890"), "12345", S("12345"));
+ test(S("12345678901234567890"), "12345678901234567890",
+ S("12345678901234567890"));
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp b/libcxx/test/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp
index 52020ec9af7..5a8f9ce09fc 100644
--- a/libcxx/test/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp
@@ -16,6 +16,8 @@
#include <stdexcept>
#include <cassert>
+#include "../../min_allocator.h"
+
template <class S>
void
test(S s, const typename S::value_type* str, typename S::size_type n, S expected)
@@ -27,6 +29,7 @@ test(S s, const typename S::value_type* str, typename S::size_type n, S expected
int main()
{
+ {
typedef std::string S;
test(S(), "", 0, S());
test(S(), "12345", 3, S("123"));
@@ -44,4 +47,26 @@ int main()
test(S("12345678901234567890"), "12345", 5, S("12345"));
test(S("12345678901234567890"), "12345678901234567890", 20,
S("12345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), "", 0, S());
+ test(S(), "12345", 3, S("123"));
+ test(S(), "12345", 4, S("1234"));
+ test(S(), "12345678901234567890", 0, S());
+ test(S(), "12345678901234567890", 1, S("1"));
+ test(S(), "12345678901234567890", 3, S("123"));
+ test(S(), "12345678901234567890", 20, S("12345678901234567890"));
+
+ test(S("12345"), "", 0, S());
+ test(S("12345"), "12345", 5, S("12345"));
+ test(S("12345"), "1234567890", 10, S("1234567890"));
+
+ test(S("12345678901234567890"), "", 0, S());
+ test(S("12345678901234567890"), "12345", 5, S("12345"));
+ test(S("12345678901234567890"), "12345678901234567890", 20,
+ S("12345678901234567890"));
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp b/libcxx/test/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp
index 59390e0c79d..8c8dc6225c5 100644
--- a/libcxx/test/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp
@@ -15,6 +15,8 @@
#include <string>
#include <cassert>
+#include "../../min_allocator.h"
+
template <class S>
void
test(S s, S str, S expected)
@@ -26,6 +28,7 @@ test(S s, S str, S expected)
int main()
{
+ {
typedef std::string S;
test(S(), S(), S());
test(S(), S("12345"), S("12345"));
@@ -47,4 +50,30 @@ int main()
test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
test(S("12345678901234567890"), S("12345678901234567890"),
S("12345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), S(), S());
+ test(S(), S("12345"), S("12345"));
+ test(S(), S("1234567890"), S("1234567890"));
+ test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("12345"), S(), S());
+ test(S("12345"), S("12345"), S("12345"));
+ test(S("12345"), S("1234567890"), S("1234567890"));
+ test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("1234567890"), S(), S());
+ test(S("1234567890"), S("12345"), S("12345"));
+ test(S("1234567890"), S("1234567890"), S("1234567890"));
+ test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("12345678901234567890"), S(), S());
+ test(S("12345678901234567890"), S("12345"), S("12345"));
+ test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
+ test(S("12345678901234567890"), S("12345678901234567890"),
+ S("12345678901234567890"));
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp b/libcxx/test/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp
index 4bec69bf53a..486161256fb 100644
--- a/libcxx/test/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp
@@ -15,6 +15,8 @@
#include <string>
#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)
@@ -26,6 +28,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(1, 'a'));
@@ -39,4 +42,22 @@ int main()
test(S("12345678901234567890"), 0, 'a', S());
test(S("12345678901234567890"), 1, 'a', S(1, 'a'));
test(S("12345678901234567890"), 10, 'a', S(10, 'a'));
+ }
+#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(1, 'a'));
+ test(S(), 10, 'a', S(10, 'a'));
+ test(S(), 100, 'a', S(100, 'a'));
+
+ test(S("12345"), 0, 'a', S());
+ test(S("12345"), 1, 'a', S(1, 'a'));
+ test(S("12345"), 10, 'a', S(10, 'a'));
+
+ test(S("12345678901234567890"), 0, 'a', S());
+ test(S("12345678901234567890"), 1, 'a', S(1, 'a'));
+ test(S("12345678901234567890"), 10, 'a', S(10, 'a'));
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.modifiers/string_assign/string.pass.cpp b/libcxx/test/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
index f38f2ccf75f..f58a8a49a13 100644
--- a/libcxx/test/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
@@ -15,6 +15,8 @@
#include <string>
#include <cassert>
+#include "../../min_allocator.h"
+
template <class S>
void
test(S s, S str, S expected)
@@ -26,6 +28,7 @@ test(S s, S str, S expected)
int main()
{
+ {
typedef std::string S;
test(S(), S(), S());
test(S(), S("12345"), S("12345"));
@@ -47,4 +50,30 @@ int main()
test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
test(S("12345678901234567890"), S("12345678901234567890"),
S("12345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), S(), S());
+ test(S(), S("12345"), S("12345"));
+ test(S(), S("1234567890"), S("1234567890"));
+ test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("12345"), S(), S());
+ test(S("12345"), S("12345"), S("12345"));
+ test(S("12345"), S("1234567890"), S("1234567890"));
+ test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("1234567890"), S(), S());
+ test(S("1234567890"), S("12345"), S("12345"));
+ test(S("1234567890"), S("1234567890"), S("1234567890"));
+ test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("12345678901234567890"), S(), S());
+ test(S("12345678901234567890"), S("12345"), S("12345"));
+ test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
+ test(S("12345678901234567890"), S("12345678901234567890"),
+ S("12345678901234567890"));
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp b/libcxx/test/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp
index 18138bfdf9a..5430be3227a 100644
--- a/libcxx/test/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp
@@ -16,6 +16,8 @@
#include <stdexcept>
#include <cassert>
+#include "../../min_allocator.h"
+
template <class S>
void
test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected)
@@ -35,6 +37,7 @@ test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected)
int main()
{
+ {
typedef std::string S;
test(S(), S(), 0, 0, S());
test(S(), S(), 1, 0, S());
@@ -57,4 +60,31 @@ int main()
test(S("12345678901234567890"), S("12345"), 1, 3, S("234"));
test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
S("6789012345"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), S(), 0, 0, S());
+ test(S(), S(), 1, 0, S());
+ test(S(), S("12345"), 0, 3, S("123"));
+ test(S(), S("12345"), 1, 4, S("2345"));
+ test(S(), S("12345"), 3, 15, S("45"));
+ test(S(), S("12345"), 5, 15, S(""));
+ test(S(), S("12345"), 6, 15, S("not happening"));
+ test(S(), S("12345678901234567890"), 0, 0, S());
+ test(S(), S("12345678901234567890"), 1, 1, S("2"));
+ test(S(), S("12345678901234567890"), 2, 3, S("345"));
+ test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
+ test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
+
+ test(S("12345"), S(), 0, 0, S());
+ test(S("12345"), S("12345"), 2, 2, S("34"));
+ test(S("12345"), S("1234567890"), 0, 100, S("1234567890"));
+
+ test(S("12345678901234567890"), S(), 0, 0, S());
+ test(S("12345678901234567890"), S("12345"), 1, 3, S("234"));
+ test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
+ S("6789012345"));
+ }
+#endif
}
OpenPOWER on IntegriCloud