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:
Howard Hinnant
2013-06-28 16:59:19 +00:00
parent 2c39cbe020
commit 9dcdcdee25
151 changed files with 5125 additions and 645 deletions

View File

@@ -0,0 +1,252 @@
#ifndef MIN_ALLOCATOR_H
#define MIN_ALLOCATOR_H
#if __cplusplus >= 201103L
#include <memory>
template <class T> class min_pointer;
template <class T> class min_pointer<const T>;
template <> class min_pointer<void>;
template <> class min_pointer<const void>;
template <class T> class min_allocator;
template <>
class min_pointer<const void>
{
const void* ptr_;
public:
min_pointer() noexcept = default;
min_pointer(std::nullptr_t) : ptr_(nullptr) {}
template <class T>
min_pointer(min_pointer<T> p) : ptr_(p.ptr_) {}
explicit operator bool() const {return ptr_ != nullptr;}
friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
template <class U> friend class min_pointer;
};
template <>
class min_pointer<void>
{
void* ptr_;
public:
min_pointer() noexcept = default;
min_pointer(std::nullptr_t) : ptr_(nullptr) {}
template <class T,
class = typename std::enable_if
<
!std::is_const<T>::value
>::type
>
min_pointer(min_pointer<T> p) : ptr_(p.ptr_) {}
explicit operator bool() const {return ptr_ != nullptr;}
friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
template <class U> friend class min_pointer;
};
template <class T>
class min_pointer
{
T* ptr_;
explicit min_pointer(T* p) : ptr_(p) {}
public:
min_pointer() noexcept = default;
min_pointer(std::nullptr_t) : ptr_(nullptr) {}
explicit min_pointer(min_pointer<void> p) : ptr_(static_cast<T*>(p.ptr_)) {}
explicit operator bool() const {return ptr_ != nullptr;}
typedef std::ptrdiff_t difference_type;
typedef T& reference;
typedef T* pointer;
typedef T value_type;
typedef std::random_access_iterator_tag iterator_category;
reference operator*() const {return *ptr_;}
pointer operator->() const {return ptr_;}
min_pointer& operator++() {++ptr_; return *this;}
min_pointer operator++(int) {min_pointer tmp(*this); ++ptr_; return tmp;}
min_pointer& operator--() {--ptr_; return *this;}
min_pointer operator--(int) {min_pointer tmp(*this); --ptr_; return tmp;}
min_pointer& operator+=(difference_type n) {ptr_ += n; return *this;}
min_pointer& operator-=(difference_type n) {ptr_ -= n; return *this;}
min_pointer operator+(difference_type n) const
{
min_pointer tmp(*this);
tmp += n;
return tmp;
}
friend min_pointer operator+(difference_type n, min_pointer x)
{
return x + n;
}
min_pointer operator-(difference_type n) const
{
min_pointer tmp(*this);
tmp -= n;
return tmp;
}
friend difference_type operator-(min_pointer x, min_pointer y)
{
return x.ptr_ - y.ptr_;
}
reference operator[](difference_type n) const {return ptr_[n];}
friend bool operator< (min_pointer x, min_pointer y) {return x.ptr_ < y.ptr_;}
friend bool operator> (min_pointer x, min_pointer y) {return y < x;}
friend bool operator<=(min_pointer x, min_pointer y) {return !(y < x);}
friend bool operator>=(min_pointer x, min_pointer y) {return !(x < y);}
static min_pointer pointer_to(T& t) {return min_pointer(std::addressof(t));}
friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
template <class U> friend class min_pointer;
template <class U> friend class min_allocator;
};
template <class T>
class min_pointer<const T>
{
const T* ptr_;
explicit min_pointer(const T* p) : ptr_(p) {}
public:
min_pointer() noexcept = default;
min_pointer(std::nullptr_t) : ptr_(nullptr) {}
min_pointer(min_pointer<T> p) : ptr_(p.ptr_) {}
explicit min_pointer(min_pointer<const void> p) : ptr_(static_cast<const T*>(p.ptr_)) {}
explicit operator bool() const {return ptr_ != nullptr;}
typedef std::ptrdiff_t difference_type;
typedef const T& reference;
typedef const T* pointer;
typedef const T value_type;
typedef std::random_access_iterator_tag iterator_category;
reference operator*() const {return *ptr_;}
pointer operator->() const {return ptr_;}
min_pointer& operator++() {++ptr_; return *this;}
min_pointer operator++(int) {min_pointer tmp(*this); ++ptr_; return tmp;}
min_pointer& operator--() {--ptr_; return *this;}
min_pointer operator--(int) {min_pointer tmp(*this); --ptr_; return tmp;}
min_pointer& operator+=(difference_type n) {ptr_ += n; return *this;}
min_pointer& operator-=(difference_type n) {ptr_ -= n; return *this;}
min_pointer operator+(difference_type n) const
{
min_pointer tmp(*this);
tmp += n;
return tmp;
}
friend min_pointer operator+(difference_type n, min_pointer x)
{
return x + n;
}
min_pointer operator-(difference_type n) const
{
min_pointer tmp(*this);
tmp -= n;
return tmp;
}
friend difference_type operator-(min_pointer x, min_pointer y)
{
return x.ptr_ - y.ptr_;
}
reference operator[](difference_type n) const {return ptr_[n];}
friend bool operator< (min_pointer x, min_pointer y) {return x.ptr_ < y.ptr_;}
friend bool operator> (min_pointer x, min_pointer y) {return y < x;}
friend bool operator<=(min_pointer x, min_pointer y) {return !(y < x);}
friend bool operator>=(min_pointer x, min_pointer y) {return !(x < y);}
static min_pointer pointer_to(const T& t) {return min_pointer(std::addressof(t));}
friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
template <class U> friend class min_pointer;
};
template <class T>
inline
bool
operator==(min_pointer<T> x, std::nullptr_t)
{
return !static_cast<bool>(x);
}
template <class T>
inline
bool
operator==(std::nullptr_t, min_pointer<T> x)
{
return !static_cast<bool>(x);
}
template <class T>
inline
bool
operator!=(min_pointer<T> x, std::nullptr_t)
{
return static_cast<bool>(x);
}
template <class T>
inline
bool
operator!=(std::nullptr_t, min_pointer<T> x)
{
return static_cast<bool>(x);
}
template <class T>
class min_allocator
{
public:
typedef T value_type;
typedef min_pointer<T> pointer;
min_allocator() = default;
template <class U>
min_allocator(min_allocator<U>) {}
pointer allocate(std::ptrdiff_t n)
{
return pointer(static_cast<T*>(::operator new(n*sizeof(T))));
}
void deallocate(pointer p, std::ptrdiff_t)
{
return ::operator delete(p.ptr_);
}
friend bool operator==(min_allocator, min_allocator) {return true;}
friend bool operator!=(min_allocator x, min_allocator y) {return !(x == y);}
};
#endif // __cplusplus >= 201103L
#endif // MIN_ALLOCATOR_H

View File

@@ -16,6 +16,8 @@
#include <stdexcept>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(S s, typename S::size_type pos)
@@ -35,10 +37,22 @@ test(S s, typename S::size_type pos)
int main()
{
{
typedef std::string S;
test(S(), 0);
test(S("123"), 0);
test(S("123"), 1);
test(S("123"), 2);
test(S("123"), 3);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), 0);
test(S("123"), 0);
test(S("123"), 1);
test(S("123"), 2);
test(S("123"), 3);
}
#endif
}

View File

