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:
@@ -15,6 +15,8 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const typename S::value_type* lhs, const S& rhs, bool x)
|
||||
@@ -22,10 +24,10 @@ test(const typename S::value_type* lhs, const S& rhs, bool x)
|
||||
assert((lhs <= rhs) == x);
|
||||
}
|
||||
|
||||
typedef std::string S;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::string S;
|
||||
test("", S(""), true);
|
||||
test("", S("abcde"), true);
|
||||
test("", S("abcdefghij"), true);
|
||||
@@ -42,4 +44,26 @@ int main()
|
||||
test("abcdefghijklmnopqrst", S("abcde"), false);
|
||||
test("abcdefghijklmnopqrst", S("abcdefghij"), false);
|
||||
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test("", S(""), true);
|
||||
test("", S("abcde"), true);
|
||||
test("", S("abcdefghij"), true);
|
||||
test("", S("abcdefghijklmnopqrst"), true);
|
||||
test("abcde", S(""), false);
|
||||
test("abcde", S("abcde"), true);
|
||||
test("abcde", S("abcdefghij"), true);
|
||||
test("abcde", S("abcdefghijklmnopqrst"), true);
|
||||
test("abcdefghij", S(""), false);
|
||||
test("abcdefghij", S("abcde"), false);
|
||||
test("abcdefghij", S("abcdefghij"), true);
|
||||
test("abcdefghij", S("abcdefghijklmnopqrst"), true);
|
||||
test("abcdefghijklmnopqrst", S(""), false);
|
||||
test("abcdefghijklmnopqrst", S("abcde"), false);
|
||||
test("abcdefghijklmnopqrst", S("abcdefghij"), false);
|
||||
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -15,6 +15,8 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const S& lhs, const typename S::value_type* rhs, bool x)
|
||||
@@ -22,10 +24,10 @@ test(const S& lhs, const typename S::value_type* rhs, bool x)
|
||||
assert((lhs <= rhs) == x);
|
||||
}
|
||||
|
||||
typedef std::string S;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(""), "", true);
|
||||
test(S(""), "abcde", true);
|
||||
test(S(""), "abcdefghij", true);
|
||||
@@ -42,4 +44,26 @@ int main()
|
||||
test(S("abcdefghijklmnopqrst"), "abcde", false);
|
||||
test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
|
||||
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(""), "", true);
|
||||
test(S(""), "abcde", true);
|
||||
test(S(""), "abcdefghij", true);
|
||||
test(S(""), "abcdefghijklmnopqrst", true);
|
||||
test(S("abcde"), "", false);
|
||||
test(S("abcde"), "abcde", true);
|
||||
test(S("abcde"), "abcdefghij", true);
|
||||
test(S("abcde"), "abcdefghijklmnopqrst", true);
|
||||
test(S("abcdefghij"), "", false);
|
||||
test(S("abcdefghij"), "abcde", false);
|
||||
test(S("abcdefghij"), "abcdefghij", true);
|
||||
test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
|
||||
test(S("abcdefghijklmnopqrst"), "", false);
|
||||
test(S("abcdefghijklmnopqrst"), "abcde", false);
|
||||
test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
|
||||
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -16,6 +16,8 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const S& lhs, const S& rhs, bool x)
|
||||
@@ -23,10 +25,10 @@ test(const S& lhs, const S& rhs, bool x)
|
||||
assert((lhs <= rhs) == x);
|
||||
}
|
||||
|
||||
typedef std::string S;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(""), S(""), true);
|
||||
test(S(""), S("abcde"), true);
|
||||
test(S(""), S("abcdefghij"), true);
|
||||
@@ -43,4 +45,26 @@ int main()
|
||||
test(S("abcdefghijklmnopqrst"), S("abcde"), false);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(""), S(""), true);
|
||||
test(S(""), S("abcde"), true);
|
||||
test(S(""), S("abcdefghij"), true);
|
||||
test(S(""), S("abcdefghijklmnopqrst"), true);
|
||||
test(S("abcde"), S(""), false);
|
||||
test(S("abcde"), S("abcde"), true);
|
||||
test(S("abcde"), S("abcdefghij"), true);
|
||||
test(S("abcde"), S("abcdefghijklmnopqrst"), true);
|
||||
test(S("abcdefghij"), S(""), false);
|
||||
test(S("abcdefghij"), S("abcde"), false);
|
||||
test(S("abcdefghij"), S("abcdefghij"), true);
|
||||
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
|
||||
test(S("abcdefghijklmnopqrst"), S(""), false);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcde"), false);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user