Implement full support for non-pointer pointers in custom allocators for string. This completes the custom pointer support for the entire library.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@185167 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(S s, typename S::value_type str, S expected)
|
||||
@@ -25,9 +27,20 @@ test(S s, typename S::value_type str, S expected)
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), 'a', S("a"));
|
||||
test(S("12345"), 'a', S("12345a"));
|
||||
test(S("1234567890"), 'a', S("1234567890a"));
|
||||
test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(), 'a', S("a"));
|
||||
test(S("12345"), 'a', S("12345a"));
|
||||
test(S("1234567890"), 'a', S("1234567890a"));
|
||||
test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -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 == "123abc");
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
S s("123");
|
||||
s += {'a', 'b', 'c'};
|
||||
assert(s == "123abc");
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(S s, const typename S::value_type* str, S expected)
|
||||
@@ -25,6 +27,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"));
|
||||
@@ -46,4 +49,30 @@ int main()
|
||||
test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890"));
|
||||
test(S("12345678901234567890"), "12345678901234567890",
|
||||
S("1234567890123456789012345678901234567890"));
|
||||
}
|
||||
#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(), "1234567890", S("1234567890"));
|
||||
test(S(), "12345678901234567890", S("12345678901234567890"));
|
||||
|
||||
test(S("12345"), "", S("12345"));
|
||||
test(S("12345"), "12345", S("1234512345"));
|
||||
test(S("12345"), "1234567890", S("123451234567890"));
|
||||
test(S("12345"), "12345678901234567890", S("1234512345678901234567890"));
|
||||
|
||||
test(S("1234567890"), "", S("1234567890"));
|
||||
test(S("1234567890"), "12345", S("123456789012345"));
|
||||
test(S("1234567890"), "1234567890", S("12345678901234567890"));
|
||||
test(S("1234567890"), "12345678901234567890", S("123456789012345678901234567890"));
|
||||
|
||||
test(S("12345678901234567890"), "", S("12345678901234567890"));
|
||||
test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
|
||||
test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890"));
|
||||
test(S("12345678901234567890"), "12345678901234567890",
|
||||
S("1234567890123456789012345678901234567890"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -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("123456789012345678901234567890"));
|
||||
test(S("12345678901234567890"), S("12345678901234567890"),
|
||||
S("1234567890123456789012345678901234567890"));
|
||||
}
|
||||
#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("12345"));
|
||||
test(S("12345"), S("12345"), S("1234512345"));
|
||||
test(S("12345"), S("1234567890"), S("123451234567890"));
|
||||
test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890"));
|
||||
|
||||
test(S("1234567890"), S(), S("1234567890"));
|
||||
test(S("1234567890"), S("12345"), S("123456789012345"));
|
||||
test(S("1234567890"), S("1234567890"), S("12345678901234567890"));
|
||||
test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890"));
|
||||
|
||||
test(S("12345678901234567890"), S(), S("12345678901234567890"));
|
||||
test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345"));
|
||||
test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
|
||||
test(S("12345678901234567890"), S("12345678901234567890"),
|
||||
S("1234567890123456789012345678901234567890"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user