@@ -15,6 +15,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(S s)
@@ -28,7 +30,16 @@ test(S s)
int main()
{
{
typedef std::string S;
test(S("1"));
test(S("1234567890123456789012345678901234567890"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S("1"));
test(S("1234567890123456789012345678901234567890"));
}
#endif
}

View File

@@ -15,6 +15,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(S s)
@@ -28,7 +30,16 @@ test(S s)
int main()
{
{
typedef std::string S;
test(S("1"));
test(S("1234567890123456789012345678901234567890"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S("1"));
test(S("1234567890123456789012345678901234567890"));
}
#endif
}

View File

@@ -15,8 +15,11 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
int main()
{
{
typedef std::string S;
S s("0123456789");
const S& cs = s;
@@ -28,4 +31,20 @@ int main()
assert(cs[cs.size()] == '\0');
const S s2 = S();
assert(s2[0] == '\0');
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s("0123456789");
const S& cs = s;
for (S::size_type i = 0; i < cs.size(); ++i)
{
assert(s[i] == '0' + i);
assert(cs[i] == s[i]);
}
assert(cs[cs.size()] == '\0');
const S s2 = S();
assert(s2[0] == '\0');
}
#endif
}

View File

@@ -15,6 +15,7 @@
#include <cassert>
#include "../test_allocator.h"
#include "../min_allocator.h"
template <class S>
void
@@ -36,6 +37,7 @@ test(S s)
int main()
{
{
typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > S;
S s;
test(s);
@@ -45,4 +47,12 @@ int main()
s.assign(100, 'a');
s.erase(50);
test(s);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s;
assert(s.capacity() > 0);
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(S s)
@@ -24,6 +26,7 @@ test(S s)
int main()
{
{
typedef std::string S;
S s;
test(s);
@@ -35,4 +38,20 @@ int main()
s.assign(100, 'a');
s.erase(50);
test(s);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s;
test(s);
s.assign(10, 'a');
s.erase(5);
test(s);
s.assign(100, 'a');
s.erase(50);
test(s);
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(const S& s)
@@ -23,8 +25,18 @@ test(const S& s)
int main()
{
{
typedef std::string S;
test(S());
test(S("123"));
test(S("12345678901234567890123456789012345678901234567890"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S());
test(S("123"));
test(S("12345678901234567890123456789012345678901234567890"));
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(const S& s)
@@ -23,8 +25,18 @@ test(const S& s)
int main()
{
{
typedef std::string S;
test(S());
test(S("123"));
test(S("12345678901234567890123456789012345678901234567890"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S());
test(S("123"));
test(S("12345678901234567890123456789012345678901234567890"));
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(const S& s)
@@ -23,8 +25,18 @@ test(const S& s)
int main()
{
{
typedef std::string S;
test(S());
test(S("123"));
test(S("12345678901234567890123456789012345678901234567890"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S());
test(S("123"));
test(S("12345678901234567890123456789012345678901234567890"));
}
#endif
}

View File

@@ -15,6 +15,8 @@
#include <stdexcept>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(S s)
@@ -50,6 +52,7 @@ test(S s, typename S::size_type res_arg)
int main()
{
{
typedef std::string S;
{
S s;
@@ -78,4 +81,37 @@ int main()
test(s, 100);
test(s, S::npos);
}
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
{
S s;
test(s);
s.assign(10, 'a');
s.erase(5);
test(s);
s.assign(100, 'a');
s.erase(50);
test(s);
}
{
S s;
test(s, 5);
test(s, 10);
test(s, 50);
}
{
S s(100, 'a');
s.erase(50);
test(s, 5);
test(s, 10);
test(s, 50);
test(s, 100);
test(s, S::npos);
}
}
#endif
}

View File

@@ -15,6 +15,8 @@
#include <stdexcept>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(S s, typename S::size_type n, S expected)
@@ -34,6 +36,7 @@ test(S s, typename S::size_type n, S expected)
int main()
{
{
typedef std::string S;
test(S(), 0, S());
test(S(), 1, S(1, '\0'));
@@ -51,4 +54,26 @@ int main()
test(S("12345678901234567890123456789012345678901234567890"), 60,
S("12345678901234567890123456789012345678901234567890\0\0\0\0\0\0\0\0\0\0", 60));
test(S(), S::npos, S("not going to happen"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), 0, S());
test(S(), 1, S(1, '\0'));
test(S(), 10, S(10, '\0'));
test(S(), 100, S(100, '\0'));
test(S("12345"), 0, S());
test(S("12345"), 2, S("12"));
test(S("12345"), 5, S("12345"));
test(S("12345"), 15, S("12345\0\0\0\0\0\0\0\0\0\0", 15));
test(S("12345678901234567890123456789012345678901234567890"), 0, S());
test(S("12345678901234567890123456789012345678901234567890"), 10,
S("1234567890"));
test(S("12345678901234567890123456789012345678901234567890"), 50,
S("12345678901234567890123456789012345678901234567890"));
test(S("12345678901234567890123456789012345678901234567890"), 60,
S("12345678901234567890123456789012345678901234567890\0\0\0\0\0\0\0\0\0\0", 60));
test(S(), S::npos, S("not going to happen"));
}
#endif
}

View File

@@ -15,6 +15,8 @@
#include <stdexcept>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(S s, typename S::size_type n, typename S::value_type c, S expected)
@@ -34,6 +36,7 @@ test(S s, typename S::size_type n, typename S::value_type c, S expected)
int main()
{
{
typedef std::string S;
test(S(), 0, 'a', S());
test(S(), 1, 'a', S("a"));
@@ -51,4 +54,26 @@ int main()
test(S("12345678901234567890123456789012345678901234567890"), 60, 'a',
S("12345678901234567890123456789012345678901234567890aaaaaaaaaa"));
test(S(), S::npos, 'a', S("not going to happen"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), 0, 'a', S());
test(S(), 1, 'a', S("a"));
test(S(), 10, 'a', S(10, 'a'));
test(S(), 100, 'a', S(100, 'a'));
test(S("12345"), 0, 'a', S());
test(S("12345"), 2, 'a', S("12"));
test(S("12345"), 5, 'a', S("12345"));
test(S("12345"), 15, 'a', S("12345aaaaaaaaaa"));
test(S("12345678901234567890123456789012345678901234567890"), 0, 'a', S());
test(S("12345678901234567890123456789012345678901234567890"), 10, 'a',
S("1234567890"));
test(S("12345678901234567890123456789012345678901234567890"), 50, 'a',
S("12345678901234567890123456789012345678901234567890"));
test(S("12345678901234567890123456789012345678901234567890"), 60, 'a',
S("12345678901234567890123456789012345678901234567890aaaaaaaaaa"));
test(S(), S::npos, 'a', S("not going to happen"));
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(S s)
@@ -29,6 +31,7 @@ test(S s)
int main()
{
{
typedef std::string S;
S s;
test(s);
@@ -40,4 +43,20 @@ int main()
s.assign(100, 'a');
s.erase(50);
test(s);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s;
test(s);
s.assign(10, 'a');
s.erase(5);
test(s);
s.assign(100, 'a');
s.erase(50);
test(s);
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(const S& s, typename S::size_type c)
@@ -23,8 +25,18 @@ test(const S& s, typename S::size_type c)
int main()
{
{
typedef std::string S;
test(S(), 0);
test(S("123"), 3);
test(S("12345678901234567890123456789012345678901234567890"), 50);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), 0);
test(S("123"), 3);
test(S("12345678901234567890123456789012345678901234567890"), 50);
}
#endif
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -15,6 +15,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(S s)
@@ -31,7 +33,16 @@ test(S s)
int main()
{
{
typedef std::string S;
test(S());
test(S("123"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S());
test(S("123"));
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(const S& s)
@@ -28,7 +30,16 @@ test(const S& s)
int main()
{
{
typedef std::string S;
test(S());
test(S("123"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S());
test(S("123"));
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(const S& s)
@@ -24,7 +26,16 @@ test(const S& s)
int main()
{
{
typedef std::string S;
test(S());
test(S("123"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S());
test(S("123"));
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(const S& s)
@@ -28,7 +30,16 @@ test(const S& s)
int main()
{
{
typedef std::string S;
test(S());
test(S("123"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S());
test(S("123"));
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(const S& s)
@@ -24,7 +26,16 @@ test(const S& s)
int main()
{
{
typedef std::string S;
test(S());
test(S("123"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S());
test(S("123"));
}
#endif
}

View File

@@ -15,6 +15,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(S s)
@@ -33,7 +35,16 @@ test(S s)
int main()
{
{
typedef std::string S;
test(S());
test(S("123"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S());
test(S("123"));
}
#endif
}

View File

@@ -15,6 +15,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(S s)
@@ -31,7 +33,16 @@ test(S s)
int main()
{
{
typedef std::string S;
test(S());
test(S("123"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S());
test(S("123"));
}
#endif
}

View File

@@ -15,6 +15,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(S s)
@@ -33,7 +35,16 @@ test(S s)
int main()
{
{
typedef std::string S;
test(S());
test(S("123"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S());
test(S("123"));
}
#endif
}

View File

@@ -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.append({'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.append({'a', 'b', 'c'});
assert(s == "123abc");
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -16,6 +16,7 @@
#include <cassert>
#include "../../input_iterator.h"
#include "../../min_allocator.h"
template <class S, class It>
void
@@ -28,6 +29,7 @@ test(S s, It first, It last, S expected)
int main()
{
{
typedef std::string S;
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
test(S(), s, s, S());
@@ -84,4 +86,65 @@ int main()
S("12345678901234567890""ABCDEFGHIJ"));
test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
test(S(), s, s, S());
test(S(), s, s+1, S("A"));
test(S(), s, s+10, S("ABCDEFGHIJ"));
test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345"), s, s, S("12345"));
test(S("12345"), s, s+1, S("12345A"));
test(S("12345"), s, s+10, S("12345ABCDEFGHIJ"));
test(S("12345"), s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("1234567890"), s, s, S("1234567890"));
test(S("1234567890"), s, s+1, S("1234567890A"));
test(S("1234567890"), s, s+10, S("1234567890ABCDEFGHIJ"));
test(S("1234567890"), s, s+52, S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345678901234567890"), s, s, S("12345678901234567890"));
test(S("12345678901234567890"), s, s+1, S("12345678901234567890""A"));
test(S("12345678901234567890"), s, s+10, S("12345678901234567890""ABCDEFGHIJ"));
test(S("12345678901234567890"), s, s+52,
S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s), S());
test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
S("ABCDEFGHIJ"));
test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s),
S("12345"));
test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
S("12345A"));
test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
S("12345ABCDEFGHIJ"));
test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
S("1234567890"));
test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
S("1234567890A"));
test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
S("1234567890ABCDEFGHIJ"));
test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
S("12345678901234567890"));
test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
S("12345678901234567890""A"));
test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
S("12345678901234567890""ABCDEFGHIJ"));
test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
}
#endif
}

View File

@@ -15,6 +15,8 @@
#include <stdexcept>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test(S s, const typename S::value_type* str, S expected)
@@ -26,6 +28,7 @@ test(S s, const typename S::value_type* str, S expected)
int main()
{
{
typedef std::string S;
test(S(), "", S());
test(S(), "12345", S("12345"));
@@ -39,4 +42,22 @@ int main()
test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
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(), "12345678901234567890", S("12345678901234567890"));
test(S("12345"), "", S("12345"));
test(S("12345"), "12345", S("1234512345"));
test(S("12345"), "1234567890", S("123451234567890"));
test(S("12345678901234567890"), "", S("12345678901234567890"));
test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
test(S("12345678901234567890"), "12345678901234567890",
S("1234567890123456789012345678901234567890"));
}
#endif
}

View File

@@ -16,6 +16,8 @@
#include <stdexcept>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test(S s, const typename S::value_type* str, typename S::size_type n, S expected)
@@ -27,6 +29,7 @@ test(S s, const typename S::value_type* str, typename S::size_type n, S expected
int main()
{
{
typedef std::string S;
test(S(), "", 0, S());
test(S(), "12345", 3, S("123"));
@@ -44,4 +47,26 @@ int main()
test(S("12345678901234567890"), "12345", 5, S("1234567890123456789012345"));
test(S("12345678901234567890"), "12345678901234567890", 20,
S("1234567890123456789012345678901234567890"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), "", 0, S());
test(S(), "12345", 3, S("123"));
test(S(), "12345", 4, S("1234"));
test(S(), "12345678901234567890", 0, S());
test(S(), "12345678901234567890", 1, S("1"));
test(S(), "12345678901234567890", 3, S("123"));
test(S(), "12345678901234567890", 20, S("12345678901234567890"));
test(S("12345"), "", 0, S("12345"));
test(S("12345"), "12345", 5, S("1234512345"));
test(S("12345"), "1234567890", 10, S("123451234567890"));
test(S("12345678901234567890"), "", 0, S("12345678901234567890"));
test(S("12345678901234567890"), "12345", 5, S("1234567890123456789012345"));
test(S("12345678901234567890"), "12345678901234567890", 20,
S("1234567890123456789012345678901234567890"));
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test(S s, typename S::value_type c, S expected)
@@ -25,8 +27,18 @@ test(S s, typename S::value_type c, S expected)
int main()
{
{
typedef std::string S;
test(S(), 'a', S(1, 'a'));
test(S("12345"), 'a', S("12345a"));
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(1, 'a'));
test(S("12345"), 'a', S("12345a"));
test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
}
#endif
}

View File

@@ -15,6 +15,8 @@
#include <string>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test(S s, typename S::size_type n, typename S::value_type c, S expected)
@@ -26,6 +28,7 @@ test(S s, typename S::size_type n, typename S::value_type c, S expected)
int main()
{
{
typedef std::string S;
test(S(), 0, 'a', S());
test(S(), 1, 'a', S(1, 'a'));
@@ -39,4 +42,22 @@ int main()
test(S("12345678901234567890"), 0, 'a', S("12345678901234567890"));
test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a"));
test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), 0, 'a', S());
test(S(), 1, 'a', S(1, 'a'));
test(S(), 10, 'a', S(10, 'a'));
test(S(), 100, 'a', S(100, 'a'));
test(S("12345"), 0, 'a', S("12345"));
test(S("12345"), 1, 'a', S("12345a"));
test(S("12345"), 10, 'a', S("12345aaaaaaaaaa"));
test(S("12345678901234567890"), 0, 'a', S("12345678901234567890"));
test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a"));
test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa"));
}
#endif
}

View File

@@ -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
}

View File

@@ -16,6 +16,8 @@
#include <stdexcept>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected)
@@ -35,6 +37,7 @@ test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected)
int main()
{
{
typedef std::string S;
test(S(), S(), 0, 0, S());
test(S(), S(), 1, 0, S());
@@ -57,4 +60,31 @@ int main()
test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234"));
test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
S("123456789012345678906789012345"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), S(), 0, 0, S());
test(S(), S(), 1, 0, S());
test(S(), S("12345"), 0, 3, S("123"));
test(S(), S("12345"), 1, 4, S("2345"));
test(S(), S("12345"), 3, 15, S("45"));
test(S(), S("12345"), 5, 15, S(""));
test(S(), S("12345"), 6, 15, S("not happening"));
test(S(), S("12345678901234567890"), 0, 0, S());
test(S(), S("12345678901234567890"), 1, 1, S("2"));
test(S(), S("12345678901234567890"), 2, 3, S("345"));
test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
test(S("12345"), S(), 0, 0, S("12345"));
test(S("12345"), S("12345"), 2, 2, S("1234534"));
test(S("12345"), S("1234567890"), 0, 100, S("123451234567890"));
test(S("12345678901234567890"), S(), 0, 0, S("12345678901234567890"));
test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234"));
test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
S("123456789012345678906789012345"));
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../../min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
@@ -22,5 +24,13 @@ int main()
s.assign({'a', 'b', 'c'});
assert(s == "abc");
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s("123");
s.assign({'a', 'b', 'c'});
assert(s == "abc");
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -16,6 +16,7 @@
#include <cassert>
#include "../../input_iterator.h"
#include "../../min_allocator.h"
template <class S, class It>
void
@@ -28,6 +29,7 @@ test(S s, It first, It last, S expected)
int main()
{
{
typedef std::string S;
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
test(S(), s, s, S());
@@ -84,4 +86,65 @@ int main()
S("ABCDEFGHIJ"));
test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
test(S(), s, s, S());
test(S(), s, s+1, S("A"));
test(S(), s, s+10, S("ABCDEFGHIJ"));
test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345"), s, s, S());
test(S("12345"), s, s+1, S("A"));
test(S("12345"), s, s+10, S("ABCDEFGHIJ"));
test(S("12345"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("1234567890"), s, s, S());
test(S("1234567890"), s, s+1, S("A"));
test(S("1234567890"), s, s+10, S("ABCDEFGHIJ"));
test(S("1234567890"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345678901234567890"), s, s, S());
test(S("12345678901234567890"), s, s+1, S("A"));
test(S("12345678901234567890"), s, s+10, S("ABCDEFGHIJ"));
test(S("12345678901234567890"), s, s+52,
S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s), S());
test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
S("ABCDEFGHIJ"));
test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s),
S());
test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
S("A"));
test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
S("ABCDEFGHIJ"));
test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
S());
test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
S("A"));
test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
S("ABCDEFGHIJ"));
test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
S());
test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
S("A"));
test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
S("ABCDEFGHIJ"));
test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
}
#endif
}

View File

@@ -15,6 +15,8 @@
#include <stdexcept>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test(S s, const typename S::value_type* str, S expected)
@@ -26,6 +28,7 @@ test(S s, const typename S::value_type* str, S expected)
int main()
{
{
typedef std::string S;
test(S(), "", S());
test(S(), "12345", S("12345"));
@@ -39,4 +42,22 @@ int main()
test(S("12345678901234567890"), "12345", S("12345"));
test(S("12345678901234567890"), "12345678901234567890",
S("12345678901234567890"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), "", S());
test(S(), "12345", S("12345"));
test(S(), "12345678901234567890", S("12345678901234567890"));
test(S("12345"), "", S());
test(S("12345"), "12345", S("12345"));
test(S("12345"), "1234567890", S("1234567890"));
test(S("12345678901234567890"), "", S());
test(S("12345678901234567890"), "12345", S("12345"));
test(S("12345678901234567890"), "12345678901234567890",
S("12345678901234567890"));
}
#endif
}

View File

@@ -16,6 +16,8 @@
#include <stdexcept>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test(S s, const typename S::value_type* str, typename S::size_type n, S expected)
@@ -27,6 +29,7 @@ test(S s, const typename S::value_type* str, typename S::size_type n, S expected
int main()
{
{
typedef std::string S;
test(S(), "", 0, S());
test(S(), "12345", 3, S("123"));
@@ -44,4 +47,26 @@ int main()
test(S("12345678901234567890"), "12345", 5, S("12345"));
test(S("12345678901234567890"), "12345678901234567890", 20,
S("12345678901234567890"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), "", 0, S());
test(S(), "12345", 3, S("123"));
test(S(), "12345", 4, S("1234"));
test(S(), "12345678901234567890", 0, S());
test(S(), "12345678901234567890", 1, S("1"));
test(S(), "12345678901234567890", 3, S("123"));
test(S(), "12345678901234567890", 20, S("12345678901234567890"));
test(S("12345"), "", 0, S());
test(S("12345"), "12345", 5, S("12345"));
test(S("12345"), "1234567890", 10, S("1234567890"));
test(S("12345678901234567890"), "", 0, S());
test(S("12345678901234567890"), "12345", 5, S("12345"));
test(S("12345678901234567890"), "12345678901234567890", 20,
S("12345678901234567890"));
}
#endif
}

View File

@@ -15,6 +15,8 @@
#include <string>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test(S s, S str, S expected)
@@ -26,6 +28,7 @@ test(S s, S str, S expected)
int main()
{
{
typedef std::string S;
test(S(), S(), S());
test(S(), S("12345"), S("12345"));
@@ -47,4 +50,30 @@ int main()
test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
test(S("12345678901234567890"), S("12345678901234567890"),
S("12345678901234567890"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), S(), S());
test(S(), S("12345"), S("12345"));
test(S(), S("1234567890"), S("1234567890"));
test(S(), S("12345678901234567890"), S("12345678901234567890"));
test(S("12345"), S(), S());
test(S("12345"), S("12345"), S("12345"));
test(S("12345"), S("1234567890"), S("1234567890"));
test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
test(S("1234567890"), S(), S());
test(S("1234567890"), S("12345"), S("12345"));
test(S("1234567890"), S("1234567890"), S("1234567890"));
test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
test(S("12345678901234567890"), S(), S());
test(S("12345678901234567890"), S("12345"), S("12345"));
test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
test(S("12345678901234567890"), S("12345678901234567890"),
S("12345678901234567890"));
}
#endif
}

View File

@@ -15,6 +15,8 @@
#include <string>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test(S s, typename S::size_type n, typename S::value_type c, S expected)
@@ -26,6 +28,7 @@ test(S s, typename S::size_type n, typename S::value_type c, S expected)
int main()
{
{
typedef std::string S;
test(S(), 0, 'a', S());
test(S(), 1, 'a', S(1, 'a'));
@@ -39,4 +42,22 @@ int main()
test(S("12345678901234567890"), 0, 'a', S());
test(S("12345678901234567890"), 1, 'a', S(1, 'a'));
test(S("12345678901234567890"), 10, 'a', S(10, 'a'));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), 0, 'a', S());
test(S(), 1, 'a', S(1, 'a'));
test(S(), 10, 'a', S(10, 'a'));
test(S(), 100, 'a', S(100, 'a'));
test(S("12345"), 0, 'a', S());
test(S("12345"), 1, 'a', S(1, 'a'));
test(S("12345"), 10, 'a', S(10, 'a'));
test(S("12345678901234567890"), 0, 'a', S());
test(S("12345678901234567890"), 1, 'a', S(1, 'a'));
test(S("12345678901234567890"), 10, 'a', S(10, 'a'));
}
#endif
}

View File

@@ -15,6 +15,8 @@
#include <string>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test(S s, S str, S expected)
@@ -26,6 +28,7 @@ test(S s, S str, S expected)
int main()
{
{
typedef std::string S;
test(S(), S(), S());
test(S(), S("12345"), S("12345"));
@@ -47,4 +50,30 @@ int main()
test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
test(S("12345678901234567890"), S("12345678901234567890"),
S("12345678901234567890"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), S(), S());
test(S(), S("12345"), S("12345"));
test(S(), S("1234567890"), S("1234567890"));
test(S(), S("12345678901234567890"), S("12345678901234567890"));
test(S("12345"), S(), S());
test(S("12345"), S("12345"), S("12345"));
test(S("12345"), S("1234567890"), S("1234567890"));
test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
test(S("1234567890"), S(), S());
test(S("1234567890"), S("12345"), S("12345"));
test(S("1234567890"), S("1234567890"), S("1234567890"));
test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
test(S("12345678901234567890"), S(), S());
test(S("12345678901234567890"), S("12345"), S("12345"));
test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
test(S("12345678901234567890"), S("12345678901234567890"),
S("12345678901234567890"));
}
#endif
}

View File

@@ -16,6 +16,8 @@
#include <stdexcept>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected)
@@ -35,6 +37,7 @@ test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected)
int main()
{
{
typedef std::string S;
test(S(), S(), 0, 0, S());
test(S(), S(), 1, 0, S());
@@ -57,4 +60,31 @@ int main()
test(S("12345678901234567890"), S("12345"), 1, 3, S("234"));
test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
S("6789012345"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), S(), 0, 0, S());
test(S(), S(), 1, 0, S());
test(S(), S("12345"), 0, 3, S("123"));
test(S(), S("12345"), 1, 4, S("2345"));
test(S(), S("12345"), 3, 15, S("45"));
test(S(), S("12345"), 5, 15, S(""));
test(S(), S("12345"), 6, 15, S("not happening"));
test(S(), S("12345678901234567890"), 0, 0, S());
test(S(), S("12345678901234567890"), 1, 1, S("2"));
test(S(), S("12345678901234567890"), 2, 3, S("345"));
test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
test(S("12345"), S(), 0, 0, S());
test(S("12345"), S("12345"), 2, 2, S("34"));
test(S("12345"), S("1234567890"), 0, 100, S("1234567890"));
test(S("12345678901234567890"), S(), 0, 0, S());
test(S("12345678901234567890"), S("12345"), 1, 3, S("234"));
test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
S("6789012345"));
}
#endif
}

View File

@@ -16,6 +16,8 @@
#include <algorithm>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test(S str, typename S::value_type* s, typename S::size_type n,
@@ -39,6 +41,7 @@ test(S str, typename S::value_type* s, typename S::size_type n,
int main()
{
{
typedef std::string S;
char s[50];
test(S(""), s, 0, 0);
@@ -99,4 +102,69 @@ int main()
test(S("abcdefghijklmnopqrst"), s, 20, 0);
test(S("abcdefghijklmnopqrst"), s, 20, 1);
test(S("abcdefghijklmnopqrst"), s, 21, 0);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
char s[50];
test(S(""), s, 0, 0);
test(S(""), s, 0, 1);
test(S(""), s, 1, 0);
test(S("abcde"), s, 0, 0);
test(S("abcde"), s, 0, 1);
test(S("abcde"), s, 0, 2);
test(S("abcde"), s, 0, 4);
test(S("abcde"), s, 0, 5);
test(S("abcde"), s, 0, 6);
test(S("abcde"), s, 1, 0);
test(S("abcde"), s, 1, 1);
test(S("abcde"), s, 1, 2);
test(S("abcde"), s, 1, 4);
test(S("abcde"), s, 1, 5);
test(S("abcde"), s, 2, 0);
test(S("abcde"), s, 2, 1);
test(S("abcde"), s, 2, 2);
test(S("abcde"), s, 2, 4);
test(S("abcde"), s, 4, 0);
test(S("abcde"), s, 4, 1);
test(S("abcde"), s, 4, 2);
test(S("abcde"), s, 5, 0);
test(S("abcde"), s, 5, 1);
test(S("abcde"), s, 6, 0);
test(S("abcdefghijklmnopqrst"), s, 0, 0);
test(S("abcdefghijklmnopqrst"), s, 0, 1);
test(S("abcdefghijklmnopqrst"), s, 0, 2);
test(S("abcdefghijklmnopqrst"), s, 0, 10);
test(S("abcdefghijklmnopqrst"), s, 0, 19);
test(S("abcdefghijklmnopqrst"), s, 0, 20);
test(S("abcdefghijklmnopqrst"), s, 0, 21);
test(S("abcdefghijklmnopqrst"), s, 1, 0);
test(S("abcdefghijklmnopqrst"), s, 1, 1);
test(S("abcdefghijklmnopqrst"), s, 1, 2);
test(S("abcdefghijklmnopqrst"), s, 1, 9);
test(S("abcdefghijklmnopqrst"), s, 1, 18);
test(S("abcdefghijklmnopqrst"), s, 1, 19);
test(S("abcdefghijklmnopqrst"), s, 1, 20);
test(S("abcdefghijklmnopqrst"), s, 2, 0);
test(S("abcdefghijklmnopqrst"), s, 2, 1);
test(S("abcdefghijklmnopqrst"), s, 2, 2);
test(S("abcdefghijklmnopqrst"), s, 2, 9);
test(S("abcdefghijklmnopqrst"), s, 2, 17);
test(S("abcdefghijklmnopqrst"), s, 2, 18);
test(S("abcdefghijklmnopqrst"), s, 2, 19);
test(S("abcdefghijklmnopqrst"), s, 10, 0);
test(S("abcdefghijklmnopqrst"), s, 10, 1);
test(S("abcdefghijklmnopqrst"), s, 10, 2);
test(S("abcdefghijklmnopqrst"), s, 10, 5);
test(S("abcdefghijklmnopqrst"), s, 10, 9);
test(S("abcdefghijklmnopqrst"), s, 10, 10);
test(S("abcdefghijklmnopqrst"), s, 10, 11);
test(S("abcdefghijklmnopqrst"), s, 19, 0);
test(S("abcdefghijklmnopqrst"), s, 19, 1);
test(S("abcdefghijklmnopqrst"), s, 19, 2);
test(S("abcdefghijklmnopqrst"), s, 20, 0);
test(S("abcdefghijklmnopqrst"), s, 20, 1);
test(S("abcdefghijklmnopqrst"), s, 21, 0);
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test(S s, typename S::difference_type pos, S expected)
@@ -27,6 +29,7 @@ test(S s, typename S::difference_type pos, S expected)
int main()
{
{
typedef std::string S;
test(S("abcde"), 0, S("bcde"));
test(S("abcde"), 1, S("acde"));
@@ -40,4 +43,22 @@ int main()
test(S("abcdefghijklmnopqrst"), 1, S("acdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, S("abcdefghijlmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S("abcde"), 0, S("bcde"));
test(S("abcde"), 1, S("acde"));
test(S("abcde"), 2, S("abde"));
test(S("abcde"), 4, S("abcd"));
test(S("abcdefghij"), 0, S("bcdefghij"));
test(S("abcdefghij"), 1, S("acdefghij"));
test(S("abcdefghij"), 5, S("abcdeghij"));
test(S("abcdefghij"), 9, S("abcdefghi"));
test(S("abcdefghijklmnopqrst"), 0, S("bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, S("acdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, S("abcdefghijlmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
}
#endif
}

View File

@@ -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::difference_type n, S expected)
@@ -28,6 +30,7 @@ test(S s, typename S::difference_type pos, typename S::difference_type n, S expe
int main()
{
{
typedef std::string S;
test(S(""), 0, 0, S(""));
test(S("abcde"), 0, 0, S("abcde"));
@@ -83,4 +86,64 @@ int main()
test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), 0, 0, S(""));
test(S("abcde"), 0, 0, S("abcde"));
test(S("abcde"), 0, 1, S("bcde"));
test(S("abcde"), 0, 2, S("cde"));
test(S("abcde"), 0, 4, S("e"));
test(S("abcde"), 0, 5, S(""));
test(S("abcde"), 1, 0, S("abcde"));
test(S("abcde"), 1, 1, S("acde"));
test(S("abcde"), 1, 2, S("ade"));
test(S("abcde"), 1, 3, S("ae"));
test(S("abcde"), 1, 4, S("a"));
test(S("abcde"), 2, 0, S("abcde"));
test(S("abcde"), 2, 1, S("abde"));
test(S("abcde"), 2, 2, S("abe"));
test(S("abcde"), 2, 3, S("ab"));
test(S("abcde"), 4, 0, S("abcde"));
test(S("abcde"), 4, 1, S("abcd"));
test(S("abcde"), 5, 0, S("abcde"));
test(S("abcdefghij"), 0, 0, S("abcdefghij"));
test(S("abcdefghij"), 0, 1, S("bcdefghij"));
test(S("abcdefghij"), 0, 5, S("fghij"));
test(S("abcdefghij"), 0, 9, S("j"));
test(S("abcdefghij"), 0, 10, S(""));
test(S("abcdefghij"), 1, 0, S("abcdefghij"));
test(S("abcdefghij"), 1, 1, S("acdefghij"));
test(S("abcdefghij"), 1, 4, S("afghij"));
test(S("abcdefghij"), 1, 8, S("aj"));
test(S("abcdefghij"), 1, 9, S("a"));
test(S("abcdefghij"), 5, 0, S("abcdefghij"));
test(S("abcdefghij"), 5, 1, S("abcdeghij"));
test(S("abcdefghij"), 5, 2, S("abcdehij"));
test(S("abcdefghij"), 5, 4, S("abcdej"));
test(S("abcdefghij"), 5, 5, S("abcde"));
test(S("abcdefghij"), 9, 0, S("abcdefghij"));
test(S("abcdefghij"), 9, 1, S("abcdefghi"));
test(S("abcdefghij"), 10, 0, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test(S s, S expected)
@@ -25,8 +27,18 @@ test(S s, S expected)
int main()
{
{
typedef std::string S;
test(S("abcde"), S("abcd"));
test(S("abcdefghij"), S("abcdefghi"));
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S("abcde"), S("abcd"));
test(S("abcdefghij"), S("abcdefghi"));
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs"));
}
#endif
}

View File

@@ -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, S expected)
@@ -67,6 +69,7 @@ test(S s, S expected)
int main()
{
{
typedef std::string S;
test(S(""), 0, 0, S(""));
test(S(""), 0, 1, S(""));
@@ -168,4 +171,110 @@ int main()
test(S("abcde"), S(""));
test(S("abcdefghij"), S(""));
test(S("abcdefghijklmnopqrst"), S(""));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), 0, 0, S(""));
test(S(""), 0, 1, S(""));
test(S(""), 1, 0, S("can't happen"));
test(S("abcde"), 0, 0, S("abcde"));
test(S("abcde"), 0, 1, S("bcde"));
test(S("abcde"), 0, 2, S("cde"));
test(S("abcde"), 0, 4, S("e"));
test(S("abcde"), 0, 5, S(""));
test(S("abcde"), 0, 6, S(""));
test(S("abcde"), 1, 0, S("abcde"));
test(S("abcde"), 1, 1, S("acde"));
test(S("abcde"), 1, 2, S("ade"));
test(S("abcde"), 1, 3, S("ae"));
test(S("abcde"), 1, 4, S("a"));
test(S("abcde"), 1, 5, S("a"));
test(S("abcde"), 2, 0, S("abcde"));
test(S("abcde"), 2, 1, S("abde"));
test(S("abcde"), 2, 2, S("abe"));
test(S("abcde"), 2, 3, S("ab"));
test(S("abcde"), 2, 4, S("ab"));
test(S("abcde"), 4, 0, S("abcde"));
test(S("abcde"), 4, 1, S("abcd"));
test(S("abcde"), 4, 2, S("abcd"));
test(S("abcde"), 5, 0, S("abcde"));
test(S("abcde"), 5, 1, S("abcde"));
test(S("abcde"), 6, 0, S("can't happen"));
test(S("abcdefghij"), 0, 0, S("abcdefghij"));
test(S("abcdefghij"), 0, 1, S("bcdefghij"));
test(S("abcdefghij"), 0, 5, S("fghij"));
test(S("abcdefghij"), 0, 9, S("j"));
test(S("abcdefghij"), 0, 10, S(""));
test(S("abcdefghij"), 0, 11, S(""));
test(S("abcdefghij"), 1, 0, S("abcdefghij"));
test(S("abcdefghij"), 1, 1, S("acdefghij"));
test(S("abcdefghij"), 1, 4, S("afghij"));
test(S("abcdefghij"), 1, 8, S("aj"));
test(S("abcdefghij"), 1, 9, S("a"));
test(S("abcdefghij"), 1, 10, S("a"));
test(S("abcdefghij"), 5, 0, S("abcdefghij"));
test(S("abcdefghij"), 5, 1, S("abcdeghij"));
test(S("abcdefghij"), 5, 2, S("abcdehij"));
test(S("abcdefghij"), 5, 4, S("abcdej"));
test(S("abcdefghij"), 5, 5, S("abcde"));
test(S("abcdefghij"), 5, 6, S("abcde"));
test(S("abcdefghij"), 9, 0, S("abcdefghij"));
test(S("abcdefghij"), 9, 1, S("abcdefghi"));
test(S("abcdefghij"), 9, 2, S("abcdefghi"));
test(S("abcdefghij"), 10, 0, S("abcdefghij"));
test(S("abcdefghij"), 10, 1, S("abcdefghij"));
test(S("abcdefghij"), 11, 0, S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
test(S("abcdefghijklmnopqrst"), 0, 21, S(""));
test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
test(S("abcdefghijklmnopqrst"), 1, 20, S("a"));
test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrs"));
test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 21, 0, S("can't happen"));
test(S(""), 0, S(""));
test(S(""), 1, S("can't happen"));
test(S("abcde"), 0, S(""));
test(S("abcde"), 1, S("a"));
test(S("abcde"), 2, S("ab"));
test(S("abcde"), 4, S("abcd"));
test(S("abcde"), 5, S("abcde"));
test(S("abcde"), 6, S("can't happen"));
test(S("abcdefghij"), 0, S(""));
test(S("abcdefghij"), 1, S("a"));
test(S("abcdefghij"), 5, S("abcde"));
test(S("abcdefghij"), 9, S("abcdefghi"));
test(S("abcdefghij"), 10, S("abcdefghij"));
test(S("abcdefghij"), 11, S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, S(""));
test(S("abcdefghijklmnopqrst"), 1, S("a"));
test(S("abcdefghijklmnopqrst"), 10, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
test(S("abcdefghijklmnopqrst"), 20, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 21, S("can't happen"));
test(S(""), S(""));
test(S("abcde"), S(""));
test(S("abcdefghij"), S(""));
test(S("abcdefghijklmnopqrst"), S(""));
}
#endif
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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.replace(s.cbegin() + 3, s.cbegin() + 6, {'a', 'b', 'c'});
assert(s == "123abc456");
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s("123def456");
s.replace(s.cbegin() + 3, s.cbegin() + 6, {'a', 'b', 'c'});
assert(s == "123abc456");
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -17,7 +17,7 @@
#include <iterator>
#include <cassert>
#include <stdio.h>
#include "../../min_allocator.h"
template <class S, class It>
void
@@ -34,10 +34,9 @@ test(S s, typename S::size_type pos1, typename S::size_type n1, It f, It l, S ex
assert(s.size() == old_size - xlen + rlen);
}
typedef std::string S;
const char* str = "12345678901234567890";
template <class S>
void test0()
{
test(S(""), 0, 0, str, str+0, S(""));
@@ -119,29 +118,30 @@ void test0()
test(S("abcde"), 0, 4, str, str+1, S("1e"));
test(S("abcde"), 0, 4, str, str+10, S("1234567890e"));
test(S("abcde"), 0, 4, str, str+19, S("1234567890123456789e"));
// test(S("abcde"), 0, 4, str, str+20, S("12345678901234567890e"));
// test(S("abcde"), 0, 5, str, str+0, S(""));
// test(S("abcde"), 0, 5, str, str+0, S(""));
// test(S("abcde"), 0, 5, str, str+1, S("1"));
// test(S("abcde"), 0, 5, str, str+2, S("12"));
// test(S("abcde"), 0, 5, str, str+4, S("1234"));
// test(S("abcde"), 0, 5, str, str+5, S("12345"));
// test(S("abcde"), 0, 5, str, str+0, S(""));
// test(S("abcde"), 0, 5, str, str+1, S("1"));
// test(S("abcde"), 0, 5, str, str+5, S("12345"));
// test(S("abcde"), 0, 5, str, str+9, S("123456789"));
// test(S("abcde"), 0, 5, str, str+10, S("1234567890"));
// test(S("abcde"), 0, 5, str, str+0, S(""));
// test(S("abcde"), 0, 5, str, str+1, S("1"));
// test(S("abcde"), 0, 5, str, str+10, S("1234567890"));
// test(S("abcde"), 0, 5, str, str+19, S("1234567890123456789"));
// test(S("abcde"), 0, 5, str, str+20, S("12345678901234567890"));
// test(S("abcde"), 1, 0, str, str+0, S("abcde"));
// test(S("abcde"), 1, 0, str, str+0, S("abcde"));
// test(S("abcde"), 1, 0, str, str+1, S("a1bcde"));
// test(S("abcde"), 1, 0, str, str+2, S("a12bcde"));
test(S("abcde"), 0, 4, str, str+20, S("12345678901234567890e"));
test(S("abcde"), 0, 5, str, str+0, S(""));
test(S("abcde"), 0, 5, str, str+0, S(""));
test(S("abcde"), 0, 5, str, str+1, S("1"));
test(S("abcde"), 0, 5, str, str+2, S("12"));
test(S("abcde"), 0, 5, str, str+4, S("1234"));
test(S("abcde"), 0, 5, str, str+5, S("12345"));
test(S("abcde"), 0, 5, str, str+0, S(""));
test(S("abcde"), 0, 5, str, str+1, S("1"));
test(S("abcde"), 0, 5, str, str+5, S("12345"));
test(S("abcde"), 0, 5, str, str+9, S("123456789"));
test(S("abcde"), 0, 5, str, str+10, S("1234567890"));
test(S("abcde"), 0, 5, str, str+0, S(""));
test(S("abcde"), 0, 5, str, str+1, S("1"));
test(S("abcde"), 0, 5, str, str+10, S("1234567890"));
test(S("abcde"), 0, 5, str, str+19, S("1234567890123456789"));
test(S("abcde"), 0, 5, str, str+20, S("12345678901234567890"));
test(S("abcde"), 1, 0, str, str+0, S("abcde"));
test(S("abcde"), 1, 0, str, str+0, S("abcde"));
test(S("abcde"), 1, 0, str, str+1, S("a1bcde"));
test(S("abcde"), 1, 0, str, str+2, S("a12bcde"));
}
/*
template <class S>
void test1()
{
test(S("abcde"), 1, 0, str, str+4, S("a1234bcde"));
@@ -246,6 +246,7 @@ void test1()
test(S("abcde"), 2, 1, str, str+1, S("ab1de"));
}
template <class S>
void test2()
{
test(S("abcde"), 2, 1, str, str+5, S("ab12345de"));
@@ -350,6 +351,7 @@ void test2()
test(S("abcdefghij"), 0, 0, str, str+0, S("abcdefghij"));
}
template <class S>
void test3()
{
test(S("abcdefghij"), 0, 0, str, str+1, S("1abcdefghij"));
@@ -454,6 +456,7 @@ void test3()
test(S("abcdefghij"), 1, 1, str, str+20, S("a12345678901234567890cdefghij"));
}
template <class S>
void test4()
{
test(S("abcdefghij"), 1, 4, str, str+0, S("afghij"));
@@ -558,6 +561,7 @@ void test4()
test(S("abcdefghij"), 5, 4, str, str+2, S("abcde12j"));
}
template <class S>
void test5()
{
test(S("abcdefghij"), 5, 4, str, str+4, S("abcde1234j"));
@@ -662,6 +666,7 @@ void test5()
test(S("abcdefghijklmnopqrst"), 0, 1, str, str+1, S("1bcdefghijklmnopqrst"));
}
template <class S>
void test6()
{
test(S("abcdefghijklmnopqrst"), 0, 1, str, str+5, S("12345bcdefghijklmnopqrst"));
@@ -766,6 +771,7 @@ void test6()
test(S("abcdefghijklmnopqrst"), 1, 9, str, str+0, S("aklmnopqrst"));
}
template <class S>
void test7()
{
test(S("abcdefghijklmnopqrst"), 1, 9, str, str+1, S("a1klmnopqrst"));
@@ -870,6 +876,7 @@ void test7()
test(S("abcdefghijklmnopqrst"), 10, 9, str, str+20, S("abcdefghij12345678901234567890t"));
}
template <class S>
void test8()
{
test(S("abcdefghijklmnopqrst"), 10, 10, str, str+0, S("abcdefghij"));
@@ -937,16 +944,33 @@ void test8()
test(S("abcdefghijklmnopqrst"), 20, 0, str, str+19, S("abcdefghijklmnopqrst1234567890123456789"));
test(S("abcdefghijklmnopqrst"), 20, 0, str, str+20, S("abcdefghijklmnopqrst12345678901234567890"));
}
*/
int main()
{
test0();
// test1();
// test2();
// test3();
// test4();
// test5();
// test6();
// test7();
// test8();
{
typedef std::string S;
test0<S>();
test1<S>();
test2<S>();
test3<S>();
test4<S>();
test5<S>();
test6<S>();
test7<S>();
test8<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>();
}
#endif
}

View File

@@ -18,22 +18,24 @@
#include <algorithm>
#include <cassert>
typedef std::string S;
#include "../../min_allocator.h"
template <class S>
void
test(S s, S::size_type pos1, S::size_type n1, const S::value_type* str, S expected)
test(S s, typename S::size_type pos1, typename S::size_type n1, const typename S::value_type* str, S expected)
{
S::size_type old_size = s.size();
S::const_iterator first = s.begin() + pos1;
S::const_iterator last = s.begin() + pos1 + n1;
typename S::size_type old_size = s.size();
typename S::const_iterator first = s.begin() + pos1;
typename S::const_iterator last = s.begin() + pos1 + n1;
s.replace(first, last, str);
assert(s.__invariants());
assert(s == expected);
S::size_type xlen = last - first;
S::size_type rlen = S::traits_type::length(str);
typename S::size_type xlen = last - first;
typename S::size_type rlen = S::traits_type::length(str);
assert(s.size() == old_size - xlen + rlen);
}
template <class S>
void test0()
{
test(S(""), 0, 0, "", S(""));
@@ -138,6 +140,7 @@ void test0()
test(S("abcdefghij"), 1, 1, "12345678901234567890", S("a12345678901234567890cdefghij"));
}
template <class S>
void test1()
{
test(S("abcdefghij"), 1, 4, "", S("afghij"));
@@ -242,6 +245,7 @@ void test1()
test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", S("abcdefghij12345678901234567890t"));
}
template <class S>
void test2()
{
test(S("abcdefghijklmnopqrst"), 10, 10, "", S("abcdefghij"));
@@ -264,7 +268,18 @@ void test2()
int main()
{
test0();
test1();
test2();
{
typedef std::string S;
test0<S>();
test1<S>();
test2<S>();
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test0<S>();
test1<S>();
test2<S>();
}
#endif
}

View File

@@ -18,23 +18,25 @@
#include <algorithm>
#include <cassert>
typedef std::string S;
#include "../../min_allocator.h"
template <class S>
void
test(S s, S::size_type pos1, S::size_type n1, const S::value_type* str,
S::size_type n2, S expected)
test(S s, typename S::size_type pos1, typename S::size_type n1, const typename S::value_type* str,
typename S::size_type n2, S expected)
{
S::size_type old_size = s.size();
S::const_iterator first = s.begin() + pos1;
S::const_iterator last = s.begin() + pos1 + n1;
typename S::size_type old_size = s.size();
typename S::const_iterator first = s.begin() + pos1;
typename S::const_iterator last = s.begin() + pos1 + n1;
s.replace(first, last, str, n2);
assert(s.__invariants());
assert(s == expected);
S::size_type xlen = last - first;
S::size_type rlen = n2;
typename S::size_type xlen = last - first;
typename S::size_type rlen = n2;
assert(s.size() == old_size - xlen + rlen);
}
template <class S>
void test0()
{
test(S(""), 0, 0, "", 0, S(""));
@@ -139,6 +141,7 @@ void test0()
test(S("abcde"), 1, 0, "12345", 2, S("a12bcde"));
}
template <class S>
void test1()
{
test(S("abcde"), 1, 0, "12345", 4, S("a1234bcde"));
@@ -243,6 +246,7 @@ void test1()
test(S("abcde"), 2, 1, "1234567890", 1, S("ab1de"));
}
template <class S>
void test2()
{
test(S("abcde"), 2, 1, "1234567890", 5, S("ab12345de"));
@@ -347,6 +351,7 @@ void test2()
test(S("abcdefghij"), 0, 0, "12345678901234567890", 0, S("abcdefghij"));
}
template <class S>
void test3()
{
test(S("abcdefghij"), 0, 0, "12345678901234567890", 1, S("1abcdefghij"));
@@ -451,6 +456,7 @@ void test3()
test(S("abcdefghij"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghij"));
}
template <class S>
void test4()
{
test(S("abcdefghij"), 1, 4, "", 0, S("afghij"));
@@ -555,6 +561,7 @@ void test4()
test(S("abcdefghij"), 5, 4, "12345", 2, S("abcde12j"));
}
template <class S>
void test5()
{
test(S("abcdefghij"), 5, 4, "12345", 4, S("abcde1234j"));
@@ -659,6 +666,7 @@ void test5()
test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 1, S("1bcdefghijklmnopqrst"));
}
template <class S>
void test6()
{
test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 5, S("12345bcdefghijklmnopqrst"));
@@ -763,6 +771,7 @@ void test6()
test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 0, S("aklmnopqrst"));
}
template <class S>
void test7()
{
test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 1, S("a1klmnopqrst"));
@@ -867,6 +876,7 @@ void test7()
test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 20, S("abcdefghij12345678901234567890t"));
}
template <class S>
void test8()
{
test(S("abcdefghijklmnopqrst"), 10, 10, "", 0, S("abcdefghij"));
@@ -937,13 +947,30 @@ void test8()
int main()
{
test0();
test1();
test2();
test3();
test4();
test5();
test6();
test7();
test8();
{
typedef std::string S;
test0<S>();
test1<S>();
test2<S>();
test3<S>();
test4<S>();
test5<S>();
test6<S>();
test7<S>();
test8<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>();
}
#endif
}

View File

@@ -18,23 +18,25 @@
#include <algorithm>
#include <cassert>
typedef std::string S;
#include "../../min_allocator.h"
template <class S>
void
test(S s, S::size_type pos1, S::size_type n1, S::size_type n2,
S::value_type c, S expected)
test(S s, typename S::size_type pos1, typename S::size_type n1, typename S::size_type n2,
typename S::value_type c, S expected)
{
S::size_type old_size = s.size();
S::const_iterator first = s.begin() + pos1;
S::const_iterator last = s.begin() + pos1 + n1;
typename S::size_type old_size = s.size();
typename S::const_iterator first = s.begin() + pos1;
typename S::const_iterator last = s.begin() + pos1 + n1;
s.replace(first, last, n2, c);
assert(s.__invariants());
assert(s == expected);
S::size_type xlen = last - first;
S::size_type rlen = n2;
typename S::size_type xlen = last - first;
typename S::size_type rlen = n2;
assert(s.size() == old_size - xlen + rlen);
}
template <class S>
void test0()
{
test(S(""), 0, 0, 0, '3', S(""));
@@ -139,6 +141,7 @@ void test0()
test(S("abcdefghij"), 1, 1, 20, '3', S("a33333333333333333333cdefghij"));
}
template <class S>
void test1()
{
test(S("abcdefghij"), 1, 4, 0, '3', S("afghij"));
@@ -243,6 +246,7 @@ void test1()
test(S("abcdefghijklmnopqrst"), 10, 9, 20, '3', S("abcdefghij33333333333333333333t"));
}
template <class S>
void test2()
{
test(S("abcdefghijklmnopqrst"), 10, 10, 0, '3', S("abcdefghij"));
@@ -265,7 +269,18 @@ void test2()
int main()
{
test0();
test1();
test2();
{
typedef std::string S;
test0<S>();
test1<S>();
test2<S>();
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test0<S>();
test1<S>();
test2<S>();
}
#endif
}

View File

@@ -18,22 +18,24 @@
#include <algorithm>
#include <cassert>
typedef std::string S;
#include "../../min_allocator.h"
template <class S>
void
test(S s, S::size_type pos1, S::size_type n1, S str, S expected)
test(S s, typename S::size_type pos1, typename S::size_type n1, S str, S expected)
{
S::size_type old_size = s.size();
S::const_iterator first = s.begin() + pos1;
S::const_iterator last = s.begin() + pos1 + n1;
typename S::size_type old_size = s.size();
typename S::const_iterator first = s.begin() + pos1;
typename S::const_iterator last = s.begin() + pos1 + n1;
s.replace(first, last, str);
assert(s.__invariants());
assert(s == expected);
S::size_type xlen = last - first;
S::size_type rlen = str.size();
typename S::size_type xlen = last - first;
typename S::size_type rlen = str.size();
assert(s.size() == old_size - xlen + rlen);
}
template <class S>
void test0()
{
test(S(""), 0, 0, S(""), S(""));
@@ -138,6 +140,7 @@ void test0()
test(S("abcdefghij"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghij"));
}
template <class S>
void test1()
{
test(S("abcdefghij"), 1, 4, S(""), S("afghij"));
@@ -242,6 +245,7 @@ void test1()
test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), S("abcdefghij12345678901234567890t"));
}
template <class S>
void test2()
{
test(S("abcdefghijklmnopqrst"), 10, 10, S(""), S("abcdefghij"));
@@ -264,7 +268,18 @@ void test2()
int main()
{
test0();
test1();
test2();
{
typedef std::string S;
test0<S>();
test1<S>();
test2<S>();
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test0<S>();
test1<S>();
test2<S>();
}
#endif
}

View File

@@ -19,13 +19,14 @@
#include <algorithm>
#include <cassert>
typedef std::string S;
#include "../../min_allocator.h"
template <class S>
void
test(S s, S::size_type pos, S::size_type n1,
const S::value_type* str, S expected)
test(S s, typename S::size_type pos, typename S::size_type n1,
const typename S::value_type* str, S expected)
{
S::size_type old_size = s.size();
typename S::size_type old_size = s.size();
S s0 = s;
try
{
@@ -33,8 +34,8 @@ test(S s, S::size_type pos, S::size_type n1,
assert(s.__invariants());
assert(pos <= old_size);
assert(s == expected);
S::size_type xlen = std::min(n1, old_size - pos);
S::size_type rlen = S::traits_type::length(str);
typename S::size_type xlen = std::min(n1, old_size - pos);
typename S::size_type rlen = S::traits_type::length(str);
assert(s.size() == old_size - xlen + rlen);
}
catch (std::out_of_range&)
@@ -44,6 +45,7 @@ test(S s, S::size_type pos, S::size_type n1,
}
}
template <class S>
void test0()
{
test(S(""), 0, 0, "", S(""));
@@ -148,6 +150,7 @@ void test0()
test(S("abcde"), 5, 1, "12345678901234567890", S("abcde12345678901234567890"));
}
template <class S>
void test1()
{
test(S("abcde"), 6, 0, "", S("can't happen"));
@@ -252,6 +255,7 @@ void test1()
test(S("abcdefghij"), 11, 0, "12345678901234567890", S("can't happen"));
}
template <class S>
void test2()
{
test(S("abcdefghijklmnopqrst"), 0, 0, "", S("abcdefghijklmnopqrst"));
@@ -354,7 +358,18 @@ void test2()
int main()
{
test0();
test1();
test2();
{
typedef std::string S;
test0<S>();
test1<S>();
test2<S>();
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test0<S>();
test1<S>();
test2<S>();
}
#endif
}

View File

@@ -19,14 +19,15 @@
#include <algorithm>
#include <cassert>
typedef std::string S;
#include "../../min_allocator.h"
template <class S>
void
test(S s, S::size_type pos, S::size_type n1,
const S::value_type* str, S::size_type n2,
test(S s, typename S::size_type pos, typename S::size_type n1,
const typename S::value_type* str, typename S::size_type n2,
S expected)
{
S::size_type old_size = s.size();
typename S::size_type old_size = s.size();
S s0 = s;
try
{
@@ -34,8 +35,8 @@ test(S s, S::size_type pos, S::size_type n1,
assert(s.__invariants());
assert(pos <= old_size);
assert(s == expected);
S::size_type xlen = std::min(n1, old_size - pos);
S::size_type rlen = n2;
typename S::size_type xlen = std::min(n1, old_size - pos);
typename S::size_type rlen = n2;
assert(s.size() == old_size - xlen + rlen);
}
catch (std::out_of_range&)
@@ -45,6 +46,7 @@ test(S s, S::size_type pos, S::size_type n1,
}
}
template <class S>
void test0()
{
test(S(""), 0, 0, "", 0, S(""));
@@ -149,6 +151,7 @@ void test0()
test(S("abcde"), 0, 4, "12345", 2, S("12e"));
}
template <class S>
void test1()
{
test(S("abcde"), 0, 4, "12345", 4, S("1234e"));
@@ -253,6 +256,7 @@ void test1()
test(S("abcde"), 1, 3, "1234567890", 1, S("a1e"));
}
template <class S>
void test2()
{
test(S("abcde"), 1, 3, "1234567890", 5, S("a12345e"));
@@ -357,6 +361,7 @@ void test2()
test(S("abcde"), 2, 3, "12345678901234567890", 0, S("ab"));
}
template <class S>
void test3()
{
test(S("abcde"), 2, 3, "12345678901234567890", 1, S("ab1"));
@@ -461,6 +466,7 @@ void test3()
test(S("abcde"), 5, 1, "12345678901234567890", 20, S("abcde12345678901234567890"));
}
template <class S>
void test4()
{
test(S("abcde"), 6, 0, "", 0, S("can't happen"));
@@ -565,6 +571,7 @@ void test4()
test(S("abcdefghij"), 0, 11, "12345", 2, S("12"));
}
template <class S>
void test5()
{
test(S("abcdefghij"), 0, 11, "12345", 4, S("1234"));
@@ -669,6 +676,7 @@ void test5()
test(S("abcdefghij"), 1, 10, "1234567890", 1, S("a1"));
}
template <class S>
void test6()
{
test(S("abcdefghij"), 1, 10, "1234567890", 5, S("a12345"));
@@ -773,6 +781,7 @@ void test6()
test(S("abcdefghij"), 5, 6, "12345678901234567890", 0, S("abcde"));
}
template <class S>
void test7()
{
test(S("abcdefghij"), 5, 6, "12345678901234567890", 1, S("abcde1"));
@@ -877,6 +886,7 @@ void test7()
test(S("abcdefghij"), 11, 0, "12345678901234567890", 20, S("can't happen"));
}
template <class S>
void test8()
{
test(S("abcdefghijklmnopqrst"), 0, 0, "", 0, S("abcdefghijklmnopqrst"));
@@ -981,6 +991,7 @@ void test8()
test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 2, S("a12bcdefghijklmnopqrst"));
}
template <class S>
void test9()
{
test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 4, S("a1234bcdefghijklmnopqrst"));
@@ -1085,6 +1096,7 @@ void test9()
test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 1, S("abcdefghij1klmnopqrst"));
}
template <class S>
void test10()
{
test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 5, S("abcdefghij12345klmnopqrst"));
@@ -1189,6 +1201,7 @@ void test10()
test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
}
template <class S>
void test11()
{
test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t"));
@@ -1279,16 +1292,36 @@ void test11()
int main()
{
test0();
test1();
test2();
test3();
test4();
test5();
test6();
test7();
test8();
test9();
test10();
test11();
{
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>();
}
#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>();
}
#endif
}

View File

@@ -17,14 +17,15 @@
#include <algorithm>
#include <cassert>
typedef std::string S;
#include "../../min_allocator.h"
template <class S>
void
test(S s, S::size_type pos, S::size_type n1,
S::size_type n2, S::value_type c,
test(S s, typename S::size_type pos, typename S::size_type n1,
typename S::size_type n2, typename S::value_type c,
S expected)
{
S::size_type old_size = s.size();
typename S::size_type old_size = s.size();
S s0 = s;
try
{
@@ -32,8 +33,8 @@ test(S s, S::size_type pos, S::size_type n1,
assert(s.__invariants());
assert(pos <= old_size);
assert(s == expected);
S::size_type xlen = std::min(n1, old_size - pos);
S::size_type rlen = n2;
typename S::size_type xlen = std::min(n1, old_size - pos);
typename S::size_type rlen = n2;
assert(s.size() == old_size - xlen + rlen);
}
catch (std::out_of_range&)
@@ -43,6 +44,7 @@ test(S s, S::size_type pos, S::size_type n1,
}
}
template <class S>
void test0()
{
test(S(""), 0, 0, 0, '2', S(""));
@@ -147,6 +149,7 @@ void test0()
test(S("abcde"), 5, 1, 20, '2', S("abcde22222222222222222222"));
}
template <class S>
void test1()
{
test(S("abcde"), 6, 0, 0, '2', S("can't happen"));
@@ -251,6 +254,7 @@ void test1()
test(S("abcdefghij"), 11, 0, 20, '2', S("can't happen"));
}
template <class S>
void test2()
{
test(S("abcdefghijklmnopqrst"), 0, 0, 0, '2', S("abcdefghijklmnopqrst"));
@@ -353,7 +357,18 @@ void test2()
int main()
{
test0();
test1();
test2();
{
typedef std::string S;
test0<S>();
test1<S>();
test2<S>();
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test0<S>();
test1<S>();
test2<S>();
}
#endif
}

View File

@@ -12,19 +12,18 @@
// basic_string<charT,traits,Allocator>&
// replace(size_type pos1, size_type n1, const basic_string<charT,traits,Allocator>& str);
#include <stdio.h>
#include <string>
#include <stdexcept>
#include <algorithm>
#include <cassert>
typedef std::string S;
#include "../../min_allocator.h"
template <class S>
void
test(S s, S::size_type pos1, S::size_type n1, S str, S expected)
test(S s, typename S::size_type pos1, typename S::size_type n1, S str, S expected)
{
S::size_type old_size = s.size();
typename S::size_type old_size = s.size();
S s0 = s;
try
{
@@ -32,8 +31,8 @@ test(S s, S::size_type pos1, S::size_type n1, S str, S expected)
assert(s.__invariants());
assert(pos1 <= old_size);
assert(s == expected);
S::size_type xlen = std::min(n1, old_size - pos1);
S::size_type rlen = str.size();
typename S::size_type xlen = std::min(n1, old_size - pos1);
typename S::size_type rlen = str.size();
assert(s.size() == old_size - xlen + rlen);
}
catch (std::out_of_range&)
@@ -43,6 +42,7 @@ test(S s, S::size_type pos1, S::size_type n1, S str, S expected)
}
}
template <class S>
void test0()
{
test(S(""), 0, 0, S(""), S(""));
@@ -147,6 +147,7 @@ void test0()
test(S("abcde"), 5, 1, S("12345678901234567890"), S("abcde12345678901234567890"));
}
template <class S>
void test1()
{
test(S("abcde"), 6, 0, S(""), S("can't happen"));
@@ -251,6 +252,7 @@ void test1()
test(S("abcdefghij"), 11, 0, S("12345678901234567890"), S("can't happen"));
}
template <class S>
void test2()
{
test(S("abcdefghijklmnopqrst"), 0, 0, S(""), S("abcdefghijklmnopqrst"));
@@ -353,7 +355,18 @@ void test2()
int main()
{
test0();
test1();
test2();
{
typedef std::string S;
test0<S>();
test1<S>();
test2<S>();
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test0<S>();
test1<S>();
test2<S>();
}
#endif
}

View File

@@ -13,21 +13,20 @@
// replace(size_type pos1, size_type n1, const basic_string<charT,traits,Allocator>& str,
// size_type pos2, size_type n2);
#include <stdio.h>
#include <string>
#include <stdexcept>
#include <algorithm>
#include <cassert>
typedef std::string S;
#include "../../min_allocator.h"
template <class S>
void
test(S s, S::size_type pos1, S::size_type n1,
S str, S::size_type pos2, S::size_type n2,
test(S s, typename S::size_type pos1, typename S::size_type n1,
S str, typename S::size_type pos2, typename S::size_type n2,
S expected)
{
S::size_type old_size = s.size();
typename S::size_type old_size = s.size();
S s0 = s;
try
{
@@ -35,8 +34,8 @@ test(S s, S::size_type pos1, S::size_type n1,
assert(s.__invariants());
assert(pos1 <= old_size && pos2 <= str.size());
assert(s == expected);
S::size_type xlen = std::min(n1, old_size - pos1);
S::size_type rlen = std::min(n2, str.size() - pos2);
typename S::size_type xlen = std::min(n1, old_size - pos1);
typename S::size_type rlen = std::min(n2, str.size() - pos2);
assert(s.size() == old_size - xlen + rlen);
}
catch (std::out_of_range&)
@@ -46,6 +45,7 @@ test(S s, S::size_type pos1, S::size_type n1,
}
}
template <class S>
void test0()
{
test(S(""), 0, 0, S(""), 0, 0, S(""));
@@ -150,6 +150,7 @@ void test0()
test(S(""), 0, 1, S("12345"), 6, 0, S("can't happen"));
}
template <class S>
void test1()
{
test(S(""), 0, 1, S("1234567890"), 0, 0, S(""));
@@ -254,6 +255,7 @@ void test1()
test(S(""), 1, 0, S("12345678901234567890"), 0, 1, S("can't happen"));
}
template <class S>
void test2()
{
test(S(""), 1, 0, S("12345678901234567890"), 0, 10, S("can't happen"));
@@ -358,6 +360,7 @@ void test2()
test(S("abcde"), 0, 1, S("12345"), 0, 0, S("bcde"));
}
template <class S>
void test3()
{
test(S("abcde"), 0, 1, S("12345"), 0, 1, S("1bcde"));
@@ -462,6 +465,7 @@ void test3()
test(S("abcde"), 0, 2, S("1234567890"), 0, 9, S("123456789cde"));
}
template <class S>
void test4()
{
test(S("abcde"), 0, 2, S("1234567890"), 0, 10, S("1234567890cde"));
@@ -566,6 +570,7 @@ void test4()
test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 21, S("12345678901234567890e"));
}
template <class S>
void test5()
{
test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 0, S("e"));
@@ -670,6 +675,7 @@ void test5()
test(S("abcde"), 0, 6, S("12345"), 0, 5, S("12345"));
}
template <class S>
void test6()
{
test(S("abcde"), 0, 6, S("12345"), 0, 6, S("12345"));
@@ -774,6 +780,7 @@ void test6()
test(S("abcde"), 1, 0, S("1234567890"), 1, 1, S("a2bcde"));
}
template <class S>
void test7()
{
test(S("abcde"), 1, 0, S("1234567890"), 1, 4, S("a2345bcde"));
@@ -878,6 +885,7 @@ void test7()
test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 18, S("a234567890123456789cde"));
}
template <class S>
void test8()
{
test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890cde"));
@@ -982,6 +990,7 @@ void test8()
test(S("abcde"), 1, 3, S("12345"), 1, 2, S("a23e"));
}
template <class S>
void test9()
{
test(S("abcde"), 1, 3, S("12345"), 1, 3, S("a234e"));
@@ -1086,6 +1095,7 @@ void test9()
test(S("abcde"), 1, 4, S("1234567890"), 1, 10, S("a234567890"));
}
template <class S>
void test10()
{
test(S("abcde"), 1, 4, S("1234567890"), 5, 0, S("a"));
@@ -1190,6 +1200,7 @@ void test10()
test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 1, S("a1"));
}
template <class S>
void test11()
{
test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 5, S("a12345"));
@@ -1294,6 +1305,7 @@ void test11()
test(S("abcde"), 2, 1, S("12345"), 2, 0, S("abde"));
}
template <class S>
void test12()
{
test(S("abcde"), 2, 1, S("12345"), 2, 1, S("ab3de"));
@@ -1398,6 +1410,7 @@ void test12()
test(S("abcde"), 2, 2, S("1234567890"), 5, 4, S("ab6789e"));
}
template <class S>
void test13()
{
test(S("abcde"), 2, 2, S("1234567890"), 5, 5, S("ab67890e"));
@@ -1502,6 +1515,7 @@ void test13()
test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 11, S("ab1234567890"));
}
template <class S>
void test14()
{
test(S("abcde"), 2, 3, S("12345678901234567890"), 19, 0, S("ab"));
@@ -1606,6 +1620,7 @@ void test14()
test(S("abcde"), 4, 0, S("12345"), 2, 4, S("abcd345e"));
}
template <class S>
void test15()
{
test(S("abcde"), 4, 0, S("12345"), 4, 0, S("abcde"));
@@ -1710,6 +1725,7 @@ void test15()
test(S("abcde"), 4, 1, S("1234567890"), 9, 1, S("abcd0"));
}
template <class S>
void test16()
{
test(S("abcde"), 4, 1, S("1234567890"), 9, 2, S("abcd0"));
@@ -1814,6 +1830,7 @@ void test16()
test(S("abcde"), 4, 2, S("12345678901234567890"), 20, 0, S("abcd"));
}
template <class S>
void test17()
{
test(S("abcde"), 4, 2, S("12345678901234567890"), 20, 1, S("abcd"));
@@ -1918,6 +1935,7 @@ void test17()
test(S("abcde"), 5, 1, S("12345"), 5, 0, S("abcde"));
}
template <class S>
void test18()
{
test(S("abcde"), 5, 1, S("12345"), 5, 1, S("abcde"));
@@ -2022,6 +2040,7 @@ void test18()
test(S("abcde"), 6, 0, S("1234567890"), 11, 0, S("can't happen"));
}
template <class S>
void test19()
{
test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 0, S("can't happen"));
@@ -2126,6 +2145,7 @@ void test19()
test(S("abcdefghij"), 0, 1, S(""), 0, 1, S("bcdefghij"));
}
template <class S>
void test20()
{
test(S("abcdefghij"), 0, 1, S(""), 1, 0, S("can't happen"));
@@ -2230,6 +2250,7 @@ void test20()
test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 1, S("1fghij"));
}
template <class S>
void test21()
{
test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 5, S("12345fghij"));
@@ -2334,6 +2355,7 @@ void test21()
test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 19, S("1234567890123456789j"));
}
template <class S>
void test22()
{
test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 20, S("12345678901234567890j"));
@@ -2438,6 +2460,7 @@ void test22()
test(S("abcdefghij"), 0, 11, S("12345"), 0, 2, S("12"));
}
template <class S>
void test23()
{
test(S("abcdefghij"), 0, 11, S("12345"), 0, 4, S("1234"));
@@ -2542,6 +2565,7 @@ void test23()
test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 11, S("a1234567890bcdefghij"));
}
template <class S>
void test24()
{
test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 0, S("abcdefghij"));
@@ -2646,6 +2670,7 @@ void test24()
test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 1, S("a2cdefghij"));
}
template <class S>
void test25()
{
test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 9, S("a234567890cdefghij"));
@@ -2750,6 +2775,7 @@ void test25()
test(S("abcdefghij"), 1, 8, S("12345"), 1, 0, S("aj"));
}
template <class S>
void test26()
{
test(S("abcdefghij"), 1, 8, S("12345"), 1, 1, S("a2j"));
@@ -2854,6 +2880,7 @@ void test26()
test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 8, S("a23456789"));
}
template <class S>
void test27()
{
test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 9, S("a234567890"));
@@ -2958,6 +2985,7 @@ void test27()
test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
}
template <class S>
void test28()
{
test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 0, S("a"));
@@ -3062,6 +3090,7 @@ void test28()
test(S("abcdefghij"), 5, 1, S("12345"), 1, 4, S("abcde2345ghij"));
}
template <class S>
void test29()
{
test(S("abcdefghij"), 5, 1, S("12345"), 1, 5, S("abcde2345ghij"));
@@ -3166,6 +3195,7 @@ void test29()
test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 1, S("abcde6hij"));
}
template <class S>
void test30()
{
test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 2, S("abcde67hij"));
@@ -3270,6 +3300,7 @@ void test30()
test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 9, S("abcde123456789j"));
}
template <class S>
void test31()
{
test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 10, S("abcde1234567890j"));
@@ -3374,6 +3405,7 @@ void test31()
test(S("abcdefghij"), 5, 6, S("12345"), 2, 2, S("abcde34"));
}
template <class S>
void test32()
{
test(S("abcdefghij"), 5, 6, S("12345"), 2, 3, S("abcde345"));
@@ -3478,6 +3510,7 @@ void test32()
test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 6, S("abcdefghi67890j"));
}
template <class S>
void test33()
{
test(S("abcdefghij"), 9, 0, S("1234567890"), 9, 0, S("abcdefghij"));
@@ -3582,6 +3615,7 @@ void test33()
test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, 1, S("abcdefghi0"));
}
template <class S>
void test34()
{
test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, 2, S("abcdefghi0"));
@@ -3686,6 +3720,7 @@ void test34()
test(S("abcdefghij"), 10, 0, S("12345"), 4, 1, S("abcdefghij5"));
}
template <class S>
void test35()
{
test(S("abcdefghij"), 10, 0, S("12345"), 4, 2, S("abcdefghij5"));
@@ -3790,6 +3825,7 @@ void test35()
test(S("abcdefghij"), 10, 1, S("1234567890"), 10, 0, S("abcdefghij"));
}
template <class S>
void test36()
{
test(S("abcdefghij"), 10, 1, S("1234567890"), 10, 1, S("abcdefghij"));
@@ -3894,6 +3930,7 @@ void test36()
test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
}
template <class S>
void test37()
{
test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
@@ -3998,6 +4035,7 @@ void test37()
test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 6, 0, S("can't happen"));
}
template <class S>
void test38()
{
test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 0, S("bcdefghijklmnopqrst"));
@@ -4102,6 +4140,7 @@ void test38()
test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 1, S("1klmnopqrst"));
}
template <class S>
void test39()
{
test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 10, S("1234567890klmnopqrst"));
@@ -4206,6 +4245,7 @@ void test39()
test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 0, S(""));
}
template <class S>
void test40()
{
test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 1, S("1"));
@@ -4310,6 +4350,7 @@ void test40()
test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 9, S("123456789"));
}
template <class S>
void test41()
{
test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 10, S("1234567890"));
@@ -4414,6 +4455,7 @@ void test41()
test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghijklmnopqrst"));
}
template <class S>
void test42()
{
test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
@@ -4518,6 +4560,7 @@ void test42()
test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 5, S("a12345klmnopqrst"));
}
template <class S>
void test43()
{
test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 6, S("a12345klmnopqrst"));
@@ -4622,6 +4665,7 @@ void test43()
test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 1, S("a2t"));
}
template <class S>
void test44()
{
test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 4, S("a2345t"));
@@ -4726,6 +4770,7 @@ void test44()
test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
}
template <class S>
void test45()
{
test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
@@ -4830,6 +4875,7 @@ void test45()
test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 2, S("abcdefghij23klmnopqrst"));
}
template <class S>
void test46()
{
test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 3, S("abcdefghij234klmnopqrst"));
@@ -4934,6 +4980,7 @@ void test46()
test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 10, S("abcdefghij234567890lmnopqrst"));
}
template <class S>
void test47()
{
test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 0, S("abcdefghijlmnopqrst"));
@@ -5038,6 +5085,7 @@ void test47()
test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 1, S("abcdefghij1pqrst"));
}
template <class S>
void test48()
{
test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 5, S("abcdefghij12345pqrst"));
@@ -5142,6 +5190,7 @@ void test48()
test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 0, S("abcdefghij"));
}
template <class S>
void test49()
{
test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 1, S("abcdefghij3"));
@@ -5246,6 +5295,7 @@ void test49()
test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 4, S("abcdefghij6789"));
}
template <class S>
void test50()
{
test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 5, S("abcdefghij67890"));
@@ -5350,6 +5400,7 @@ void test50()
test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890t"));
}
template <class S>
void test51()
{
test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
@@ -5454,6 +5505,7 @@ void test51()
test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 4, S("abcdefghijklmnopqrs345"));
}
template <class S>
void test52()
{
test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 4, 0, S("abcdefghijklmnopqrs"));
@@ -5558,6 +5610,7 @@ void test52()
test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 9, 1, S("abcdefghijklmnopqrst0"));
}
template <class S>
void test53()
{
test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 9, 2, S("abcdefghijklmnopqrst0"));
@@ -5662,6 +5715,7 @@ void test53()
test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
}
template <class S>
void test54()
{
test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
@@ -5744,59 +5798,122 @@ void test54()
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();
test30();
test31();
test32();
test33();
test34();
test35();
test36();
test37();
test38();
test39();
test40();
test41();
test42();
test43();
test44();
test45();
test46();
test47();
test48();
test49();
test50();
test51();
test52();
test53();
test54();
{
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>();
test30<S>();
test31<S>();
test32<S>();
test33<S>();
test34<S>();
test35<S>();
test36<S>();
test37<S>();
test38<S>();
test39<S>();
test40<S>();
test41<S>();
test42<S>();
test43<S>();
test44<S>();
test45<S>();
test46<S>();
test47<S>();
test48<S>();
test49<S>();
test50<S>();
test51<S>();
test52<S>();
test53<S>();
test54<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>();
test30<S>();
test31<S>();
test32<S>();
test33<S>();
test34<S>();
test35<S>();
test36<S>();
test37<S>();
test38<S>();
test39<S>();
test40<S>();
test41<S>();
test42<S>();
test43<S>();
test44<S>();
test45<S>();
test46<S>();
test47<S>();
test48<S>();
test49<S>();
test50<S>();
test51<S>();
test52<S>();
test53<S>();
test54<S>();
}
#endif
}

