summaryrefslogtreecommitdiffstats
path: root/libcxx/test/strings/basic.string/string.cons
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.cons
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.cons')
-rw-r--r--libcxx/test/strings/basic.string/string.cons/alloc.pass.cpp30
-rw-r--r--libcxx/test/strings/basic.string/string.cons/char_assignment.pass.cpp13
-rw-r--r--libcxx/test/strings/basic.string/string.cons/copy.pass.cpp12
-rw-r--r--libcxx/test/strings/basic.string/string.cons/copy_alloc.pass.cpp12
-rw-r--r--libcxx/test/strings/basic.string/string.cons/copy_assignment.pass.cpp24
-rw-r--r--libcxx/test/strings/basic.string/string.cons/initializer_list.pass.cpp14
-rw-r--r--libcxx/test/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp10
-rw-r--r--libcxx/test/strings/basic.string/string.cons/iter_alloc.pass.cpp40
-rw-r--r--libcxx/test/strings/basic.string/string.cons/move.pass.cpp12
-rw-r--r--libcxx/test/strings/basic.string/string.cons/move_alloc.pass.cpp13
-rw-r--r--libcxx/test/strings/basic.string/string.cons/move_assignment.pass.cpp23
-rw-r--r--libcxx/test/strings/basic.string/string.cons/pointer_alloc.pass.cpp28
-rw-r--r--libcxx/test/strings/basic.string/string.cons/pointer_assignment.pass.cpp24
-rw-r--r--libcxx/test/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp28
-rw-r--r--libcxx/test/strings/basic.string/string.cons/size_char_alloc.pass.cpp38
-rw-r--r--libcxx/test/strings/basic.string/string.cons/substr.pass.cpp47
16 files changed, 346 insertions, 22 deletions
diff --git a/libcxx/test/strings/basic.string/string.cons/alloc.pass.cpp b/libcxx/test/strings/basic.string/string.cons/alloc.pass.cpp
index 8eb9c844d20..3a8c571344f 100644
--- a/libcxx/test/strings/basic.string/string.cons/alloc.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.cons/alloc.pass.cpp
@@ -15,6 +15,7 @@
#include <cassert>
#include "../test_allocator.h"
+#include "../min_allocator.h"
template <class S>
void
@@ -38,7 +39,36 @@ test()
}
}
+#if __cplusplus >= 201103L
+
+template <class S>
+void
+test2()
+{
+ {
+ S s;
+ assert(s.__invariants());
+ assert(s.data());
+ assert(s.size() == 0);
+ assert(s.capacity() >= s.size());
+ assert(s.get_allocator() == typename S::allocator_type());
+ }
+ {
+ S s(typename S::allocator_type{});
+ assert(s.__invariants());
+ assert(s.data());
+ assert(s.size() == 0);
+ assert(s.capacity() >= s.size());
+ assert(s.get_allocator() == typename S::allocator_type());
+ }
+}
+
+#endif
+
int main()
{
test<std::basic_string<char, std::char_traits<char>, test_allocator<char> > >();
+#if __cplusplus >= 201103L
+ test2<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.cons/char_assignment.pass.cpp b/libcxx/test/strings/basic.string/string.cons/char_assignment.pass.cpp
index 2a5afa2a066..4d750d8555c 100644
--- a/libcxx/test/strings/basic.string/string.cons/char_assignment.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.cons/char_assignment.pass.cpp
@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
+#include "../min_allocator.h"
+
template <class S>
void
test(S s1, typename S::value_type s2)
@@ -28,9 +30,20 @@ test(S s1, typename S::value_type s2)
int main()
{
+ {
typedef std::string S;
test(S(), 'a');
test(S("1"), 'a');
test(S("123456789"), 'a');
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), 'a');
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), 'a');
+ test(S("1"), 'a');
+ test(S("123456789"), 'a');
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), 'a');
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.cons/copy.pass.cpp b/libcxx/test/strings/basic.string/string.cons/copy.pass.cpp
index c34658f4568..3ebb22862dc 100644
--- a/libcxx/test/strings/basic.string/string.cons/copy.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.cons/copy.pass.cpp
@@ -15,6 +15,7 @@
#include <cassert>
#include "../test_allocator.h"
+#include "../min_allocator.h"
template <class S>
void
@@ -29,9 +30,20 @@ test(S s1)
int main()
{
+ {
typedef test_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
test(S(A(3)));
test(S("1", A(5)));
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+ test(S(A{}));
+ test(S("1", A()));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()));
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.cons/copy_alloc.pass.cpp b/libcxx/test/strings/basic.string/string.cons/copy_alloc.pass.cpp
index 951330c596f..693ecf38b77 100644
--- a/libcxx/test/strings/basic.string/string.cons/copy_alloc.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.cons/copy_alloc.pass.cpp
@@ -15,6 +15,7 @@
#include <cassert>
#include "../test_allocator.h"
+#include "../min_allocator.h"
template <class S>
void
@@ -29,9 +30,20 @@ test(S s1, const typename S::allocator_type& a)
int main()
{
+ {
typedef test_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
test(S(), A(3));
test(S("1"), A(5));
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+ test(S(), A());
+ test(S("1"), A());
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A());
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.cons/copy_assignment.pass.cpp b/libcxx/test/strings/basic.string/string.cons/copy_assignment.pass.cpp
index f15f2796d0b..10c49e55fff 100644
--- a/libcxx/test/strings/basic.string/string.cons/copy_assignment.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.cons/copy_assignment.pass.cpp
@@ -15,6 +15,8 @@
#include <string>
#include <cassert>
+#include "../min_allocator.h"
+
template <class S>
void
test(S s1, const S& s2)
@@ -27,6 +29,7 @@ test(S s1, const S& s2)
int main()
{
+ {
typedef std::string S;
test(S(), S());
test(S("1"), S());
@@ -43,4 +46,25 @@ int main()
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
"1234567890123456789012345678901234567890123456789012345678901234567890"),
S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), S());
+ test(S("1"), S());
+ test(S(), S("1"));
+ test(S("1"), S("2"));
+ test(S("1"), S("2"));
+
+ test(S(),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("123456789"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890123456789012345678901234567890"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.cons/initializer_list.pass.cpp b/libcxx/test/strings/basic.string/string.cons/initializer_list.pass.cpp
index 430c2acf62e..7654901b851 100644
--- a/libcxx/test/strings/basic.string/string.cons/initializer_list.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.cons/initializer_list.pass.cpp
@@ -15,6 +15,7 @@
#include <cassert>
#include "../test_allocator.h"
+#include "../min_allocator.h"
int main()
{
@@ -28,5 +29,18 @@ int main()
s = {L'a', L'b', L'c'};
assert(s == L"abc");
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s = {'a', 'b', 'c'};
+ assert(s == "abc");
+ }
+ {
+ typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
+ S s;
+ s = {L'a', L'b', L'c'};
+ assert(s == L"abc");
+ }
+#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}
diff --git a/libcxx/test/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp b/libcxx/test/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp
index f7ac16f1fb6..6bbf51a8805 100644
--- a/libcxx/test/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.cons/initializer_list_assignment.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 = {'a', 'b', 'c'};
assert(s == "abc");
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s;
+ s = {'a', 'b', 'c'};
+ assert(s == "abc");
+ }
+#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}
diff --git a/libcxx/test/strings/basic.string/string.cons/iter_alloc.pass.cpp b/libcxx/test/strings/basic.string/string.cons/iter_alloc.pass.cpp
index c902531aca4..ebd0974cd72 100644
--- a/libcxx/test/strings/basic.string/string.cons/iter_alloc.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.cons/iter_alloc.pass.cpp
@@ -19,6 +19,7 @@
#include "../test_allocator.h"
#include "../input_iterator.h"
+#include "../min_allocator.h"
template <class It>
void
@@ -38,14 +39,13 @@ test(It first, It last)
assert(s2.capacity() >= s2.size());
}
-template <class It>
+template <class It, class A>
void
-test(It first, It last, const test_allocator<typename std::iterator_traits<It>::value_type>& a)
+test(It first, It last, const A& a)
{
typedef typename std::iterator_traits<It>::value_type charT;
- typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+ typedef std::basic_string<charT, std::char_traits<charT>, A> S;
typedef typename S::traits_type T;
- typedef typename S::allocator_type A;
S s2(first, last, a);
assert(s2.__invariants());
assert(s2.size() == std::distance(first, last));
@@ -58,6 +58,7 @@ test(It first, It last, const test_allocator<typename std::iterator_traits<It>::
int main()
{
+ {
typedef test_allocator<char> A;
const char* s = "12345678901234567890123456789012345678901234567890";
@@ -84,4 +85,35 @@ int main()
test(input_iterator<const char*>(s), input_iterator<const char*>(s+50));
test(input_iterator<const char*>(s), input_iterator<const char*>(s+50), A(2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ const char* s = "12345678901234567890123456789012345678901234567890";
+
+ test(s, s);
+ test(s, s, A());
+
+ test(s, s+1);
+ test(s, s+1, A());
+
+ test(s, s+10);
+ test(s, s+10, A());
+
+ test(s, s+50);
+ test(s, s+50, A());
+
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s));
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s), A());
+
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+1));
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+1), A());
+
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+10));
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+10), A());
+
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+50));
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+50), A());
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.cons/move.pass.cpp b/libcxx/test/strings/basic.string/string.cons/move.pass.cpp
index 2d33937d4fe..ba68087aa5d 100644
--- a/libcxx/test/strings/basic.string/string.cons/move.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.cons/move.pass.cpp
@@ -17,6 +17,7 @@
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include "../test_allocator.h"
+#include "../min_allocator.h"
template <class S>
void
@@ -36,10 +37,21 @@ test(S s0)
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
typedef test_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
test(S(A(3)));
test(S("1", A(5)));
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+ test(S(A{}));
+ test(S("1", A()));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()));
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/libcxx/test/strings/basic.string/string.cons/move_alloc.pass.cpp b/libcxx/test/strings/basic.string/string.cons/move_alloc.pass.cpp
index 60d132f2139..80aadcb355a 100644
--- a/libcxx/test/strings/basic.string/string.cons/move_alloc.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.cons/move_alloc.pass.cpp
@@ -17,6 +17,8 @@
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include "../test_allocator.h"
+#include "../min_allocator.h"
+
template <class S>
void
@@ -36,10 +38,21 @@ test(S s0, const typename S::allocator_type& a)
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
typedef test_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
test(S(), A(3));
test(S("1"), A(5));
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+ test(S(), A());
+ test(S("1"), A());
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A());
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/libcxx/test/strings/basic.string/string.cons/move_assignment.pass.cpp b/libcxx/test/strings/basic.string/string.cons/move_assignment.pass.cpp
index 739f09d1e0f..3e6626b60eb 100644
--- a/libcxx/test/strings/basic.string/string.cons/move_assignment.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.cons/move_assignment.pass.cpp
@@ -18,6 +18,7 @@
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include "../test_allocator.h"
+#include "../min_allocator.h"
template <class S>
void
@@ -36,6 +37,7 @@ test(S s1, S s2)
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
typedef std::string S;
test(S(), S());
test(S("1"), S());
@@ -52,5 +54,26 @@ int main()
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
"1234567890123456789012345678901234567890123456789012345678901234567890"),
S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), S());
+ test(S("1"), S());
+ test(S(), S("1"));
+ test(S("1"), S("2"));
+ test(S("1"), S("2"));
+
+ test(S(),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("123456789"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890123456789012345678901234567890"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/libcxx/test/strings/basic.string/string.cons/pointer_alloc.pass.cpp b/libcxx/test/strings/basic.string/string.cons/pointer_alloc.pass.cpp
index db2f733331e..befb143d973 100644
--- a/libcxx/test/strings/basic.string/string.cons/pointer_alloc.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.cons/pointer_alloc.pass.cpp
@@ -17,6 +17,7 @@
#include <cassert>
#include "../test_allocator.h"
+#include "../min_allocator.h"
template <class charT>
void
@@ -34,13 +35,12 @@ test(const charT* s)
assert(s2.capacity() >= s2.size());
}
-template <class charT>
+template <class charT, class A>
void
-test(const charT* s, const test_allocator<charT>& a)
+test(const charT* s, const A& a)
{
- typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+ typedef std::basic_string<charT, std::char_traits<charT>, A> S;
typedef typename S::traits_type T;
- typedef typename S::allocator_type A;
unsigned n = T::length(s);
S s2(s, a);
assert(s2.__invariants());
@@ -52,6 +52,7 @@ test(const charT* s, const test_allocator<charT>& a)
int main()
{
+ {
typedef test_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
@@ -66,4 +67,23 @@ int main()
test("123456798012345679801234567980123456798012345679801234567980");
test("123456798012345679801234567980123456798012345679801234567980", A(2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+ test("");
+ test("", A());
+
+ test("1");
+ test("1", A());
+
+ test("1234567980");
+ test("1234567980", A());
+
+ test("123456798012345679801234567980123456798012345679801234567980");
+ test("123456798012345679801234567980123456798012345679801234567980", A());
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.cons/pointer_assignment.pass.cpp b/libcxx/test/strings/basic.string/string.cons/pointer_assignment.pass.cpp
index 660e1cf189d..d035837cd97 100644
--- a/libcxx/test/strings/basic.string/string.cons/pointer_assignment.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.cons/pointer_assignment.pass.cpp
@@ -15,6 +15,8 @@
#include <string>
#include <cassert>
+#include "../min_allocator.h"
+
template <class S>
void
test(S s1, const typename S::value_type* s2)
@@ -29,6 +31,7 @@ test(S s1, const typename S::value_type* s2)
int main()
{
+ {
typedef std::string S;
test(S(), "");
test(S("1"), "");
@@ -45,4 +48,25 @@ int main()
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
"1234567890123456789012345678901234567890123456789012345678901234567890"),
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), "");
+ test(S("1"), "");
+ test(S(), "1");
+ test(S("1"), "2");
+ test(S("1"), "2");
+
+ test(S(),
+ "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+ test(S("123456789"),
+ "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+ "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890123456789012345678901234567890"),
+ "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp b/libcxx/test/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp
index 169e1128f16..dbfcec7e33e 100644
--- a/libcxx/test/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp
@@ -17,6 +17,7 @@
#include <cassert>
#include "../test_allocator.h"
+#include "../min_allocator.h"
template <class charT>
void
@@ -33,13 +34,12 @@ test(const charT* s, unsigned n)
assert(s2.capacity() >= s2.size());
}
-template <class charT>
+template <class charT, class A>
void
-test(const charT* s, unsigned n, const test_allocator<charT>& a)
+test(const charT* s, unsigned n, const A& a)
{
- typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+ typedef std::basic_string<charT, std::char_traits<charT>, A> S;
typedef typename S::traits_type T;
- typedef typename S::allocator_type A;
S s2(s, n, a);
assert(s2.__invariants());
assert(s2.size() == n);
@@ -50,6 +50,7 @@ test(const charT* s, unsigned n, const test_allocator<charT>& a)
int main()
{
+ {
typedef test_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
@@ -64,4 +65,23 @@ int main()
test("123456798012345679801234567980123456798012345679801234567980", 60);
test("123456798012345679801234567980123456798012345679801234567980", 60, A(2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+ test("", 0);
+ test("", 0, A());
+
+ test("1", 1);
+ test("1", 1, A());
+
+ test("1234567980", 10);
+ test("1234567980", 10, A());
+
+ test("123456798012345679801234567980123456798012345679801234567980", 60);
+ test("123456798012345679801234567980123456798012345679801234567980", 60, A());
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.cons/size_char_alloc.pass.cpp b/libcxx/test/strings/basic.string/string.cons/size_char_alloc.pass.cpp
index 6ed5f047067..a427d72ba8f 100644
--- a/libcxx/test/strings/basic.string/string.cons/size_char_alloc.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.cons/size_char_alloc.pass.cpp
@@ -17,6 +17,7 @@
#include <cassert>
#include "../test_allocator.h"
+#include "../min_allocator.h"
template <class charT>
void
@@ -34,13 +35,12 @@ test(unsigned n, charT c)
assert(s2.capacity() >= s2.size());
}
-template <class charT>
+template <class charT, class A>
void
-test(unsigned n, charT c, const test_allocator<charT>& a)
+test(unsigned n, charT c, const A& a)
{
- typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+ typedef std::basic_string<charT, std::char_traits<charT>, A> S;
typedef typename S::traits_type T;
- typedef typename S::allocator_type A;
S s2(n, c, a);
assert(s2.__invariants());
assert(s2.size() == n);
@@ -67,14 +67,13 @@ test(Tp n, Tp c)
assert(s2.capacity() >= s2.size());
}
-template <class Tp>
+template <class Tp, class A>
void
-test(Tp n, Tp c, const test_allocator<char>& a)
+test(Tp n, Tp c, const A& a)
{
typedef char charT;
- typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+ typedef std::basic_string<charT, std::char_traits<charT>, A> S;
typedef typename S::traits_type T;
- typedef typename S::allocator_type A;
S s2(n, c, a);
assert(s2.__invariants());
assert(s2.size() == n);
@@ -86,6 +85,7 @@ test(Tp n, Tp c, const test_allocator<char>& a)
int main()
{
+ {
typedef test_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
@@ -103,4 +103,26 @@ int main()
test(100, 65);
test(100, 65, A(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+ test(0, 'a');
+ test(0, 'a', A());
+
+ test(1, 'a');
+ test(1, 'a', A());
+
+ test(10, 'a');
+ test(10, 'a', A());
+
+ test(100, 'a');
+ test(100, 'a', A());
+
+ test(100, 65);
+ test(100, 65, A());
+ }
+#endif
}
diff --git a/libcxx/test/strings/basic.string/string.cons/substr.pass.cpp b/libcxx/test/strings/basic.string/string.cons/substr.pass.cpp
index 65fbfbd1316..16072111c89 100644
--- a/libcxx/test/strings/basic.string/string.cons/substr.pass.cpp
+++ b/libcxx/test/strings/basic.string/string.cons/substr.pass.cpp
@@ -19,6 +19,7 @@
#include <cassert>
#include "../test_allocator.h"
+#include "../min_allocator.h"
template <class S>
void
@@ -54,7 +55,7 @@ test(S str, unsigned pos, unsigned n)
S s2(str, pos, n);
assert(s2.__invariants());
assert(pos <= str.size());
- unsigned rlen = std::min(str.size() - pos, n);
+ unsigned rlen = std::min<unsigned>(str.size() - pos, n);
assert(s2.size() == rlen);
assert(T::compare(s2.data(), str.data() + pos, rlen) == 0);
assert(s2.get_allocator() == A());
@@ -77,7 +78,7 @@ test(S str, unsigned pos, unsigned n, const typename S::allocator_type& a)
S s2(str, pos, n, a);
assert(s2.__invariants());
assert(pos <= str.size());
- unsigned rlen = std::min(str.size() - pos, n);
+ unsigned rlen = std::min<unsigned>(str.size() - pos, n);
assert(s2.size() == rlen);
assert(T::compare(s2.data(), str.data() + pos, rlen) == 0);
assert(s2.get_allocator() == a);
@@ -91,6 +92,7 @@ test(S str, unsigned pos, unsigned n, const typename S::allocator_type& a)
int main()
{
+ {
typedef test_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
@@ -127,4 +129,45 @@ int main()
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 1, A(8));
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 10, A(8));
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 100, A(8));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+ test(S(A()), 0);
+ test(S(A()), 1);
+ test(S("1", A()), 0);
+ test(S("1", A()), 1);
+ test(S("1", A()), 2);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 0);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 5);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 500);
+
+ test(S(A()), 0, 0);
+ test(S(A()), 0, 1);
+ test(S(A()), 1, 0);
+ test(S(A()), 1, 1);
+ test(S(A()), 1, 2);
+ test(S("1", A()), 0, 0);
+ test(S("1", A()), 0, 1);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 0);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 1);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 10);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 100);
+
+ test(S(A()), 0, 0, A());
+ test(S(A()), 0, 1, A());
+ test(S(A()), 1, 0, A());
+ test(S(A()), 1, 1, A());
+ test(S(A()), 1, 2, A());
+ test(S("1", A()), 0, 0, A());
+ test(S("1", A()), 0, 1, A());
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 0, A());
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 1, A());
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 10, A());
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 100, A());
+ }
+#endif
}
OpenPOWER on IntegriCloud