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 <stdexcept>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(S& s, typename S::const_iterator p, typename S::value_type c, S expected)
|
||||
@@ -32,6 +34,7 @@ test(S& s, typename S::const_iterator p, typename S::value_type c, S expected)
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::string S;
|
||||
S s;
|
||||
test(s, s.begin(), '1', S("1"));
|
||||
@@ -48,4 +51,25 @@ int main()
|
||||
test(s, s.begin()+4, 'A', S("a567A1432dcb"));
|
||||
test(s, s.begin()+5, 'B', S("a567AB1432dcb"));
|
||||
test(s, s.begin()+6, 'C', S("a567ABC1432dcb"));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
S s;
|
||||
test(s, s.begin(), '1', S("1"));
|
||||
test(s, s.begin(), 'a', S("a1"));
|
||||
test(s, s.end(), 'b', S("a1b"));
|
||||
test(s, s.end()-1, 'c', S("a1cb"));
|
||||
test(s, s.end()-2, 'd', S("a1dcb"));
|
||||
test(s, s.end()-3, '2', S("a12dcb"));
|
||||
test(s, s.end()-4, '3', S("a132dcb"));
|
||||
test(s, s.end()-5, '4', S("a1432dcb"));
|
||||
test(s, s.begin()+1, '5', S("a51432dcb"));
|
||||
test(s, s.begin()+2, '6', S("a561432dcb"));
|
||||
test(s, s.begin()+3, '7', S("a5671432dcb"));
|
||||
test(s, s.begin()+4, 'A', S("a567A1432dcb"));
|
||||
test(s, s.begin()+5, 'B', S("a567AB1432dcb"));
|
||||
test(s, s.begin()+6, 'C', S("a567ABC1432dcb"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
@@ -23,5 +25,14 @@ int main()
|
||||
assert(i - s.begin() == 3);
|
||||
assert(s == "123abc456");
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
S s("123456");
|
||||
S::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'});
|
||||
assert(i - s.begin() == 3);
|
||||
assert(s == "123abc456");
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#include <cassert>
|
||||
|
||||
#include "../../input_iterator.h"
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class S, class It>
|
||||
void
|
||||
@@ -30,6 +31,7 @@ test(S s, typename S::difference_type pos, It first, It last, S expected)
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::string S;
|
||||
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
test(S(), 0, s, s, S());
|
||||
@@ -73,4 +75,52 @@ int main()
|
||||
test(S("12345678901234567890"), 15, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("123456789012345ABCDEFGHIJ67890"));
|
||||
test(S("12345678901234567890"), 20, input_iterator<const char*>(s), input_iterator<const char*>(s+52),
|
||||
S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
test(S(), 0, s, s, S());
|
||||
test(S(), 0, s, s+1, S("A"));
|
||||
test(S(), 0, s, s+10, S("ABCDEFGHIJ"));
|
||||
test(S(), 0, s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
|
||||
|
||||
test(S("12345"), 0, s, s, S("12345"));
|
||||
test(S("12345"), 1, s, s+1, S("1A2345"));
|
||||
test(S("12345"), 4, s, s+10, S("1234ABCDEFGHIJ5"));
|
||||
test(S("12345"), 5, s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
|
||||
|
||||
test(S("1234567890"), 0, s, s, S("1234567890"));
|
||||
test(S("1234567890"), 1, s, s+1, S("1A234567890"));
|
||||
test(S("1234567890"), 10, s, s+10, S("1234567890ABCDEFGHIJ"));
|
||||
test(S("1234567890"), 8, s, s+52, S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
|
||||
|
||||
test(S("12345678901234567890"), 3, s, s, S("12345678901234567890"));
|
||||
test(S("12345678901234567890"), 3, s, s+1, S("123A45678901234567890"));
|
||||
test(S("12345678901234567890"), 15, s, s+10, S("123456789012345ABCDEFGHIJ67890"));
|
||||
test(S("12345678901234567890"), 20, s, s+52,
|
||||
S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
|
||||
|
||||
test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S());
|
||||
test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
|
||||
test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("ABCDEFGHIJ"));
|
||||
test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
|
||||
|
||||
test(S("12345"), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S("12345"));
|
||||
test(S("12345"), 1, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("1A2345"));
|
||||
test(S("12345"), 4, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("1234ABCDEFGHIJ5"));
|
||||
test(S("12345"), 5, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
|
||||
|
||||
test(S("1234567890"), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S("1234567890"));
|
||||
test(S("1234567890"), 1, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("1A234567890"));
|
||||
test(S("1234567890"), 10, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("1234567890ABCDEFGHIJ"));
|
||||
test(S("1234567890"), 8, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
|
||||
|
||||
test(S("12345678901234567890"), 3, input_iterator<const char*>(s), input_iterator<const char*>(s), S("12345678901234567890"));
|
||||
test(S("12345678901234567890"), 3, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("123A45678901234567890"));
|
||||
test(S("12345678901234567890"), 15, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("123456789012345ABCDEFGHIJ67890"));
|
||||
test(S("12345678901234567890"), 20, input_iterator<const char*>(s), input_iterator<const char*>(s+52),
|
||||
S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(S s, typename S::difference_type pos, typename S::size_type n,
|
||||
@@ -28,6 +30,7 @@ test(S s, typename S::difference_type pos, typename S::size_type n,
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(""), 0, 0, '1', S(""));
|
||||
test(S(""), 0, 5, '1', S("11111"));
|
||||
@@ -93,4 +96,74 @@ int main()
|
||||
test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(""), 0, 0, '1', S(""));
|
||||
test(S(""), 0, 5, '1', S("11111"));
|
||||
test(S(""), 0, 10, '1', S("1111111111"));
|
||||
test(S(""), 0, 20, '1', S("11111111111111111111"));
|
||||
test(S("abcde"), 0, 0, '1', S("abcde"));
|
||||
test(S("abcde"), 0, 5, '1', S("11111abcde"));
|
||||
test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
|
||||
test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
|
||||
test(S("abcde"), 1, 0, '1', S("abcde"));
|
||||
test(S("abcde"), 1, 5, '1', S("a11111bcde"));
|
||||
test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
|
||||
test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
|
||||
test(S("abcde"), 2, 0, '1', S("abcde"));
|
||||
test(S("abcde"), 2, 5, '1', S("ab11111cde"));
|
||||
test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
|
||||
test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
|
||||
test(S("abcde"), 4, 0, '1', S("abcde"));
|
||||
test(S("abcde"), 4, 5, '1', S("abcd11111e"));
|
||||
test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
|
||||
test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
|
||||
test(S("abcde"), 5, 0, '1', S("abcde"));
|
||||
test(S("abcde"), 5, 5, '1', S("abcde11111"));
|
||||
test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
|
||||
test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
|
||||
test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
|
||||
test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
|
||||
test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
|
||||
test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
|
||||
test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
|
||||
test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
|
||||
test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
|
||||
test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
|
||||
test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
|
||||
test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
|
||||
test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
|
||||
test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
|
||||
test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
|
||||
test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
|
||||
test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
|
||||
test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
|
||||
test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
|
||||
test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
|
||||
test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
|
||||
test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -16,6 +16,8 @@
|
||||
#include <stdexcept>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(S s, typename S::size_type pos, const typename S::value_type* str, S expected)
|
||||
@@ -38,6 +40,7 @@ test(S s, typename S::size_type pos, const typename S::value_type* str, S expect
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(""), 0, "", S(""));
|
||||
test(S(""), 0, "12345", S("12345"));
|
||||
@@ -119,4 +122,90 @@ int main()
|
||||
test(S("abcdefghijklmnopqrst"), 21, "12345", S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "1234567890", S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", S("can't happen"));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(""), 0, "", S(""));
|
||||
test(S(""), 0, "12345", S("12345"));
|
||||
test(S(""), 0, "1234567890", S("1234567890"));
|
||||
test(S(""), 0, "12345678901234567890", S("12345678901234567890"));
|
||||
test(S(""), 1, "", S("can't happen"));
|
||||
test(S(""), 1, "12345", S("can't happen"));
|
||||
test(S(""), 1, "1234567890", S("can't happen"));
|
||||
test(S(""), 1, "12345678901234567890", S("can't happen"));
|
||||
test(S("abcde"), 0, "", S("abcde"));
|
||||
test(S("abcde"), 0, "12345", S("12345abcde"));
|
||||
test(S("abcde"), 0, "1234567890", S("1234567890abcde"));
|
||||
test(S("abcde"), 0, "12345678901234567890", S("12345678901234567890abcde"));
|
||||
test(S("abcde"), 1, "", S("abcde"));
|
||||
test(S("abcde"), 1, "12345", S("a12345bcde"));
|
||||
test(S("abcde"), 1, "1234567890", S("a1234567890bcde"));
|
||||
test(S("abcde"), 1, "12345678901234567890", S("a12345678901234567890bcde"));
|
||||
test(S("abcde"), 2, "", S("abcde"));
|
||||
test(S("abcde"), 2, "12345", S("ab12345cde"));
|
||||
test(S("abcde"), 2, "1234567890", S("ab1234567890cde"));
|
||||
test(S("abcde"), 2, "12345678901234567890", S("ab12345678901234567890cde"));
|
||||
test(S("abcde"), 4, "", S("abcde"));
|
||||
test(S("abcde"), 4, "12345", S("abcd12345e"));
|
||||
test(S("abcde"), 4, "1234567890", S("abcd1234567890e"));
|
||||
test(S("abcde"), 4, "12345678901234567890", S("abcd12345678901234567890e"));
|
||||
test(S("abcde"), 5, "", S("abcde"));
|
||||
test(S("abcde"), 5, "12345", S("abcde12345"));
|
||||
test(S("abcde"), 5, "1234567890", S("abcde1234567890"));
|
||||
test(S("abcde"), 5, "12345678901234567890", S("abcde12345678901234567890"));
|
||||
test(S("abcde"), 6, "", S("can't happen"));
|
||||
test(S("abcde"), 6, "12345", S("can't happen"));
|
||||
test(S("abcde"), 6, "1234567890", S("can't happen"));
|
||||
test(S("abcde"), 6, "12345678901234567890", S("can't happen"));
|
||||
test(S("abcdefghij"), 0, "", S("abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "12345", S("12345abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "1234567890", S("1234567890abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "12345678901234567890", S("12345678901234567890abcdefghij"));
|
||||
test(S("abcdefghij"), 1, "", S("abcdefghij"));
|
||||
test(S("abcdefghij"), 1, "12345", S("a12345bcdefghij"));
|
||||
test(S("abcdefghij"), 1, "1234567890", S("a1234567890bcdefghij"));
|
||||
test(S("abcdefghij"), 1, "12345678901234567890", S("a12345678901234567890bcdefghij"));
|
||||
test(S("abcdefghij"), 5, "", S("abcdefghij"));
|
||||
test(S("abcdefghij"), 5, "12345", S("abcde12345fghij"));
|
||||
test(S("abcdefghij"), 5, "1234567890", S("abcde1234567890fghij"));
|
||||
test(S("abcdefghij"), 5, "12345678901234567890", S("abcde12345678901234567890fghij"));
|
||||
test(S("abcdefghij"), 9, "", S("abcdefghij"));
|
||||
test(S("abcdefghij"), 9, "12345", S("abcdefghi12345j"));
|
||||
test(S("abcdefghij"), 9, "1234567890", S("abcdefghi1234567890j"));
|
||||
test(S("abcdefghij"), 9, "12345678901234567890", S("abcdefghi12345678901234567890j"));
|
||||
test(S("abcdefghij"), 10, "", S("abcdefghij"));
|
||||
test(S("abcdefghij"), 10, "12345", S("abcdefghij12345"));
|
||||
test(S("abcdefghij"), 10, "1234567890", S("abcdefghij1234567890"));
|
||||
test(S("abcdefghij"), 10, "12345678901234567890", S("abcdefghij12345678901234567890"));
|
||||
test(S("abcdefghij"), 11, "", S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "12345", S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "1234567890", S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "12345678901234567890", S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "", S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "12345", S("12345abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "1234567890", S("1234567890abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "", S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "12345", S("a12345bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "1234567890", S("a1234567890bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "", S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "12345", S("abcdefghij12345klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "1234567890", S("abcdefghij1234567890klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "", S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "12345", S("abcdefghijklmnopqrs12345t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "1234567890", S("abcdefghijklmnopqrs1234567890t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "", S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "12345", S("abcdefghijklmnopqrst12345"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "1234567890", S("abcdefghijklmnopqrst1234567890"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "", S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "12345", S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "1234567890", S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", S("can't happen"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -16,6 +16,8 @@
|
||||
#include <stdexcept>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(S s, typename S::size_type pos, const typename S::value_type* str,
|
||||
@@ -39,6 +41,7 @@ test(S s, typename S::size_type pos, const typename S::value_type* str,
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(""), 0, "", 0, S(""));
|
||||
test(S(""), 0, "12345", 0, S(""));
|
||||
@@ -360,4 +363,330 @@ int main()
|
||||
test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 10, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 19, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 20, S("can't happen"));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(""), 0, "", 0, S(""));
|
||||
test(S(""), 0, "12345", 0, S(""));
|
||||
test(S(""), 0, "12345", 1, S("1"));
|
||||
test(S(""), 0, "12345", 2, S("12"));
|
||||
test(S(""), 0, "12345", 4, S("1234"));
|
||||
test(S(""), 0, "12345", 5, S("12345"));
|
||||
test(S(""), 0, "1234567890", 0, S(""));
|
||||
test(S(""), 0, "1234567890", 1, S("1"));
|
||||
test(S(""), 0, "1234567890", 5, S("12345"));
|
||||
test(S(""), 0, "1234567890", 9, S("123456789"));
|
||||
test(S(""), 0, "1234567890", 10, S("1234567890"));
|
||||
test(S(""), 0, "12345678901234567890", 0, S(""));
|
||||
test(S(""), 0, "12345678901234567890", 1, S("1"));
|
||||
test(S(""), 0, "12345678901234567890", 10, S("1234567890"));
|
||||
test(S(""), 0, "12345678901234567890", 19, S("1234567890123456789"));
|
||||
test(S(""), 0, "12345678901234567890", 20, S("12345678901234567890"));
|
||||
test(S(""), 1, "", 0, S("can't happen"));
|
||||
test(S(""), 1, "12345", 0, S("can't happen"));
|
||||
test(S(""), 1, "12345", 1, S("can't happen"));
|
||||
test(S(""), 1, "12345", 2, S("can't happen"));
|
||||
test(S(""), 1, "12345", 4, S("can't happen"));
|
||||
test(S(""), 1, "12345", 5, S("can't happen"));
|
||||
test(S(""), 1, "1234567890", 0, S("can't happen"));
|
||||
test(S(""), 1, "1234567890", 1, S("can't happen"));
|
||||
test(S(""), 1, "1234567890", 5, S("can't happen"));
|
||||
test(S(""), 1, "1234567890", 9, S("can't happen"));
|
||||
test(S(""), 1, "1234567890", 10, S("can't happen"));
|
||||
test(S(""), 1, "12345678901234567890", 0, S("can't happen"));
|
||||
test(S(""), 1, "12345678901234567890", 1, S("can't happen"));
|
||||
test(S(""), 1, "12345678901234567890", 10, S("can't happen"));
|
||||
test(S(""), 1, "12345678901234567890", 19, S("can't happen"));
|
||||
test(S(""), 1, "12345678901234567890", 20, S("can't happen"));
|
||||
test(S("abcde"), 0, "", 0, S("abcde"));
|
||||
test(S("abcde"), 0, "12345", 0, S("abcde"));
|
||||
test(S("abcde"), 0, "12345", 1, S("1abcde"));
|
||||
test(S("abcde"), 0, "12345", 2, S("12abcde"));
|
||||
test(S("abcde"), 0, "12345", 4, S("1234abcde"));
|
||||
test(S("abcde"), 0, "12345", 5, S("12345abcde"));
|
||||
test(S("abcde"), 0, "1234567890", 0, S("abcde"));
|
||||
test(S("abcde"), 0, "1234567890", 1, S("1abcde"));
|
||||
test(S("abcde"), 0, "1234567890", 5, S("12345abcde"));
|
||||
test(S("abcde"), 0, "1234567890", 9, S("123456789abcde"));
|
||||
test(S("abcde"), 0, "1234567890", 10, S("1234567890abcde"));
|
||||
test(S("abcde"), 0, "12345678901234567890", 0, S("abcde"));
|
||||
test(S("abcde"), 0, "12345678901234567890", 1, S("1abcde"));
|
||||
test(S("abcde"), 0, "12345678901234567890", 10, S("1234567890abcde"));
|
||||
test(S("abcde"), 0, "12345678901234567890", 19, S("1234567890123456789abcde"));
|
||||
test(S("abcde"), 0, "12345678901234567890", 20, S("12345678901234567890abcde"));
|
||||
test(S("abcde"), 1, "", 0, S("abcde"));
|
||||
test(S("abcde"), 1, "12345", 0, S("abcde"));
|
||||
test(S("abcde"), 1, "12345", 1, S("a1bcde"));
|
||||
test(S("abcde"), 1, "12345", 2, S("a12bcde"));
|
||||
test(S("abcde"), 1, "12345", 4, S("a1234bcde"));
|
||||
test(S("abcde"), 1, "12345", 5, S("a12345bcde"));
|
||||
test(S("abcde"), 1, "1234567890", 0, S("abcde"));
|
||||
test(S("abcde"), 1, "1234567890", 1, S("a1bcde"));
|
||||
test(S("abcde"), 1, "1234567890", 5, S("a12345bcde"));
|
||||
test(S("abcde"), 1, "1234567890", 9, S("a123456789bcde"));
|
||||
test(S("abcde"), 1, "1234567890", 10, S("a1234567890bcde"));
|
||||
test(S("abcde"), 1, "12345678901234567890", 0, S("abcde"));
|
||||
test(S("abcde"), 1, "12345678901234567890", 1, S("a1bcde"));
|
||||
test(S("abcde"), 1, "12345678901234567890", 10, S("a1234567890bcde"));
|
||||
test(S("abcde"), 1, "12345678901234567890", 19, S("a1234567890123456789bcde"));
|
||||
test(S("abcde"), 1, "12345678901234567890", 20, S("a12345678901234567890bcde"));
|
||||
test(S("abcde"), 2, "", 0, S("abcde"));
|
||||
test(S("abcde"), 2, "12345", 0, S("abcde"));
|
||||
test(S("abcde"), 2, "12345", 1, S("ab1cde"));
|
||||
test(S("abcde"), 2, "12345", 2, S("ab12cde"));
|
||||
test(S("abcde"), 2, "12345", 4, S("ab1234cde"));
|
||||
test(S("abcde"), 2, "12345", 5, S("ab12345cde"));
|
||||
test(S("abcde"), 2, "1234567890", 0, S("abcde"));
|
||||
test(S("abcde"), 2, "1234567890", 1, S("ab1cde"));
|
||||
test(S("abcde"), 2, "1234567890", 5, S("ab12345cde"));
|
||||
test(S("abcde"), 2, "1234567890", 9, S("ab123456789cde"));
|
||||
test(S("abcde"), 2, "1234567890", 10, S("ab1234567890cde"));
|
||||
test(S("abcde"), 2, "12345678901234567890", 0, S("abcde"));
|
||||
test(S("abcde"), 2, "12345678901234567890", 1, S("ab1cde"));
|
||||
test(S("abcde"), 2, "12345678901234567890", 10, S("ab1234567890cde"));
|
||||
test(S("abcde"), 2, "12345678901234567890", 19, S("ab1234567890123456789cde"));
|
||||
test(S("abcde"), 2, "12345678901234567890", 20, S("ab12345678901234567890cde"));
|
||||
test(S("abcde"), 4, "", 0, S("abcde"));
|
||||
test(S("abcde"), 4, "12345", 0, S("abcde"));
|
||||
test(S("abcde"), 4, "12345", 1, S("abcd1e"));
|
||||
test(S("abcde"), 4, "12345", 2, S("abcd12e"));
|
||||
test(S("abcde"), 4, "12345", 4, S("abcd1234e"));
|
||||
test(S("abcde"), 4, "12345", 5, S("abcd12345e"));
|
||||
test(S("abcde"), 4, "1234567890", 0, S("abcde"));
|
||||
test(S("abcde"), 4, "1234567890", 1, S("abcd1e"));
|
||||
test(S("abcde"), 4, "1234567890", 5, S("abcd12345e"));
|
||||
test(S("abcde"), 4, "1234567890", 9, S("abcd123456789e"));
|
||||
test(S("abcde"), 4, "1234567890", 10, S("abcd1234567890e"));
|
||||
test(S("abcde"), 4, "12345678901234567890", 0, S("abcde"));
|
||||
test(S("abcde"), 4, "12345678901234567890", 1, S("abcd1e"));
|
||||
test(S("abcde"), 4, "12345678901234567890", 10, S("abcd1234567890e"));
|
||||
test(S("abcde"), 4, "12345678901234567890", 19, S("abcd1234567890123456789e"));
|
||||
test(S("abcde"), 4, "12345678901234567890", 20, S("abcd12345678901234567890e"));
|
||||
test(S("abcde"), 5, "", 0, S("abcde"));
|
||||
test(S("abcde"), 5, "12345", 0, S("abcde"));
|
||||
test(S("abcde"), 5, "12345", 1, S("abcde1"));
|
||||
test(S("abcde"), 5, "12345", 2, S("abcde12"));
|
||||
test(S("abcde"), 5, "12345", 4, S("abcde1234"));
|
||||
test(S("abcde"), 5, "12345", 5, S("abcde12345"));
|
||||
test(S("abcde"), 5, "1234567890", 0, S("abcde"));
|
||||
test(S("abcde"), 5, "1234567890", 1, S("abcde1"));
|
||||
test(S("abcde"), 5, "1234567890", 5, S("abcde12345"));
|
||||
test(S("abcde"), 5, "1234567890", 9, S("abcde123456789"));
|
||||
test(S("abcde"), 5, "1234567890", 10, S("abcde1234567890"));
|
||||
test(S("abcde"), 5, "12345678901234567890", 0, S("abcde"));
|
||||
test(S("abcde"), 5, "12345678901234567890", 1, S("abcde1"));
|
||||
test(S("abcde"), 5, "12345678901234567890", 10, S("abcde1234567890"));
|
||||
test(S("abcde"), 5, "12345678901234567890", 19, S("abcde1234567890123456789"));
|
||||
test(S("abcde"), 5, "12345678901234567890", 20, S("abcde12345678901234567890"));
|
||||
test(S("abcde"), 6, "", 0, S("can't happen"));
|
||||
test(S("abcde"), 6, "12345", 0, S("can't happen"));
|
||||
test(S("abcde"), 6, "12345", 1, S("can't happen"));
|
||||
test(S("abcde"), 6, "12345", 2, S("can't happen"));
|
||||
test(S("abcde"), 6, "12345", 4, S("can't happen"));
|
||||
test(S("abcde"), 6, "12345", 5, S("can't happen"));
|
||||
test(S("abcde"), 6, "1234567890", 0, S("can't happen"));
|
||||
test(S("abcde"), 6, "1234567890", 1, S("can't happen"));
|
||||
test(S("abcde"), 6, "1234567890", 5, S("can't happen"));
|
||||
test(S("abcde"), 6, "1234567890", 9, S("can't happen"));
|
||||
test(S("abcde"), 6, "1234567890", 10, S("can't happen"));
|
||||
test(S("abcde"), 6, "12345678901234567890", 0, S("can't happen"));
|
||||
test(S("abcde"), 6, "12345678901234567890", 1, S("can't happen"));
|
||||
test(S("abcde"), 6, "12345678901234567890", 10, S("can't happen"));
|
||||
test(S("abcde"), 6, "12345678901234567890", 19, S("can't happen"));
|
||||
test(S("abcde"), 6, "12345678901234567890", 20, S("can't happen"));
|
||||
test(S("abcdefghij"), 0, "", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "12345", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "12345", 1, S("1abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "12345", 2, S("12abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "12345", 4, S("1234abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "12345", 5, S("12345abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "1234567890", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "1234567890", 1, S("1abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "1234567890", 5, S("12345abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "1234567890", 9, S("123456789abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "1234567890", 10, S("1234567890abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "12345678901234567890", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "12345678901234567890", 1, S("1abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "12345678901234567890", 10, S("1234567890abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij"));
|
||||
test(S("abcdefghij"), 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij"));
|
||||
test(S("abcdefghij"), 1, "", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 1, "12345", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 1, "12345", 1, S("a1bcdefghij"));
|
||||
test(S("abcdefghij"), 1, "12345", 2, S("a12bcdefghij"));
|
||||
test(S("abcdefghij"), 1, "12345", 4, S("a1234bcdefghij"));
|
||||
test(S("abcdefghij"), 1, "12345", 5, S("a12345bcdefghij"));
|
||||
test(S("abcdefghij"), 1, "1234567890", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 1, "1234567890", 1, S("a1bcdefghij"));
|
||||
test(S("abcdefghij"), 1, "1234567890", 5, S("a12345bcdefghij"));
|
||||
test(S("abcdefghij"), 1, "1234567890", 9, S("a123456789bcdefghij"));
|
||||
test(S("abcdefghij"), 1, "1234567890", 10, S("a1234567890bcdefghij"));
|
||||
test(S("abcdefghij"), 1, "12345678901234567890", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 1, "12345678901234567890", 1, S("a1bcdefghij"));
|
||||
test(S("abcdefghij"), 1, "12345678901234567890", 10, S("a1234567890bcdefghij"));
|
||||
test(S("abcdefghij"), 1, "12345678901234567890", 19, S("a1234567890123456789bcdefghij"));
|
||||
test(S("abcdefghij"), 1, "12345678901234567890", 20, S("a12345678901234567890bcdefghij"));
|
||||
test(S("abcdefghij"), 5, "", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 5, "12345", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 5, "12345", 1, S("abcde1fghij"));
|
||||
test(S("abcdefghij"), 5, "12345", 2, S("abcde12fghij"));
|
||||
test(S("abcdefghij"), 5, "12345", 4, S("abcde1234fghij"));
|
||||
test(S("abcdefghij"), 5, "12345", 5, S("abcde12345fghij"));
|
||||
test(S("abcdefghij"), 5, "1234567890", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 5, "1234567890", 1, S("abcde1fghij"));
|
||||
test(S("abcdefghij"), 5, "1234567890", 5, S("abcde12345fghij"));
|
||||
test(S("abcdefghij"), 5, "1234567890", 9, S("abcde123456789fghij"));
|
||||
test(S("abcdefghij"), 5, "1234567890", 10, S("abcde1234567890fghij"));
|
||||
test(S("abcdefghij"), 5, "12345678901234567890", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 5, "12345678901234567890", 1, S("abcde1fghij"));
|
||||
test(S("abcdefghij"), 5, "12345678901234567890", 10, S("abcde1234567890fghij"));
|
||||
test(S("abcdefghij"), 5, "12345678901234567890", 19, S("abcde1234567890123456789fghij"));
|
||||
test(S("abcdefghij"), 5, "12345678901234567890", 20, S("abcde12345678901234567890fghij"));
|
||||
test(S("abcdefghij"), 9, "", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 9, "12345", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 9, "12345", 1, S("abcdefghi1j"));
|
||||
test(S("abcdefghij"), 9, "12345", 2, S("abcdefghi12j"));
|
||||
test(S("abcdefghij"), 9, "12345", 4, S("abcdefghi1234j"));
|
||||
test(S("abcdefghij"), 9, "12345", 5, S("abcdefghi12345j"));
|
||||
test(S("abcdefghij"), 9, "1234567890", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 9, "1234567890", 1, S("abcdefghi1j"));
|
||||
test(S("abcdefghij"), 9, "1234567890", 5, S("abcdefghi12345j"));
|
||||
test(S("abcdefghij"), 9, "1234567890", 9, S("abcdefghi123456789j"));
|
||||
test(S("abcdefghij"), 9, "1234567890", 10, S("abcdefghi1234567890j"));
|
||||
test(S("abcdefghij"), 9, "12345678901234567890", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 9, "12345678901234567890", 1, S("abcdefghi1j"));
|
||||
test(S("abcdefghij"), 9, "12345678901234567890", 10, S("abcdefghi1234567890j"));
|
||||
test(S("abcdefghij"), 9, "12345678901234567890", 19, S("abcdefghi1234567890123456789j"));
|
||||
test(S("abcdefghij"), 9, "12345678901234567890", 20, S("abcdefghi12345678901234567890j"));
|
||||
test(S("abcdefghij"), 10, "", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 10, "12345", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 10, "12345", 1, S("abcdefghij1"));
|
||||
test(S("abcdefghij"), 10, "12345", 2, S("abcdefghij12"));
|
||||
test(S("abcdefghij"), 10, "12345", 4, S("abcdefghij1234"));
|
||||
test(S("abcdefghij"), 10, "12345", 5, S("abcdefghij12345"));
|
||||
test(S("abcdefghij"), 10, "1234567890", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 10, "1234567890", 1, S("abcdefghij1"));
|
||||
test(S("abcdefghij"), 10, "1234567890", 5, S("abcdefghij12345"));
|
||||
test(S("abcdefghij"), 10, "1234567890", 9, S("abcdefghij123456789"));
|
||||
test(S("abcdefghij"), 10, "1234567890", 10, S("abcdefghij1234567890"));
|
||||
test(S("abcdefghij"), 10, "12345678901234567890", 0, S("abcdefghij"));
|
||||
test(S("abcdefghij"), 10, "12345678901234567890", 1, S("abcdefghij1"));
|
||||
test(S("abcdefghij"), 10, "12345678901234567890", 10, S("abcdefghij1234567890"));
|
||||
test(S("abcdefghij"), 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
|
||||
test(S("abcdefghij"), 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
|
||||
test(S("abcdefghij"), 11, "", 0, S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "12345", 0, S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "12345", 1, S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "12345", 2, S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "12345", 4, S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "12345", 5, S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "1234567890", 0, S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "1234567890", 1, S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "1234567890", 5, S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "1234567890", 9, S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "1234567890", 10, S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "12345678901234567890", 0, S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "12345678901234567890", 1, S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "12345678901234567890", 10, S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "12345678901234567890", 19, S("can't happen"));
|
||||
test(S("abcdefghij"), 11, "12345678901234567890", 20, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "12345", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "12345", 1, S("1abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "12345", 2, S("12abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "12345", 4, S("1234abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "12345", 5, S("12345abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "1234567890", 1, S("1abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "1234567890", 5, S("12345abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "12345", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "12345", 1, S("a1bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "12345", 2, S("a12bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "12345", 4, S("a1234bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "12345", 5, S("a12345bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "1234567890", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "1234567890", 1, S("a1bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "1234567890", 5, S("a12345bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "1234567890", 9, S("a123456789bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "12345", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "12345", 1, S("abcdefghij1klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "12345", 2, S("abcdefghij12klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "12345", 4, S("abcdefghij1234klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "12345", 5, S("abcdefghij12345klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "1234567890", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "1234567890", 1, S("abcdefghij1klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "1234567890", 5, S("abcdefghij12345klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "1234567890", 9, S("abcdefghij123456789klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "1234567890", 10, S("abcdefghij1234567890klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 1, S("abcdefghij1klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "12345", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "12345", 1, S("abcdefghijklmnopqrs1t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "12345", 2, S("abcdefghijklmnopqrs12t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "12345", 4, S("abcdefghijklmnopqrs1234t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "12345", 5, S("abcdefghijklmnopqrs12345t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "1234567890", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "1234567890", 1, S("abcdefghijklmnopqrs1t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "1234567890", 5, S("abcdefghijklmnopqrs12345t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "1234567890", 9, S("abcdefghijklmnopqrs123456789t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "12345", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "12345", 1, S("abcdefghijklmnopqrst1"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "12345", 2, S("abcdefghijklmnopqrst12"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "12345", 4, S("abcdefghijklmnopqrst1234"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "12345", 5, S("abcdefghijklmnopqrst12345"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "1234567890", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "1234567890", 1, S("abcdefghijklmnopqrst1"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "1234567890", 5, S("abcdefghijklmnopqrst12345"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "1234567890", 9, S("abcdefghijklmnopqrst123456789"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "1234567890", 10, S("abcdefghijklmnopqrst1234567890"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 1, S("abcdefghijklmnopqrst1"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "", 0, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "12345", 0, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "12345", 1, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "12345", 2, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "12345", 4, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "12345", 5, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "1234567890", 0, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "1234567890", 1, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "1234567890", 5, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "1234567890", 9, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "1234567890", 10, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 0, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 1, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 10, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 19, S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 20, S("can't happen"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -16,6 +16,8 @@
|
||||
#include <stdexcept>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(S s, typename S::size_type pos, typename S::size_type n,
|
||||
@@ -39,6 +41,7 @@ test(S s, typename S::size_type pos, typename S::size_type n,
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(""), 0, 0, '1', S(""));
|
||||
test(S(""), 0, 5, '1', S("11111"));
|
||||
@@ -120,4 +123,90 @@ int main()
|
||||
test(S("abcdefghijklmnopqrst"), 21, 5, '1', S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, 10, '1', S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, 20, '1', S("can't happen"));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(""), 0, 0, '1', S(""));
|
||||
test(S(""), 0, 5, '1', S("11111"));
|
||||
test(S(""), 0, 10, '1', S("1111111111"));
|
||||
test(S(""), 0, 20, '1', S("11111111111111111111"));
|
||||
test(S(""), 1, 0, '1', S("can't happen"));
|
||||
test(S(""), 1, 5, '1', S("can't happen"));
|
||||
test(S(""), 1, 10, '1', S("can't happen"));
|
||||
test(S(""), 1, 20, '1', S("can't happen"));
|
||||
test(S("abcde"), 0, 0, '1', S("abcde"));
|
||||
test(S("abcde"), 0, 5, '1', S("11111abcde"));
|
||||
test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
|
||||
test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
|
||||
test(S("abcde"), 1, 0, '1', S("abcde"));
|
||||
test(S("abcde"), 1, 5, '1', S("a11111bcde"));
|
||||
test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
|
||||
test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
|
||||
test(S("abcde"), 2, 0, '1', S("abcde"));
|
||||
test(S("abcde"), 2, 5, '1', S("ab11111cde"));
|
||||
test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
|
||||
test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
|
||||
test(S("abcde"), 4, 0, '1', S("abcde"));
|
||||
test(S("abcde"), 4, 5, '1', S("abcd11111e"));
|
||||
test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
|
||||
test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
|
||||
test(S("abcde"), 5, 0, '1', S("abcde"));
|
||||
test(S("abcde"), 5, 5, '1', S("abcde11111"));
|
||||
test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
|
||||
test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
|
||||
test(S("abcde"), 6, 0, '1', S("can't happen"));
|
||||
test(S("abcde"), 6, 5, '1', S("can't happen"));
|
||||
test(S("abcde"), 6, 10, '1', S("can't happen"));
|
||||
test(S("abcde"), 6, 20, '1', S("can't happen"));
|
||||
test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
|
||||
test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
|
||||
test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
|
||||
test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
|
||||
test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
|
||||
test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
|
||||
test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
|
||||
test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
|
||||
test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
|
||||
test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
|
||||
test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
|
||||
test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
|
||||
test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
|
||||
test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
|
||||
test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
|
||||
test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
|
||||
test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
|
||||
test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
|
||||
test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
|
||||
test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
|
||||
test(S("abcdefghij"), 11, 0, '1', S("can't happen"));
|
||||
test(S("abcdefghij"), 11, 5, '1', S("can't happen"));
|
||||
test(S("abcdefghij"), 11, 10, '1', S("can't happen"));
|
||||
test(S("abcdefghij"), 11, 20, '1', S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, 0, '1', S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, 5, '1', S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, 10, '1', S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, 20, '1', S("can't happen"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -16,6 +16,8 @@
|
||||
#include <stdexcept>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(S s, typename S::size_type pos, S str, S expected)
|
||||
@@ -38,6 +40,7 @@ test(S s, typename S::size_type pos, S str, S expected)
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(""), 0, S(""), S(""));
|
||||
test(S(""), 0, S("12345"), S("12345"));
|
||||
@@ -119,4 +122,90 @@ int main()
|
||||
test(S("abcdefghijklmnopqrst"), 21, S("12345"), S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), S("can't happen"));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(""), 0, S(""), S(""));
|
||||
test(S(""), 0, S("12345"), S("12345"));
|
||||
test(S(""), 0, S("1234567890"), S("1234567890"));
|
||||
test(S(""), 0, S("12345678901234567890"), S("12345678901234567890"));
|
||||
test(S(""), 1, S(""), S("can't happen"));
|
||||
test(S(""), 1, S("12345"), S("can't happen"));
|
||||
test(S(""), 1, S("1234567890"), S("can't happen"));
|
||||
test(S(""), 1, S("12345678901234567890"), S("can't happen"));
|
||||
test(S("abcde"), 0, S(""), S("abcde"));
|
||||
test(S("abcde"), 0, S("12345"), S("12345abcde"));
|
||||
test(S("abcde"), 0, S("1234567890"), S("1234567890abcde"));
|
||||
test(S("abcde"), 0, S("12345678901234567890"), S("12345678901234567890abcde"));
|
||||
test(S("abcde"), 1, S(""), S("abcde"));
|
||||
test(S("abcde"), 1, S("12345"), S("a12345bcde"));
|
||||
test(S("abcde"), 1, S("1234567890"), S("a1234567890bcde"));
|
||||
test(S("abcde"), 1, S("12345678901234567890"), S("a12345678901234567890bcde"));
|
||||
test(S("abcde"), 2, S(""), S("abcde"));
|
||||
test(S("abcde"), 2, S("12345"), S("ab12345cde"));
|
||||
test(S("abcde"), 2, S("1234567890"), S("ab1234567890cde"));
|
||||
test(S("abcde"), 2, S("12345678901234567890"), S("ab12345678901234567890cde"));
|
||||
test(S("abcde"), 4, S(""), S("abcde"));
|
||||
test(S("abcde"), 4, S("12345"), S("abcd12345e"));
|
||||
test(S("abcde"), 4, S("1234567890"), S("abcd1234567890e"));
|
||||
test(S("abcde"), 4, S("12345678901234567890"), S("abcd12345678901234567890e"));
|
||||
test(S("abcde"), 5, S(""), S("abcde"));
|
||||
test(S("abcde"), 5, S("12345"), S("abcde12345"));
|
||||
test(S("abcde"), 5, S("1234567890"), S("abcde1234567890"));
|
||||
test(S("abcde"), 5, S("12345678901234567890"), S("abcde12345678901234567890"));
|
||||
test(S("abcde"), 6, S(""), S("can't happen"));
|
||||
test(S("abcde"), 6, S("12345"), S("can't happen"));
|
||||
test(S("abcde"), 6, S("1234567890"), S("can't happen"));
|
||||
test(S("abcde"), 6, S("12345678901234567890"), S("can't happen"));
|
||||
test(S("abcdefghij"), 0, S(""), S("abcdefghij"));
|
||||
test(S("abcdefghij"), 0, S("12345"), S("12345abcdefghij"));
|
||||
test(S("abcdefghij"), 0, S("1234567890"), S("1234567890abcdefghij"));
|
||||
test(S("abcdefghij"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghij"));
|
||||
test(S("abcdefghij"), 1, S(""), S("abcdefghij"));
|
||||
test(S("abcdefghij"), 1, S("12345"), S("a12345bcdefghij"));
|
||||
test(S("abcdefghij"), 1, S("1234567890"), S("a1234567890bcdefghij"));
|
||||
test(S("abcdefghij"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghij"));
|
||||
test(S("abcdefghij"), 5, S(""), S("abcdefghij"));
|
||||
test(S("abcdefghij"), 5, S("12345"), S("abcde12345fghij"));
|
||||
test(S("abcdefghij"), 5, S("1234567890"), S("abcde1234567890fghij"));
|
||||
test(S("abcdefghij"), 5, S("12345678901234567890"), S("abcde12345678901234567890fghij"));
|
||||
test(S("abcdefghij"), 9, S(""), S("abcdefghij"));
|
||||
test(S("abcdefghij"), 9, S("12345"), S("abcdefghi12345j"));
|
||||
test(S("abcdefghij"), 9, S("1234567890"), S("abcdefghi1234567890j"));
|
||||
test(S("abcdefghij"), 9, S("12345678901234567890"), S("abcdefghi12345678901234567890j"));
|
||||
test(S("abcdefghij"), 10, S(""), S("abcdefghij"));
|
||||
test(S("abcdefghij"), 10, S("12345"), S("abcdefghij12345"));
|
||||
test(S("abcdefghij"), 10, S("1234567890"), S("abcdefghij1234567890"));
|
||||
test(S("abcdefghij"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
|
||||
test(S("abcdefghij"), 11, S(""), S("can't happen"));
|
||||
test(S("abcdefghij"), 11, S("12345"), S("can't happen"));
|
||||
test(S("abcdefghij"), 11, S("1234567890"), S("can't happen"));
|
||||
test(S("abcdefghij"), 11, S("12345678901234567890"), S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, S(""), S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, S("12345"), S("12345abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, S(""), S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, S("12345"), S("a12345bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, S(""), S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, S("12345"), S("abcdefghij12345klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), S("abcdefghij1234567890klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, S(""), S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, S("12345"), S("abcdefghijklmnopqrs12345t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
|
||||
test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, S(""), S("abcdefghijklmnopqrst"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, S("12345"), S("abcdefghijklmnopqrst12345"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
|
||||
test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, S(""), S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, S("12345"), S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), S("can't happen"));
|
||||
test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), S("can't happen"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -17,13 +17,14 @@
|
||||
#include <stdexcept>
|
||||
#include <cassert>
|
||||
|
||||
typedef std::string S;
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(S s, S::size_type pos1, S str, S::size_type pos2,
|
||||
S::size_type n, S expected)
|
||||
test(S s, typename S::size_type pos1, S str, typename S::size_type pos2,
|
||||
typename S::size_type n, S expected)
|
||||
{
|
||||
S::size_type old_size = s.size();
|
||||
typename S::size_type old_size = s.size();
|
||||
S s0 = s;
|
||||
try
|
||||
{
|
||||
@@ -39,6 +40,7 @@ test(S s, S::size_type pos1, S str, S::size_type pos2,
|
||||
}
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test0()
|
||||
{
|
||||
test(S(""), 0, S(""), 0, 0, S(""));
|
||||
@@ -93,6 +95,7 @@ void test0()
|
||||
test(S(""), 0, S("1234567890"), 11, 0, S("can't happen"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test1()
|
||||
{
|
||||
test(S(""), 0, S("12345678901234567890"), 0, 0, S(""));
|
||||
@@ -147,6 +150,7 @@ void test1()
|
||||
test(S(""), 1, S("12345"), 6, 0, S("can't happen"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test2()
|
||||
{
|
||||
test(S(""), 1, S("1234567890"), 0, 0, S("can't happen"));
|
||||
@@ -201,6 +205,7 @@ void test2()
|
||||
test(S("abcde"), 0, S(""), 0, 1, S("abcde"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test3()
|
||||
{
|
||||
test(S("abcde"), 0, S(""), 1, 0, S("can't happen"));
|
||||
@@ -255,6 +260,7 @@ void test3()
|
||||
test(S("abcde"), 0, S("12345678901234567890"), 0, 1, S("1abcde"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test4()
|
||||
{
|
||||
test(S("abcde"), 0, S("12345678901234567890"), 0, 10, S("1234567890abcde"));
|
||||
@@ -309,6 +315,7 @@ void test4()
|
||||
test(S("abcde"), 1, S("1234567890"), 0, 1, S("a1bcde"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test5()
|
||||
{
|
||||
test(S("abcde"), 1, S("1234567890"), 0, 5, S("a12345bcde"));
|
||||
@@ -363,6 +370,7 @@ void test5()
|
||||
test(S("abcde"), 2, S("12345"), 0, 0, S("abcde"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test6()
|
||||
{
|
||||
test(S("abcde"), 2, S("12345"), 0, 1, S("ab1cde"));
|
||||
@@ -417,6 +425,7 @@ void test6()
|
||||
test(S("abcde"), 2, S("12345678901234567890"), 0, 19, S("ab1234567890123456789cde"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test7()
|
||||
{
|
||||
test(S("abcde"), 2, S("12345678901234567890"), 0, 20, S("ab12345678901234567890cde"));
|
||||
@@ -471,6 +480,7 @@ void test7()
|
||||
test(S("abcde"), 4, S("1234567890"), 0, 9, S("abcd123456789e"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test8()
|
||||
{
|
||||
test(S("abcde"), 4, S("1234567890"), 0, 10, S("abcd1234567890e"));
|
||||
@@ -525,6 +535,7 @@ void test8()
|
||||
test(S("abcde"), 5, S("12345"), 0, 2, S("abcde12"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test9()
|
||||
{
|
||||
test(S("abcde"), 5, S("12345"), 0, 4, S("abcde1234"));
|
||||
@@ -579,6 +590,7 @@ void test9()
|
||||
test(S("abcde"), 5, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test10()
|
||||
{
|
||||
test(S("abcde"), 5, S("12345678901234567890"), 1, 0, S("abcde"));
|
||||
@@ -633,6 +645,7 @@ void test10()
|
||||
test(S("abcde"), 6, S("1234567890"), 0, 11, S("can't happen"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test11()
|
||||
{
|
||||
test(S("abcde"), 6, S("1234567890"), 1, 0, S("can't happen"));
|
||||
@@ -687,6 +700,7 @@ void test11()
|
||||
test(S("abcdefghij"), 0, S("12345"), 0, 5, S("12345abcdefghij"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test12()
|
||||
{
|
||||
test(S("abcdefghij"), 0, S("12345"), 0, 6, S("12345abcdefghij"));
|
||||
@@ -741,6 +755,7 @@ void test12()
|
||||
test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 1, S("2abcdefghij"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test13()
|
||||
{
|
||||
test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghij"));
|
||||
@@ -795,6 +810,7 @@ void test13()
|
||||
test(S("abcdefghij"), 1, S("1234567890"), 1, 1, S("a2bcdefghij"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test14()
|
||||
{
|
||||
test(S("abcdefghij"), 1, S("1234567890"), 1, 4, S("a2345bcdefghij"));
|
||||
@@ -849,6 +865,7 @@ void test14()
|
||||
test(S("abcdefghij"), 5, S("12345"), 1, 0, S("abcdefghij"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test15()
|
||||
{
|
||||
test(S("abcdefghij"), 5, S("12345"), 1, 1, S("abcde2fghij"));
|
||||
@@ -903,6 +920,7 @@ void test15()
|
||||
test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 18, S("abcde234567890123456789fghij"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test16()
|
||||
{
|
||||
test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890fghij"));
|
||||
@@ -957,6 +975,7 @@ void test16()
|
||||
test(S("abcdefghij"), 9, S("1234567890"), 1, 8, S("abcdefghi23456789j"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test17()
|
||||
{
|
||||
test(S("abcdefghij"), 9, S("1234567890"), 1, 9, S("abcdefghi234567890j"));
|
||||
@@ -1011,6 +1030,7 @@ void test17()
|
||||
test(S("abcdefghij"), 10, S("12345"), 1, 2, S("abcdefghij23"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test18()
|
||||
{
|
||||
test(S("abcdefghij"), 10, S("12345"), 1, 3, S("abcdefghij234"));
|
||||
@@ -1065,6 +1085,7 @@ void test18()
|
||||
test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test19()
|
||||
{
|
||||
test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 0, S("abcdefghij"));
|
||||
@@ -1119,6 +1140,7 @@ void test19()
|
||||
test(S("abcdefghij"), 11, S("1234567890"), 1, 10, S("can't happen"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test20()
|
||||
{
|
||||
test(S("abcdefghij"), 11, S("1234567890"), 5, 0, S("can't happen"));
|
||||
@@ -1173,6 +1195,7 @@ void test20()
|
||||
test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 4, S("2345abcdefghijklmnopqrst"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test21()
|
||||
{
|
||||
test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 5, S("2345abcdefghijklmnopqrst"));
|
||||
@@ -1227,6 +1250,7 @@ void test21()
|
||||
test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 1, S("1abcdefghijklmnopqrst"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test22()
|
||||
{
|
||||
test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 5, S("12345abcdefghijklmnopqrst"));
|
||||
@@ -1281,6 +1305,7 @@ void test22()
|
||||
test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 1, S("a6bcdefghijklmnopqrst"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test23()
|
||||
{
|
||||
test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 2, S("a67bcdefghijklmnopqrst"));
|
||||
@@ -1335,6 +1360,7 @@ void test23()
|
||||
test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test24()
|
||||
{
|
||||
test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 1, S("abcdefghij3klmnopqrst"));
|
||||
@@ -1389,6 +1415,7 @@ void test24()
|
||||
test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 9, S("abcdefghij123456789klmnopqrst"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test25()
|
||||
{
|
||||
test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890klmnopqrst"));
|
||||
@@ -1443,6 +1470,7 @@ void test25()
|
||||
test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789t"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test26()
|
||||
{
|
||||
test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890t"));
|
||||
@@ -1497,6 +1525,7 @@ void test26()
|
||||
test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 2, S("abcdefghijklmnopqrst34"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test27()
|
||||
{
|
||||
test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 3, S("abcdefghijklmnopqrst345"));
|
||||
@@ -1551,6 +1580,7 @@ void test27()
|
||||
test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrst1234567890"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test28()
|
||||
{
|
||||
test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
|
||||
@@ -1605,6 +1635,7 @@ void test28()
|
||||
test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 6, S("can't happen"));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test29()
|
||||
{
|
||||
test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 9, 0, S("can't happen"));
|
||||
@@ -1641,34 +1672,72 @@ void test29()
|
||||
|
||||
int main()
|
||||
{
|
||||
test0();
|
||||
test1();
|
||||
test2();
|
||||
test3();
|
||||
test4();
|
||||
test5();
|
||||
test6();
|
||||
test7();
|
||||
test8();
|
||||
test9();
|
||||
test10();
|
||||
test11();
|
||||
test12();
|
||||
test13();
|
||||
test14();
|
||||
test15();
|
||||
test16();
|
||||
test17();
|
||||
test18();
|
||||
test19();
|
||||
test20();
|
||||
test21();
|
||||
test22();
|
||||
test23();
|
||||
test24();
|
||||
test25();
|
||||
test26();
|
||||
test27();
|
||||
test28();
|
||||
test29();
|
||||
{
|
||||
typedef std::string S;
|
||||
test0<S>();
|
||||
test1<S>();
|
||||
test2<S>();
|
||||
test3<S>();
|
||||
test4<S>();
|
||||
test5<S>();
|
||||
test6<S>();
|
||||
test7<S>();
|
||||
test8<S>();
|
||||
test9<S>();
|
||||
test10<S>();
|
||||
test11<S>();
|
||||
test12<S>();
|
||||
test13<S>();
|
||||
test14<S>();
|
||||
test15<S>();
|
||||
test16<S>();
|
||||
test17<S>();
|
||||
test18<S>();
|
||||
test19<S>();
|
||||
test20<S>();
|
||||
test21<S>();
|
||||
test22<S>();
|
||||
test23<S>();
|
||||
test24<S>();
|
||||
test25<S>();
|
||||
test26<S>();
|
||||
test27<S>();
|
||||
test28<S>();
|
||||
test29<S>();
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test0<S>();
|
||||
test1<S>();
|
||||
test2<S>();
|
||||
test3<S>();
|
||||
test4<S>();
|
||||
test5<S>();
|
||||
test6<S>();
|
||||
test7<S>();
|
||||
test8<S>();
|
||||
test9<S>();
|
||||
test10<S>();
|
||||
test11<S>();
|
||||
test12<S>();
|
||||
test13<S>();
|
||||
test14<S>();
|
||||
test15<S>();
|
||||
test16<S>();
|
||||
test17<S>();
|
||||
test18<S>();
|
||||
test19<S>();
|
||||
test20<S>();
|
||||
test21<S>();
|
||||
test22<S>();
|
||||
test23<S>();
|
||||
test24<S>();
|
||||
test25<S>();
|
||||
test26<S>();
|
||||
test27<S>();
|
||||
test28<S>();
|
||||
test29<S>();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user