View File

@@ -16,6 +16,8 @@
#include <algorithm>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test(S s1, S s2)
@@ -31,6 +33,7 @@ test(S s1, S s2)
int main()
{
{
typedef std::string S;
test(S(""), S(""));
test(S(""), S("12345"));
@@ -48,4 +51,26 @@ int main()
test(S("abcdefghijklmnopqrst"), S("12345"));
test(S("abcdefghijklmnopqrst"), S("1234567890"));
test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), S(""));
test(S(""), S("12345"));
test(S(""), S("1234567890"));
test(S(""), S("12345678901234567890"));
test(S("abcde"), S(""));
test(S("abcde"), S("12345"));
test(S("abcde"), S("1234567890"));
test(S("abcde"), S("12345678901234567890"));
test(S("abcdefghij"), S(""));
test(S("abcdefghij"), S("12345"));
test(S("abcdefghij"), S("1234567890"));
test(S("abcdefghij"), S("12345678901234567890"));
test(S("abcdefghijklmnopqrst"), S(""));
test(S("abcdefghijklmnopqrst"), S("12345"));
test(S("abcdefghijklmnopqrst"), S("1234567890"));
test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
}
#endif
}

View File

@@ -18,6 +18,8 @@
#include <sstream>
#include <cassert>
#include "../../min_allocator.h"
int main()
{
{
@@ -46,4 +48,34 @@ int main()
assert(in.eof());
assert(s == L" ghij");
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
std::istringstream in(" abc\n def\n ghij");
S s("initial text");
getline(in, s);
assert(in.good());
assert(s == " abc");
getline(in, s);
assert(in.good());
assert(s == " def");
getline(in, s);
assert(in.eof());
assert(s == " ghij");
}
{
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
std::wistringstream in(L" abc\n def\n ghij");
S s(L"initial text");
getline(in, s);
assert(in.good());
assert(s == L" abc");
getline(in, s);
assert(in.good());
assert(s == L" def");
getline(in, s);
assert(in.eof());
assert(s == L" ghij");
}
#endif
}

