Move test into test/std subdirectory.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2014-12-20 01:40:03 +00:00
parent 669a8a5a19
commit a90c6dd460
4817 changed files with 13 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// template <class T>
// struct hash
// : public unary_function<T, size_t>
// {
// size_t operator()(T val) const;
// };
// Not very portable
#include <string>
#include <cassert>
#include <type_traits>
template <class T>
void
test()
{
typedef std::hash<T> H;
static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
H>::value), "");
H h;
std::string g1 = "1234567890";
std::string g2 = "1234567891";
T s1(g1.begin(), g1.end());
T s2(g2.begin(), g2.end());
assert(h(s1) != h(s2));
}
int main()
{
test<std::string>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<std::u16string>();
test<std::u32string>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
test<std::wstring>();
}

View File

@@ -0,0 +1,47 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include <string>
#include <cassert>
int main()
{
#if _LIBCPP_STD_VER > 11
using namespace std::literals::string_literals;
static_assert ( std::is_same<decltype( "Hi"s), std::string>::value, "" );
static_assert ( std::is_same<decltype( u8"Hi"s), std::string>::value, "" );
static_assert ( std::is_same<decltype( L"Hi"s), std::wstring>::value, "" );
static_assert ( std::is_same<decltype( u"Hi"s), std::u16string>::value, "" );
static_assert ( std::is_same<decltype( U"Hi"s), std::u32string>::value, "" );
std::string foo;
std::wstring Lfoo;
std::u16string ufoo;
std::u32string Ufoo;
foo = ""s; assert( foo.size() == 0);
foo = u8""s; assert( foo.size() == 0);
Lfoo = L""s; assert(Lfoo.size() == 0);
ufoo = u""s; assert(ufoo.size() == 0);
Ufoo = U""s; assert(Ufoo.size() == 0);
foo = " "s; assert( foo.size() == 1);
foo = u8" "s; assert( foo.size() == 1);
Lfoo = L" "s; assert(Lfoo.size() == 1);
ufoo = u" "s; assert(ufoo.size() == 1);
Ufoo = U" "s; assert(Ufoo.size() == 1);
foo = "ABC"s; assert( foo == "ABC"); assert( foo == std::string ( "ABC"));
foo = u8"ABC"s; assert( foo == u8"ABC"); assert( foo == std::string (u8"ABC"));
Lfoo = L"ABC"s; assert(Lfoo == L"ABC"); assert(Lfoo == std::wstring ( L"ABC"));
ufoo = u"ABC"s; assert(ufoo == u"ABC"); assert(ufoo == std::u16string( u"ABC"));
Ufoo = U"ABC"s; assert(Ufoo == U"ABC"); assert(Ufoo == std::u32string( U"ABC"));
#endif
}

View File

@@ -0,0 +1,22 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include <string>
#include <cassert>
int main()
{
#if _LIBCPP_STD_VER > 11
using std::string;
string foo = ""s; // should fail w/conversion operator not found
#else
#error
#endif
}

View File

@@ -0,0 +1,20 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include <string>
#include <cassert>
int main()
{
#if _LIBCPP_STD_VER > 11
using namespace std::literals;
std::string foo = ""s;
#endif
}

View File

@@ -0,0 +1,20 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include <string>
#include <cassert>
int main()
{
#if _LIBCPP_STD_VER > 11
std::string foo = ""s; // should fail w/conversion operator not found
#else
#error
#endif
}

View File

@@ -0,0 +1,20 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include <string>
#include <cassert>
int main()
{
#if _LIBCPP_STD_VER > 11
using namespace std::literals::string_literals;
std::string foo = ""s;
#endif
}

View File

@@ -0,0 +1,20 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include <string>
#include <cassert>
int main()
{
#if _LIBCPP_STD_VER > 11
using namespace std;
string foo = ""s;
#endif
}

View File

@@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef INPUT_ITERATOR_H
#define INPUT_ITERATOR_H
#include <iterator>
template <class It>
class input_iterator
{
It it_;
public:
typedef typename std::input_iterator_tag iterator_category;
typedef typename std::iterator_traits<It>::value_type value_type;
typedef typename std::iterator_traits<It>::difference_type difference_type;
typedef It pointer;
typedef typename std::iterator_traits<It>::reference reference;
input_iterator() : it_() {}
explicit input_iterator(It it) : it_(it) {}
reference operator*() const {return *it_;}
pointer operator->() const {return it_;}
input_iterator& operator++() {++it_; return *this;}
input_iterator operator++(int) {input_iterator tmp(*this); ++(*this); return tmp;}
friend bool operator==(const input_iterator& x, const input_iterator& y)
{return x.it_ == y.it_;}
friend bool operator!=(const input_iterator& x, const input_iterator& y)
{return !(x == y);}
};
#endif // INPUT_ITERATOR_H

View File

@@ -0,0 +1,58 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// const_reference at(size_type pos) const;
// reference at(size_type pos);
#include <string>
#include <stdexcept>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s, typename S::size_type pos)
{
try
{
const S& cs = s;
assert(s.at(pos) == s[pos]);
assert(cs.at(pos) == cs[pos]);
assert(pos < cs.size());
}
catch (std::out_of_range&)
{
assert(pos >= s.size());
}
}
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

@@ -0,0 +1,56 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// const charT& back() const;
// charT& back();
#ifdef _LIBCPP_DEBUG
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s)
{
const S& cs = s;
assert(&cs.back() == &cs[cs.size()-1]);
assert(&s.back() == &s[cs.size()-1]);
s.back() = typename S::value_type('z');
assert(s.back() == typename S::value_type('z'));
}
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
#ifdef _LIBCPP_DEBUG
{
std::string s;
char c = s.back();
assert(false);
}
#endif
}

View File

@@ -0,0 +1,54 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Call back() on empty container.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <iterator>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef std::string S;
S s(1, '\0');
assert(s.back() == 0);
s.clear();
assert(s.back() == 0);
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s(1, '\0');
assert(s.back() == 0);
s.clear();
assert(s.back() == 0);
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Call back() on empty const container.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <iterator>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef std::string S;
const S s;
assert(s.back() == 0);
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
const S s;
assert(s.back() == 0);
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Call front() on empty const container.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <iterator>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef std::string S;
const S s;
assert(s.front() == 0);
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
const S s;
assert(s.front() == 0);
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Index const string out of bounds.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <iterator>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef std::string S;
const S s;
assert(s[0] == 0);
assert(s[1] == 0);
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
const S s;
assert(s[0] == 0);
assert(s[1] == 0);
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,54 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Call front() on empty container.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <iterator>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef std::string S;
S s(1, '\0');
assert(s.front() == 0);
s.clear();
assert(s.front() == 0);
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s(1, '\0');
assert(s.front() == 0);
s.clear();
assert(s.front() == 0);
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Index string out of bounds.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <iterator>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef std::string S;
S s;
assert(s[0] == 0);
assert(s[1] == 0);
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s;
assert(s[0] == 0);
assert(s[1] == 0);
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,56 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// const charT& front() const;
// charT& front();
#ifdef _LIBCPP_DEBUG
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s)
{
const S& cs = s;
assert(&cs.front() == &cs[0]);
assert(&s.front() == &s[0]);
s.front() = typename S::value_type('z');
assert(s.front() == typename S::value_type('z'));
}
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
#ifdef _LIBCPP_DEBUG
{
std::string s;
char c = s.front();
assert(false);
}
#endif
}

View File

@@ -0,0 +1,63 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// const_reference operator[](size_type pos) const;
// reference operator[](size_type pos);
#ifdef _LIBCPP_DEBUG
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
#include <string>
#include <cassert>
#include "min_allocator.h"
int main()
{
{
typedef std::string 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');
}
#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
#ifdef _LIBCPP_DEBUG
{
std::string s;
char c = s[0];
assert(c == '\0');
c = s[1];
assert(false);
}
#endif
}

View File

@@ -0,0 +1,58 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// size_type capacity() const;
#include <string>
#include <cassert>
#include "test_allocator.h"
#include "min_allocator.h"
template <class S>
void
test(S s)
{
S::allocator_type::throw_after = 0;
try
{
while (s.size() < s.capacity())
s.push_back(typename S::value_type());
assert(s.size() == s.capacity());
}
catch (...)
{
assert(false);
}
S::allocator_type::throw_after = INT_MAX;
}
int main()
{
{
typedef std::basic_string<char, std::char_traits<char>, test_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);
}
#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