View File

@@ -18,6 +18,8 @@
#include <sstream>
#include <cassert>
#include "../../min_allocator.h"
int main()
{
{
@@ -52,4 +54,40 @@ int main()
assert(in.eof());
assert(s == L" ghij");
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
std::istringstream in(" abc* def** ghij");
S s("initial text");
getline(in, s, '*');
assert(in.good());
assert(s == " abc");
getline(in, s, '*');
assert(in.good());
assert(s == " def");
getline(in, s, '*');
assert(in.good());
assert(s == "");
getline(in, s, '*');
assert(in.eof());
assert(s == " ghij");
}
{
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
std::wistringstream in(L" abc* def** ghij");
S s(L"initial text");
getline(in, s, L'*');
assert(in.good());
assert(s == L" abc");
getline(in, s, L'*');
assert(in.good());
assert(s == L" def");
getline(in, s, L'*');
assert(in.good());
assert(s == L"");
getline(in, s, L'*');
assert(in.eof());
assert(s == L" ghij");
}
#endif
}

View File

@@ -18,6 +18,8 @@
#include <sstream>
#include <cassert>
#include "../../min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -31,5 +33,19 @@ int main()
getline(std::wistringstream(L" abc* def* ghij"), s, L'*');
assert(s == L" abc");
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s("initial text");
getline(std::istringstream(" abc* def* ghij"), s, '*');
assert(s == " abc");
}
{
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
S s(L"initial text");
getline(std::wistringstream(L" abc* def* ghij"), s, L'*');
assert(s == L" abc");
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -18,6 +18,8 @@
#include <sstream>
#include <cassert>
#include "../../min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -31,5 +33,19 @@ int main()
getline(std::wistringstream(L" abc\n def\n ghij"), s);
assert(s == L" abc");
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s("initial text");
getline(std::istringstream(" abc\n def\n ghij"), s);
assert(s == " abc");
}
{
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
S s(L"initial text");
getline(std::wistringstream(L" abc\n def\n ghij"), s);
assert(s == L" abc");
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -18,6 +18,8 @@
#include <sstream>
#include <cassert>
#include "../../min_allocator.h"
int main()
{
{
@@ -64,4 +66,52 @@ int main()
in >> s;
assert(in.fail());
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
std::istringstream in("a bc defghij");
S s("initial text");
in >> s;
assert(in.good());
assert(s == "a");
assert(in.peek() == ' ');
in >> s;
assert(in.good());
assert(s == "bc");
assert(in.peek() == ' ');
in.width(3);
in >> s;
assert(in.good());
assert(s == "def");
assert(in.peek() == 'g');
in >> s;
assert(in.eof());
assert(s == "ghij");
in >> s;
assert(in.fail());
}
{
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
std::wistringstream in(L"a bc defghij");
S s(L"initial text");
in >> s;
assert(in.good());
assert(s == L"a");
assert(in.peek() == L' ');
in >> s;
assert(in.good());
assert(s == L"bc");
assert(in.peek() == L' ');
in.width(3);
in >> s;
assert(in.good());
assert(s == L"def");
assert(in.peek() == L'g');
in >> s;
assert(in.eof());
assert(s == L"ghij");
in >> s;
assert(in.fail());
}
#endif
}

View File

@@ -18,6 +18,8 @@
#include <sstream>
#include <cassert>
#include "../../min_allocator.h"
int main()
{
{
@@ -50,4 +52,40 @@ int main()
assert(out.good());
assert(L" " + s == out.str());
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
S s("some text");
out << s;
assert(out.good());
assert(s == out.str());
}
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
S s("some text");
out.width(12);
out << s;
assert(out.good());
assert(" " + s == out.str());
}
{
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
S s(L"some text");
out << s;
assert(out.good());
assert(s == out.str());
}
{
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
S s(L"some text");
out.width(12);
out << s;
assert(out.good());
assert(L" " + s == out.str());
}
#endif
}