@@ -0,0 +1,57 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// void clear();
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s)
{
s.clear();
assert(s.size() == 0);
}
int main()
{
{
typedef std::string S;
S s;
test(s);
s.assign(10, 'a');
s.erase(5);
test(s);
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

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// bool empty() const;
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(const S& s)
{
assert(s.empty() == (s.size() == 0));
}
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

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// size_type length() const;
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(const S& s)
{
assert(s.length() == s.size());
}
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

@@ -0,0 +1,73 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// size_type max_size() const;
// NOTE: asan and msan will fail for one of two reasons
// 1. If allocator_may_return_null=0 then they will fail because the allocation
// returns null.
// 2. If allocator_may_return_null=1 then they will fail because the allocation
// is too large to succeed.
// UNSUPPORTED: asan, msan
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test1(const S& s)
{
S s2(s);
const size_t sz = s2.max_size() - 1;
try { s2.resize(sz, 'x'); }
catch ( const std::bad_alloc & ) { return ; }
assert ( s2.size() == sz );
}
template <class S>
void
test2(const S& s)
{
S s2(s);
const size_t sz = s2.max_size();
try { s2.resize(sz, 'x'); }
catch ( const std::bad_alloc & ) { return ; }
assert ( s.size() == sz );
}
template <class S>
void
test(const S& s)
{
assert(s.max_size() >= s.size());
test1(s);
test2(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

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// size_type max_size() const;
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(const S& s)
{
assert(s.max_size() >= s.size());
S s2(s);
const size_t sz = s2.max_size() + 1;
try { s2.resize(sz, 'x'); }
catch ( const std::length_error & ) { return ; }
assert ( false );
}
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

@@ -0,0 +1,117 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// void reserve(size_type res_arg=0);
#include <string>
#include <stdexcept>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s)
{
typename S::size_type old_cap = s.capacity();
S s0 = s;
s.reserve();
assert(s.__invariants());
assert(s == s0);
assert(s.capacity() <= old_cap);
assert(s.capacity() >= s.size());
}
template <class S>
void
test(S s, typename S::size_type res_arg)
{
typename S::size_type old_cap = s.capacity();
S s0 = s;
try
{
s.reserve(res_arg);
assert(res_arg <= s.max_size());
assert(s == s0);
assert(s.capacity() >= res_arg);
assert(s.capacity() >= s.size());
}
catch (std::length_error&)
{
assert(res_arg > s.max_size());
}
}
int main()
{
{
typedef std::string 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);
}
}
#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

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// void resize(size_type n);
#include <string>
#include <stdexcept>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s, typename S::size_type n, S expected)
{
try
{
s.resize(n);
assert(s.__invariants());
assert(n <= s.max_size());
assert(s == expected);
}
catch (std::length_error&)
{
assert(n > s.max_size());
}
}
int main()
{
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// void resize(size_type n, charT c);
#include <string>
#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)
{
try
{
s.resize(n, c);
assert(s.__invariants());
assert(n <= s.max_size());
assert(s == expected);
}
catch (std::length_error&)
{
assert(n > s.max_size());
}
}
int main()
{
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,62 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// void shrink_to_fit();
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s)
{
typename S::size_type old_cap = s.capacity();
S s0 = s;
s.shrink_to_fit();
assert(s.__invariants());
assert(s == s0);
assert(s.capacity() <= old_cap);
assert(s.capacity() >= s.size());
}
int main()
{
{
typedef std::string S;
S s;
test(s);
s.assign(10, 'a');
s.erase(5);
test(s);
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

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// size_type size() const;
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(const S& s, typename S::size_type c)
{
assert(s.size() == 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

@@ -0,0 +1,74 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// explicit basic_string(const Allocator& a = Allocator());
#include <string>
#include <cassert>
#include "test_allocator.h"
#include "min_allocator.h"
template <class S>
void
test()
{
{
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(5));
assert(s.__invariants());
assert(s.data());
assert(s.size() == 0);
assert(s.capacity() >= s.size());
assert(s.get_allocator() == typename S::allocator_type(5));
}
}
#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

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>& operator=(charT c);
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s1, typename S::value_type s2)
{
typedef typename S::traits_type T;
s1 = s2;
assert(s1.__invariants());
assert(s1.size() == 1);
assert(T::eq(s1[0], s2));
assert(s1.capacity() >= s1.size());
}
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

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string(const basic_string<charT,traits,Allocator>& str);
#include <string>
#include <cassert>
#include "test_allocator.h"
#include "min_allocator.h"
template <class S>
void
test(S s1)
{
S s2 = s1;
assert(s2.__invariants());
assert(s2 == s1);
assert(s2.capacity() >= s2.size());
assert(s2.get_allocator() == s1.get_allocator());
}
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

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string(const basic_string& str, const Allocator& alloc);
#include <string>
#include <cassert>
#include "test_allocator.h"
#include "min_allocator.h"
template <class S>
void
test(S s1, const typename S::allocator_type& a)
{
S s2(s1, a);
assert(s2.__invariants());
assert(s2 == s1);
assert(s2.capacity() >= s2.size());
assert(s2.get_allocator() == 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

@@ -0,0 +1,70 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>&
// operator=(const basic_string<charT,traits,Allocator>& str);
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s1, const S& s2)
{
s1 = s2;
assert(s1.__invariants());
assert(s1 == s2);
assert(s1.capacity() >= s1.size());
}
int main()
{
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,45 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string()
// noexcept(is_nothrow_default_constructible<allocator_type>::value);
// This tests a conforming extension
#include <string>
#include <cassert>
#include "test_allocator.h"
template <class T>
struct some_alloc
{
typedef T value_type;
some_alloc(const some_alloc&);
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::string C;
static_assert(std::is_nothrow_default_constructible<C>::value, "");
}
{
typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
static_assert(std::is_nothrow_default_constructible<C>::value, "");
}
{
typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
}
#endif
}

View File

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// ~basic_string() // implied noexcept;
#include <string>
#include <cassert>
#include "test_allocator.h"
#if __has_feature(cxx_noexcept)
template <class T>
struct some_alloc
{
typedef T value_type;
some_alloc(const some_alloc&);
~some_alloc() noexcept(false);
};
#endif
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::string C;
static_assert(std::is_nothrow_destructible<C>::value, "");
}
{
typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
static_assert(std::is_nothrow_destructible<C>::value, "");
}
{
typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
static_assert(!std::is_nothrow_destructible<C>::value, "");
}
#endif
}

View File

@@ -0,0 +1,46 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string(initializer_list<charT> il, const Allocator& a = Allocator());
#include <string>
#include <cassert>
#include "test_allocator.h"
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::string s = {'a', 'b', 'c'};
assert(s == "abc");
}
{
std::wstring s;
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

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string& operator=(initializer_list<charT> il);
#include <string>
#include <cassert>
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::string s;
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

@@ -0,0 +1,119 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// template<class InputIterator>
// basic_string(InputIterator begin, InputIterator end,
// const Allocator& a = Allocator());
#include <string>
#include <iterator>
#include <cassert>
#include "test_allocator.h"
#include "../input_iterator.h"
#include "min_allocator.h"
template <class It>
void
test(It first, It last)
{
typedef typename std::iterator_traits<It>::value_type charT;
typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
typedef typename S::traits_type T;
typedef typename S::allocator_type A;
S s2(first, last);
assert(s2.__invariants());
assert(s2.size() == std::distance(first, last));
unsigned i = 0;
for (It it = first; it != last; ++it, ++i)
assert(s2[i] == *it);
assert(s2.get_allocator() == A());
assert(s2.capacity() >= s2.size());
}
template <class It, class A>
void
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>, A> S;
typedef typename S::traits_type T;
S s2(first, last, a);
assert(s2.__invariants());
assert(s2.size() == std::distance(first, last));
unsigned i = 0;
for (It it = first; it != last; ++it, ++i)
assert(s2[i] == *it);
assert(s2.get_allocator() == a);
assert(s2.capacity() >= s2.size());
}
int main()
{
{
typedef test_allocator<char> A;
const char* s = "12345678901234567890123456789012345678901234567890";
test(s, s);
test(s, s, A(2));
test(s, s+1);
test(s, s+1, A(2));
test(s, s+10);
test(s, s+10, A(2));
test(s, s+50);
test(s, s+50, A(2));
test(input_iterator<const char*>(s), input_iterator<const char*>(s));
test(input_iterator<const char*>(s), input_iterator<const char*>(s), A(2));
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(2));
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(2));
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

@@ -0,0 +1,57 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string(basic_string<charT,traits,Allocator>&& str);
#include <string>
#include <cassert>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include "test_allocator.h"
#include "min_allocator.h"
template <class S>
void
test(S s0)
{
S s1 = s0;
S s2 = std::move(s0);
assert(s2.__invariants());
assert(s0.__invariants());
assert(s2 == s1);
assert(s2.capacity() >= s2.size());
assert(s2.get_allocator() == s1.get_allocator());
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
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

@@ -0,0 +1,68 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string(basic_string&& str, const Allocator& alloc);
#include <string>
#include <cassert>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include "test_allocator.h"
#include "min_allocator.h"
template <class S>
void
test(S s0, const typename S::allocator_type& a)
{
S s1 = s0;
S s2(std::move(s0), a);
assert(s2.__invariants());
assert(s0.__invariants());
assert(s2 == s1);
assert(s2.capacity() >= s2.size());
assert(s2.get_allocator() == a);
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
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));
}
int alloc_count = test_alloc_base::alloc_count;
{
typedef test_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
S s1 ( "Twas brillig, and the slivy toves did gyre and gymbal in the wabe" );
S s2 (std::move(s1), A(1));
}
assert ( test_alloc_base::alloc_count == alloc_count );
#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

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string& operator=(basic_string&& c)
// noexcept(
// allocator_type::propagate_on_container_move_assignment::value &&
// is_nothrow_move_assignable<allocator_type>::value);
// This tests a conforming extension
#include <string>
#include <cassert>
#include "test_allocator.h"
template <class T>
struct some_alloc
{
typedef T value_type;
some_alloc(const some_alloc&);
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::string C;
static_assert(std::is_nothrow_move_assignable<C>::value, "");
}
{
typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
}
{
typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
}
#endif
}

View File

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>&
// operator=(basic_string<charT,traits,Allocator>&& str);
#include <string>
#include <cassert>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include "test_allocator.h"
#include "min_allocator.h"
template <class S>
void
test(S s1, S s2)
{
S s0 = s2;
s1 = std::move(s2);
assert(s1.__invariants());
assert(s2.__invariants());
assert(s1 == s0);
assert(s1.capacity() >= s1.size());
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,45 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string(basic_string&&)
// noexcept(is_nothrow_move_constructible<allocator_type>::value);
// This tests a conforming extension
#include <string>
#include <cassert>
#include "test_allocator.h"
template <class T>
struct some_alloc
{
typedef T value_type;
some_alloc(const some_alloc&);
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::string C;
static_assert(std::is_nothrow_move_constructible<C>::value, "");
}
{
typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, "");
}
{
typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
static_assert(!std::is_nothrow_move_constructible<C>::value, "");
}
#endif
}

View File

@@ -0,0 +1,89 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string(const charT* s, const Allocator& a = Allocator());
#include <string>
#include <stdexcept>
#include <algorithm>
#include <cassert>
#include "test_allocator.h"
#include "min_allocator.h"
template <class charT>
void
test(const charT* s)
{
typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
typedef typename S::traits_type T;
typedef typename S::allocator_type A;
unsigned n = T::length(s);
S s2(s);
assert(s2.__invariants());
assert(s2.size() == n);
assert(T::compare(s2.data(), s, n) == 0);
assert(s2.get_allocator() == A());
assert(s2.capacity() >= s2.size());
}
template <class charT, class A>
void
test(const charT* s, const A& a)
{
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
typedef typename S::traits_type T;
unsigned n = T::length(s);
S s2(s, a);
assert(s2.__invariants());
assert(s2.size() == n);
assert(T::compare(s2.data(), s, n) == 0);
assert(s2.get_allocator() == a);
assert(s2.capacity() >= s2.size());
}
int main()
{
{
typedef test_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
test("");
test("", A(2));
test("1");
test("1", A(2));
test("1234567980");
test("1234567980", A(2));
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

@@ -0,0 +1,72 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>&
// operator=(const charT* s);
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s1, const typename S::value_type* s2)
{
typedef typename S::traits_type T;
s1 = s2;
assert(s1.__invariants());
assert(s1.size() == T::length(s2));
assert(T::compare(s1.data(), s2, s1.size()) == 0);
assert(s1.capacity() >= s1.size());
}
int main()
{
{
typedef std::string 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");
}
#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

@@ -0,0 +1,87 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string(const charT* s, size_type n, const Allocator& a = Allocator());
#include <string>
#include <stdexcept>
#include <algorithm>
#include <cassert>
#include "test_allocator.h"
#include "min_allocator.h"
template <class charT>
void
test(const charT* s, unsigned n)
{
typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
typedef typename S::traits_type T;
typedef typename S::allocator_type A;
S s2(s, n);
assert(s2.__invariants());
assert(s2.size() == n);
assert(T::compare(s2.data(), s, n) == 0);
assert(s2.get_allocator() == A());
assert(s2.capacity() >= s2.size());
}
template <class charT, class A>
void
test(const charT* s, unsigned n, const A& a)
{
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
typedef typename S::traits_type T;
S s2(s, n, a);
assert(s2.__invariants());
assert(s2.size() == n);
assert(T::compare(s2.data(), s, n) == 0);
assert(s2.get_allocator() == a);
assert(s2.capacity() >= s2.size());
}
int main()
{
{
typedef test_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
test("", 0);
test("", 0, A(2));
test("1", 1);
test("1", 1, A(2));
test("1234567980", 10);
test("1234567980", 10, A(2));
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

@@ -0,0 +1,128 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string(size_type n, charT c, const Allocator& a = Allocator());
#include <string>
#include <stdexcept>
#include <algorithm>
#include <cassert>
#include "test_allocator.h"
#include "min_allocator.h"
template <class charT>
void
test(unsigned n, charT c)
{
typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
typedef typename S::traits_type T;
typedef typename S::allocator_type A;
S s2(n, c);
assert(s2.__invariants());
assert(s2.size() == n);
for (unsigned i = 0; i < n; ++i)
assert(s2[i] == c);
assert(s2.get_allocator() == A());
assert(s2.capacity() >= s2.size());
}
template <class charT, class A>
void
test(unsigned n, charT c, const A& a)
{
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
typedef typename S::traits_type T;
S s2(n, c, a);
assert(s2.__invariants());
assert(s2.size() == n);
for (unsigned i = 0; i < n; ++i)
assert(s2[i] == c);
assert(s2.get_allocator() == a);
assert(s2.capacity() >= s2.size());
}
template <class Tp>
void
test(Tp n, Tp c)
{
typedef char charT;
typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
typedef typename S::traits_type T;
typedef typename S::allocator_type A;
S s2(n, c);
assert(s2.__invariants());
assert(s2.size() == n);
for (unsigned i = 0; i < n; ++i)
assert(s2[i] == c);
assert(s2.get_allocator() == A());
assert(s2.capacity() >= s2.size());
}
template <class Tp, class A>
void
test(Tp n, Tp c, const A& a)
{
typedef char charT;
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
typedef typename S::traits_type T;
S s2(n, c, a);
assert(s2.__invariants());
assert(s2.size() == n);
for (unsigned i = 0; i < n; ++i)
assert(s2[i] == c);
assert(s2.get_allocator() == a);
assert(s2.capacity() >= s2.size());
}
int main()
{
{
typedef test_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
test(0, 'a');
test(0, 'a', A(2));
test(1, 'a');
test(1, 'a', A(2));
test(10, 'a');
test(10, 'a', A(2));
test(100, 'a');
test(100, 'a', A(2));
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

@@ -0,0 +1,173 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string(const basic_string<charT,traits,Allocator>& str,
// size_type pos, size_type n = npos,
// const Allocator& a = Allocator());
#include <string>
#include <stdexcept>
#include <algorithm>
#include <cassert>
#include "test_allocator.h"
#include "min_allocator.h"
template <class S>
void
test(S str, unsigned pos)
{
typedef typename S::traits_type T;
typedef typename S::allocator_type A;
try
{
S s2(str, pos);
assert(s2.__invariants());
assert(pos <= str.size());
unsigned rlen = str.size() - pos;
assert(s2.size() == rlen);
assert(T::compare(s2.data(), str.data() + pos, rlen) == 0);
assert(s2.get_allocator() == A());
assert(s2.capacity() >= s2.size());
}
catch (std::out_of_range&)
{
assert(pos > str.size());
}
}
template <class S>
void
test(S str, unsigned pos, unsigned n)
{
typedef typename S::traits_type T;
typedef typename S::allocator_type A;
try
{
S s2(str, pos, n);
assert(s2.__invariants());
assert(pos <= str.size());
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());
assert(s2.capacity() >= s2.size());
}
catch (std::out_of_range&)
{
assert(pos > str.size());
}
}
template <class S>
void
test(S str, unsigned pos, unsigned n, const typename S::allocator_type& a)
{
typedef typename S::traits_type T;
typedef typename S::allocator_type A;
try
{
S s2(str, pos, n, a);
assert(s2.__invariants());
assert(pos <= str.size());
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);
assert(s2.capacity() >= s2.size());
}
catch (std::out_of_range&)
{
assert(pos > str.size());
}
}
int main()
{
{
typedef test_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
test(S(A(3)), 0);
test(S(A(3)), 1);
test(S("1", A(5)), 0);
test(S("1", A(5)), 1);
test(S("1", A(5)), 2);
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 0);
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 5);
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50);
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 500);
test(S(A(3)), 0, 0);
test(S(A(3)), 0, 1);
test(S(A(3)), 1, 0);
test(S(A(3)), 1, 1);
test(S(A(3)), 1, 2);
test(S("1", A(5)), 0, 0);
test(S("1", A(5)), 0, 1);
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 0);
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 1);
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 10);
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 100);
test(S(A(3)), 0, 0, A(4));
test(S(A(3)), 0, 1, A(4));
test(S(A(3)), 1, 0, A(4));
test(S(A(3)), 1, 1, A(4));
test(S(A(3)), 1, 2, A(4));
test(S("1", A(5)), 0, 0, A(6));
test(S("1", A(5)), 0, 1, A(6));
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 0, A(8));
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

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// iterator begin();
// const_iterator begin() const;
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s)
{
const S& cs = s;
typename S::iterator b = s.begin();
typename S::const_iterator cb = cs.begin();
if (!s.empty())
{
assert(*b == s[0]);
}
assert(b == cb);
}
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

@@ -0,0 +1,45 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// const_iterator cbegin() const;
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(const S& s)
{
typename S::const_iterator cb = s.cbegin();
if (!s.empty())
{
assert(*cb == s[0]);
}
assert(cb == s.begin());
}
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

@@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// const_iterator cend() const;
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(const S& s)
{
typename S::const_iterator ce = s.cend();
assert(ce == s.end());
}
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

@@ -0,0 +1,45 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// const_reverse_iterator crbegin() const;
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(const S& s)
{
typename S::const_reverse_iterator cb = s.crbegin();
if (!s.empty())
{
assert(*cb == s.back());
}
assert(cb == s.rbegin());
}
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

@@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// const_reverse_iterator crend() const;
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(const S& s)
{
typename S::const_reverse_iterator ce = s.crend();
assert(ce == s.rend());
}
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

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Compare iterators from different containers with <.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <iterator>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef std::string S;
S s1;
S s2;
bool b = s1.begin() < s2.begin();
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s1;
S s2;
bool b = s1.begin() < s2.begin();
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Subtract iterators from different containers with <.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <iterator>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef std::string S;
S s1;
S s2;
int i = s1.begin() - s2.begin();
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s1;
S s2;
int i = s1.begin() - s2.begin();
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,54 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Index iterator out of bounds.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <iterator>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef std::string C;
C c(1, '\0');
C::iterator i = c.begin();
assert(i[0] == 0);
assert(i[1] == 0);
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
C c(1, '\0');
C::iterator i = c.begin();
assert(i[0] == 0);
assert(i[1] == 0);
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,58 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Add to iterator out of bounds.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <iterator>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef std::string C;
C c(1, '\0');
C::iterator i = c.begin();
i += 1;
assert(i == c.end());
i = c.begin();
i += 2;
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
C c(1, '\0');
C::iterator i = c.begin();
i += 1;
assert(i == c.end());
i = c.begin();
i += 2;
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,56 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Decrement iterator prior to begin.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <iterator>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef std::string C;
C c(1, '\0');
C::iterator i = c.end();
--i;
assert(i == c.begin());
--i;
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
C c(1, '\0');
C::iterator i = c.end();
--i;
assert(i == c.begin());
--i;
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,56 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Increment iterator past end.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <iterator>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef std::string C;
C c(1, '\0');
C::iterator i = c.begin();
++i;
assert(i == c.end());
++i;
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
C c(1, '\0');
C::iterator i = c.begin();
++i;
assert(i == c.end());
++i;
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Dereference non-dereferenceable iterator.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <iterator>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef std::string C;
C c(1, '\0');
C::iterator i = c.end();
char j = *i;
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
C c(1, '\0');
C::iterator i = c.end();
char j = *i;
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// iterator end();
// const_iterator end() const;
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s)
{
const S& cs = s;
typename S::iterator e = s.end();
typename S::const_iterator ce = cs.end();
if (s.empty())
{
assert(e == s.begin());
assert(ce == cs.begin());
}
assert(e - s.begin() == s.size());
assert(ce - cs.begin() == cs.size());
}
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