View File

@@ -18,6 +18,8 @@
#include <algorithm>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test(S s1, S s2)
@@ -33,6 +35,7 @@ test(S s1, S s2)
int main()
{
{
typedef std::string S;
test(S(""), S(""));
test(S(""), S("12345"));
@@ -50,4 +53,26 @@ int main()
test(S("abcdefghijklmnopqrst"), S("12345"));
test(S("abcdefghijklmnopqrst"), S("1234567890"));
test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), S(""));
test(S(""), S("12345"));
test(S(""), S("1234567890"));
test(S(""), S("12345678901234567890"));
test(S("abcde"), S(""));
test(S("abcde"), S("12345"));
test(S("abcde"), S("1234567890"));
test(S("abcde"), S("12345678901234567890"));
test(S("abcdefghij"), S(""));
test(S("abcdefghij"), S("12345"));
test(S("abcdefghij"), S("1234567890"));
test(S("abcdefghij"), S("12345678901234567890"));
test(S("abcdefghijklmnopqrst"), S(""));
test(S("abcdefghijklmnopqrst"), S("12345"));
test(S("abcdefghijklmnopqrst"), S("1234567890"));
test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
}
#endif
}

View File

@@ -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(""), false);
test("", S("abcde"), true);
test("", S("abcdefghij"), true);
@@ -42,4 +44,26 @@ int main()
test("abcdefghijklmnopqrst", S("abcde"), true);
test("abcdefghijklmnopqrst", S("abcdefghij"), true);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test("", S(""), false);
test("", S("abcde"), true);
test("", S("abcdefghij"), true);
test("", S("abcdefghijklmnopqrst"), true);
test("abcde", S(""), true);
test("abcde", S("abcde"), false);
test("abcde", S("abcdefghij"), true);
test("abcde", S("abcdefghijklmnopqrst"), true);
test("abcdefghij", S(""), true);
test("abcdefghij", S("abcde"), true);
test("abcdefghij", S("abcdefghij"), false);
test("abcdefghij", S("abcdefghijklmnopqrst"), true);
test("abcdefghijklmnopqrst", S(""), true);
test("abcdefghijklmnopqrst", S("abcde"), true);
test("abcdefghijklmnopqrst", S("abcdefghij"), true);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
}
#endif
}