@@ -0,0 +1,73 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// iterator begin();
// iterator end();
// const_iterator begin() const;
// const_iterator end() const;
// const_iterator cbegin() const;
// const_iterator cend() const;
#include <string>
#include <cassert>
int main()
{
#if _LIBCPP_STD_VER > 11
{ // N3644 testing
typedef std::string C;
C::iterator ii1{}, ii2{};
C::iterator ii4 = ii1;
C::const_iterator cii{};
assert ( ii1 == ii2 );
assert ( ii1 == ii4 );
assert ( ii1 == cii );
assert ( !(ii1 != ii2 ));
assert ( !(ii1 != cii ));
}
{ // N3644 testing
typedef std::wstring C;
C::iterator ii1{}, ii2{};
C::iterator ii4 = ii1;
C::const_iterator cii{};
assert ( ii1 == ii2 );
assert ( ii1 == ii4 );
assert ( ii1 == cii );
assert ( !(ii1 != ii2 ));
assert ( !(ii1 != cii ));
}
{ // N3644 testing
typedef std::u16string C;
C::iterator ii1{}, ii2{};
C::iterator ii4 = ii1;
C::const_iterator cii{};
assert ( ii1 == ii2 );
assert ( ii1 == ii4 );
assert ( ii1 == cii );
assert ( !(ii1 != ii2 ));
assert ( !(ii1 != cii ));
}
{ // N3644 testing
typedef std::u32string C;
C::iterator ii1{}, ii2{};
C::iterator ii4 = ii1;
C::const_iterator cii{};
assert ( ii1 == ii2 );
assert ( ii1 == ii4 );
assert ( ii1 == cii );
assert ( !(ii1 != ii2 ));
assert ( !(ii1 != cii ));
}
#endif
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// reverse_iterator rbegin();
// const_reverse_iterator rbegin() const;
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s)
{
const S& cs = s;
typename S::reverse_iterator b = s.rbegin();
typename S::const_reverse_iterator cb = cs.rbegin();
if (!s.empty())
{
assert(*b == s.back());
}
assert(b == cb);
}
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

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// reverse_iterator rend();
// const_reverse_iterator rend() const;
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s)
{
const S& cs = s;
typename S::reverse_iterator e = s.rend();
typename S::const_reverse_iterator ce = cs.rend();
if (s.empty())
{
assert(e == s.rbegin());
assert(ce == cs.rbegin());
}
assert(e - s.rbegin() == s.size());
assert(ce - cs.rbegin() == cs.size());
}
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

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
int main()
{
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string& append(initializer_list<charT> il);
#include <string>
#include <cassert>
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::string s("123");
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

@@ -0,0 +1,150 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// template<class InputIterator>
// basic_string& append(InputIterator first, InputIterator last);
#include <string>
#include <cassert>
#include "../../input_iterator.h"
#include "min_allocator.h"
template <class S, class It>
void
test(S s, It first, It last, S expected)
{
s.append(first, last);
assert(s.__invariants());
assert(s == expected);
}
int main()
{
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,63 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>& append(const charT* s);
#include <string>
#include <stdexcept>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s, const typename S::value_type* str, S expected)
{
s.append(str);
assert(s.__invariants());
assert(s == expected);
}
int main()
{
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,72 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>&
// append(const charT* s, size_type n);
#include <string>
#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)
{
s.append(str, n);
assert(s.__invariants());
assert(s == expected);
}
int main()
{
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// void push_back(charT c)
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s, typename S::value_type c, S expected)
{
s.push_back(c);
assert(s.__invariants());
assert(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

@@ -0,0 +1,63 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>&
// append(size_type n, charT c);
#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)
{
s.append(n, c);
assert(s.__invariants());
assert(s == expected);
}
int main()
{
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>&
// append(const basic_string<charT,traits>& str);
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s, S str, S expected)
{
s.append(str);
assert(s.__invariants());
assert(s == expected);
}
int main()
{
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,118 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>&
// append(const basic_string<charT,traits>& str, size_type pos, size_type n = npos);
// the "= npos" was added for C++14
#include <string>
#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)
{
try
{
s.append(str, pos, n);
assert(s.__invariants());
assert(pos <= str.size());
assert(s == expected);
}
catch (std::out_of_range&)
{
assert(pos > str.size());
}
}
template <class S>
void
test_npos(S s, S str, typename S::size_type pos, S expected)
{
try
{
s.append(str, pos);
assert(s.__invariants());
assert(pos <= str.size());
assert(s == expected);
}
catch (std::out_of_range&)
{
assert(pos > str.size());
}
}
int main()
{
{
typedef std::string 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"));
}
#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
{
typedef std::string S;
test_npos(S(), S(), 0, S());
test_npos(S(), S(), 1, S());
test_npos(S(), S("12345"), 0, S("12345"));
test_npos(S(), S("12345"), 1, S("2345"));
test_npos(S(), S("12345"), 3, S("45"));
test_npos(S(), S("12345"), 5, S(""));
test_npos(S(), S("12345"), 6, S("not happening"));
}
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string& assign(initializer_list<charT> il);
#include <string>
#include <cassert>
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::string s("123");
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

@@ -0,0 +1,150 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// template<class InputIterator>
// basic_string& assign(InputIterator first, InputIterator last);
#include <string>
#include <cassert>
#include "../../input_iterator.h"
#include "min_allocator.h"
template <class S, class It>
void
test(S s, It first, It last, S expected)
{
s.assign(first, last);
assert(s.__invariants());
assert(s == expected);
}
int main()
{
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,63 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>& assign(const charT* s);
#include <string>
#include <stdexcept>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s, const typename S::value_type* str, S expected)
{
s.assign(str);
assert(s.__invariants());
assert(s == expected);
}
int main()
{
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,72 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>&
// assign(const charT* s, size_type n);
#include <string>
#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)
{
s.assign(str, n);
assert(s.__invariants());
assert(s == expected);
}
int main()
{
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>&
// assign(basic_string<charT,traits>&& str);
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s, S str, S expected)
{
s.assign(std::move(str));
assert(s.__invariants());
assert(s == expected);
}
int main()
{
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,63 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>&
// assign(size_type n, charT c);
#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)
{
s.assign(n, c);
assert(s.__invariants());
assert(s == expected);
}
int main()
{
{
typedef std::string 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'));
}
#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

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>&
// assign(const basic_string<charT,traits>& str);
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s, S str, S expected)
{
s.assign(str);
assert(s.__invariants());
assert(s == expected);
}
int main()
{
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,118 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>&
// assign(const basic_string<charT,traits>& str, size_type pos, size_type n=npos);
// the =npos was added for C++14
#include <string>
#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)
{
try
{
s.assign(str, pos, n);
assert(s.__invariants());
assert(pos <= str.size());
assert(s == expected);
}
catch (std::out_of_range&)
{
assert(pos > str.size());
}
}
template <class S>
void
test_npos(S s, S str, typename S::size_type pos, S expected)
{
try
{
s.assign(str, pos);
assert(s.__invariants());
assert(pos <= str.size());
assert(s == expected);
}
catch (std::out_of_range&)
{
assert(pos > str.size());
}
}
int main()
{
{
typedef std::string 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"));
}
#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
{
typedef std::string S;
test_npos(S(), S(), 0, S());
test_npos(S(), S(), 1, S());
test_npos(S(), S("12345"), 0, S("12345"));
test_npos(S(), S("12345"), 1, S("2345"));
test_npos(S(), S("12345"), 3, S("45"));
test_npos(S(), S("12345"), 5, S(""));
test_npos(S(), S("12345"), 6, S("not happening"));
}
}

View File

@@ -0,0 +1,170 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// size_type copy(charT* s, size_type n, size_type pos = 0) const;
#include <string>
#include <stdexcept>
#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,
typename S::size_type pos)
{
try
{
const S& cs = str;
typename S::size_type r = cs.copy(s, n, pos);
assert(pos <= cs.size());
typename S::size_type rlen = std::min(n, cs.size() - pos);
assert(r == rlen);
for (r = 0; r < rlen; ++r)
assert(S::traits_type::eq(cs[pos+r], s[r]));
}
catch (std::out_of_range&)
{
assert(pos > str.size());
}
}
int main()
{
{
typedef std::string 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);
}
#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

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Call erase(const_iterator position) with end()
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <cstdlib>
#include <exception>
#include "min_allocator.h"
int main()
{
{
std::string l1("123");
std::string::const_iterator i = l1.end();
l1.erase(i);
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S l1("123");
S::const_iterator i = l1.end();
l1.erase(i);
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Call erase(const_iterator position) with iterator from another container
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <cstdlib>
#include <exception>
#include "min_allocator.h"
int main()
{
{
std::string l1("123");
std::string l2("123");
std::string::const_iterator i = l2.begin();
l1.erase(i);
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S l1("123");
S l2("123");
S::const_iterator i = l2.begin();
l1.erase(i);
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Call erase(const_iterator first, const_iterator last); with first iterator from another container
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
std::string l1("123");
std::string l2("123");
std::string::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S l1("123");
S l2("123");
S::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Call erase(const_iterator first, const_iterator last); with second iterator from another container
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
std::string l1("123");
std::string l2("123");
std::string::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S l1("123");
S l2("123");
S::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Call erase(const_iterator first, const_iterator last); with both iterators from another container
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
std::string l1("123");
std::string l2("123");
std::string::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S l1("123");
S l2("123");
S::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// Call erase(const_iterator first, const_iterator last); with a bad range
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <string>
#include <cassert>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
std::string l1("123");
std::string::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
assert(false);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S l1("123");
S::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,64 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// iterator erase(const_iterator p);
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s, typename S::difference_type pos, S expected)
{
typename S::const_iterator p = s.begin() + pos;
typename S::iterator i = s.erase(p);
assert(s.__invariants());
assert(s == expected);
assert(i - s.begin() == pos);
}
int main()
{
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,149 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// iterator erase(const_iterator first, const_iterator last);
#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)
{
typename S::const_iterator first = s.cbegin() + pos;
typename S::const_iterator last = s.cbegin() + pos + n;
typename S::iterator i = s.erase(first, last);
assert(s.__invariants());
assert(s == expected);
assert(i - s.begin() == pos);
}
int main()
{
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,55 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// void pop_back();
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(S s, S expected)
{
s.pop_back();
assert(s.__invariants());
assert(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
#if _LIBCPP_DEBUG >= 1
{
std::string s;
s.pop_back();
assert(false);
}
#endif
}

View File

@@ -0,0 +1,280 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>&
// erase(size_type pos = 0, size_type n = npos);
#include <string>
#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)
{
typename S::size_type old_size = s.size();
S s0 = s;
try
{
s.erase(pos, n);
assert(s.__invariants());
assert(pos <= old_size);
assert(s == expected);
}
catch (std::out_of_range&)
{
assert(pos > old_size);
assert(s == s0);
}
}
template <class S>
void
test(S s, typename S::size_type pos, S expected)
{
typename S::size_type old_size = s.size();
S s0 = s;
try
{
s.erase(pos);
assert(s.__invariants());
assert(pos <= old_size);
assert(s == expected);
}
catch (std::out_of_range&)
{
assert(pos > old_size);
assert(s == s0);
}
}
template <class S>
void
test(S s, S expected)
{
s.erase();
assert(s.__invariants());
assert(s == expected);
}
int main()
{
{
typedef std::string 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(""));
}
#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

@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// iterator insert(const_iterator p, charT c);
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
#include <string>
#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)
{
bool sufficient_cap = s.size() < s.capacity();
typename S::difference_type pos = p - s.begin();
typename S::iterator i = s.insert(p, c);
assert(s.__invariants());
assert(s == expected);
assert(i - s.begin() == pos);
assert(*i == c);
if (sufficient_cap)
assert(i == p);
}
int main()
{
{
typedef std::string 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"));
}
#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
#if _LIBCPP_DEBUG >= 1
{
typedef std::string S;
S s;
S s2;
s.insert(s2.begin(), '1');
assert(false);
}
#endif
}

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// iterator insert(const_iterator p, initializer_list<charT> il);
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
#include <string>
#include <cassert>
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::string s("123456");
std::string::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'});
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
#if _LIBCPP_DEBUG >= 1
{
std::string s;
std::string s2;
s.insert(s2.begin(), {'a', 'b', 'c'});
assert(false);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,140 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// template<class InputIterator>
// iterator insert(const_iterator p, InputIterator first, InputIterator last);
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
#include <string>
#include <cassert>
#include "../../input_iterator.h"
#include "min_allocator.h"
template <class S, class It>
void
test(S s, typename S::difference_type pos, It first, It last, S expected)
{
typename S::const_iterator p = s.cbegin() + pos;
typename S::iterator i = s.insert(p, first, last);
assert(s.__invariants());
assert(i - s.begin() == pos);
assert(s == expected);
}
int main()
{
{
typedef std::string 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"));
}
#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
#if _LIBCPP_DEBUG >= 1
{
std::string v;
std::string v2;
char a[] = "123";
const int N = sizeof(a)/sizeof(a[0]);
std::string::iterator i = v.insert(v2.cbegin() + 10, a, a+N);
assert(false);
}
#endif
}

View File

@@ -0,0 +1,181 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// iterator insert(const_iterator p, size_type n, charT c);
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
#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,
typename S::value_type c, S expected)
{
typename S::const_iterator p = s.cbegin() + pos;
typename S::iterator i = s.insert(p, n, c);
assert(s.__invariants());
assert(i - s.begin() == pos);
assert(s == expected);
}
int main()
{
{
typedef std::string 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"));
}
#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
#if _LIBCPP_DEBUG >= 1
{
std::string s;
std::string s2;
s.insert(s2.begin(), 1, 'a');
assert(false);
}
#endif
}

View File

@@ -0,0 +1,211 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>&
// insert(size_type pos, const charT* s);
#include <string>
#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)
{
typename S::size_type old_size = s.size();
S s0 = s;
try
{
s.insert(pos, str);
assert(s.__invariants());
assert(pos <= old_size);
assert(s == expected);
}
catch (std::out_of_range&)
{
assert(pos > old_size);
assert(s == s0);
}
}
int main()
{
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,692 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>&
// insert(size_type pos, const charT* s, size_type n);
#include <string>
#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,
typename S::size_type n, S expected)
{
typename S::size_type old_size = s.size();
S s0 = s;
try
{
s.insert(pos, str, n);
assert(s.__invariants());
assert(pos <= old_size);
assert(s == expected);
}
catch (std::out_of_range&)
{
assert(pos > old_size);
assert(s == s0);
}
}
int main()
{
{
typedef std::string 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"));
}
#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

@@ -0,0 +1,212 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// basic_string<charT,traits,Allocator>&
// insert(size_type pos, size_type n, charT c);
#include <string>
#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,
typename S::value_type str, S expected)
{
typename S::size_type old_size = s.size();
S s0 = s;
try
{
s.insert(pos, n, str);
assert(s.__invariants());
assert(pos <= old_size);
assert(s == expected);
}
catch (std::out_of_range&)
{
assert(pos > old_size);
assert(s == s0);
}
}
int main()
{
{
typedef std::string 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"));
}
#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
}

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