View File

@@ -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(""), "", false);
test(S(""), "abcde", true);
test(S(""), "abcdefghij", true);
@@ -42,4 +44,26 @@ int main()
test(S("abcdefghijklmnopqrst"), "abcde", true);
test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), "", false);
test(S(""), "abcde", true);
test(S(""), "abcdefghij", true);
test(S(""), "abcdefghijklmnopqrst", true);
test(S("abcde"), "", true);
test(S("abcde"), "abcde", false);
test(S("abcde"), "abcdefghij", true);
test(S("abcde"), "abcdefghijklmnopqrst", true);
test(S("abcdefghij"), "", true);
test(S("abcdefghij"), "abcde", true);
test(S("abcdefghij"), "abcdefghij", false);
test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
test(S("abcdefghijklmnopqrst"), "", true);
test(S("abcdefghijklmnopqrst"), "abcde", true);
test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
}
#endif
}

View File

@@ -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(""), false);
test(S(""), S("abcde"), true);
test(S(""), S("abcdefghij"), true);
@@ -43,4 +45,26 @@ int main()
test(S("abcdefghijklmnopqrst"), S("abcde"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), S(""), false);
test(S(""), S("abcde"), true);
test(S(""), S("abcdefghij"), true);
test(S(""), S("abcdefghijklmnopqrst"), true);
test(S("abcde"), S(""), true);
test(S("abcde"), S("abcde"), false);
test(S("abcde"), S("abcdefghij"), true);
test(S("abcde"), S("abcdefghijklmnopqrst"), true);
test(S("abcdefghij"), S(""), true);
test(S("abcdefghij"), S("abcde"), true);
test(S("abcdefghij"), S("abcdefghij"), false);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
test(S("abcdefghijklmnopqrst"), S(""), true);
test(S("abcdefghijklmnopqrst"), S("abcde"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
}
#endif
}

View File

@@ -20,6 +20,8 @@
#include <string>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test0(typename S::value_type lhs, const S& rhs, const S& x)
@@ -38,15 +40,15 @@ test1(typename S::value_type lhs, S&& rhs, const S& x)
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
typedef std::string S;
int main()
{
{
typedef std::string S;
test0('a', S(""), S("a"));
test0('a', S("12345"), S("a12345"));
test0('a', S("1234567890"), S("a1234567890"));
test0('a', S("12345678901234567890"), S("a12345678901234567890"));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test1('a', S(""), S("a"));
@@ -55,4 +57,23 @@ int main()
test1('a', S("12345678901234567890"), S("a12345678901234567890"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test0('a', S(""), S("a"));
test0('a', S("12345"), S("a12345"));
test0('a', S("1234567890"), S("a1234567890"));
test0('a', S("12345678901234567890"), S("a12345678901234567890"));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test1('a', S(""), S("a"));
test1('a', S("12345"), S("a12345"));
test1('a', S("1234567890"), S("a1234567890"));
test1('a', S("12345678901234567890"), S("a12345678901234567890"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#endif
}

View File

@@ -20,6 +20,8 @@
#include <string>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test0(const typename S::value_type* lhs, const S& rhs, const S& x)
@@ -38,10 +40,10 @@ test1(const typename S::value_type* lhs, S&& rhs, const S& x)
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
typedef std::string S;
int main()
{
{
typedef std::string S;
test0("", S(""), S(""));
test0("", S("12345"), S("12345"));
test0("", S("1234567890"), S("1234567890"));
@@ -79,4 +81,47 @@ int main()
test1("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test0("", S(""), S(""));
test0("", S("12345"), S("12345"));
test0("", S("1234567890"), S("1234567890"));
test0("", S("12345678901234567890"), S("12345678901234567890"));
test0("abcde", S(""), S("abcde"));
test0("abcde", S("12345"), S("abcde12345"));
test0("abcde", S("1234567890"), S("abcde1234567890"));
test0("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
test0("abcdefghij", S(""), S("abcdefghij"));
test0("abcdefghij", S("12345"), S("abcdefghij12345"));
test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
test0("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
test0("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test0("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test1("", S(""), S(""));
test1("", S("12345"), S("12345"));
test1("", S("1234567890"), S("1234567890"));
test1("", S("12345678901234567890"), S("12345678901234567890"));
test1("abcde", S(""), S("abcde"));
test1("abcde", S("12345"), S("abcde12345"));
test1("abcde", S("1234567890"), S("abcde1234567890"));
test1("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
test1("abcdefghij", S(""), S("abcdefghij"));
test1("abcdefghij", S("12345"), S("abcdefghij12345"));
test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
test1("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
test1("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test1("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#endif
}

View File

@@ -20,6 +20,8 @@
#include <string>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test0(const S& lhs, typename S::value_type rhs, const S& x)
@@ -38,10 +40,10 @@ test1(S&& lhs, typename S::value_type rhs, const S& x)
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
typedef std::string S;
int main()
{
{
typedef std::string S;
test0(S(""), '1', S("1"));
test0(S("abcde"), '1', S("abcde1"));
test0(S("abcdefghij"), '1', S("abcdefghij1"));
@@ -55,4 +57,23 @@ int main()
test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test0(S(""), '1', S("1"));
test0(S("abcde"), '1', S("abcde1"));
test0(S("abcdefghij"), '1', S("abcdefghij1"));
test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test1(S(""), '1', S("1"));
test1(S("abcde"), '1', S("abcde1"));
test1(S("abcdefghij"), '1', S("abcdefghij1"));
test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#endif
}

View File

@@ -20,6 +20,8 @@
#include <string>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test0(const S& lhs, const typename S::value_type* rhs, const S& x)
@@ -38,10 +40,10 @@ test1(S&& lhs, const typename S::value_type* rhs, const S& x)
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
typedef std::string S;
int main()
{
{
typedef std::string S;
test0(S(""), "", S(""));
test0(S(""), "12345", S("12345"));
test0(S(""), "1234567890", S("1234567890"));
@@ -79,4 +81,47 @@ int main()
test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test0(S(""), "", S(""));
test0(S(""), "12345", S("12345"));
test0(S(""), "1234567890", S("1234567890"));
test0(S(""), "12345678901234567890", S("12345678901234567890"));
test0(S("abcde"), "", S("abcde"));
test0(S("abcde"), "12345", S("abcde12345"));
test0(S("abcde"), "1234567890", S("abcde1234567890"));
test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
test0(S("abcdefghij"), "", S("abcdefghij"));
test0(S("abcdefghij"), "12345", S("abcdefghij12345"));
test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
test0(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test1(S(""), "", S(""));
test1(S(""), "12345", S("12345"));
test1(S(""), "1234567890", S("1234567890"));
test1(S(""), "12345678901234567890", S("12345678901234567890"));
test1(S("abcde"), "", S("abcde"));
test1(S("abcde"), "12345", S("abcde12345"));
test1(S("abcde"), "1234567890", S("abcde1234567890"));
test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
test1(S("abcdefghij"), "", S("abcdefghij"));
test1(S("abcdefghij"), "12345", S("abcdefghij12345"));
test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
test1(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#endif
}

View File

@@ -32,6 +32,8 @@
#include <string>
#include <cassert>
#include "../../min_allocator.h"
template <class S>
void
test0(const S& lhs, const S& rhs, const S& x)
@@ -64,10 +66,10 @@ test3(S&& lhs, S&& rhs, const S& x)
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
typedef std::string S;
int main()
{
{
typedef std::string S;
test0(S(""), S(""), S(""));
test0(S(""), S("12345"), S("12345"));
test0(S(""), S("1234567890"), S("1234567890"));
@@ -139,4 +141,81 @@ int main()
test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test0(S(""), S(""), S(""));
test0(S(""), S("12345"), S("12345"));
test0(S(""), S("1234567890"), S("1234567890"));
test0(S(""), S("12345678901234567890"), S("12345678901234567890"));
test0(S("abcde"), S(""), S("abcde"));
test0(S("abcde"), S("12345"), S("abcde12345"));
test0(S("abcde"), S("1234567890"), S("abcde1234567890"));
test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
test0(S("abcdefghij"), S(""), S("abcdefghij"));
test0(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test1(S(""), S(""), S(""));
test1(S(""), S("12345"), S("12345"));
test1(S(""), S("1234567890"), S("1234567890"));
test1(S(""), S("12345678901234567890"), S("12345678901234567890"));
test1(S("abcde"), S(""), S("abcde"));
test1(S("abcde"), S("12345"), S("abcde12345"));
test1(S("abcde"), S("1234567890"), S("abcde1234567890"));
test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
test1(S("abcdefghij"), S(""), S("abcdefghij"));
test1(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
test2(S(""), S(""), S(""));
test2(S(""), S("12345"), S("12345"));
test2(S(""), S("1234567890"), S("1234567890"));
test2(S(""), S("12345678901234567890"), S("12345678901234567890"));
test2(S("abcde"), S(""), S("abcde"));
test2(S("abcde"), S("12345"), S("abcde12345"));
test2(S("abcde"), S("1234567890"), S("abcde1234567890"));
test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
test2(S("abcdefghij"), S(""), S("abcdefghij"));
test2(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
test3(S(""), S(""), S(""));
test3(S(""), S("12345"), S("12345"));
test3(S(""), S("1234567890"), S("1234567890"));
test3(S(""), S("12345678901234567890"), S("12345678901234567890"));
test3(S("abcde"), S(""), S("abcde"));
test3(S("abcde"), S("12345"), S("abcde12345"));
test3(S("abcde"), S("1234567890"), S("abcde1234567890"));
test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
test3(S("abcdefghij"), S(""), S("abcdefghij"));
test3(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#endif
}

Some files were not shown because too many files have changed in this diff Show More