diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
commit | 61b9a7258a7693d7f3674a5a1daf7b036ff1d382 (patch) | |
tree | ec41ed70ffca97240e76f9a78bb2dedba28f310c /test/std/strings | |
parent | f857581820d15e410e9945d2fcd5f7163be25a96 (diff) | |
download | src-61b9a7258a7693d7f3674a5a1daf7b036ff1d382.tar.gz src-61b9a7258a7693d7f3674a5a1daf7b036ff1d382.zip |
Import libc++ 3.7.0 release (r246257).vendor/libc++/libc++-release_370-r246257
Notes
Notes:
svn path=/vendor/libc++/dist/; revision=287518
svn path=/vendor/libc++/libc++-release_370-r246257/; revision=287519; tag=vendor/libc++/libc++-release_370-r246257
Diffstat (limited to 'test/std/strings')
275 files changed, 40914 insertions, 0 deletions
diff --git a/test/std/strings/basic.string.hash/strings.pass.cpp b/test/std/strings/basic.string.hash/strings.pass.cpp new file mode 100644 index 000000000000..5fc32c06a701 --- /dev/null +++ b/test/std/strings/basic.string.hash/strings.pass.cpp @@ -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_same<typename H::argument_type, T>::value), "" ); + static_assert((std::is_same<typename H::result_type, std::size_t>::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>(); +} diff --git a/test/std/strings/basic.string.literals/literal.pass.cpp b/test/std/strings/basic.string.literals/literal.pass.cpp new file mode 100644 index 000000000000..dbb5f681395b --- /dev/null +++ b/test/std/strings/basic.string.literals/literal.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string.literals/literal1.fail.cpp b/test/std/strings/basic.string.literals/literal1.fail.cpp new file mode 100644 index 000000000000..6ba0b30d458d --- /dev/null +++ b/test/std/strings/basic.string.literals/literal1.fail.cpp @@ -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 +} diff --git a/test/std/strings/basic.string.literals/literal1.pass.cpp b/test/std/strings/basic.string.literals/literal1.pass.cpp new file mode 100644 index 000000000000..f5143746b0bb --- /dev/null +++ b/test/std/strings/basic.string.literals/literal1.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string.literals/literal2.fail.cpp b/test/std/strings/basic.string.literals/literal2.fail.cpp new file mode 100644 index 000000000000..68f1d254e327 --- /dev/null +++ b/test/std/strings/basic.string.literals/literal2.fail.cpp @@ -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 +} diff --git a/test/std/strings/basic.string.literals/literal2.pass.cpp b/test/std/strings/basic.string.literals/literal2.pass.cpp new file mode 100644 index 000000000000..86d28e60e52b --- /dev/null +++ b/test/std/strings/basic.string.literals/literal2.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string.literals/literal3.pass.cpp b/test/std/strings/basic.string.literals/literal3.pass.cpp new file mode 100644 index 000000000000..98e3e40e058c --- /dev/null +++ b/test/std/strings/basic.string.literals/literal3.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/input_iterator.h b/test/std/strings/basic.string/input_iterator.h new file mode 100644 index 000000000000..fa6bb80a1499 --- /dev/null +++ b/test/std/strings/basic.string/input_iterator.h @@ -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 diff --git a/test/std/strings/basic.string/string.access/at.pass.cpp b/test/std/strings/basic.string/string.access/at.pass.cpp new file mode 100644 index 000000000000..8fada8fb1eea --- /dev/null +++ b/test/std/strings/basic.string/string.access/at.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.access/back.pass.cpp b/test/std/strings/basic.string/string.access/back.pass.cpp new file mode 100644 index 000000000000..e91521441b80 --- /dev/null +++ b/test/std/strings/basic.string/string.access/back.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.access/db_back.pass.cpp b/test/std/strings/basic.string/string.access/db_back.pass.cpp new file mode 100644 index 000000000000..2b31fabc7c70 --- /dev/null +++ b/test/std/strings/basic.string/string.access/db_back.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.access/db_cback.pass.cpp b/test/std/strings/basic.string/string.access/db_cback.pass.cpp new file mode 100644 index 000000000000..7feb4239f07a --- /dev/null +++ b/test/std/strings/basic.string/string.access/db_cback.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.access/db_cfront.pass.cpp b/test/std/strings/basic.string/string.access/db_cfront.pass.cpp new file mode 100644 index 000000000000..9f7785b85cda --- /dev/null +++ b/test/std/strings/basic.string/string.access/db_cfront.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.access/db_cindex.pass.cpp b/test/std/strings/basic.string/string.access/db_cindex.pass.cpp new file mode 100644 index 000000000000..6294200104ba --- /dev/null +++ b/test/std/strings/basic.string/string.access/db_cindex.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.access/db_front.pass.cpp b/test/std/strings/basic.string/string.access/db_front.pass.cpp new file mode 100644 index 000000000000..ff675bc5c217 --- /dev/null +++ b/test/std/strings/basic.string/string.access/db_front.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.access/db_index.pass.cpp b/test/std/strings/basic.string/string.access/db_index.pass.cpp new file mode 100644 index 000000000000..b20e20188023 --- /dev/null +++ b/test/std/strings/basic.string/string.access/db_index.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.access/front.pass.cpp b/test/std/strings/basic.string/string.access/front.pass.cpp new file mode 100644 index 000000000000..ed80916f16f0 --- /dev/null +++ b/test/std/strings/basic.string/string.access/front.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.access/index.pass.cpp b/test/std/strings/basic.string/string.access/index.pass.cpp new file mode 100644 index 000000000000..cd3162385160 --- /dev/null +++ b/test/std/strings/basic.string/string.access/index.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.capacity/capacity.pass.cpp b/test/std/strings/basic.string/string.capacity/capacity.pass.cpp new file mode 100644 index 000000000000..bae762155527 --- /dev/null +++ b/test/std/strings/basic.string/string.capacity/capacity.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.capacity/clear.pass.cpp b/test/std/strings/basic.string/string.capacity/clear.pass.cpp new file mode 100644 index 000000000000..b73af7599344 --- /dev/null +++ b/test/std/strings/basic.string/string.capacity/clear.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.capacity/empty.pass.cpp b/test/std/strings/basic.string/string.capacity/empty.pass.cpp new file mode 100644 index 000000000000..ac65f5144858 --- /dev/null +++ b/test/std/strings/basic.string/string.capacity/empty.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.capacity/length.pass.cpp b/test/std/strings/basic.string/string.capacity/length.pass.cpp new file mode 100644 index 000000000000..d3ae1aaee036 --- /dev/null +++ b/test/std/strings/basic.string/string.capacity/length.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.capacity/max_size.pass.cpp b/test/std/strings/basic.string/string.capacity/max_size.pass.cpp new file mode 100644 index 000000000000..e4ff556d9e3f --- /dev/null +++ b/test/std/strings/basic.string/string.capacity/max_size.pass.cpp @@ -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: sanitizer-new-delete + +#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 +} diff --git a/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp b/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp new file mode 100644 index 000000000000..bbadb9ccc5a8 --- /dev/null +++ b/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.capacity/reserve.pass.cpp b/test/std/strings/basic.string/string.capacity/reserve.pass.cpp new file mode 100644 index 000000000000..a155825be752 --- /dev/null +++ b/test/std/strings/basic.string/string.capacity/reserve.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp b/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp new file mode 100644 index 000000000000..14fe209fd59a --- /dev/null +++ b/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp b/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp new file mode 100644 index 000000000000..f293df971f21 --- /dev/null +++ b/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp b/test/std/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp new file mode 100644 index 000000000000..aacbffd098f0 --- /dev/null +++ b/test/std/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.capacity/size.pass.cpp b/test/std/strings/basic.string/string.capacity/size.pass.cpp new file mode 100644 index 000000000000..21b475a8113f --- /dev/null +++ b/test/std/strings/basic.string/string.capacity/size.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.cons/alloc.pass.cpp b/test/std/strings/basic.string/string.cons/alloc.pass.cpp new file mode 100644 index 000000000000..1c4f2044834e --- /dev/null +++ b/test/std/strings/basic.string/string.cons/alloc.pass.cpp @@ -0,0 +1,95 @@ +//===----------------------------------------------------------------------===// +// +// 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_macros.h" +#include "test_allocator.h" +#include "min_allocator.h" + +template <class S> +void +test() +{ + { +#if TEST_STD_VER > 14 + static_assert((noexcept(S{})), "" ); +#elif TEST_STD_VER >= 11 + static_assert((noexcept(S()) == noexcept(typename S::allocator_type())), "" ); +#endif + 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()); + } + { +#if TEST_STD_VER > 14 + static_assert((noexcept(S{typename S::allocator_type{}})), "" ); +#elif TEST_STD_VER >= 11 + static_assert((noexcept(S(typename S::allocator_type())) == std::is_nothrow_copy_constructible<typename S::allocator_type>::value), "" ); +#endif + 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 TEST_STD_VER >= 11 + +template <class S> +void +test2() +{ + { +#if TEST_STD_VER > 14 + static_assert((noexcept(S{})), "" ); +#elif TEST_STD_VER >= 11 + static_assert((noexcept(S()) == noexcept(typename S::allocator_type())), "" ); +#endif + 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()); + } + { +#if TEST_STD_VER > 14 + static_assert((noexcept(S{typename S::allocator_type{}})), "" ); +#elif TEST_STD_VER >= 11 + static_assert((noexcept(S(typename S::allocator_type())) == std::is_nothrow_copy_constructible<typename S::allocator_type>::value), "" ); +#endif + 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 TEST_STD_VER >= 11 + test2<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >(); +#endif +} diff --git a/test/std/strings/basic.string/string.cons/char_assignment.pass.cpp b/test/std/strings/basic.string/string.cons/char_assignment.pass.cpp new file mode 100644 index 000000000000..1c582bc51637 --- /dev/null +++ b/test/std/strings/basic.string/string.cons/char_assignment.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.cons/copy.pass.cpp b/test/std/strings/basic.string/string.cons/copy.pass.cpp new file mode 100644 index 000000000000..9c9fc3230668 --- /dev/null +++ b/test/std/strings/basic.string/string.cons/copy.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp new file mode 100644 index 000000000000..cf8021019a2e --- /dev/null +++ b/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.cons/copy_assignment.pass.cpp b/test/std/strings/basic.string/string.cons/copy_assignment.pass.cpp new file mode 100644 index 000000000000..ccb6c599974b --- /dev/null +++ b/test/std/strings/basic.string/string.cons/copy_assignment.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.cons/default_noexcept.pass.cpp b/test/std/strings/basic.string/string.cons/default_noexcept.pass.cpp new file mode 100644 index 000000000000..af117103d827 --- /dev/null +++ b/test/std/strings/basic.string/string.cons/default_noexcept.pass.cpp @@ -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() +// noexcept(is_nothrow_default_constructible<allocator_type>::value); + +// This tests a conforming extension + +#include <string> +#include <cassert> + +#include "test_macros.h" +#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 +} diff --git a/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp b/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp new file mode 100644 index 000000000000..b3cc127fbc46 --- /dev/null +++ b/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.cons/initializer_list.pass.cpp b/test/std/strings/basic.string/string.cons/initializer_list.pass.cpp new file mode 100644 index 000000000000..d6ff8504e9da --- /dev/null +++ b/test/std/strings/basic.string/string.cons/initializer_list.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp b/test/std/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp new file mode 100644 index 000000000000..753076895359 --- /dev/null +++ b/test/std/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp new file mode 100644 index 000000000000..664cb80b10fe --- /dev/null +++ b/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.cons/move.pass.cpp b/test/std/strings/basic.string/string.cons/move.pass.cpp new file mode 100644 index 000000000000..b94f189ecb46 --- /dev/null +++ b/test/std/strings/basic.string/string.cons/move.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.cons/move_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/move_alloc.pass.cpp new file mode 100644 index 000000000000..a232a46bd9fb --- /dev/null +++ b/test/std/strings/basic.string/string.cons/move_alloc.pass.cpp @@ -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(basic_string&& str, const Allocator& alloc); + +#include <string> +#include <cassert> + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +#include "test_macros.h" +#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 +// #if _LIBCPP_STD_VER <= 14 +// _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); +// #else +// _NOEXCEPT; +// #endif + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef test_allocator<char> A; + typedef std::basic_string<char, std::char_traits<char>, A> S; +#if TEST_STD_VER > 14 + static_assert((noexcept(S{})), "" ); +#elif TEST_STD_VER >= 11 + static_assert((noexcept(S()) == std::is_nothrow_move_constructible<A>::value), "" ); +#endif + 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; +#if TEST_STD_VER > 14 + static_assert((noexcept(S{})), "" ); +#elif TEST_STD_VER >= 11 + static_assert((noexcept(S()) == std::is_nothrow_move_constructible<A>::value), "" ); +#endif + 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 TEST_STD_VER >= 11 + { + typedef min_allocator<char> A; + typedef std::basic_string<char, std::char_traits<char>, A> S; +#if TEST_STD_VER > 14 + static_assert((noexcept(S{})), "" ); +#elif TEST_STD_VER >= 11 + static_assert((noexcept(S()) == std::is_nothrow_move_constructible<A>::value), "" ); +#endif + test(S(), A()); + test(S("1"), A()); + test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A()); + } +#endif +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp b/test/std/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp new file mode 100644 index 000000000000..32c9514a9154 --- /dev/null +++ b/test/std/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.cons/move_assignment.pass.cpp b/test/std/strings/basic.string/string.cons/move_assignment.pass.cpp new file mode 100644 index 000000000000..5bc1c8a9153f --- /dev/null +++ b/test/std/strings/basic.string/string.cons/move_assignment.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.cons/move_noexcept.pass.cpp b/test/std/strings/basic.string/string.cons/move_noexcept.pass.cpp new file mode 100644 index 000000000000..b287a940cc82 --- /dev/null +++ b/test/std/strings/basic.string/string.cons/move_noexcept.pass.cpp @@ -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> + +// basic_string(basic_string&&) +// noexcept(is_nothrow_move_constructible<allocator_type>::value); + +// This tests a conforming extension + +#include <string> +#include <cassert> + +#include "test_macros.h" +#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; +#if TEST_STD_VER <= 14 + static_assert(!std::is_nothrow_move_constructible<C>::value, ""); +#else + static_assert( std::is_nothrow_move_constructible<C>::value, ""); +#endif + } +#endif +} diff --git a/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp new file mode 100644 index 000000000000..f6e9e00e590f --- /dev/null +++ b/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp b/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp new file mode 100644 index 000000000000..c691613379a2 --- /dev/null +++ b/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp new file mode 100644 index 000000000000..f1f107af20bb --- /dev/null +++ b/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp new file mode 100644 index 000000000000..4dfe9063a23e --- /dev/null +++ b/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.cons/substr.pass.cpp b/test/std/strings/basic.string/string.cons/substr.pass.cpp new file mode 100644 index 000000000000..2a9bf2ac88bb --- /dev/null +++ b/test/std/strings/basic.string/string.cons/substr.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.iterators/begin.pass.cpp b/test/std/strings/basic.string/string.iterators/begin.pass.cpp new file mode 100644 index 000000000000..55f2eb30f80a --- /dev/null +++ b/test/std/strings/basic.string/string.iterators/begin.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.iterators/cbegin.pass.cpp b/test/std/strings/basic.string/string.iterators/cbegin.pass.cpp new file mode 100644 index 000000000000..d0c6ddbb9508 --- /dev/null +++ b/test/std/strings/basic.string/string.iterators/cbegin.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.iterators/cend.pass.cpp b/test/std/strings/basic.string/string.iterators/cend.pass.cpp new file mode 100644 index 000000000000..6b86d263245b --- /dev/null +++ b/test/std/strings/basic.string/string.iterators/cend.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.iterators/crbegin.pass.cpp b/test/std/strings/basic.string/string.iterators/crbegin.pass.cpp new file mode 100644 index 000000000000..6f29f433f314 --- /dev/null +++ b/test/std/strings/basic.string/string.iterators/crbegin.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.iterators/crend.pass.cpp b/test/std/strings/basic.string/string.iterators/crend.pass.cpp new file mode 100644 index 000000000000..1fb422c080ac --- /dev/null +++ b/test/std/strings/basic.string/string.iterators/crend.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.iterators/db_iterators_2.pass.cpp b/test/std/strings/basic.string/string.iterators/db_iterators_2.pass.cpp new file mode 100644 index 000000000000..6cac1875ce81 --- /dev/null +++ b/test/std/strings/basic.string/string.iterators/db_iterators_2.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.iterators/db_iterators_3.pass.cpp b/test/std/strings/basic.string/string.iterators/db_iterators_3.pass.cpp new file mode 100644 index 000000000000..d90387e3a46d --- /dev/null +++ b/test/std/strings/basic.string/string.iterators/db_iterators_3.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.iterators/db_iterators_4.pass.cpp b/test/std/strings/basic.string/string.iterators/db_iterators_4.pass.cpp new file mode 100644 index 000000000000..c4a2d0a4baf6 --- /dev/null +++ b/test/std/strings/basic.string/string.iterators/db_iterators_4.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.iterators/db_iterators_5.pass.cpp b/test/std/strings/basic.string/string.iterators/db_iterators_5.pass.cpp new file mode 100644 index 000000000000..ce44cb1ba5b4 --- /dev/null +++ b/test/std/strings/basic.string/string.iterators/db_iterators_5.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.iterators/db_iterators_6.pass.cpp b/test/std/strings/basic.string/string.iterators/db_iterators_6.pass.cpp new file mode 100644 index 000000000000..8fab8babc613 --- /dev/null +++ b/test/std/strings/basic.string/string.iterators/db_iterators_6.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.iterators/db_iterators_7.pass.cpp b/test/std/strings/basic.string/string.iterators/db_iterators_7.pass.cpp new file mode 100644 index 000000000000..d1cac07e222b --- /dev/null +++ b/test/std/strings/basic.string/string.iterators/db_iterators_7.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.iterators/db_iterators_8.pass.cpp b/test/std/strings/basic.string/string.iterators/db_iterators_8.pass.cpp new file mode 100644 index 000000000000..914c77d48c5c --- /dev/null +++ b/test/std/strings/basic.string/string.iterators/db_iterators_8.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.iterators/end.pass.cpp b/test/std/strings/basic.string/string.iterators/end.pass.cpp new file mode 100644 index 000000000000..02180bbd73de --- /dev/null +++ b/test/std/strings/basic.string/string.iterators/end.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.iterators/iterators.pass.cpp b/test/std/strings/basic.string/string.iterators/iterators.pass.cpp new file mode 100644 index 000000000000..386cededa53f --- /dev/null +++ b/test/std/strings/basic.string/string.iterators/iterators.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.iterators/rbegin.pass.cpp b/test/std/strings/basic.string/string.iterators/rbegin.pass.cpp new file mode 100644 index 000000000000..0111ad113638 --- /dev/null +++ b/test/std/strings/basic.string/string.iterators/rbegin.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.iterators/rend.pass.cpp b/test/std/strings/basic.string/string.iterators/rend.pass.cpp new file mode 100644 index 000000000000..750173dc342e --- /dev/null +++ b/test/std/strings/basic.string/string.iterators/rend.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/nothing_to_do.pass.cpp b/test/std/strings/basic.string/string.modifiers/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..b58f5c55b643 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/nothing_to_do.pass.cpp @@ -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() +{ +} diff --git a/test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp new file mode 100644 index 000000000000..fb28e498c321 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp new file mode 100644 index 000000000000..3bf2afa25521 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp new file mode 100644 index 000000000000..5ae15f0a0a4a --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp new file mode 100644 index 000000000000..5a9e8e2b814b --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp new file mode 100644 index 000000000000..b0a2eb5e5cbd --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp new file mode 100644 index 000000000000..00e6ae375cce --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp new file mode 100644 index 000000000000..31f174b4f305 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp new file mode 100644 index 000000000000..e8f54f475240 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp @@ -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")); + } +} diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp new file mode 100644 index 000000000000..2dae10745965 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp new file mode 100644 index 000000000000..83b5dd14b3f6 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp new file mode 100644 index 000000000000..adf24ac49877 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp new file mode 100644 index 000000000000..476fe963de73 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp new file mode 100644 index 000000000000..4273860f41ad --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// 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 <utility> +#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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp new file mode 100644 index 000000000000..a8f747091c6d --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp new file mode 100644 index 000000000000..d7ddb77b8e0f --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp new file mode 100644 index 000000000000..5f5983e76c94 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp @@ -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")); + } +} diff --git a/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp new file mode 100644 index 000000000000..33801352816f --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_db1.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_db1.pass.cpp new file mode 100644 index 000000000000..6c2929d7f1d3 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_db1.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_db2.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_db2.pass.cpp new file mode 100644 index 000000000000..d20fcd4623b7 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_db2.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db1.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db1.pass.cpp new file mode 100644 index 000000000000..5015241ad63e --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db1.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db2.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db2.pass.cpp new file mode 100644 index 000000000000..6a23bf88ca5c --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db2.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db3.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db3.pass.cpp new file mode 100644 index 000000000000..a8443818aea5 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db3.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db4.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db4.pass.cpp new file mode 100644 index 000000000000..0549e816b44c --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db4.pass.cpp @@ -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 diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp new file mode 100644 index 000000000000..c44db71ae3b0 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp new file mode 100644 index 000000000000..dbe6d7ba0e73 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp new file mode 100644 index 000000000000..790ce40b0a00 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp new file mode 100644 index 000000000000..bc9ec1cf8255 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp new file mode 100644 index 000000000000..b9e5fa8bc064 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp new file mode 100644 index 000000000000..e091662eae06 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp new file mode 100644 index 000000000000..38353dd2f4e4 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp new file mode 100644 index 000000000000..739c89404c1d --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp new file mode 100644 index 000000000000..734dd8dffb78 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp new file mode 100644 index 000000000000..29b00ec55b9f --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp new file mode 100644 index 000000000000..fd85696704cd --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp @@ -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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp new file mode 100644 index 000000000000..8c18941cf46a --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp @@ -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 pos1, const basic_string& str); + +#include <string> +#include <stdexcept> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s, typename S::size_type pos, S 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(""), S("")); + test(S(""), 0, S("12345"), S("12345")); + test(S(""), 0, S("1234567890"), S("1234567890")); + test(S(""), 0, S("12345678901234567890"), S("12345678901234567890")); + test(S(""), 1, S(""), S("can't happen")); + test(S(""), 1, S("12345"), S("can't happen")); + test(S(""), 1, S("1234567890"), S("can't happen")); + test(S(""), 1, S("12345678901234567890"), S("can't happen")); + test(S("abcde"), 0, S(""), S("abcde")); + test(S("abcde"), 0, S("12345"), S("12345abcde")); + test(S("abcde"), 0, S("1234567890"), S("1234567890abcde")); + test(S("abcde"), 0, S("12345678901234567890"), S("12345678901234567890abcde")); + test(S("abcde"), 1, S(""), S("abcde")); + test(S("abcde"), 1, S("12345"), S("a12345bcde")); + test(S("abcde"), 1, S("1234567890"), S("a1234567890bcde")); + test(S("abcde"), 1, S("12345678901234567890"), S("a12345678901234567890bcde")); + test(S("abcde"), 2, S(""), S("abcde")); + test(S("abcde"), 2, S("12345"), S("ab12345cde")); + test(S("abcde"), 2, S("1234567890"), S("ab1234567890cde")); + test(S("abcde"), 2, S("12345678901234567890"), S("ab12345678901234567890cde")); + test(S("abcde"), 4, S(""), S("abcde")); + test(S("abcde"), 4, S("12345"), S("abcd12345e")); + test(S("abcde"), 4, S("1234567890"), S("abcd1234567890e")); + test(S("abcde"), 4, S("12345678901234567890"), S("abcd12345678901234567890e")); + test(S("abcde"), 5, S(""), S("abcde")); + test(S("abcde"), 5, S("12345"), S("abcde12345")); + test(S("abcde"), 5, S("1234567890"), S("abcde1234567890")); + test(S("abcde"), 5, S("12345678901234567890"), S("abcde12345678901234567890")); + test(S("abcde"), 6, S(""), S("can't happen")); + test(S("abcde"), 6, S("12345"), S("can't happen")); + test(S("abcde"), 6, S("1234567890"), S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), S("can't happen")); + test(S("abcdefghij"), 0, S(""), S("abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), S("12345abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghij")); + test(S("abcdefghij"), 1, S(""), S("abcdefghij")); + test(S("abcdefghij"), 1, S("12345"), S("a12345bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghij")); + test(S("abcdefghij"), 5, S(""), S("abcdefghij")); + test(S("abcdefghij"), 5, S("12345"), S("abcde12345fghij")); + test(S("abcdefghij"), 5, S("1234567890"), S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), S("abcde12345678901234567890fghij")); + test(S("abcdefghij"), 9, S(""), S("abcdefghij")); + test(S("abcdefghij"), 9, S("12345"), S("abcdefghi12345j")); + test(S("abcdefghij"), 9, S("1234567890"), S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), S("abcdefghi12345678901234567890j")); + test(S("abcdefghij"), 10, S(""), S("abcdefghij")); + test(S("abcdefghij"), 10, S("12345"), S("abcdefghij12345")); + test(S("abcdefghij"), 10, S("1234567890"), S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test(S("abcdefghij"), 11, S(""), S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 20, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 21, S(""), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), S("can't happen")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), 0, S(""), S("")); + test(S(""), 0, S("12345"), S("12345")); + test(S(""), 0, S("1234567890"), S("1234567890")); + test(S(""), 0, S("12345678901234567890"), S("12345678901234567890")); + test(S(""), 1, S(""), S("can't happen")); + test(S(""), 1, S("12345"), S("can't happen")); + test(S(""), 1, S("1234567890"), S("can't happen")); + test(S(""), 1, S("12345678901234567890"), S("can't happen")); + test(S("abcde"), 0, S(""), S("abcde")); + test(S("abcde"), 0, S("12345"), S("12345abcde")); + test(S("abcde"), 0, S("1234567890"), S("1234567890abcde")); + test(S("abcde"), 0, S("12345678901234567890"), S("12345678901234567890abcde")); + test(S("abcde"), 1, S(""), S("abcde")); + test(S("abcde"), 1, S("12345"), S("a12345bcde")); + test(S("abcde"), 1, S("1234567890"), S("a1234567890bcde")); + test(S("abcde"), 1, S("12345678901234567890"), S("a12345678901234567890bcde")); + test(S("abcde"), 2, S(""), S("abcde")); + test(S("abcde"), 2, S("12345"), S("ab12345cde")); + test(S("abcde"), 2, S("1234567890"), S("ab1234567890cde")); + test(S("abcde"), 2, S("12345678901234567890"), S("ab12345678901234567890cde")); + test(S("abcde"), 4, S(""), S("abcde")); + test(S("abcde"), 4, S("12345"), S("abcd12345e")); + test(S("abcde"), 4, S("1234567890"), S("abcd1234567890e")); + test(S("abcde"), 4, S("12345678901234567890"), S("abcd12345678901234567890e")); + test(S("abcde"), 5, S(""), S("abcde")); + test(S("abcde"), 5, S("12345"), S("abcde12345")); + test(S("abcde"), 5, S("1234567890"), S("abcde1234567890")); + test(S("abcde"), 5, S("12345678901234567890"), S("abcde12345678901234567890")); + test(S("abcde"), 6, S(""), S("can't happen")); + test(S("abcde"), 6, S("12345"), S("can't happen")); + test(S("abcde"), 6, S("1234567890"), S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), S("can't happen")); + test(S("abcdefghij"), 0, S(""), S("abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), S("12345abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghij")); + test(S("abcdefghij"), 1, S(""), S("abcdefghij")); + test(S("abcdefghij"), 1, S("12345"), S("a12345bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghij")); + test(S("abcdefghij"), 5, S(""), S("abcdefghij")); + test(S("abcdefghij"), 5, S("12345"), S("abcde12345fghij")); + test(S("abcdefghij"), 5, S("1234567890"), S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), S("abcde12345678901234567890fghij")); + test(S("abcdefghij"), 9, S(""), S("abcdefghij")); + test(S("abcdefghij"), 9, S("12345"), S("abcdefghi12345j")); + test(S("abcdefghij"), 9, S("1234567890"), S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), S("abcdefghi12345678901234567890j")); + test(S("abcdefghij"), 10, S(""), S("abcdefghij")); + test(S("abcdefghij"), 10, S("12345"), S("abcdefghij12345")); + test(S("abcdefghij"), 10, S("1234567890"), S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test(S("abcdefghij"), 11, S(""), S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 20, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 21, S(""), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), S("can't happen")); + } +#endif +} diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp new file mode 100644 index 000000000000..51c9e72fc56f --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp @@ -0,0 +1,1784 @@ +//===----------------------------------------------------------------------===// +// +// 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 pos1, const basic_string<charT,traits,Allocator>& str, +// size_type pos2, size_type n=npos); +// the "=npos" was added in C++14 + +#include <string> +#include <stdexcept> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s, typename S::size_type pos1, S str, typename S::size_type pos2, + typename S::size_type n, S expected) +{ + typename S::size_type old_size = s.size(); + S s0 = s; + try + { + s.insert(pos1, str, pos2, n); + assert(s.__invariants()); + assert(pos1 <= old_size && pos2 <= str.size()); + assert(s == expected); + } + catch (std::out_of_range&) + { + assert(pos1 > old_size || pos2 > str.size()); + assert(s == s0); + } +} + +template <class S> +void +test_npos(S s, typename S::size_type pos1, S str, typename S::size_type pos2, S expected) +{ + typename S::size_type old_size = s.size(); + S s0 = s; + try + { + s.insert(pos1, str, pos2); + assert(s.__invariants()); + assert(pos1 <= old_size && pos2 <= str.size()); + assert(s == expected); + } + catch (std::out_of_range&) + { + assert(pos1 > old_size || pos2 > str.size()); + assert(s == s0); + } +} + + +template <class S> +void test0() +{ + test(S(""), 0, S(""), 0, 0, S("")); + test(S(""), 0, S(""), 0, 1, S("")); + test(S(""), 0, S(""), 1, 0, S("can't happen")); + test(S(""), 0, S("12345"), 0, 0, S("")); + test(S(""), 0, S("12345"), 0, 1, S("1")); + test(S(""), 0, S("12345"), 0, 2, S("12")); + test(S(""), 0, S("12345"), 0, 4, S("1234")); + test(S(""), 0, S("12345"), 0, 5, S("12345")); + test(S(""), 0, S("12345"), 0, 6, S("12345")); + test(S(""), 0, S("12345"), 1, 0, S("")); + test(S(""), 0, S("12345"), 1, 1, S("2")); + test(S(""), 0, S("12345"), 1, 2, S("23")); + test(S(""), 0, S("12345"), 1, 3, S("234")); + test(S(""), 0, S("12345"), 1, 4, S("2345")); + test(S(""), 0, S("12345"), 1, 5, S("2345")); + test(S(""), 0, S("12345"), 2, 0, S("")); + test(S(""), 0, S("12345"), 2, 1, S("3")); + test(S(""), 0, S("12345"), 2, 2, S("34")); + test(S(""), 0, S("12345"), 2, 3, S("345")); + test(S(""), 0, S("12345"), 2, 4, S("345")); + test(S(""), 0, S("12345"), 4, 0, S("")); + test(S(""), 0, S("12345"), 4, 1, S("5")); + test(S(""), 0, S("12345"), 4, 2, S("5")); + test(S(""), 0, S("12345"), 5, 0, S("")); + test(S(""), 0, S("12345"), 5, 1, S("")); + test(S(""), 0, S("12345"), 6, 0, S("can't happen")); + test(S(""), 0, S("1234567890"), 0, 0, S("")); + test(S(""), 0, S("1234567890"), 0, 1, S("1")); + test(S(""), 0, S("1234567890"), 0, 5, S("12345")); + test(S(""), 0, S("1234567890"), 0, 9, S("123456789")); + test(S(""), 0, S("1234567890"), 0, 10, S("1234567890")); + test(S(""), 0, S("1234567890"), 0, 11, S("1234567890")); + test(S(""), 0, S("1234567890"), 1, 0, S("")); + test(S(""), 0, S("1234567890"), 1, 1, S("2")); + test(S(""), 0, S("1234567890"), 1, 4, S("2345")); + test(S(""), 0, S("1234567890"), 1, 8, S("23456789")); + test(S(""), 0, S("1234567890"), 1, 9, S("234567890")); + test(S(""), 0, S("1234567890"), 1, 10, S("234567890")); + test(S(""), 0, S("1234567890"), 5, 0, S("")); + test(S(""), 0, S("1234567890"), 5, 1, S("6")); + test(S(""), 0, S("1234567890"), 5, 2, S("67")); + test(S(""), 0, S("1234567890"), 5, 4, S("6789")); + test(S(""), 0, S("1234567890"), 5, 5, S("67890")); + test(S(""), 0, S("1234567890"), 5, 6, S("67890")); + test(S(""), 0, S("1234567890"), 9, 0, S("")); + test(S(""), 0, S("1234567890"), 9, 1, S("0")); + test(S(""), 0, S("1234567890"), 9, 2, S("0")); + test(S(""), 0, S("1234567890"), 10, 0, S("")); + test(S(""), 0, S("1234567890"), 10, 1, S("")); + test(S(""), 0, S("1234567890"), 11, 0, S("can't happen")); +} + +template <class S> +void test1() +{ + test(S(""), 0, S("12345678901234567890"), 0, 0, S("")); + test(S(""), 0, S("12345678901234567890"), 0, 1, S("1")); + test(S(""), 0, S("12345678901234567890"), 0, 10, S("1234567890")); + test(S(""), 0, S("12345678901234567890"), 0, 19, S("1234567890123456789")); + test(S(""), 0, S("12345678901234567890"), 0, 20, S("12345678901234567890")); + test(S(""), 0, S("12345678901234567890"), 0, 21, S("12345678901234567890")); + test(S(""), 0, S("12345678901234567890"), 1, 0, S("")); + test(S(""), 0, S("12345678901234567890"), 1, 1, S("2")); + test(S(""), 0, S("12345678901234567890"), 1, 9, S("234567890")); + test(S(""), 0, S("12345678901234567890"), 1, 18, S("234567890123456789")); + test(S(""), 0, S("12345678901234567890"), 1, 19, S("2345678901234567890")); + test(S(""), 0, S("12345678901234567890"), 1, 20, S("2345678901234567890")); + test(S(""), 0, S("12345678901234567890"), 10, 0, S("")); + test(S(""), 0, S("12345678901234567890"), 10, 1, S("1")); + test(S(""), 0, S("12345678901234567890"), 10, 5, S("12345")); + test(S(""), 0, S("12345678901234567890"), 10, 9, S("123456789")); + test(S(""), 0, S("12345678901234567890"), 10, 10, S("1234567890")); + test(S(""), 0, S("12345678901234567890"), 10, 11, S("1234567890")); + test(S(""), 0, S("12345678901234567890"), 19, 0, S("")); + test(S(""), 0, S("12345678901234567890"), 19, 1, S("0")); + test(S(""), 0, S("12345678901234567890"), 19, 2, S("0")); + test(S(""), 0, S("12345678901234567890"), 20, 0, S("")); + test(S(""), 0, S("12345678901234567890"), 20, 1, S("")); + test(S(""), 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S(""), 1, S(""), 0, 0, S("can't happen")); + test(S(""), 1, S(""), 0, 1, S("can't happen")); + test(S(""), 1, S(""), 1, 0, S("can't happen")); + test(S(""), 1, S("12345"), 0, 0, S("can't happen")); + test(S(""), 1, S("12345"), 0, 1, S("can't happen")); + test(S(""), 1, S("12345"), 0, 2, S("can't happen")); + test(S(""), 1, S("12345"), 0, 4, S("can't happen")); + test(S(""), 1, S("12345"), 0, 5, S("can't happen")); + test(S(""), 1, S("12345"), 0, 6, S("can't happen")); + test(S(""), 1, S("12345"), 1, 0, S("can't happen")); + test(S(""), 1, S("12345"), 1, 1, S("can't happen")); + test(S(""), 1, S("12345"), 1, 2, S("can't happen")); + test(S(""), 1, S("12345"), 1, 3, S("can't happen")); + test(S(""), 1, S("12345"), 1, 4, S("can't happen")); + test(S(""), 1, S("12345"), 1, 5, S("can't happen")); + test(S(""), 1, S("12345"), 2, 0, S("can't happen")); + test(S(""), 1, S("12345"), 2, 1, S("can't happen")); + test(S(""), 1, S("12345"), 2, 2, S("can't happen")); + test(S(""), 1, S("12345"), 2, 3, S("can't happen")); + test(S(""), 1, S("12345"), 2, 4, S("can't happen")); + test(S(""), 1, S("12345"), 4, 0, S("can't happen")); + test(S(""), 1, S("12345"), 4, 1, S("can't happen")); + test(S(""), 1, S("12345"), 4, 2, S("can't happen")); + test(S(""), 1, S("12345"), 5, 0, S("can't happen")); + test(S(""), 1, S("12345"), 5, 1, S("can't happen")); + test(S(""), 1, S("12345"), 6, 0, S("can't happen")); +} + +template <class S> +void test2() +{ + test(S(""), 1, S("1234567890"), 0, 0, S("can't happen")); + test(S(""), 1, S("1234567890"), 0, 1, S("can't happen")); + test(S(""), 1, S("1234567890"), 0, 5, S("can't happen")); + test(S(""), 1, S("1234567890"), 0, 9, S("can't happen")); + test(S(""), 1, S("1234567890"), 0, 10, S("can't happen")); + test(S(""), 1, S("1234567890"), 0, 11, S("can't happen")); + test(S(""), 1, S("1234567890"), 1, 0, S("can't happen")); + test(S(""), 1, S("1234567890"), 1, 1, S("can't happen")); + test(S(""), 1, S("1234567890"), 1, 4, S("can't happen")); + test(S(""), 1, S("1234567890"), 1, 8, S("can't happen")); + test(S(""), 1, S("1234567890"), 1, 9, S("can't happen")); + test(S(""), 1, S("1234567890"), 1, 10, S("can't happen")); + test(S(""), 1, S("1234567890"), 5, 0, S("can't happen")); + test(S(""), 1, S("1234567890"), 5, 1, S("can't happen")); + test(S(""), 1, S("1234567890"), 5, 2, S("can't happen")); + test(S(""), 1, S("1234567890"), 5, 4, S("can't happen")); + test(S(""), 1, S("1234567890"), 5, 5, S("can't happen")); + test(S(""), 1, S("1234567890"), 5, 6, S("can't happen")); + test(S(""), 1, S("1234567890"), 9, 0, S("can't happen")); + test(S(""), 1, S("1234567890"), 9, 1, S("can't happen")); + test(S(""), 1, S("1234567890"), 9, 2, S("can't happen")); + test(S(""), 1, S("1234567890"), 10, 0, S("can't happen")); + test(S(""), 1, S("1234567890"), 10, 1, S("can't happen")); + test(S(""), 1, S("1234567890"), 11, 0, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 0, 0, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 0, 1, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 0, 10, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 0, 19, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 0, 20, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 0, 21, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 1, 0, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 1, 1, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 1, 9, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 1, 18, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 1, 19, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 1, 20, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 10, 0, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 10, 1, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 10, 5, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 10, 9, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 10, 10, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 10, 11, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 19, 0, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 19, 1, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 19, 2, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 20, 0, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 20, 1, S("can't happen")); + test(S(""), 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 0, S(""), 0, 0, S("abcde")); + test(S("abcde"), 0, S(""), 0, 1, S("abcde")); +} + +template <class S> +void test3() +{ + test(S("abcde"), 0, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 0, S("12345"), 0, 0, S("abcde")); + test(S("abcde"), 0, S("12345"), 0, 1, S("1abcde")); + test(S("abcde"), 0, S("12345"), 0, 2, S("12abcde")); + test(S("abcde"), 0, S("12345"), 0, 4, S("1234abcde")); + test(S("abcde"), 0, S("12345"), 0, 5, S("12345abcde")); + test(S("abcde"), 0, S("12345"), 0, 6, S("12345abcde")); + test(S("abcde"), 0, S("12345"), 1, 0, S("abcde")); + test(S("abcde"), 0, S("12345"), 1, 1, S("2abcde")); + test(S("abcde"), 0, S("12345"), 1, 2, S("23abcde")); + test(S("abcde"), 0, S("12345"), 1, 3, S("234abcde")); + test(S("abcde"), 0, S("12345"), 1, 4, S("2345abcde")); + test(S("abcde"), 0, S("12345"), 1, 5, S("2345abcde")); + test(S("abcde"), 0, S("12345"), 2, 0, S("abcde")); + test(S("abcde"), 0, S("12345"), 2, 1, S("3abcde")); + test(S("abcde"), 0, S("12345"), 2, 2, S("34abcde")); + test(S("abcde"), 0, S("12345"), 2, 3, S("345abcde")); + test(S("abcde"), 0, S("12345"), 2, 4, S("345abcde")); + test(S("abcde"), 0, S("12345"), 4, 0, S("abcde")); + test(S("abcde"), 0, S("12345"), 4, 1, S("5abcde")); + test(S("abcde"), 0, S("12345"), 4, 2, S("5abcde")); + test(S("abcde"), 0, S("12345"), 5, 0, S("abcde")); + test(S("abcde"), 0, S("12345"), 5, 1, S("abcde")); + test(S("abcde"), 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 0, S("1234567890"), 0, 0, S("abcde")); + test(S("abcde"), 0, S("1234567890"), 0, 1, S("1abcde")); + test(S("abcde"), 0, S("1234567890"), 0, 5, S("12345abcde")); + test(S("abcde"), 0, S("1234567890"), 0, 9, S("123456789abcde")); + test(S("abcde"), 0, S("1234567890"), 0, 10, S("1234567890abcde")); + test(S("abcde"), 0, S("1234567890"), 0, 11, S("1234567890abcde")); + test(S("abcde"), 0, S("1234567890"), 1, 0, S("abcde")); + test(S("abcde"), 0, S("1234567890"), 1, 1, S("2abcde")); + test(S("abcde"), 0, S("1234567890"), 1, 4, S("2345abcde")); + test(S("abcde"), 0, S("1234567890"), 1, 8, S("23456789abcde")); + test(S("abcde"), 0, S("1234567890"), 1, 9, S("234567890abcde")); + test(S("abcde"), 0, S("1234567890"), 1, 10, S("234567890abcde")); + test(S("abcde"), 0, S("1234567890"), 5, 0, S("abcde")); + test(S("abcde"), 0, S("1234567890"), 5, 1, S("6abcde")); + test(S("abcde"), 0, S("1234567890"), 5, 2, S("67abcde")); + test(S("abcde"), 0, S("1234567890"), 5, 4, S("6789abcde")); + test(S("abcde"), 0, S("1234567890"), 5, 5, S("67890abcde")); + test(S("abcde"), 0, S("1234567890"), 5, 6, S("67890abcde")); + test(S("abcde"), 0, S("1234567890"), 9, 0, S("abcde")); + test(S("abcde"), 0, S("1234567890"), 9, 1, S("0abcde")); + test(S("abcde"), 0, S("1234567890"), 9, 2, S("0abcde")); + test(S("abcde"), 0, S("1234567890"), 10, 0, S("abcde")); + test(S("abcde"), 0, S("1234567890"), 10, 1, S("abcde")); + test(S("abcde"), 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 0, S("12345678901234567890"), 0, 0, S("abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 0, 1, S("1abcde")); +} + +template <class S> +void test4() +{ + test(S("abcde"), 0, S("12345678901234567890"), 0, 10, S("1234567890abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 1, 0, S("abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 1, 1, S("2abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 1, 9, S("234567890abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 10, 0, S("abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 10, 1, S("1abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 10, 5, S("12345abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 10, 9, S("123456789abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 10, 10, S("1234567890abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 10, 11, S("1234567890abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 19, 0, S("abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 19, 1, S("0abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 19, 2, S("0abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 20, 0, S("abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 20, 1, S("abcde")); + test(S("abcde"), 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 1, S(""), 0, 0, S("abcde")); + test(S("abcde"), 1, S(""), 0, 1, S("abcde")); + test(S("abcde"), 1, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 1, S("12345"), 0, 0, S("abcde")); + test(S("abcde"), 1, S("12345"), 0, 1, S("a1bcde")); + test(S("abcde"), 1, S("12345"), 0, 2, S("a12bcde")); + test(S("abcde"), 1, S("12345"), 0, 4, S("a1234bcde")); + test(S("abcde"), 1, S("12345"), 0, 5, S("a12345bcde")); + test(S("abcde"), 1, S("12345"), 0, 6, S("a12345bcde")); + test(S("abcde"), 1, S("12345"), 1, 0, S("abcde")); + test(S("abcde"), 1, S("12345"), 1, 1, S("a2bcde")); + test(S("abcde"), 1, S("12345"), 1, 2, S("a23bcde")); + test(S("abcde"), 1, S("12345"), 1, 3, S("a234bcde")); + test(S("abcde"), 1, S("12345"), 1, 4, S("a2345bcde")); + test(S("abcde"), 1, S("12345"), 1, 5, S("a2345bcde")); + test(S("abcde"), 1, S("12345"), 2, 0, S("abcde")); + test(S("abcde"), 1, S("12345"), 2, 1, S("a3bcde")); + test(S("abcde"), 1, S("12345"), 2, 2, S("a34bcde")); + test(S("abcde"), 1, S("12345"), 2, 3, S("a345bcde")); + test(S("abcde"), 1, S("12345"), 2, 4, S("a345bcde")); + test(S("abcde"), 1, S("12345"), 4, 0, S("abcde")); + test(S("abcde"), 1, S("12345"), 4, 1, S("a5bcde")); + test(S("abcde"), 1, S("12345"), 4, 2, S("a5bcde")); + test(S("abcde"), 1, S("12345"), 5, 0, S("abcde")); + test(S("abcde"), 1, S("12345"), 5, 1, S("abcde")); + test(S("abcde"), 1, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 1, S("1234567890"), 0, 0, S("abcde")); + test(S("abcde"), 1, S("1234567890"), 0, 1, S("a1bcde")); +} + +template <class S> +void test5() +{ + test(S("abcde"), 1, S("1234567890"), 0, 5, S("a12345bcde")); + test(S("abcde"), 1, S("1234567890"), 0, 9, S("a123456789bcde")); + test(S("abcde"), 1, S("1234567890"), 0, 10, S("a1234567890bcde")); + test(S("abcde"), 1, S("1234567890"), 0, 11, S("a1234567890bcde")); + test(S("abcde"), 1, S("1234567890"), 1, 0, S("abcde")); + test(S("abcde"), 1, S("1234567890"), 1, 1, S("a2bcde")); + test(S("abcde"), 1, S("1234567890"), 1, 4, S("a2345bcde")); + test(S("abcde"), 1, S("1234567890"), 1, 8, S("a23456789bcde")); + test(S("abcde"), 1, S("1234567890"), 1, 9, S("a234567890bcde")); + test(S("abcde"), 1, S("1234567890"), 1, 10, S("a234567890bcde")); + test(S("abcde"), 1, S("1234567890"), 5, 0, S("abcde")); + test(S("abcde"), 1, S("1234567890"), 5, 1, S("a6bcde")); + test(S("abcde"), 1, S("1234567890"), 5, 2, S("a67bcde")); + test(S("abcde"), 1, S("1234567890"), 5, 4, S("a6789bcde")); + test(S("abcde"), 1, S("1234567890"), 5, 5, S("a67890bcde")); + test(S("abcde"), 1, S("1234567890"), 5, 6, S("a67890bcde")); + test(S("abcde"), 1, S("1234567890"), 9, 0, S("abcde")); + test(S("abcde"), 1, S("1234567890"), 9, 1, S("a0bcde")); + test(S("abcde"), 1, S("1234567890"), 9, 2, S("a0bcde")); + test(S("abcde"), 1, S("1234567890"), 10, 0, S("abcde")); + test(S("abcde"), 1, S("1234567890"), 10, 1, S("abcde")); + test(S("abcde"), 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 1, S("12345678901234567890"), 0, 0, S("abcde")); + test(S("abcde"), 1, S("12345678901234567890"), 0, 1, S("a1bcde")); + test(S("abcde"), 1, S("12345678901234567890"), 0, 10, S("a1234567890bcde")); + test(S("abcde"), 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcde")); + test(S("abcde"), 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcde")); + test(S("abcde"), 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcde")); + test(S("abcde"), 1, S("12345678901234567890"), 1, 0, S("abcde")); + test(S("abcde"), 1, S("12345678901234567890"), 1, 1, S("a2bcde")); + test(S("abcde"), 1, S("12345678901234567890"), 1, 9, S("a234567890bcde")); + test(S("abcde"), 1, S("12345678901234567890"), 1, 18, S("a234567890123456789bcde")); + test(S("abcde"), 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcde")); + test(S("abcde"), 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcde")); + test(S("abcde"), 1, S("12345678901234567890"), 10, 0, S("abcde")); + test(S("abcde"), 1, S("12345678901234567890"), 10, 1, S("a1bcde")); + test(S("abcde"), 1, S("12345678901234567890"), 10, 5, S("a12345bcde")); + test(S("abcde"), 1, S("12345678901234567890"), 10, 9, S("a123456789bcde")); + test(S("abcde"), 1, S("12345678901234567890"), 10, 10, S("a1234567890bcde")); + test(S("abcde"), 1, S("12345678901234567890"), 10, 11, S("a1234567890bcde")); + test(S("abcde"), 1, S("12345678901234567890"), 19, 0, S("abcde")); + test(S("abcde"), 1, S("12345678901234567890"), 19, 1, S("a0bcde")); + test(S("abcde"), 1, S("12345678901234567890"), 19, 2, S("a0bcde")); + test(S("abcde"), 1, S("12345678901234567890"), 20, 0, S("abcde")); + test(S("abcde"), 1, S("12345678901234567890"), 20, 1, S("abcde")); + test(S("abcde"), 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 2, S(""), 0, 0, S("abcde")); + test(S("abcde"), 2, S(""), 0, 1, S("abcde")); + test(S("abcde"), 2, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 2, S("12345"), 0, 0, S("abcde")); +} + +template <class S> +void test6() +{ + test(S("abcde"), 2, S("12345"), 0, 1, S("ab1cde")); + test(S("abcde"), 2, S("12345"), 0, 2, S("ab12cde")); + test(S("abcde"), 2, S("12345"), 0, 4, S("ab1234cde")); + test(S("abcde"), 2, S("12345"), 0, 5, S("ab12345cde")); + test(S("abcde"), 2, S("12345"), 0, 6, S("ab12345cde")); + test(S("abcde"), 2, S("12345"), 1, 0, S("abcde")); + test(S("abcde"), 2, S("12345"), 1, 1, S("ab2cde")); + test(S("abcde"), 2, S("12345"), 1, 2, S("ab23cde")); + test(S("abcde"), 2, S("12345"), 1, 3, S("ab234cde")); + test(S("abcde"), 2, S("12345"), 1, 4, S("ab2345cde")); + test(S("abcde"), 2, S("12345"), 1, 5, S("ab2345cde")); + test(S("abcde"), 2, S("12345"), 2, 0, S("abcde")); + test(S("abcde"), 2, S("12345"), 2, 1, S("ab3cde")); + test(S("abcde"), 2, S("12345"), 2, 2, S("ab34cde")); + test(S("abcde"), 2, S("12345"), 2, 3, S("ab345cde")); + test(S("abcde"), 2, S("12345"), 2, 4, S("ab345cde")); + test(S("abcde"), 2, S("12345"), 4, 0, S("abcde")); + test(S("abcde"), 2, S("12345"), 4, 1, S("ab5cde")); + test(S("abcde"), 2, S("12345"), 4, 2, S("ab5cde")); + test(S("abcde"), 2, S("12345"), 5, 0, S("abcde")); + test(S("abcde"), 2, S("12345"), 5, 1, S("abcde")); + test(S("abcde"), 2, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 2, S("1234567890"), 0, 0, S("abcde")); + test(S("abcde"), 2, S("1234567890"), 0, 1, S("ab1cde")); + test(S("abcde"), 2, S("1234567890"), 0, 5, S("ab12345cde")); + test(S("abcde"), 2, S("1234567890"), 0, 9, S("ab123456789cde")); + test(S("abcde"), 2, S("1234567890"), 0, 10, S("ab1234567890cde")); + test(S("abcde"), 2, S("1234567890"), 0, 11, S("ab1234567890cde")); + test(S("abcde"), 2, S("1234567890"), 1, 0, S("abcde")); + test(S("abcde"), 2, S("1234567890"), 1, 1, S("ab2cde")); + test(S("abcde"), 2, S("1234567890"), 1, 4, S("ab2345cde")); + test(S("abcde"), 2, S("1234567890"), 1, 8, S("ab23456789cde")); + test(S("abcde"), 2, S("1234567890"), 1, 9, S("ab234567890cde")); + test(S("abcde"), 2, S("1234567890"), 1, 10, S("ab234567890cde")); + test(S("abcde"), 2, S("1234567890"), 5, 0, S("abcde")); + test(S("abcde"), 2, S("1234567890"), 5, 1, S("ab6cde")); + test(S("abcde"), 2, S("1234567890"), 5, 2, S("ab67cde")); + test(S("abcde"), 2, S("1234567890"), 5, 4, S("ab6789cde")); + test(S("abcde"), 2, S("1234567890"), 5, 5, S("ab67890cde")); + test(S("abcde"), 2, S("1234567890"), 5, 6, S("ab67890cde")); + test(S("abcde"), 2, S("1234567890"), 9, 0, S("abcde")); + test(S("abcde"), 2, S("1234567890"), 9, 1, S("ab0cde")); + test(S("abcde"), 2, S("1234567890"), 9, 2, S("ab0cde")); + test(S("abcde"), 2, S("1234567890"), 10, 0, S("abcde")); + test(S("abcde"), 2, S("1234567890"), 10, 1, S("abcde")); + test(S("abcde"), 2, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 2, S("12345678901234567890"), 0, 0, S("abcde")); + test(S("abcde"), 2, S("12345678901234567890"), 0, 1, S("ab1cde")); + test(S("abcde"), 2, S("12345678901234567890"), 0, 10, S("ab1234567890cde")); + test(S("abcde"), 2, S("12345678901234567890"), 0, 19, S("ab1234567890123456789cde")); +} + +template <class S> +void test7() +{ + test(S("abcde"), 2, S("12345678901234567890"), 0, 20, S("ab12345678901234567890cde")); + test(S("abcde"), 2, S("12345678901234567890"), 0, 21, S("ab12345678901234567890cde")); + test(S("abcde"), 2, S("12345678901234567890"), 1, 0, S("abcde")); + test(S("abcde"), 2, S("12345678901234567890"), 1, 1, S("ab2cde")); + test(S("abcde"), 2, S("12345678901234567890"), 1, 9, S("ab234567890cde")); + test(S("abcde"), 2, S("12345678901234567890"), 1, 18, S("ab234567890123456789cde")); + test(S("abcde"), 2, S("12345678901234567890"), 1, 19, S("ab2345678901234567890cde")); + test(S("abcde"), 2, S("12345678901234567890"), 1, 20, S("ab2345678901234567890cde")); + test(S("abcde"), 2, S("12345678901234567890"), 10, 0, S("abcde")); + test(S("abcde"), 2, S("12345678901234567890"), 10, 1, S("ab1cde")); + test(S("abcde"), 2, S("12345678901234567890"), 10, 5, S("ab12345cde")); + test(S("abcde"), 2, S("12345678901234567890"), 10, 9, S("ab123456789cde")); + test(S("abcde"), 2, S("12345678901234567890"), 10, 10, S("ab1234567890cde")); + test(S("abcde"), 2, S("12345678901234567890"), 10, 11, S("ab1234567890cde")); + test(S("abcde"), 2, S("12345678901234567890"), 19, 0, S("abcde")); + test(S("abcde"), 2, S("12345678901234567890"), 19, 1, S("ab0cde")); + test(S("abcde"), 2, S("12345678901234567890"), 19, 2, S("ab0cde")); + test(S("abcde"), 2, S("12345678901234567890"), 20, 0, S("abcde")); + test(S("abcde"), 2, S("12345678901234567890"), 20, 1, S("abcde")); + test(S("abcde"), 2, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 4, S(""), 0, 0, S("abcde")); + test(S("abcde"), 4, S(""), 0, 1, S("abcde")); + test(S("abcde"), 4, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 4, S("12345"), 0, 0, S("abcde")); + test(S("abcde"), 4, S("12345"), 0, 1, S("abcd1e")); + test(S("abcde"), 4, S("12345"), 0, 2, S("abcd12e")); + test(S("abcde"), 4, S("12345"), 0, 4, S("abcd1234e")); + test(S("abcde"), 4, S("12345"), 0, 5, S("abcd12345e")); + test(S("abcde"), 4, S("12345"), 0, 6, S("abcd12345e")); + test(S("abcde"), 4, S("12345"), 1, 0, S("abcde")); + test(S("abcde"), 4, S("12345"), 1, 1, S("abcd2e")); + test(S("abcde"), 4, S("12345"), 1, 2, S("abcd23e")); + test(S("abcde"), 4, S("12345"), 1, 3, S("abcd234e")); + test(S("abcde"), 4, S("12345"), 1, 4, S("abcd2345e")); + test(S("abcde"), 4, S("12345"), 1, 5, S("abcd2345e")); + test(S("abcde"), 4, S("12345"), 2, 0, S("abcde")); + test(S("abcde"), 4, S("12345"), 2, 1, S("abcd3e")); + test(S("abcde"), 4, S("12345"), 2, 2, S("abcd34e")); + test(S("abcde"), 4, S("12345"), 2, 3, S("abcd345e")); + test(S("abcde"), 4, S("12345"), 2, 4, S("abcd345e")); + test(S("abcde"), 4, S("12345"), 4, 0, S("abcde")); + test(S("abcde"), 4, S("12345"), 4, 1, S("abcd5e")); + test(S("abcde"), 4, S("12345"), 4, 2, S("abcd5e")); + test(S("abcde"), 4, S("12345"), 5, 0, S("abcde")); + test(S("abcde"), 4, S("12345"), 5, 1, S("abcde")); + test(S("abcde"), 4, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 4, S("1234567890"), 0, 0, S("abcde")); + test(S("abcde"), 4, S("1234567890"), 0, 1, S("abcd1e")); + test(S("abcde"), 4, S("1234567890"), 0, 5, S("abcd12345e")); + test(S("abcde"), 4, S("1234567890"), 0, 9, S("abcd123456789e")); +} + +template <class S> +void test8() +{ + test(S("abcde"), 4, S("1234567890"), 0, 10, S("abcd1234567890e")); + test(S("abcde"), 4, S("1234567890"), 0, 11, S("abcd1234567890e")); + test(S("abcde"), 4, S("1234567890"), 1, 0, S("abcde")); + test(S("abcde"), 4, S("1234567890"), 1, 1, S("abcd2e")); + test(S("abcde"), 4, S("1234567890"), 1, 4, S("abcd2345e")); + test(S("abcde"), 4, S("1234567890"), 1, 8, S("abcd23456789e")); + test(S("abcde"), 4, S("1234567890"), 1, 9, S("abcd234567890e")); + test(S("abcde"), 4, S("1234567890"), 1, 10, S("abcd234567890e")); + test(S("abcde"), 4, S("1234567890"), 5, 0, S("abcde")); + test(S("abcde"), 4, S("1234567890"), 5, 1, S("abcd6e")); + test(S("abcde"), 4, S("1234567890"), 5, 2, S("abcd67e")); + test(S("abcde"), 4, S("1234567890"), 5, 4, S("abcd6789e")); + test(S("abcde"), 4, S("1234567890"), 5, 5, S("abcd67890e")); + test(S("abcde"), 4, S("1234567890"), 5, 6, S("abcd67890e")); + test(S("abcde"), 4, S("1234567890"), 9, 0, S("abcde")); + test(S("abcde"), 4, S("1234567890"), 9, 1, S("abcd0e")); + test(S("abcde"), 4, S("1234567890"), 9, 2, S("abcd0e")); + test(S("abcde"), 4, S("1234567890"), 10, 0, S("abcde")); + test(S("abcde"), 4, S("1234567890"), 10, 1, S("abcde")); + test(S("abcde"), 4, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 4, S("12345678901234567890"), 0, 0, S("abcde")); + test(S("abcde"), 4, S("12345678901234567890"), 0, 1, S("abcd1e")); + test(S("abcde"), 4, S("12345678901234567890"), 0, 10, S("abcd1234567890e")); + test(S("abcde"), 4, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789e")); + test(S("abcde"), 4, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890e")); + test(S("abcde"), 4, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890e")); + test(S("abcde"), 4, S("12345678901234567890"), 1, 0, S("abcde")); + test(S("abcde"), 4, S("12345678901234567890"), 1, 1, S("abcd2e")); + test(S("abcde"), 4, S("12345678901234567890"), 1, 9, S("abcd234567890e")); + test(S("abcde"), 4, S("12345678901234567890"), 1, 18, S("abcd234567890123456789e")); + test(S("abcde"), 4, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890e")); + test(S("abcde"), 4, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890e")); + test(S("abcde"), 4, S("12345678901234567890"), 10, 0, S("abcde")); + test(S("abcde"), 4, S("12345678901234567890"), 10, 1, S("abcd1e")); + test(S("abcde"), 4, S("12345678901234567890"), 10, 5, S("abcd12345e")); + test(S("abcde"), 4, S("12345678901234567890"), 10, 9, S("abcd123456789e")); + test(S("abcde"), 4, S("12345678901234567890"), 10, 10, S("abcd1234567890e")); + test(S("abcde"), 4, S("12345678901234567890"), 10, 11, S("abcd1234567890e")); + test(S("abcde"), 4, S("12345678901234567890"), 19, 0, S("abcde")); + test(S("abcde"), 4, S("12345678901234567890"), 19, 1, S("abcd0e")); + test(S("abcde"), 4, S("12345678901234567890"), 19, 2, S("abcd0e")); + test(S("abcde"), 4, S("12345678901234567890"), 20, 0, S("abcde")); + test(S("abcde"), 4, S("12345678901234567890"), 20, 1, S("abcde")); + test(S("abcde"), 4, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 5, S(""), 0, 0, S("abcde")); + test(S("abcde"), 5, S(""), 0, 1, S("abcde")); + test(S("abcde"), 5, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 5, S("12345"), 0, 0, S("abcde")); + test(S("abcde"), 5, S("12345"), 0, 1, S("abcde1")); + test(S("abcde"), 5, S("12345"), 0, 2, S("abcde12")); +} + +template <class S> +void test9() +{ + test(S("abcde"), 5, S("12345"), 0, 4, S("abcde1234")); + test(S("abcde"), 5, S("12345"), 0, 5, S("abcde12345")); + test(S("abcde"), 5, S("12345"), 0, 6, S("abcde12345")); + test(S("abcde"), 5, S("12345"), 1, 0, S("abcde")); + test(S("abcde"), 5, S("12345"), 1, 1, S("abcde2")); + test(S("abcde"), 5, S("12345"), 1, 2, S("abcde23")); + test(S("abcde"), 5, S("12345"), 1, 3, S("abcde234")); + test(S("abcde"), 5, S("12345"), 1, 4, S("abcde2345")); + test(S("abcde"), 5, S("12345"), 1, 5, S("abcde2345")); + test(S("abcde"), 5, S("12345"), 2, 0, S("abcde")); + test(S("abcde"), 5, S("12345"), 2, 1, S("abcde3")); + test(S("abcde"), 5, S("12345"), 2, 2, S("abcde34")); + test(S("abcde"), 5, S("12345"), 2, 3, S("abcde345")); + test(S("abcde"), 5, S("12345"), 2, 4, S("abcde345")); + test(S("abcde"), 5, S("12345"), 4, 0, S("abcde")); + test(S("abcde"), 5, S("12345"), 4, 1, S("abcde5")); + test(S("abcde"), 5, S("12345"), 4, 2, S("abcde5")); + test(S("abcde"), 5, S("12345"), 5, 0, S("abcde")); + test(S("abcde"), 5, S("12345"), 5, 1, S("abcde")); + test(S("abcde"), 5, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 5, S("1234567890"), 0, 0, S("abcde")); + test(S("abcde"), 5, S("1234567890"), 0, 1, S("abcde1")); + test(S("abcde"), 5, S("1234567890"), 0, 5, S("abcde12345")); + test(S("abcde"), 5, S("1234567890"), 0, 9, S("abcde123456789")); + test(S("abcde"), 5, S("1234567890"), 0, 10, S("abcde1234567890")); + test(S("abcde"), 5, S("1234567890"), 0, 11, S("abcde1234567890")); + test(S("abcde"), 5, S("1234567890"), 1, 0, S("abcde")); + test(S("abcde"), 5, S("1234567890"), 1, 1, S("abcde2")); + test(S("abcde"), 5, S("1234567890"), 1, 4, S("abcde2345")); + test(S("abcde"), 5, S("1234567890"), 1, 8, S("abcde23456789")); + test(S("abcde"), 5, S("1234567890"), 1, 9, S("abcde234567890")); + test(S("abcde"), 5, S("1234567890"), 1, 10, S("abcde234567890")); + test(S("abcde"), 5, S("1234567890"), 5, 0, S("abcde")); + test(S("abcde"), 5, S("1234567890"), 5, 1, S("abcde6")); + test(S("abcde"), 5, S("1234567890"), 5, 2, S("abcde67")); + test(S("abcde"), 5, S("1234567890"), 5, 4, S("abcde6789")); + test(S("abcde"), 5, S("1234567890"), 5, 5, S("abcde67890")); + test(S("abcde"), 5, S("1234567890"), 5, 6, S("abcde67890")); + test(S("abcde"), 5, S("1234567890"), 9, 0, S("abcde")); + test(S("abcde"), 5, S("1234567890"), 9, 1, S("abcde0")); + test(S("abcde"), 5, S("1234567890"), 9, 2, S("abcde0")); + test(S("abcde"), 5, S("1234567890"), 10, 0, S("abcde")); + test(S("abcde"), 5, S("1234567890"), 10, 1, S("abcde")); + test(S("abcde"), 5, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 5, S("12345678901234567890"), 0, 0, S("abcde")); + test(S("abcde"), 5, S("12345678901234567890"), 0, 1, S("abcde1")); + test(S("abcde"), 5, S("12345678901234567890"), 0, 10, S("abcde1234567890")); + test(S("abcde"), 5, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789")); + test(S("abcde"), 5, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890")); + test(S("abcde"), 5, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890")); +} + +template <class S> +void test10() +{ + test(S("abcde"), 5, S("12345678901234567890"), 1, 0, S("abcde")); + test(S("abcde"), 5, S("12345678901234567890"), 1, 1, S("abcde2")); + test(S("abcde"), 5, S("12345678901234567890"), 1, 9, S("abcde234567890")); + test(S("abcde"), 5, S("12345678901234567890"), 1, 18, S("abcde234567890123456789")); + test(S("abcde"), 5, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890")); + test(S("abcde"), 5, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890")); + test(S("abcde"), 5, S("12345678901234567890"), 10, 0, S("abcde")); + test(S("abcde"), 5, S("12345678901234567890"), 10, 1, S("abcde1")); + test(S("abcde"), 5, S("12345678901234567890"), 10, 5, S("abcde12345")); + test(S("abcde"), 5, S("12345678901234567890"), 10, 9, S("abcde123456789")); + test(S("abcde"), 5, S("12345678901234567890"), 10, 10, S("abcde1234567890")); + test(S("abcde"), 5, S("12345678901234567890"), 10, 11, S("abcde1234567890")); + test(S("abcde"), 5, S("12345678901234567890"), 19, 0, S("abcde")); + test(S("abcde"), 5, S("12345678901234567890"), 19, 1, S("abcde0")); + test(S("abcde"), 5, S("12345678901234567890"), 19, 2, S("abcde0")); + test(S("abcde"), 5, S("12345678901234567890"), 20, 0, S("abcde")); + test(S("abcde"), 5, S("12345678901234567890"), 20, 1, S("abcde")); + test(S("abcde"), 5, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 6, S(""), 0, 0, S("can't happen")); + test(S("abcde"), 6, S(""), 0, 1, S("can't happen")); + test(S("abcde"), 6, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 6, S("12345"), 0, 0, S("can't happen")); + test(S("abcde"), 6, S("12345"), 0, 1, S("can't happen")); + test(S("abcde"), 6, S("12345"), 0, 2, S("can't happen")); + test(S("abcde"), 6, S("12345"), 0, 4, S("can't happen")); + test(S("abcde"), 6, S("12345"), 0, 5, S("can't happen")); + test(S("abcde"), 6, S("12345"), 0, 6, S("can't happen")); + test(S("abcde"), 6, S("12345"), 1, 0, S("can't happen")); + test(S("abcde"), 6, S("12345"), 1, 1, S("can't happen")); + test(S("abcde"), 6, S("12345"), 1, 2, S("can't happen")); + test(S("abcde"), 6, S("12345"), 1, 3, S("can't happen")); + test(S("abcde"), 6, S("12345"), 1, 4, S("can't happen")); + test(S("abcde"), 6, S("12345"), 1, 5, S("can't happen")); + test(S("abcde"), 6, S("12345"), 2, 0, S("can't happen")); + test(S("abcde"), 6, S("12345"), 2, 1, S("can't happen")); + test(S("abcde"), 6, S("12345"), 2, 2, S("can't happen")); + test(S("abcde"), 6, S("12345"), 2, 3, S("can't happen")); + test(S("abcde"), 6, S("12345"), 2, 4, S("can't happen")); + test(S("abcde"), 6, S("12345"), 4, 0, S("can't happen")); + test(S("abcde"), 6, S("12345"), 4, 1, S("can't happen")); + test(S("abcde"), 6, S("12345"), 4, 2, S("can't happen")); + test(S("abcde"), 6, S("12345"), 5, 0, S("can't happen")); + test(S("abcde"), 6, S("12345"), 5, 1, S("can't happen")); + test(S("abcde"), 6, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 0, 0, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 0, 1, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 0, 5, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 0, 9, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 0, 10, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 0, 11, S("can't happen")); +} + +template <class S> +void test11() +{ + test(S("abcde"), 6, S("1234567890"), 1, 0, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 1, 1, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 1, 4, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 1, 8, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 1, 9, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 1, 10, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 5, 0, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 5, 1, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 5, 2, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 5, 4, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 5, 5, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 5, 6, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 9, 0, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 9, 1, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 9, 2, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 10, 0, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 10, 1, S("can't happen")); + test(S("abcde"), 6, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 0, 0, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 0, 1, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 0, 10, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 0, 19, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 0, 20, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 0, 21, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 1, 0, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 1, 1, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 1, 9, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 1, 18, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 1, 19, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 1, 20, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 10, 0, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 10, 1, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 10, 5, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 10, 9, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 10, 10, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 10, 11, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 19, 0, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 19, 1, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 19, 2, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 20, 0, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 20, 1, S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 0, S(""), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, S(""), 0, 1, S("abcdefghij")); + test(S("abcdefghij"), 0, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 0, S("12345"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 0, 1, S("1abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 0, 2, S("12abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 0, 4, S("1234abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 0, 5, S("12345abcdefghij")); +} + +template <class S> +void test12() +{ + test(S("abcdefghij"), 0, S("12345"), 0, 6, S("12345abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 1, 1, S("2abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 1, 2, S("23abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 1, 3, S("234abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 1, 4, S("2345abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 1, 5, S("2345abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 2, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 2, 1, S("3abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 2, 2, S("34abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 2, 3, S("345abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 2, 4, S("345abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 4, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 4, 1, S("5abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 4, 2, S("5abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 5, 1, S("abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 0, S("1234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 0, 1, S("1abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 0, 5, S("12345abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 0, 9, S("123456789abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 0, 10, S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 0, 11, S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 1, 1, S("2abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 1, 4, S("2345abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 1, 8, S("23456789abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 1, 9, S("234567890abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 1, 10, S("234567890abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 5, 1, S("6abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 5, 2, S("67abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 5, 4, S("6789abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 5, 5, S("67890abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 5, 6, S("67890abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 9, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 9, 1, S("0abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 9, 2, S("0abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 10, 1, S("abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 1, S("1abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 1, S("2abcdefghij")); +} + +template <class S> +void test13() +{ + test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 1, S("1abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 5, S("12345abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 19, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 19, 1, S("0abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 19, 2, S("0abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 20, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 20, 1, S("abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 1, S(""), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, S(""), 0, 1, S("abcdefghij")); + test(S("abcdefghij"), 1, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 1, S("12345"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 0, 1, S("a1bcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 0, 2, S("a12bcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 0, 4, S("a1234bcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 0, 5, S("a12345bcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 0, 6, S("a12345bcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 1, 1, S("a2bcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 1, 2, S("a23bcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 1, 3, S("a234bcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 1, 4, S("a2345bcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 1, 5, S("a2345bcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 2, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 2, 1, S("a3bcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 2, 2, S("a34bcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 2, 3, S("a345bcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 2, 4, S("a345bcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 4, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 4, 1, S("a5bcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 4, 2, S("a5bcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 5, 1, S("abcdefghij")); + test(S("abcdefghij"), 1, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 1, S("1234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 0, 1, S("a1bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 0, 5, S("a12345bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 0, 9, S("a123456789bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 0, 10, S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 0, 11, S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 1, 1, S("a2bcdefghij")); +} + +template <class S> +void test14() +{ + test(S("abcdefghij"), 1, S("1234567890"), 1, 4, S("a2345bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 1, 8, S("a23456789bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 1, 9, S("a234567890bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 1, 10, S("a234567890bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 5, 1, S("a6bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 5, 2, S("a67bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 5, 4, S("a6789bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 5, 5, S("a67890bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 5, 6, S("a67890bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 9, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 9, 1, S("a0bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 9, 2, S("a0bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 10, 1, S("abcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 1, S("a1bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 1, S("a2bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 9, S("a234567890bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 1, S("a1bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 5, S("a12345bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 9, S("a123456789bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 19, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 19, 1, S("a0bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 19, 2, S("a0bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 20, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 20, 1, S("abcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 5, S(""), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, S(""), 0, 1, S("abcdefghij")); + test(S("abcdefghij"), 5, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 5, S("12345"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, S("12345"), 0, 1, S("abcde1fghij")); + test(S("abcdefghij"), 5, S("12345"), 0, 2, S("abcde12fghij")); + test(S("abcdefghij"), 5, S("12345"), 0, 4, S("abcde1234fghij")); + test(S("abcdefghij"), 5, S("12345"), 0, 5, S("abcde12345fghij")); + test(S("abcdefghij"), 5, S("12345"), 0, 6, S("abcde12345fghij")); + test(S("abcdefghij"), 5, S("12345"), 1, 0, S("abcdefghij")); +} + +template <class S> +void test15() +{ + test(S("abcdefghij"), 5, S("12345"), 1, 1, S("abcde2fghij")); + test(S("abcdefghij"), 5, S("12345"), 1, 2, S("abcde23fghij")); + test(S("abcdefghij"), 5, S("12345"), 1, 3, S("abcde234fghij")); + test(S("abcdefghij"), 5, S("12345"), 1, 4, S("abcde2345fghij")); + test(S("abcdefghij"), 5, S("12345"), 1, 5, S("abcde2345fghij")); + test(S("abcdefghij"), 5, S("12345"), 2, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, S("12345"), 2, 1, S("abcde3fghij")); + test(S("abcdefghij"), 5, S("12345"), 2, 2, S("abcde34fghij")); + test(S("abcdefghij"), 5, S("12345"), 2, 3, S("abcde345fghij")); + test(S("abcdefghij"), 5, S("12345"), 2, 4, S("abcde345fghij")); + test(S("abcdefghij"), 5, S("12345"), 4, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, S("12345"), 4, 1, S("abcde5fghij")); + test(S("abcdefghij"), 5, S("12345"), 4, 2, S("abcde5fghij")); + test(S("abcdefghij"), 5, S("12345"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, S("12345"), 5, 1, S("abcdefghij")); + test(S("abcdefghij"), 5, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 5, S("1234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, S("1234567890"), 0, 1, S("abcde1fghij")); + test(S("abcdefghij"), 5, S("1234567890"), 0, 5, S("abcde12345fghij")); + test(S("abcdefghij"), 5, S("1234567890"), 0, 9, S("abcde123456789fghij")); + test(S("abcdefghij"), 5, S("1234567890"), 0, 10, S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, S("1234567890"), 0, 11, S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, S("1234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, S("1234567890"), 1, 1, S("abcde2fghij")); + test(S("abcdefghij"), 5, S("1234567890"), 1, 4, S("abcde2345fghij")); + test(S("abcdefghij"), 5, S("1234567890"), 1, 8, S("abcde23456789fghij")); + test(S("abcdefghij"), 5, S("1234567890"), 1, 9, S("abcde234567890fghij")); + test(S("abcdefghij"), 5, S("1234567890"), 1, 10, S("abcde234567890fghij")); + test(S("abcdefghij"), 5, S("1234567890"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, S("1234567890"), 5, 1, S("abcde6fghij")); + test(S("abcdefghij"), 5, S("1234567890"), 5, 2, S("abcde67fghij")); + test(S("abcdefghij"), 5, S("1234567890"), 5, 4, S("abcde6789fghij")); + test(S("abcdefghij"), 5, S("1234567890"), 5, 5, S("abcde67890fghij")); + test(S("abcdefghij"), 5, S("1234567890"), 5, 6, S("abcde67890fghij")); + test(S("abcdefghij"), 5, S("1234567890"), 9, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, S("1234567890"), 9, 1, S("abcde0fghij")); + test(S("abcdefghij"), 5, S("1234567890"), 9, 2, S("abcde0fghij")); + test(S("abcdefghij"), 5, S("1234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, S("1234567890"), 10, 1, S("abcdefghij")); + test(S("abcdefghij"), 5, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 1, S("abcde1fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 10, S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 1, S("abcde2fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 9, S("abcde234567890fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 18, S("abcde234567890123456789fghij")); +} + +template <class S> +void test16() +{ + test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 1, S("abcde1fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 5, S("abcde12345fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 9, S("abcde123456789fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 10, S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 11, S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 19, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 19, 1, S("abcde0fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 19, 2, S("abcde0fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 20, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 20, 1, S("abcdefghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 9, S(""), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, S(""), 0, 1, S("abcdefghij")); + test(S("abcdefghij"), 9, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 9, S("12345"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, S("12345"), 0, 1, S("abcdefghi1j")); + test(S("abcdefghij"), 9, S("12345"), 0, 2, S("abcdefghi12j")); + test(S("abcdefghij"), 9, S("12345"), 0, 4, S("abcdefghi1234j")); + test(S("abcdefghij"), 9, S("12345"), 0, 5, S("abcdefghi12345j")); + test(S("abcdefghij"), 9, S("12345"), 0, 6, S("abcdefghi12345j")); + test(S("abcdefghij"), 9, S("12345"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, S("12345"), 1, 1, S("abcdefghi2j")); + test(S("abcdefghij"), 9, S("12345"), 1, 2, S("abcdefghi23j")); + test(S("abcdefghij"), 9, S("12345"), 1, 3, S("abcdefghi234j")); + test(S("abcdefghij"), 9, S("12345"), 1, 4, S("abcdefghi2345j")); + test(S("abcdefghij"), 9, S("12345"), 1, 5, S("abcdefghi2345j")); + test(S("abcdefghij"), 9, S("12345"), 2, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, S("12345"), 2, 1, S("abcdefghi3j")); + test(S("abcdefghij"), 9, S("12345"), 2, 2, S("abcdefghi34j")); + test(S("abcdefghij"), 9, S("12345"), 2, 3, S("abcdefghi345j")); + test(S("abcdefghij"), 9, S("12345"), 2, 4, S("abcdefghi345j")); + test(S("abcdefghij"), 9, S("12345"), 4, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, S("12345"), 4, 1, S("abcdefghi5j")); + test(S("abcdefghij"), 9, S("12345"), 4, 2, S("abcdefghi5j")); + test(S("abcdefghij"), 9, S("12345"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, S("12345"), 5, 1, S("abcdefghij")); + test(S("abcdefghij"), 9, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 9, S("1234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, S("1234567890"), 0, 1, S("abcdefghi1j")); + test(S("abcdefghij"), 9, S("1234567890"), 0, 5, S("abcdefghi12345j")); + test(S("abcdefghij"), 9, S("1234567890"), 0, 9, S("abcdefghi123456789j")); + test(S("abcdefghij"), 9, S("1234567890"), 0, 10, S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, S("1234567890"), 0, 11, S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, S("1234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, S("1234567890"), 1, 1, S("abcdefghi2j")); + test(S("abcdefghij"), 9, S("1234567890"), 1, 4, S("abcdefghi2345j")); + test(S("abcdefghij"), 9, S("1234567890"), 1, 8, S("abcdefghi23456789j")); +} + +template <class S> +void test17() +{ + test(S("abcdefghij"), 9, S("1234567890"), 1, 9, S("abcdefghi234567890j")); + test(S("abcdefghij"), 9, S("1234567890"), 1, 10, S("abcdefghi234567890j")); + test(S("abcdefghij"), 9, S("1234567890"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, S("1234567890"), 5, 1, S("abcdefghi6j")); + test(S("abcdefghij"), 9, S("1234567890"), 5, 2, S("abcdefghi67j")); + test(S("abcdefghij"), 9, S("1234567890"), 5, 4, S("abcdefghi6789j")); + test(S("abcdefghij"), 9, S("1234567890"), 5, 5, S("abcdefghi67890j")); + test(S("abcdefghij"), 9, S("1234567890"), 5, 6, S("abcdefghi67890j")); + test(S("abcdefghij"), 9, S("1234567890"), 9, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, S("1234567890"), 9, 1, S("abcdefghi0j")); + test(S("abcdefghij"), 9, S("1234567890"), 9, 2, S("abcdefghi0j")); + test(S("abcdefghij"), 9, S("1234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, S("1234567890"), 10, 1, S("abcdefghij")); + test(S("abcdefghij"), 9, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 1, S("abcdefghi1j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 1, S("abcdefghi2j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 9, S("abcdefghi234567890j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 1, S("abcdefghi1j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 5, S("abcdefghi12345j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 9, S("abcdefghi123456789j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 19, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 19, 1, S("abcdefghi0j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 19, 2, S("abcdefghi0j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 20, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 20, 1, S("abcdefghij")); + test(S("abcdefghij"), 9, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 10, S(""), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, S(""), 0, 1, S("abcdefghij")); + test(S("abcdefghij"), 10, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 10, S("12345"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, S("12345"), 0, 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, S("12345"), 0, 2, S("abcdefghij12")); + test(S("abcdefghij"), 10, S("12345"), 0, 4, S("abcdefghij1234")); + test(S("abcdefghij"), 10, S("12345"), 0, 5, S("abcdefghij12345")); + test(S("abcdefghij"), 10, S("12345"), 0, 6, S("abcdefghij12345")); + test(S("abcdefghij"), 10, S("12345"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, S("12345"), 1, 1, S("abcdefghij2")); + test(S("abcdefghij"), 10, S("12345"), 1, 2, S("abcdefghij23")); +} + +template <class S> +void test18() +{ + test(S("abcdefghij"), 10, S("12345"), 1, 3, S("abcdefghij234")); + test(S("abcdefghij"), 10, S("12345"), 1, 4, S("abcdefghij2345")); + test(S("abcdefghij"), 10, S("12345"), 1, 5, S("abcdefghij2345")); + test(S("abcdefghij"), 10, S("12345"), 2, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, S("12345"), 2, 1, S("abcdefghij3")); + test(S("abcdefghij"), 10, S("12345"), 2, 2, S("abcdefghij34")); + test(S("abcdefghij"), 10, S("12345"), 2, 3, S("abcdefghij345")); + test(S("abcdefghij"), 10, S("12345"), 2, 4, S("abcdefghij345")); + test(S("abcdefghij"), 10, S("12345"), 4, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, S("12345"), 4, 1, S("abcdefghij5")); + test(S("abcdefghij"), 10, S("12345"), 4, 2, S("abcdefghij5")); + test(S("abcdefghij"), 10, S("12345"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, S("12345"), 5, 1, S("abcdefghij")); + test(S("abcdefghij"), 10, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 10, S("1234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, S("1234567890"), 0, 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, S("1234567890"), 0, 5, S("abcdefghij12345")); + test(S("abcdefghij"), 10, S("1234567890"), 0, 9, S("abcdefghij123456789")); + test(S("abcdefghij"), 10, S("1234567890"), 0, 10, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, S("1234567890"), 0, 11, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, S("1234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, S("1234567890"), 1, 1, S("abcdefghij2")); + test(S("abcdefghij"), 10, S("1234567890"), 1, 4, S("abcdefghij2345")); + test(S("abcdefghij"), 10, S("1234567890"), 1, 8, S("abcdefghij23456789")); + test(S("abcdefghij"), 10, S("1234567890"), 1, 9, S("abcdefghij234567890")); + test(S("abcdefghij"), 10, S("1234567890"), 1, 10, S("abcdefghij234567890")); + test(S("abcdefghij"), 10, S("1234567890"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, S("1234567890"), 5, 1, S("abcdefghij6")); + test(S("abcdefghij"), 10, S("1234567890"), 5, 2, S("abcdefghij67")); + test(S("abcdefghij"), 10, S("1234567890"), 5, 4, S("abcdefghij6789")); + test(S("abcdefghij"), 10, S("1234567890"), 5, 5, S("abcdefghij67890")); + test(S("abcdefghij"), 10, S("1234567890"), 5, 6, S("abcdefghij67890")); + test(S("abcdefghij"), 10, S("1234567890"), 9, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, S("1234567890"), 9, 1, S("abcdefghij0")); + test(S("abcdefghij"), 10, S("1234567890"), 9, 2, S("abcdefghij0")); + test(S("abcdefghij"), 10, S("1234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, S("1234567890"), 10, 1, S("abcdefghij")); + test(S("abcdefghij"), 10, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 1, S("abcdefghij2")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 9, S("abcdefghij234567890")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890")); +} + +template <class S> +void test19() +{ + test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 5, S("abcdefghij12345")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 9, S("abcdefghij123456789")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 19, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 19, 1, S("abcdefghij0")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 19, 2, S("abcdefghij0")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 20, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 20, 1, S("abcdefghij")); + test(S("abcdefghij"), 10, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 11, S(""), 0, 0, S("can't happen")); + test(S("abcdefghij"), 11, S(""), 0, 1, S("can't happen")); + test(S("abcdefghij"), 11, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 0, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 0, 1, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 0, 2, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 0, 4, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 0, 5, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 0, 6, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 1, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 1, 1, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 1, 2, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 1, 3, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 1, 4, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 1, 5, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 2, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 2, 1, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 2, 2, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 2, 3, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 2, 4, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 4, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 4, 1, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 4, 2, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 5, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 5, 1, S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 0, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 0, 1, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 0, 5, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 0, 9, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 0, 10, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 0, 11, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 1, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 1, 1, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 1, 4, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 1, 8, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 1, 9, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 1, 10, S("can't happen")); +} + +template <class S> +void test20() +{ + test(S("abcdefghij"), 11, S("1234567890"), 5, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 5, 1, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 5, 2, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 5, 4, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 5, 5, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 5, 6, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 9, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 9, 1, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 9, 2, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 10, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 10, 1, S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 1, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 10, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 19, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 20, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 21, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 1, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 9, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 18, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 19, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 20, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 1, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 5, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 9, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 10, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 11, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 19, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 19, 1, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 19, 2, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 20, 0, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 20, 1, S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, S(""), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S(""), 0, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 1, S("1abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 2, S("12abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 4, S("1234abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 5, S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 6, S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 1, S("2abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 2, S("23abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 3, S("234abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 4, S("2345abcdefghijklmnopqrst")); +} + +template <class S> +void test21() +{ + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 5, S("2345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 1, S("3abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 2, S("34abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 3, S("345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 4, S("345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 4, 1, S("5abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 4, 2, S("5abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 1, S("1abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 5, S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 9, S("123456789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 11, S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 1, S("2abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 4, S("2345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 8, S("23456789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 9, S("234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 10, S("234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 1, S("6abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 2, S("67abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 4, S("6789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 5, S("67890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 6, S("67890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 9, 1, S("0abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 9, 2, S("0abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 1, S("1abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 1, S("2abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 1, S("1abcdefghijklmnopqrst")); +} + +template <class S> +void test22() +{ + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 5, S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 19, 1, S("0abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 19, 2, S("0abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, S(""), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S(""), 0, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 1, S("a1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 2, S("a12bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 4, S("a1234bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 5, S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 6, S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 1, S("a2bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 2, S("a23bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 3, S("a234bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 4, S("a2345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 5, S("a2345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 1, S("a3bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 2, S("a34bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 3, S("a345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 4, S("a345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 4, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 4, 1, S("a5bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 4, 2, S("a5bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 5, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 1, S("a1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 5, S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 9, S("a123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 11, S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 1, S("a2bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 4, S("a2345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 8, S("a23456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 10, S("a234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 1, S("a6bcdefghijklmnopqrst")); +} + +template <class S> +void test23() +{ + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 2, S("a67bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 4, S("a6789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 5, S("a67890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 6, S("a67890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 9, 1, S("a0bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 9, 2, S("a0bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 1, S("a1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 1, S("a2bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 1, S("a1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 5, S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 9, S("a123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 19, 1, S("a0bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 19, 2, S("a0bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, S(""), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S(""), 0, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 1, S("abcdefghij1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 2, S("abcdefghij12klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 4, S("abcdefghij1234klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 5, S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 6, S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 1, S("abcdefghij2klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 2, S("abcdefghij23klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 3, S("abcdefghij234klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 4, S("abcdefghij2345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 5, S("abcdefghij2345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 0, S("abcdefghijklmnopqrst")); +} + +template <class S> +void test24() +{ + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 1, S("abcdefghij3klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 2, S("abcdefghij34klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 3, S("abcdefghij345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 4, S("abcdefghij345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 4, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 4, 1, S("abcdefghij5klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 4, 2, S("abcdefghij5klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 5, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 1, S("abcdefghij1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 5, S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 9, S("abcdefghij123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 11, S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 1, S("abcdefghij2klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 4, S("abcdefghij2345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 8, S("abcdefghij23456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 9, S("abcdefghij234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 10, S("abcdefghij234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 1, S("abcdefghij6klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 2, S("abcdefghij67klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 4, S("abcdefghij6789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 5, S("abcdefghij67890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 6, S("abcdefghij67890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 9, 1, S("abcdefghij0klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 9, 2, S("abcdefghij0klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 1, S("abcdefghij1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 1, S("abcdefghij2klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 9, S("abcdefghij234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 1, S("abcdefghij1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 5, S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 9, S("abcdefghij123456789klmnopqrst")); +} + +template <class S> +void test25() +{ + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 19, 1, S("abcdefghij0klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 19, 2, S("abcdefghij0klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 19, S(""), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S(""), 0, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 1, S("abcdefghijklmnopqrs1t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 2, S("abcdefghijklmnopqrs12t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 1, S("abcdefghijklmnopqrs2t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 2, S("abcdefghijklmnopqrs23t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 3, S("abcdefghijklmnopqrs234t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 1, S("abcdefghijklmnopqrs3t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 2, S("abcdefghijklmnopqrs34t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 3, S("abcdefghijklmnopqrs345t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 4, S("abcdefghijklmnopqrs345t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 4, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 4, 1, S("abcdefghijklmnopqrs5t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 4, 2, S("abcdefghijklmnopqrs5t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 5, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789t")); +} + +template <class S> +void test26() +{ + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 20, S(""), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S(""), 0, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 2, S("abcdefghijklmnopqrst12")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 4, S("abcdefghijklmnopqrst1234")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 5, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 6, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 1, S("abcdefghijklmnopqrst2")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 2, S("abcdefghijklmnopqrst23")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 3, S("abcdefghijklmnopqrst234")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 4, S("abcdefghijklmnopqrst2345")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 5, S("abcdefghijklmnopqrst2345")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 1, S("abcdefghijklmnopqrst3")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 2, S("abcdefghijklmnopqrst34")); +} + +template <class S> +void test27() +{ + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 3, S("abcdefghijklmnopqrst345")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 4, S("abcdefghijklmnopqrst345")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 4, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 4, 1, S("abcdefghijklmnopqrst5")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 4, 2, S("abcdefghijklmnopqrst5")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 5, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 5, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 9, S("abcdefghijklmnopqrst123456789")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 11, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 1, S("abcdefghijklmnopqrst2")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 4, S("abcdefghijklmnopqrst2345")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 8, S("abcdefghijklmnopqrst23456789")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 9, S("abcdefghijklmnopqrst234567890")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 10, S("abcdefghijklmnopqrst234567890")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 1, S("abcdefghijklmnopqrst6")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 2, S("abcdefghijklmnopqrst67")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 4, S("abcdefghijklmnopqrst6789")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 5, S("abcdefghijklmnopqrst67890")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 6, S("abcdefghijklmnopqrst67890")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 9, 1, S("abcdefghijklmnopqrst0")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 9, 2, S("abcdefghijklmnopqrst0")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrst1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrst12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrst12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrst2")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrst234567890")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrst234567890123456789")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrst2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrst2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrst123456789")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrst1234567890")); +} + +template <class S> +void test28() +{ + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrst0")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrst0")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S(""), 0, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S(""), 0, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 2, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 4, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 5, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 6, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 2, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 3, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 4, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 5, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 2, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 3, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 4, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 4, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 4, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 4, 2, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 5, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 5, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 5, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 9, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 10, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 11, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 4, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 8, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 9, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 10, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 2, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 4, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 5, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 6, S("can't happen")); +} + +template <class S> +void test29() +{ + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 9, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 9, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 9, 2, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 10, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 10, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 10, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 19, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 20, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 21, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 9, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 18, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 19, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 20, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 5, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 9, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 10, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 11, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 19, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 19, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 19, 2, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 20, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 20, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 21, 0, S("can't happen")); +} + +template <class S> +void test30() +{ + test_npos(S(""), 0, S("12345678901234567890"), 0, S("12345678901234567890")); + test_npos(S(""), 0, S("12345678901234567890"), 1, S( "2345678901234567890")); + test_npos(S(""), 0, S("12345678901234567890"), 2, S( "345678901234567890")); + test_npos(S(""), 0, S("12345678901234567890"), 3, S( "45678901234567890")); + test_npos(S(""), 0, S("12345678901234567890"), 5, S( "678901234567890")); + test_npos(S(""), 0, S("12345678901234567890"), 10, S( "1234567890")); + test_npos(S(""), 0, S("12345678901234567890"), 21, S("can't happen")); + test_npos(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, S("abcdefghij12345klmnopqrst")); + test_npos(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, S("abcdefghij2345klmnopqrst")); + test_npos(S("abcdefghijklmnopqrst"), 10, S("12345"), 3, S("abcdefghij45klmnopqrst")); + test_npos(S("abcdefghijklmnopqrst"), 10, S("12345"), 5, S("abcdefghijklmnopqrst")); + test_npos(S("abcdefghijklmnopqrst"), 10, S("12345"), 6, S("can't happen")); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + test4<S>(); + test5<S>(); + test6<S>(); + test7<S>(); + test8<S>(); + test9<S>(); + test10<S>(); + test11<S>(); + test12<S>(); + test13<S>(); + test14<S>(); + test15<S>(); + test16<S>(); + test17<S>(); + test18<S>(); + test19<S>(); + test20<S>(); + test21<S>(); + test22<S>(); + test23<S>(); + test24<S>(); + test25<S>(); + test26<S>(); + test27<S>(); + test28<S>(); + test29<S>(); + test30<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + test4<S>(); + test5<S>(); + test6<S>(); + test7<S>(); + test8<S>(); + test9<S>(); + test10<S>(); + test11<S>(); + test12<S>(); + test13<S>(); + test14<S>(); + test15<S>(); + test16<S>(); + test17<S>(); + test18<S>(); + test19<S>(); + test20<S>(); + test21<S>(); + test22<S>(); + test23<S>(); + test24<S>(); + test25<S>(); + test26<S>(); + test27<S>(); + test28<S>(); + test29<S>(); + test30<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp new file mode 100644 index 000000000000..7384ae7f1d3c --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp @@ -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<charT,traits,Allocator>& operator+=(charT c); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s, typename S::value_type str, S expected) +{ + s += str; + assert(s.__invariants()); + assert(s == expected); +} + +int main() +{ + { + typedef std::string S; + test(S(), 'a', S("a")); + test(S("12345"), 'a', S("12345a")); + test(S("1234567890"), 'a', S("1234567890a")); + test(S("12345678901234567890"), 'a', S("12345678901234567890a")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(), 'a', S("a")); + test(S("12345"), 'a', S("12345a")); + test(S("1234567890"), 'a', S("1234567890a")); + test(S("12345678901234567890"), 'a', S("12345678901234567890a")); + } +#endif +} diff --git a/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp new file mode 100644 index 000000000000..c291028998df --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp @@ -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("123"); + s += {'a', 'b', 'c'}; + assert(s == "123abc"); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S s("123"); + s += {'a', 'b', 'c'}; + assert(s == "123abc"); + } +#endif +#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +} diff --git a/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp new file mode 100644 index 000000000000..77b20d1bc080 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp @@ -0,0 +1,78 @@ +//===----------------------------------------------------------------------===// +// +// 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 s, const typename S::value_type* str, S expected) +{ + s += str; + assert(s.__invariants()); + assert(s == expected); +} + +int main() +{ + { + typedef std::string S; + test(S(), "", S()); + test(S(), "12345", S("12345")); + test(S(), "1234567890", S("1234567890")); + test(S(), "12345678901234567890", S("12345678901234567890")); + + test(S("12345"), "", S("12345")); + test(S("12345"), "12345", S("1234512345")); + test(S("12345"), "1234567890", S("123451234567890")); + test(S("12345"), "12345678901234567890", S("1234512345678901234567890")); + + test(S("1234567890"), "", S("1234567890")); + test(S("1234567890"), "12345", S("123456789012345")); + test(S("1234567890"), "1234567890", S("12345678901234567890")); + test(S("1234567890"), "12345678901234567890", S("123456789012345678901234567890")); + + test(S("12345678901234567890"), "", S("12345678901234567890")); + test(S("12345678901234567890"), "12345", S("1234567890123456789012345")); + test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890")); + test(S("12345678901234567890"), "12345678901234567890", + S("1234567890123456789012345678901234567890")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(), "", S()); + test(S(), "12345", S("12345")); + test(S(), "1234567890", S("1234567890")); + test(S(), "12345678901234567890", S("12345678901234567890")); + + test(S("12345"), "", S("12345")); + test(S("12345"), "12345", S("1234512345")); + test(S("12345"), "1234567890", S("123451234567890")); + test(S("12345"), "12345678901234567890", S("1234512345678901234567890")); + + test(S("1234567890"), "", S("1234567890")); + test(S("1234567890"), "12345", S("123456789012345")); + test(S("1234567890"), "1234567890", S("12345678901234567890")); + test(S("1234567890"), "12345678901234567890", S("123456789012345678901234567890")); + + test(S("12345678901234567890"), "", S("12345678901234567890")); + test(S("12345678901234567890"), "12345", S("1234567890123456789012345")); + test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890")); + test(S("12345678901234567890"), "12345678901234567890", + S("1234567890123456789012345678901234567890")); + } +#endif +} diff --git a/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp new file mode 100644 index 000000000000..33649792521c --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp @@ -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+=(const basic_string<charT,traits,Allocator>& str); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s, S str, S expected) +{ + s += 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 +} diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp new file mode 100644 index 000000000000..20455b258c0a --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp @@ -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& replace(const_iterator i1, const_iterator i2, initializer_list<charT> il); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::string s("123def456"); + s.replace(s.cbegin() + 3, s.cbegin() + 6, {'a', 'b', 'c'}); + assert(s == "123abc456"); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S s("123def456"); + s.replace(s.cbegin() + 3, s.cbegin() + 6, {'a', 'b', 'c'}); + assert(s == "123abc456"); + } +#endif +#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +} diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp new file mode 100644 index 000000000000..9295c5bde9fa --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp @@ -0,0 +1,976 @@ +//===----------------------------------------------------------------------===// +// +// 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& +// replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2); + +#include <string> +#include <iterator> +#include <cassert> + +#include "min_allocator.h" + +template <class S, class It> +void +test(S s, typename S::size_type pos1, typename S::size_type n1, It f, It l, S expected) +{ + typename S::size_type old_size = s.size(); + typename S::const_iterator first = s.begin() + pos1; + typename S::const_iterator last = s.begin() + pos1 + n1; + typename S::size_type xlen = last - first; + s.replace(first, last, f, l); + assert(s.__invariants()); + assert(s == expected); + typename S::size_type rlen = std::distance(f, l); + assert(s.size() == old_size - xlen + rlen); +} + +const char* str = "12345678901234567890"; + +template <class S> +void test0() +{ + test(S(""), 0, 0, str, str+0, S("")); + test(S(""), 0, 0, str, str+0, S("")); + test(S(""), 0, 0, str, str+1, S("1")); + test(S(""), 0, 0, str, str+2, S("12")); + test(S(""), 0, 0, str, str+4, S("1234")); + test(S(""), 0, 0, str, str+5, S("12345")); + test(S(""), 0, 0, str, str+0, S("")); + test(S(""), 0, 0, str, str+1, S("1")); + test(S(""), 0, 0, str, str+5, S("12345")); + test(S(""), 0, 0, str, str+9, S("123456789")); + test(S(""), 0, 0, str, str+10, S("1234567890")); + test(S(""), 0, 0, str, str+0, S("")); + test(S(""), 0, 0, str, str+1, S("1")); + test(S(""), 0, 0, str, str+10, S("1234567890")); + test(S(""), 0, 0, str, str+19, S("1234567890123456789")); + test(S(""), 0, 0, str, str+20, S("12345678901234567890")); + test(S("abcde"), 0, 0, str, str+0, S("abcde")); + test(S("abcde"), 0, 0, str, str+0, S("abcde")); + test(S("abcde"), 0, 0, str, str+1, S("1abcde")); + test(S("abcde"), 0, 0, str, str+2, S("12abcde")); + test(S("abcde"), 0, 0, str, str+4, S("1234abcde")); + test(S("abcde"), 0, 0, str, str+5, S("12345abcde")); + test(S("abcde"), 0, 0, str, str+0, S("abcde")); + test(S("abcde"), 0, 0, str, str+1, S("1abcde")); + test(S("abcde"), 0, 0, str, str+5, S("12345abcde")); + test(S("abcde"), 0, 0, str, str+9, S("123456789abcde")); + test(S("abcde"), 0, 0, str, str+10, S("1234567890abcde")); + test(S("abcde"), 0, 0, str, str+0, S("abcde")); + test(S("abcde"), 0, 0, str, str+1, S("1abcde")); + test(S("abcde"), 0, 0, str, str+10, S("1234567890abcde")); + test(S("abcde"), 0, 0, str, str+19, S("1234567890123456789abcde")); + test(S("abcde"), 0, 0, str, str+20, S("12345678901234567890abcde")); + test(S("abcde"), 0, 1, str, str+0, S("bcde")); + test(S("abcde"), 0, 1, str, str+0, S("bcde")); + test(S("abcde"), 0, 1, str, str+1, S("1bcde")); + test(S("abcde"), 0, 1, str, str+2, S("12bcde")); + test(S("abcde"), 0, 1, str, str+4, S("1234bcde")); + test(S("abcde"), 0, 1, str, str+5, S("12345bcde")); + test(S("abcde"), 0, 1, str, str+0, S("bcde")); + test(S("abcde"), 0, 1, str, str+1, S("1bcde")); + test(S("abcde"), 0, 1, str, str+5, S("12345bcde")); + test(S("abcde"), 0, 1, str, str+9, S("123456789bcde")); + test(S("abcde"), 0, 1, str, str+10, S("1234567890bcde")); + test(S("abcde"), 0, 1, str, str+0, S("bcde")); + test(S("abcde"), 0, 1, str, str+1, S("1bcde")); + test(S("abcde"), 0, 1, str, str+10, S("1234567890bcde")); + test(S("abcde"), 0, 1, str, str+19, S("1234567890123456789bcde")); + test(S("abcde"), 0, 1, str, str+20, S("12345678901234567890bcde")); + test(S("abcde"), 0, 2, str, str+0, S("cde")); + test(S("abcde"), 0, 2, str, str+0, S("cde")); + test(S("abcde"), 0, 2, str, str+1, S("1cde")); + test(S("abcde"), 0, 2, str, str+2, S("12cde")); + test(S("abcde"), 0, 2, str, str+4, S("1234cde")); + test(S("abcde"), 0, 2, str, str+5, S("12345cde")); + test(S("abcde"), 0, 2, str, str+0, S("cde")); + test(S("abcde"), 0, 2, str, str+1, S("1cde")); + test(S("abcde"), 0, 2, str, str+5, S("12345cde")); + test(S("abcde"), 0, 2, str, str+9, S("123456789cde")); + test(S("abcde"), 0, 2, str, str+10, S("1234567890cde")); + test(S("abcde"), 0, 2, str, str+0, S("cde")); + test(S("abcde"), 0, 2, str, str+1, S("1cde")); + test(S("abcde"), 0, 2, str, str+10, S("1234567890cde")); + test(S("abcde"), 0, 2, str, str+19, S("1234567890123456789cde")); + test(S("abcde"), 0, 2, str, str+20, S("12345678901234567890cde")); + test(S("abcde"), 0, 4, str, str+0, S("e")); + test(S("abcde"), 0, 4, str, str+0, S("e")); + test(S("abcde"), 0, 4, str, str+1, S("1e")); + test(S("abcde"), 0, 4, str, str+2, S("12e")); + test(S("abcde"), 0, 4, str, str+4, S("1234e")); + test(S("abcde"), 0, 4, str, str+5, S("12345e")); + test(S("abcde"), 0, 4, str, str+0, S("e")); + test(S("abcde"), 0, 4, str, str+1, S("1e")); + test(S("abcde"), 0, 4, str, str+5, S("12345e")); + test(S("abcde"), 0, 4, str, str+9, S("123456789e")); + test(S("abcde"), 0, 4, str, str+10, S("1234567890e")); + test(S("abcde"), 0, 4, str, str+0, S("e")); + test(S("abcde"), 0, 4, str, str+1, S("1e")); + test(S("abcde"), 0, 4, str, str+10, S("1234567890e")); + test(S("abcde"), 0, 4, str, str+19, S("1234567890123456789e")); + test(S("abcde"), 0, 4, str, str+20, S("12345678901234567890e")); + test(S("abcde"), 0, 5, str, str+0, S("")); + test(S("abcde"), 0, 5, str, str+0, S("")); + test(S("abcde"), 0, 5, str, str+1, S("1")); + test(S("abcde"), 0, 5, str, str+2, S("12")); + test(S("abcde"), 0, 5, str, str+4, S("1234")); + test(S("abcde"), 0, 5, str, str+5, S("12345")); + test(S("abcde"), 0, 5, str, str+0, S("")); + test(S("abcde"), 0, 5, str, str+1, S("1")); + test(S("abcde"), 0, 5, str, str+5, S("12345")); + test(S("abcde"), 0, 5, str, str+9, S("123456789")); + test(S("abcde"), 0, 5, str, str+10, S("1234567890")); + test(S("abcde"), 0, 5, str, str+0, S("")); + test(S("abcde"), 0, 5, str, str+1, S("1")); + test(S("abcde"), 0, 5, str, str+10, S("1234567890")); + test(S("abcde"), 0, 5, str, str+19, S("1234567890123456789")); + test(S("abcde"), 0, 5, str, str+20, S("12345678901234567890")); + test(S("abcde"), 1, 0, str, str+0, S("abcde")); + test(S("abcde"), 1, 0, str, str+0, S("abcde")); + test(S("abcde"), 1, 0, str, str+1, S("a1bcde")); + test(S("abcde"), 1, 0, str, str+2, S("a12bcde")); +} + +template <class S> +void test1() +{ + test(S("abcde"), 1, 0, str, str+4, S("a1234bcde")); + test(S("abcde"), 1, 0, str, str+5, S("a12345bcde")); + test(S("abcde"), 1, 0, str, str+0, S("abcde")); + test(S("abcde"), 1, 0, str, str+1, S("a1bcde")); + test(S("abcde"), 1, 0, str, str+5, S("a12345bcde")); + test(S("abcde"), 1, 0, str, str+9, S("a123456789bcde")); + test(S("abcde"), 1, 0, str, str+10, S("a1234567890bcde")); + test(S("abcde"), 1, 0, str, str+0, S("abcde")); + test(S("abcde"), 1, 0, str, str+1, S("a1bcde")); + test(S("abcde"), 1, 0, str, str+10, S("a1234567890bcde")); + test(S("abcde"), 1, 0, str, str+19, S("a1234567890123456789bcde")); + test(S("abcde"), 1, 0, str, str+20, S("a12345678901234567890bcde")); + test(S("abcde"), 1, 1, str, str+0, S("acde")); + test(S("abcde"), 1, 1, str, str+0, S("acde")); + test(S("abcde"), 1, 1, str, str+1, S("a1cde")); + test(S("abcde"), 1, 1, str, str+2, S("a12cde")); + test(S("abcde"), 1, 1, str, str+4, S("a1234cde")); + test(S("abcde"), 1, 1, str, str+5, S("a12345cde")); + test(S("abcde"), 1, 1, str, str+0, S("acde")); + test(S("abcde"), 1, 1, str, str+1, S("a1cde")); + test(S("abcde"), 1, 1, str, str+5, S("a12345cde")); + test(S("abcde"), 1, 1, str, str+9, S("a123456789cde")); + test(S("abcde"), 1, 1, str, str+10, S("a1234567890cde")); + test(S("abcde"), 1, 1, str, str+0, S("acde")); + test(S("abcde"), 1, 1, str, str+1, S("a1cde")); + test(S("abcde"), 1, 1, str, str+10, S("a1234567890cde")); + test(S("abcde"), 1, 1, str, str+19, S("a1234567890123456789cde")); + test(S("abcde"), 1, 1, str, str+20, S("a12345678901234567890cde")); + test(S("abcde"), 1, 2, str, str+0, S("ade")); + test(S("abcde"), 1, 2, str, str+0, S("ade")); + test(S("abcde"), 1, 2, str, str+1, S("a1de")); + test(S("abcde"), 1, 2, str, str+2, S("a12de")); + test(S("abcde"), 1, 2, str, str+4, S("a1234de")); + test(S("abcde"), 1, 2, str, str+5, S("a12345de")); + test(S("abcde"), 1, 2, str, str+0, S("ade")); + test(S("abcde"), 1, 2, str, str+1, S("a1de")); + test(S("abcde"), 1, 2, str, str+5, S("a12345de")); + test(S("abcde"), 1, 2, str, str+9, S("a123456789de")); + test(S("abcde"), 1, 2, str, str+10, S("a1234567890de")); + test(S("abcde"), 1, 2, str, str+0, S("ade")); + test(S("abcde"), 1, 2, str, str+1, S("a1de")); + test(S("abcde"), 1, 2, str, str+10, S("a1234567890de")); + test(S("abcde"), 1, 2, str, str+19, S("a1234567890123456789de")); + test(S("abcde"), 1, 2, str, str+20, S("a12345678901234567890de")); + test(S("abcde"), 1, 3, str, str+0, S("ae")); + test(S("abcde"), 1, 3, str, str+0, S("ae")); + test(S("abcde"), 1, 3, str, str+1, S("a1e")); + test(S("abcde"), 1, 3, str, str+2, S("a12e")); + test(S("abcde"), 1, 3, str, str+4, S("a1234e")); + test(S("abcde"), 1, 3, str, str+5, S("a12345e")); + test(S("abcde"), 1, 3, str, str+0, S("ae")); + test(S("abcde"), 1, 3, str, str+1, S("a1e")); + test(S("abcde"), 1, 3, str, str+5, S("a12345e")); + test(S("abcde"), 1, 3, str, str+9, S("a123456789e")); + test(S("abcde"), 1, 3, str, str+10, S("a1234567890e")); + test(S("abcde"), 1, 3, str, str+0, S("ae")); + test(S("abcde"), 1, 3, str, str+1, S("a1e")); + test(S("abcde"), 1, 3, str, str+10, S("a1234567890e")); + test(S("abcde"), 1, 3, str, str+19, S("a1234567890123456789e")); + test(S("abcde"), 1, 3, str, str+20, S("a12345678901234567890e")); + test(S("abcde"), 1, 4, str, str+0, S("a")); + test(S("abcde"), 1, 4, str, str+0, S("a")); + test(S("abcde"), 1, 4, str, str+1, S("a1")); + test(S("abcde"), 1, 4, str, str+2, S("a12")); + test(S("abcde"), 1, 4, str, str+4, S("a1234")); + test(S("abcde"), 1, 4, str, str+5, S("a12345")); + test(S("abcde"), 1, 4, str, str+0, S("a")); + test(S("abcde"), 1, 4, str, str+1, S("a1")); + test(S("abcde"), 1, 4, str, str+5, S("a12345")); + test(S("abcde"), 1, 4, str, str+9, S("a123456789")); + test(S("abcde"), 1, 4, str, str+10, S("a1234567890")); + test(S("abcde"), 1, 4, str, str+0, S("a")); + test(S("abcde"), 1, 4, str, str+1, S("a1")); + test(S("abcde"), 1, 4, str, str+10, S("a1234567890")); + test(S("abcde"), 1, 4, str, str+19, S("a1234567890123456789")); + test(S("abcde"), 1, 4, str, str+20, S("a12345678901234567890")); + test(S("abcde"), 2, 0, str, str+0, S("abcde")); + test(S("abcde"), 2, 0, str, str+0, S("abcde")); + test(S("abcde"), 2, 0, str, str+1, S("ab1cde")); + test(S("abcde"), 2, 0, str, str+2, S("ab12cde")); + test(S("abcde"), 2, 0, str, str+4, S("ab1234cde")); + test(S("abcde"), 2, 0, str, str+5, S("ab12345cde")); + test(S("abcde"), 2, 0, str, str+0, S("abcde")); + test(S("abcde"), 2, 0, str, str+1, S("ab1cde")); + test(S("abcde"), 2, 0, str, str+5, S("ab12345cde")); + test(S("abcde"), 2, 0, str, str+9, S("ab123456789cde")); + test(S("abcde"), 2, 0, str, str+10, S("ab1234567890cde")); + test(S("abcde"), 2, 0, str, str+0, S("abcde")); + test(S("abcde"), 2, 0, str, str+1, S("ab1cde")); + test(S("abcde"), 2, 0, str, str+10, S("ab1234567890cde")); + test(S("abcde"), 2, 0, str, str+19, S("ab1234567890123456789cde")); + test(S("abcde"), 2, 0, str, str+20, S("ab12345678901234567890cde")); + test(S("abcde"), 2, 1, str, str+0, S("abde")); + test(S("abcde"), 2, 1, str, str+0, S("abde")); + test(S("abcde"), 2, 1, str, str+1, S("ab1de")); + test(S("abcde"), 2, 1, str, str+2, S("ab12de")); + test(S("abcde"), 2, 1, str, str+4, S("ab1234de")); + test(S("abcde"), 2, 1, str, str+5, S("ab12345de")); + test(S("abcde"), 2, 1, str, str+0, S("abde")); + test(S("abcde"), 2, 1, str, str+1, S("ab1de")); +} + +template <class S> +void test2() +{ + test(S("abcde"), 2, 1, str, str+5, S("ab12345de")); + test(S("abcde"), 2, 1, str, str+9, S("ab123456789de")); + test(S("abcde"), 2, 1, str, str+10, S("ab1234567890de")); + test(S("abcde"), 2, 1, str, str+0, S("abde")); + test(S("abcde"), 2, 1, str, str+1, S("ab1de")); + test(S("abcde"), 2, 1, str, str+10, S("ab1234567890de")); + test(S("abcde"), 2, 1, str, str+19, S("ab1234567890123456789de")); + test(S("abcde"), 2, 1, str, str+20, S("ab12345678901234567890de")); + test(S("abcde"), 2, 2, str, str+0, S("abe")); + test(S("abcde"), 2, 2, str, str+0, S("abe")); + test(S("abcde"), 2, 2, str, str+1, S("ab1e")); + test(S("abcde"), 2, 2, str, str+2, S("ab12e")); + test(S("abcde"), 2, 2, str, str+4, S("ab1234e")); + test(S("abcde"), 2, 2, str, str+5, S("ab12345e")); + test(S("abcde"), 2, 2, str, str+0, S("abe")); + test(S("abcde"), 2, 2, str, str+1, S("ab1e")); + test(S("abcde"), 2, 2, str, str+5, S("ab12345e")); + test(S("abcde"), 2, 2, str, str+9, S("ab123456789e")); + test(S("abcde"), 2, 2, str, str+10, S("ab1234567890e")); + test(S("abcde"), 2, 2, str, str+0, S("abe")); + test(S("abcde"), 2, 2, str, str+1, S("ab1e")); + test(S("abcde"), 2, 2, str, str+10, S("ab1234567890e")); + test(S("abcde"), 2, 2, str, str+19, S("ab1234567890123456789e")); + test(S("abcde"), 2, 2, str, str+20, S("ab12345678901234567890e")); + test(S("abcde"), 2, 3, str, str+0, S("ab")); + test(S("abcde"), 2, 3, str, str+0, S("ab")); + test(S("abcde"), 2, 3, str, str+1, S("ab1")); + test(S("abcde"), 2, 3, str, str+2, S("ab12")); + test(S("abcde"), 2, 3, str, str+4, S("ab1234")); + test(S("abcde"), 2, 3, str, str+5, S("ab12345")); + test(S("abcde"), 2, 3, str, str+0, S("ab")); + test(S("abcde"), 2, 3, str, str+1, S("ab1")); + test(S("abcde"), 2, 3, str, str+5, S("ab12345")); + test(S("abcde"), 2, 3, str, str+9, S("ab123456789")); + test(S("abcde"), 2, 3, str, str+10, S("ab1234567890")); + test(S("abcde"), 2, 3, str, str+0, S("ab")); + test(S("abcde"), 2, 3, str, str+1, S("ab1")); + test(S("abcde"), 2, 3, str, str+10, S("ab1234567890")); + test(S("abcde"), 2, 3, str, str+19, S("ab1234567890123456789")); + test(S("abcde"), 2, 3, str, str+20, S("ab12345678901234567890")); + test(S("abcde"), 4, 0, str, str+0, S("abcde")); + test(S("abcde"), 4, 0, str, str+0, S("abcde")); + test(S("abcde"), 4, 0, str, str+1, S("abcd1e")); + test(S("abcde"), 4, 0, str, str+2, S("abcd12e")); + test(S("abcde"), 4, 0, str, str+4, S("abcd1234e")); + test(S("abcde"), 4, 0, str, str+5, S("abcd12345e")); + test(S("abcde"), 4, 0, str, str+0, S("abcde")); + test(S("abcde"), 4, 0, str, str+1, S("abcd1e")); + test(S("abcde"), 4, 0, str, str+5, S("abcd12345e")); + test(S("abcde"), 4, 0, str, str+9, S("abcd123456789e")); + test(S("abcde"), 4, 0, str, str+10, S("abcd1234567890e")); + test(S("abcde"), 4, 0, str, str+0, S("abcde")); + test(S("abcde"), 4, 0, str, str+1, S("abcd1e")); + test(S("abcde"), 4, 0, str, str+10, S("abcd1234567890e")); + test(S("abcde"), 4, 0, str, str+19, S("abcd1234567890123456789e")); + test(S("abcde"), 4, 0, str, str+20, S("abcd12345678901234567890e")); + test(S("abcde"), 4, 1, str, str+0, S("abcd")); + test(S("abcde"), 4, 1, str, str+0, S("abcd")); + test(S("abcde"), 4, 1, str, str+1, S("abcd1")); + test(S("abcde"), 4, 1, str, str+2, S("abcd12")); + test(S("abcde"), 4, 1, str, str+4, S("abcd1234")); + test(S("abcde"), 4, 1, str, str+5, S("abcd12345")); + test(S("abcde"), 4, 1, str, str+0, S("abcd")); + test(S("abcde"), 4, 1, str, str+1, S("abcd1")); + test(S("abcde"), 4, 1, str, str+5, S("abcd12345")); + test(S("abcde"), 4, 1, str, str+9, S("abcd123456789")); + test(S("abcde"), 4, 1, str, str+10, S("abcd1234567890")); + test(S("abcde"), 4, 1, str, str+0, S("abcd")); + test(S("abcde"), 4, 1, str, str+1, S("abcd1")); + test(S("abcde"), 4, 1, str, str+10, S("abcd1234567890")); + test(S("abcde"), 4, 1, str, str+19, S("abcd1234567890123456789")); + test(S("abcde"), 4, 1, str, str+20, S("abcd12345678901234567890")); + test(S("abcde"), 5, 0, str, str+0, S("abcde")); + test(S("abcde"), 5, 0, str, str+0, S("abcde")); + test(S("abcde"), 5, 0, str, str+1, S("abcde1")); + test(S("abcde"), 5, 0, str, str+2, S("abcde12")); + test(S("abcde"), 5, 0, str, str+4, S("abcde1234")); + test(S("abcde"), 5, 0, str, str+5, S("abcde12345")); + test(S("abcde"), 5, 0, str, str+0, S("abcde")); + test(S("abcde"), 5, 0, str, str+1, S("abcde1")); + test(S("abcde"), 5, 0, str, str+5, S("abcde12345")); + test(S("abcde"), 5, 0, str, str+9, S("abcde123456789")); + test(S("abcde"), 5, 0, str, str+10, S("abcde1234567890")); + test(S("abcde"), 5, 0, str, str+0, S("abcde")); + test(S("abcde"), 5, 0, str, str+1, S("abcde1")); + test(S("abcde"), 5, 0, str, str+10, S("abcde1234567890")); + test(S("abcde"), 5, 0, str, str+19, S("abcde1234567890123456789")); + test(S("abcde"), 5, 0, str, str+20, S("abcde12345678901234567890")); + test(S("abcdefghij"), 0, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, str, str+1, S("1abcdefghij")); + test(S("abcdefghij"), 0, 0, str, str+2, S("12abcdefghij")); + test(S("abcdefghij"), 0, 0, str, str+4, S("1234abcdefghij")); + test(S("abcdefghij"), 0, 0, str, str+5, S("12345abcdefghij")); + test(S("abcdefghij"), 0, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, str, str+1, S("1abcdefghij")); + test(S("abcdefghij"), 0, 0, str, str+5, S("12345abcdefghij")); + test(S("abcdefghij"), 0, 0, str, str+9, S("123456789abcdefghij")); + test(S("abcdefghij"), 0, 0, str, str+10, S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, str, str+0, S("abcdefghij")); +} + +template <class S> +void test3() +{ + test(S("abcdefghij"), 0, 0, str, str+1, S("1abcdefghij")); + test(S("abcdefghij"), 0, 0, str, str+10, S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, str, str+19, S("1234567890123456789abcdefghij")); + test(S("abcdefghij"), 0, 0, str, str+20, S("12345678901234567890abcdefghij")); + test(S("abcdefghij"), 0, 1, str, str+0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, str, str+0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, str, str+1, S("1bcdefghij")); + test(S("abcdefghij"), 0, 1, str, str+2, S("12bcdefghij")); + test(S("abcdefghij"), 0, 1, str, str+4, S("1234bcdefghij")); + test(S("abcdefghij"), 0, 1, str, str+5, S("12345bcdefghij")); + test(S("abcdefghij"), 0, 1, str, str+0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, str, str+1, S("1bcdefghij")); + test(S("abcdefghij"), 0, 1, str, str+5, S("12345bcdefghij")); + test(S("abcdefghij"), 0, 1, str, str+9, S("123456789bcdefghij")); + test(S("abcdefghij"), 0, 1, str, str+10, S("1234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, str, str+0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, str, str+1, S("1bcdefghij")); + test(S("abcdefghij"), 0, 1, str, str+10, S("1234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, str, str+19, S("1234567890123456789bcdefghij")); + test(S("abcdefghij"), 0, 1, str, str+20, S("12345678901234567890bcdefghij")); + test(S("abcdefghij"), 0, 5, str, str+0, S("fghij")); + test(S("abcdefghij"), 0, 5, str, str+0, S("fghij")); + test(S("abcdefghij"), 0, 5, str, str+1, S("1fghij")); + test(S("abcdefghij"), 0, 5, str, str+2, S("12fghij")); + test(S("abcdefghij"), 0, 5, str, str+4, S("1234fghij")); + test(S("abcdefghij"), 0, 5, str, str+5, S("12345fghij")); + test(S("abcdefghij"), 0, 5, str, str+0, S("fghij")); + test(S("abcdefghij"), 0, 5, str, str+1, S("1fghij")); + test(S("abcdefghij"), 0, 5, str, str+5, S("12345fghij")); + test(S("abcdefghij"), 0, 5, str, str+9, S("123456789fghij")); + test(S("abcdefghij"), 0, 5, str, str+10, S("1234567890fghij")); + test(S("abcdefghij"), 0, 5, str, str+0, S("fghij")); + test(S("abcdefghij"), 0, 5, str, str+1, S("1fghij")); + test(S("abcdefghij"), 0, 5, str, str+10, S("1234567890fghij")); + test(S("abcdefghij"), 0, 5, str, str+19, S("1234567890123456789fghij")); + test(S("abcdefghij"), 0, 5, str, str+20, S("12345678901234567890fghij")); + test(S("abcdefghij"), 0, 9, str, str+0, S("j")); + test(S("abcdefghij"), 0, 9, str, str+0, S("j")); + test(S("abcdefghij"), 0, 9, str, str+1, S("1j")); + test(S("abcdefghij"), 0, 9, str, str+2, S("12j")); + test(S("abcdefghij"), 0, 9, str, str+4, S("1234j")); + test(S("abcdefghij"), 0, 9, str, str+5, S("12345j")); + test(S("abcdefghij"), 0, 9, str, str+0, S("j")); + test(S("abcdefghij"), 0, 9, str, str+1, S("1j")); + test(S("abcdefghij"), 0, 9, str, str+5, S("12345j")); + test(S("abcdefghij"), 0, 9, str, str+9, S("123456789j")); + test(S("abcdefghij"), 0, 9, str, str+10, S("1234567890j")); + test(S("abcdefghij"), 0, 9, str, str+0, S("j")); + test(S("abcdefghij"), 0, 9, str, str+1, S("1j")); + test(S("abcdefghij"), 0, 9, str, str+10, S("1234567890j")); + test(S("abcdefghij"), 0, 9, str, str+19, S("1234567890123456789j")); + test(S("abcdefghij"), 0, 9, str, str+20, S("12345678901234567890j")); + test(S("abcdefghij"), 0, 10, str, str+0, S("")); + test(S("abcdefghij"), 0, 10, str, str+0, S("")); + test(S("abcdefghij"), 0, 10, str, str+1, S("1")); + test(S("abcdefghij"), 0, 10, str, str+2, S("12")); + test(S("abcdefghij"), 0, 10, str, str+4, S("1234")); + test(S("abcdefghij"), 0, 10, str, str+5, S("12345")); + test(S("abcdefghij"), 0, 10, str, str+0, S("")); + test(S("abcdefghij"), 0, 10, str, str+1, S("1")); + test(S("abcdefghij"), 0, 10, str, str+5, S("12345")); + test(S("abcdefghij"), 0, 10, str, str+9, S("123456789")); + test(S("abcdefghij"), 0, 10, str, str+10, S("1234567890")); + test(S("abcdefghij"), 0, 10, str, str+0, S("")); + test(S("abcdefghij"), 0, 10, str, str+1, S("1")); + test(S("abcdefghij"), 0, 10, str, str+10, S("1234567890")); + test(S("abcdefghij"), 0, 10, str, str+19, S("1234567890123456789")); + test(S("abcdefghij"), 0, 10, str, str+20, S("12345678901234567890")); + test(S("abcdefghij"), 1, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, str, str+1, S("a1bcdefghij")); + test(S("abcdefghij"), 1, 0, str, str+2, S("a12bcdefghij")); + test(S("abcdefghij"), 1, 0, str, str+4, S("a1234bcdefghij")); + test(S("abcdefghij"), 1, 0, str, str+5, S("a12345bcdefghij")); + test(S("abcdefghij"), 1, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, str, str+1, S("a1bcdefghij")); + test(S("abcdefghij"), 1, 0, str, str+5, S("a12345bcdefghij")); + test(S("abcdefghij"), 1, 0, str, str+9, S("a123456789bcdefghij")); + test(S("abcdefghij"), 1, 0, str, str+10, S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, str, str+1, S("a1bcdefghij")); + test(S("abcdefghij"), 1, 0, str, str+10, S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, str, str+19, S("a1234567890123456789bcdefghij")); + test(S("abcdefghij"), 1, 0, str, str+20, S("a12345678901234567890bcdefghij")); + test(S("abcdefghij"), 1, 1, str, str+0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, str, str+0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, str, str+1, S("a1cdefghij")); + test(S("abcdefghij"), 1, 1, str, str+2, S("a12cdefghij")); + test(S("abcdefghij"), 1, 1, str, str+4, S("a1234cdefghij")); + test(S("abcdefghij"), 1, 1, str, str+5, S("a12345cdefghij")); + test(S("abcdefghij"), 1, 1, str, str+0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, str, str+1, S("a1cdefghij")); + test(S("abcdefghij"), 1, 1, str, str+5, S("a12345cdefghij")); + test(S("abcdefghij"), 1, 1, str, str+9, S("a123456789cdefghij")); + test(S("abcdefghij"), 1, 1, str, str+10, S("a1234567890cdefghij")); + test(S("abcdefghij"), 1, 1, str, str+0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, str, str+1, S("a1cdefghij")); + test(S("abcdefghij"), 1, 1, str, str+10, S("a1234567890cdefghij")); + test(S("abcdefghij"), 1, 1, str, str+19, S("a1234567890123456789cdefghij")); + test(S("abcdefghij"), 1, 1, str, str+20, S("a12345678901234567890cdefghij")); +} + +template <class S> +void test4() +{ + test(S("abcdefghij"), 1, 4, str, str+0, S("afghij")); + test(S("abcdefghij"), 1, 4, str, str+0, S("afghij")); + test(S("abcdefghij"), 1, 4, str, str+1, S("a1fghij")); + test(S("abcdefghij"), 1, 4, str, str+2, S("a12fghij")); + test(S("abcdefghij"), 1, 4, str, str+4, S("a1234fghij")); + test(S("abcdefghij"), 1, 4, str, str+5, S("a12345fghij")); + test(S("abcdefghij"), 1, 4, str, str+0, S("afghij")); + test(S("abcdefghij"), 1, 4, str, str+1, S("a1fghij")); + test(S("abcdefghij"), 1, 4, str, str+5, S("a12345fghij")); + test(S("abcdefghij"), 1, 4, str, str+9, S("a123456789fghij")); + test(S("abcdefghij"), 1, 4, str, str+10, S("a1234567890fghij")); + test(S("abcdefghij"), 1, 4, str, str+0, S("afghij")); + test(S("abcdefghij"), 1, 4, str, str+1, S("a1fghij")); + test(S("abcdefghij"), 1, 4, str, str+10, S("a1234567890fghij")); + test(S("abcdefghij"), 1, 4, str, str+19, S("a1234567890123456789fghij")); + test(S("abcdefghij"), 1, 4, str, str+20, S("a12345678901234567890fghij")); + test(S("abcdefghij"), 1, 8, str, str+0, S("aj")); + test(S("abcdefghij"), 1, 8, str, str+0, S("aj")); + test(S("abcdefghij"), 1, 8, str, str+1, S("a1j")); + test(S("abcdefghij"), 1, 8, str, str+2, S("a12j")); + test(S("abcdefghij"), 1, 8, str, str+4, S("a1234j")); + test(S("abcdefghij"), 1, 8, str, str+5, S("a12345j")); + test(S("abcdefghij"), 1, 8, str, str+0, S("aj")); + test(S("abcdefghij"), 1, 8, str, str+1, S("a1j")); + test(S("abcdefghij"), 1, 8, str, str+5, S("a12345j")); + test(S("abcdefghij"), 1, 8, str, str+9, S("a123456789j")); + test(S("abcdefghij"), 1, 8, str, str+10, S("a1234567890j")); + test(S("abcdefghij"), 1, 8, str, str+0, S("aj")); + test(S("abcdefghij"), 1, 8, str, str+1, S("a1j")); + test(S("abcdefghij"), 1, 8, str, str+10, S("a1234567890j")); + test(S("abcdefghij"), 1, 8, str, str+19, S("a1234567890123456789j")); + test(S("abcdefghij"), 1, 8, str, str+20, S("a12345678901234567890j")); + test(S("abcdefghij"), 1, 9, str, str+0, S("a")); + test(S("abcdefghij"), 1, 9, str, str+0, S("a")); + test(S("abcdefghij"), 1, 9, str, str+1, S("a1")); + test(S("abcdefghij"), 1, 9, str, str+2, S("a12")); + test(S("abcdefghij"), 1, 9, str, str+4, S("a1234")); + test(S("abcdefghij"), 1, 9, str, str+5, S("a12345")); + test(S("abcdefghij"), 1, 9, str, str+0, S("a")); + test(S("abcdefghij"), 1, 9, str, str+1, S("a1")); + test(S("abcdefghij"), 1, 9, str, str+5, S("a12345")); + test(S("abcdefghij"), 1, 9, str, str+9, S("a123456789")); + test(S("abcdefghij"), 1, 9, str, str+10, S("a1234567890")); + test(S("abcdefghij"), 1, 9, str, str+0, S("a")); + test(S("abcdefghij"), 1, 9, str, str+1, S("a1")); + test(S("abcdefghij"), 1, 9, str, str+10, S("a1234567890")); + test(S("abcdefghij"), 1, 9, str, str+19, S("a1234567890123456789")); + test(S("abcdefghij"), 1, 9, str, str+20, S("a12345678901234567890")); + test(S("abcdefghij"), 5, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, str, str+1, S("abcde1fghij")); + test(S("abcdefghij"), 5, 0, str, str+2, S("abcde12fghij")); + test(S("abcdefghij"), 5, 0, str, str+4, S("abcde1234fghij")); + test(S("abcdefghij"), 5, 0, str, str+5, S("abcde12345fghij")); + test(S("abcdefghij"), 5, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, str, str+1, S("abcde1fghij")); + test(S("abcdefghij"), 5, 0, str, str+5, S("abcde12345fghij")); + test(S("abcdefghij"), 5, 0, str, str+9, S("abcde123456789fghij")); + test(S("abcdefghij"), 5, 0, str, str+10, S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, str, str+1, S("abcde1fghij")); + test(S("abcdefghij"), 5, 0, str, str+10, S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, 0, str, str+19, S("abcde1234567890123456789fghij")); + test(S("abcdefghij"), 5, 0, str, str+20, S("abcde12345678901234567890fghij")); + test(S("abcdefghij"), 5, 1, str, str+0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, str, str+0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, str, str+1, S("abcde1ghij")); + test(S("abcdefghij"), 5, 1, str, str+2, S("abcde12ghij")); + test(S("abcdefghij"), 5, 1, str, str+4, S("abcde1234ghij")); + test(S("abcdefghij"), 5, 1, str, str+5, S("abcde12345ghij")); + test(S("abcdefghij"), 5, 1, str, str+0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, str, str+1, S("abcde1ghij")); + test(S("abcdefghij"), 5, 1, str, str+5, S("abcde12345ghij")); + test(S("abcdefghij"), 5, 1, str, str+9, S("abcde123456789ghij")); + test(S("abcdefghij"), 5, 1, str, str+10, S("abcde1234567890ghij")); + test(S("abcdefghij"), 5, 1, str, str+0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, str, str+1, S("abcde1ghij")); + test(S("abcdefghij"), 5, 1, str, str+10, S("abcde1234567890ghij")); + test(S("abcdefghij"), 5, 1, str, str+19, S("abcde1234567890123456789ghij")); + test(S("abcdefghij"), 5, 1, str, str+20, S("abcde12345678901234567890ghij")); + test(S("abcdefghij"), 5, 2, str, str+0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, str, str+0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, str, str+1, S("abcde1hij")); + test(S("abcdefghij"), 5, 2, str, str+2, S("abcde12hij")); + test(S("abcdefghij"), 5, 2, str, str+4, S("abcde1234hij")); + test(S("abcdefghij"), 5, 2, str, str+5, S("abcde12345hij")); + test(S("abcdefghij"), 5, 2, str, str+0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, str, str+1, S("abcde1hij")); + test(S("abcdefghij"), 5, 2, str, str+5, S("abcde12345hij")); + test(S("abcdefghij"), 5, 2, str, str+9, S("abcde123456789hij")); + test(S("abcdefghij"), 5, 2, str, str+10, S("abcde1234567890hij")); + test(S("abcdefghij"), 5, 2, str, str+0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, str, str+1, S("abcde1hij")); + test(S("abcdefghij"), 5, 2, str, str+10, S("abcde1234567890hij")); + test(S("abcdefghij"), 5, 2, str, str+19, S("abcde1234567890123456789hij")); + test(S("abcdefghij"), 5, 2, str, str+20, S("abcde12345678901234567890hij")); + test(S("abcdefghij"), 5, 4, str, str+0, S("abcdej")); + test(S("abcdefghij"), 5, 4, str, str+0, S("abcdej")); + test(S("abcdefghij"), 5, 4, str, str+1, S("abcde1j")); + test(S("abcdefghij"), 5, 4, str, str+2, S("abcde12j")); +} + +template <class S> +void test5() +{ + test(S("abcdefghij"), 5, 4, str, str+4, S("abcde1234j")); + test(S("abcdefghij"), 5, 4, str, str+5, S("abcde12345j")); + test(S("abcdefghij"), 5, 4, str, str+0, S("abcdej")); + test(S("abcdefghij"), 5, 4, str, str+1, S("abcde1j")); + test(S("abcdefghij"), 5, 4, str, str+5, S("abcde12345j")); + test(S("abcdefghij"), 5, 4, str, str+9, S("abcde123456789j")); + test(S("abcdefghij"), 5, 4, str, str+10, S("abcde1234567890j")); + test(S("abcdefghij"), 5, 4, str, str+0, S("abcdej")); + test(S("abcdefghij"), 5, 4, str, str+1, S("abcde1j")); + test(S("abcdefghij"), 5, 4, str, str+10, S("abcde1234567890j")); + test(S("abcdefghij"), 5, 4, str, str+19, S("abcde1234567890123456789j")); + test(S("abcdefghij"), 5, 4, str, str+20, S("abcde12345678901234567890j")); + test(S("abcdefghij"), 5, 5, str, str+0, S("abcde")); + test(S("abcdefghij"), 5, 5, str, str+0, S("abcde")); + test(S("abcdefghij"), 5, 5, str, str+1, S("abcde1")); + test(S("abcdefghij"), 5, 5, str, str+2, S("abcde12")); + test(S("abcdefghij"), 5, 5, str, str+4, S("abcde1234")); + test(S("abcdefghij"), 5, 5, str, str+5, S("abcde12345")); + test(S("abcdefghij"), 5, 5, str, str+0, S("abcde")); + test(S("abcdefghij"), 5, 5, str, str+1, S("abcde1")); + test(S("abcdefghij"), 5, 5, str, str+5, S("abcde12345")); + test(S("abcdefghij"), 5, 5, str, str+9, S("abcde123456789")); + test(S("abcdefghij"), 5, 5, str, str+10, S("abcde1234567890")); + test(S("abcdefghij"), 5, 5, str, str+0, S("abcde")); + test(S("abcdefghij"), 5, 5, str, str+1, S("abcde1")); + test(S("abcdefghij"), 5, 5, str, str+10, S("abcde1234567890")); + test(S("abcdefghij"), 5, 5, str, str+19, S("abcde1234567890123456789")); + test(S("abcdefghij"), 5, 5, str, str+20, S("abcde12345678901234567890")); + test(S("abcdefghij"), 9, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, str, str+1, S("abcdefghi1j")); + test(S("abcdefghij"), 9, 0, str, str+2, S("abcdefghi12j")); + test(S("abcdefghij"), 9, 0, str, str+4, S("abcdefghi1234j")); + test(S("abcdefghij"), 9, 0, str, str+5, S("abcdefghi12345j")); + test(S("abcdefghij"), 9, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, str, str+1, S("abcdefghi1j")); + test(S("abcdefghij"), 9, 0, str, str+5, S("abcdefghi12345j")); + test(S("abcdefghij"), 9, 0, str, str+9, S("abcdefghi123456789j")); + test(S("abcdefghij"), 9, 0, str, str+10, S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, str, str+1, S("abcdefghi1j")); + test(S("abcdefghij"), 9, 0, str, str+10, S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, 0, str, str+19, S("abcdefghi1234567890123456789j")); + test(S("abcdefghij"), 9, 0, str, str+20, S("abcdefghi12345678901234567890j")); + test(S("abcdefghij"), 9, 1, str, str+0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, str, str+0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, str, str+1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 1, str, str+2, S("abcdefghi12")); + test(S("abcdefghij"), 9, 1, str, str+4, S("abcdefghi1234")); + test(S("abcdefghij"), 9, 1, str, str+5, S("abcdefghi12345")); + test(S("abcdefghij"), 9, 1, str, str+0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, str, str+1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 1, str, str+5, S("abcdefghi12345")); + test(S("abcdefghij"), 9, 1, str, str+9, S("abcdefghi123456789")); + test(S("abcdefghij"), 9, 1, str, str+10, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 1, str, str+0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, str, str+1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 1, str, str+10, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 1, str, str+19, S("abcdefghi1234567890123456789")); + test(S("abcdefghij"), 9, 1, str, str+20, S("abcdefghi12345678901234567890")); + test(S("abcdefghij"), 10, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, str, str+1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 0, str, str+2, S("abcdefghij12")); + test(S("abcdefghij"), 10, 0, str, str+4, S("abcdefghij1234")); + test(S("abcdefghij"), 10, 0, str, str+5, S("abcdefghij12345")); + test(S("abcdefghij"), 10, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, str, str+1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 0, str, str+5, S("abcdefghij12345")); + test(S("abcdefghij"), 10, 0, str, str+9, S("abcdefghij123456789")); + test(S("abcdefghij"), 10, 0, str, str+10, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 0, str, str+0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, str, str+1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 0, str, str+10, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 0, str, str+19, S("abcdefghij1234567890123456789")); + test(S("abcdefghij"), 10, 0, str, str+20, S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 0, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, str, str+1, S("1abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, str, str+2, S("12abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, str, str+4, S("1234abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, str, str+5, S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, str, str+1, S("1abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, str, str+5, S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, str, str+9, S("123456789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, str, str+10, S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, str, str+1, S("1abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, str, str+10, S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, str, str+19, S("1234567890123456789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, str, str+20, S("12345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, str, str+0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, str, str+0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, str, str+1, S("1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, str, str+2, S("12bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, str, str+4, S("1234bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, str, str+5, S("12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, str, str+0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, str, str+1, S("1bcdefghijklmnopqrst")); +} + +template <class S> +void test6() +{ + test(S("abcdefghijklmnopqrst"), 0, 1, str, str+5, S("12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, str, str+9, S("123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, str, str+10, S("1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, str, str+0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, str, str+1, S("1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, str, str+10, S("1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, str, str+19, S("1234567890123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, str, str+20, S("12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, str, str+0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, str, str+0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, str, str+1, S("1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, str, str+2, S("12klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, str, str+4, S("1234klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, str, str+5, S("12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, str, str+0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, str, str+1, S("1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, str, str+5, S("12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, str, str+9, S("123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, str, str+10, S("1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, str, str+0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, str, str+1, S("1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, str, str+10, S("1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, str, str+19, S("1234567890123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, str, str+20, S("12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 19, str, str+0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, str, str+0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, str, str+1, S("1t")); + test(S("abcdefghijklmnopqrst"), 0, 19, str, str+2, S("12t")); + test(S("abcdefghijklmnopqrst"), 0, 19, str, str+4, S("1234t")); + test(S("abcdefghijklmnopqrst"), 0, 19, str, str+5, S("12345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, str, str+0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, str, str+1, S("1t")); + test(S("abcdefghijklmnopqrst"), 0, 19, str, str+5, S("12345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, str, str+9, S("123456789t")); + test(S("abcdefghijklmnopqrst"), 0, 19, str, str+10, S("1234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, str, str+0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, str, str+1, S("1t")); + test(S("abcdefghijklmnopqrst"), 0, 19, str, str+10, S("1234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, str, str+19, S("1234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 0, 19, str, str+20, S("12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 20, str, str+0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, str, str+0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, str, str+1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 20, str, str+2, S("12")); + test(S("abcdefghijklmnopqrst"), 0, 20, str, str+4, S("1234")); + test(S("abcdefghijklmnopqrst"), 0, 20, str, str+5, S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 20, str, str+0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, str, str+1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 20, str, str+5, S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 20, str, str+9, S("123456789")); + test(S("abcdefghijklmnopqrst"), 0, 20, str, str+10, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, str, str+0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, str, str+1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 20, str, str+10, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, str, str+19, S("1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 0, 20, str, str+20, S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, str, str+1, S("a1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, str, str+2, S("a12bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, str, str+4, S("a1234bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, str, str+5, S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, str, str+1, S("a1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, str, str+5, S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, str, str+9, S("a123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, str, str+10, S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, str, str+1, S("a1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, str, str+10, S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, str, str+19, S("a1234567890123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, str, str+20, S("a12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, str, str+0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, str, str+0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, str, str+1, S("a1cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, str, str+2, S("a12cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, str, str+4, S("a1234cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, str, str+5, S("a12345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, str, str+0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, str, str+1, S("a1cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, str, str+5, S("a12345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, str, str+9, S("a123456789cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, str, str+10, S("a1234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, str, str+0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, str, str+1, S("a1cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, str, str+10, S("a1234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, str, str+19, S("a1234567890123456789cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, str, str+20, S("a12345678901234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, str, str+0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, str, str+0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, str, str+1, S("a1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, str, str+2, S("a12klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, str, str+4, S("a1234klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, str, str+5, S("a12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, str, str+0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, str, str+1, S("a1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, str, str+5, S("a12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, str, str+9, S("a123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, str, str+10, S("a1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, str, str+0, S("aklmnopqrst")); +} + +template <class S> +void test7() +{ + test(S("abcdefghijklmnopqrst"), 1, 9, str, str+1, S("a1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, str, str+10, S("a1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, str, str+19, S("a1234567890123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, str, str+20, S("a12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 18, str, str+0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, str, str+0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, str, str+1, S("a1t")); + test(S("abcdefghijklmnopqrst"), 1, 18, str, str+2, S("a12t")); + test(S("abcdefghijklmnopqrst"), 1, 18, str, str+4, S("a1234t")); + test(S("abcdefghijklmnopqrst"), 1, 18, str, str+5, S("a12345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, str, str+0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, str, str+1, S("a1t")); + test(S("abcdefghijklmnopqrst"), 1, 18, str, str+5, S("a12345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, str, str+9, S("a123456789t")); + test(S("abcdefghijklmnopqrst"), 1, 18, str, str+10, S("a1234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, str, str+0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, str, str+1, S("a1t")); + test(S("abcdefghijklmnopqrst"), 1, 18, str, str+10, S("a1234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, str, str+19, S("a1234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 1, 18, str, str+20, S("a12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 19, str, str+0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, str, str+0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, str, str+1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 19, str, str+2, S("a12")); + test(S("abcdefghijklmnopqrst"), 1, 19, str, str+4, S("a1234")); + test(S("abcdefghijklmnopqrst"), 1, 19, str, str+5, S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 19, str, str+0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, str, str+1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 19, str, str+5, S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 19, str, str+9, S("a123456789")); + test(S("abcdefghijklmnopqrst"), 1, 19, str, str+10, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, str, str+0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, str, str+1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 19, str, str+10, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, str, str+19, S("a1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 1, 19, str, str+20, S("a12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, str, str+1, S("abcdefghij1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, str, str+2, S("abcdefghij12klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, str, str+4, S("abcdefghij1234klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, str, str+5, S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, str, str+1, S("abcdefghij1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, str, str+5, S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, str, str+9, S("abcdefghij123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, str, str+10, S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, str, str+1, S("abcdefghij1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, str, str+10, S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, str, str+19, S("abcdefghij1234567890123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, str, str+20, S("abcdefghij12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, str, str+0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, str, str+0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, str, str+1, S("abcdefghij1lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, str, str+2, S("abcdefghij12lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, str, str+4, S("abcdefghij1234lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, str, str+5, S("abcdefghij12345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, str, str+0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, str, str+1, S("abcdefghij1lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, str, str+5, S("abcdefghij12345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, str, str+9, S("abcdefghij123456789lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, str, str+10, S("abcdefghij1234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, str, str+0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, str, str+1, S("abcdefghij1lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, str, str+10, S("abcdefghij1234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, str, str+19, S("abcdefghij1234567890123456789lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, str, str+20, S("abcdefghij12345678901234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, str, str+0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, str, str+0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, str, str+1, S("abcdefghij1pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, str, str+2, S("abcdefghij12pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, str, str+4, S("abcdefghij1234pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, str, str+5, S("abcdefghij12345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, str, str+0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, str, str+1, S("abcdefghij1pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, str, str+5, S("abcdefghij12345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, str, str+9, S("abcdefghij123456789pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, str, str+10, S("abcdefghij1234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, str, str+0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, str, str+1, S("abcdefghij1pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, str, str+10, S("abcdefghij1234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, str, str+19, S("abcdefghij1234567890123456789pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, str, str+20, S("abcdefghij12345678901234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 9, str, str+0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, str, str+0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, str, str+1, S("abcdefghij1t")); + test(S("abcdefghijklmnopqrst"), 10, 9, str, str+2, S("abcdefghij12t")); + test(S("abcdefghijklmnopqrst"), 10, 9, str, str+4, S("abcdefghij1234t")); + test(S("abcdefghijklmnopqrst"), 10, 9, str, str+5, S("abcdefghij12345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, str, str+0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, str, str+1, S("abcdefghij1t")); + test(S("abcdefghijklmnopqrst"), 10, 9, str, str+5, S("abcdefghij12345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, str, str+9, S("abcdefghij123456789t")); + test(S("abcdefghijklmnopqrst"), 10, 9, str, str+10, S("abcdefghij1234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, str, str+0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, str, str+1, S("abcdefghij1t")); + test(S("abcdefghijklmnopqrst"), 10, 9, str, str+10, S("abcdefghij1234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, str, str+19, S("abcdefghij1234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 10, 9, str, str+20, S("abcdefghij12345678901234567890t")); +} + +template <class S> +void test8() +{ + test(S("abcdefghijklmnopqrst"), 10, 10, str, str+0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, str, str+0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, str, str+1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 10, str, str+2, S("abcdefghij12")); + test(S("abcdefghijklmnopqrst"), 10, 10, str, str+4, S("abcdefghij1234")); + test(S("abcdefghijklmnopqrst"), 10, 10, str, str+5, S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 10, str, str+0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, str, str+1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 10, str, str+5, S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 10, str, str+9, S("abcdefghij123456789")); + test(S("abcdefghijklmnopqrst"), 10, 10, str, str+10, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, str, str+0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, str, str+1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 10, str, str+10, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, str, str+19, S("abcdefghij1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 10, 10, str, str+20, S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, str, str+1, S("abcdefghijklmnopqrs1t")); + test(S("abcdefghijklmnopqrst"), 19, 0, str, str+2, S("abcdefghijklmnopqrs12t")); + test(S("abcdefghijklmnopqrst"), 19, 0, str, str+4, S("abcdefghijklmnopqrs1234t")); + test(S("abcdefghijklmnopqrst"), 19, 0, str, str+5, S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, str, str+1, S("abcdefghijklmnopqrs1t")); + test(S("abcdefghijklmnopqrst"), 19, 0, str, str+5, S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, str, str+9, S("abcdefghijklmnopqrs123456789t")); + test(S("abcdefghijklmnopqrst"), 19, 0, str, str+10, S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, str, str+1, S("abcdefghijklmnopqrs1t")); + test(S("abcdefghijklmnopqrst"), 19, 0, str, str+10, S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, str, str+19, S("abcdefghijklmnopqrs1234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 19, 0, str, str+20, S("abcdefghijklmnopqrs12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 1, str, str+0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, str, str+0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, str, str+1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 1, str, str+2, S("abcdefghijklmnopqrs12")); + test(S("abcdefghijklmnopqrst"), 19, 1, str, str+4, S("abcdefghijklmnopqrs1234")); + test(S("abcdefghijklmnopqrst"), 19, 1, str, str+5, S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 1, str, str+0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, str, str+1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 1, str, str+5, S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 1, str, str+9, S("abcdefghijklmnopqrs123456789")); + test(S("abcdefghijklmnopqrst"), 19, 1, str, str+10, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, str, str+0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, str, str+1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 1, str, str+10, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, str, str+19, S("abcdefghijklmnopqrs1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 19, 1, str, str+20, S("abcdefghijklmnopqrs12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, str, str+1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 0, str, str+2, S("abcdefghijklmnopqrst12")); + test(S("abcdefghijklmnopqrst"), 20, 0, str, str+4, S("abcdefghijklmnopqrst1234")); + test(S("abcdefghijklmnopqrst"), 20, 0, str, str+5, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, str, str+1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 0, str, str+5, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 0, str, str+9, S("abcdefghijklmnopqrst123456789")); + test(S("abcdefghijklmnopqrst"), 20, 0, str, str+10, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, str, str+0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, str, str+1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 0, str, str+10, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, str, str+19, S("abcdefghijklmnopqrst1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 20, 0, str, str+20, S("abcdefghijklmnopqrst12345678901234567890")); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + test4<S>(); + test5<S>(); + test6<S>(); + test7<S>(); + test8<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + test4<S>(); + test5<S>(); + test6<S>(); + test7<S>(); + test8<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp new file mode 100644 index 000000000000..cb4ce61d0942 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp @@ -0,0 +1,285 @@ +//===----------------------------------------------------------------------===// +// +// 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>& +// replace(const_iterator i1, const_iterator i2, const charT* s); + +#include <stdio.h> + +#include <string> +#include <algorithm> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s, typename S::size_type pos1, typename S::size_type n1, const typename S::value_type* str, S expected) +{ + typename S::size_type old_size = s.size(); + typename S::const_iterator first = s.begin() + pos1; + typename S::const_iterator last = s.begin() + pos1 + n1; + typename S::size_type xlen = last - first; + s.replace(first, last, str); + assert(s.__invariants()); + assert(s == expected); + typename S::size_type rlen = S::traits_type::length(str); + assert(s.size() == old_size - xlen + rlen); +} + +template <class S> +void test0() +{ + test(S(""), 0, 0, "", S("")); + test(S(""), 0, 0, "12345", S("12345")); + test(S(""), 0, 0, "1234567890", S("1234567890")); + test(S(""), 0, 0, "12345678901234567890", S("12345678901234567890")); + test(S("abcde"), 0, 0, "", S("abcde")); + test(S("abcde"), 0, 0, "12345", S("12345abcde")); + test(S("abcde"), 0, 0, "1234567890", S("1234567890abcde")); + test(S("abcde"), 0, 0, "12345678901234567890", S("12345678901234567890abcde")); + test(S("abcde"), 0, 1, "", S("bcde")); + test(S("abcde"), 0, 1, "12345", S("12345bcde")); + test(S("abcde"), 0, 1, "1234567890", S("1234567890bcde")); + test(S("abcde"), 0, 1, "12345678901234567890", S("12345678901234567890bcde")); + test(S("abcde"), 0, 2, "", S("cde")); + test(S("abcde"), 0, 2, "12345", S("12345cde")); + test(S("abcde"), 0, 2, "1234567890", S("1234567890cde")); + test(S("abcde"), 0, 2, "12345678901234567890", S("12345678901234567890cde")); + test(S("abcde"), 0, 4, "", S("e")); + test(S("abcde"), 0, 4, "12345", S("12345e")); + test(S("abcde"), 0, 4, "1234567890", S("1234567890e")); + test(S("abcde"), 0, 4, "12345678901234567890", S("12345678901234567890e")); + test(S("abcde"), 0, 5, "", S("")); + test(S("abcde"), 0, 5, "12345", S("12345")); + test(S("abcde"), 0, 5, "1234567890", S("1234567890")); + test(S("abcde"), 0, 5, "12345678901234567890", S("12345678901234567890")); + test(S("abcde"), 1, 0, "", S("abcde")); + test(S("abcde"), 1, 0, "12345", S("a12345bcde")); + test(S("abcde"), 1, 0, "1234567890", S("a1234567890bcde")); + test(S("abcde"), 1, 0, "12345678901234567890", S("a12345678901234567890bcde")); + test(S("abcde"), 1, 1, "", S("acde")); + test(S("abcde"), 1, 1, "12345", S("a12345cde")); + test(S("abcde"), 1, 1, "1234567890", S("a1234567890cde")); + test(S("abcde"), 1, 1, "12345678901234567890", S("a12345678901234567890cde")); + test(S("abcde"), 1, 2, "", S("ade")); + test(S("abcde"), 1, 2, "12345", S("a12345de")); + test(S("abcde"), 1, 2, "1234567890", S("a1234567890de")); + test(S("abcde"), 1, 2, "12345678901234567890", S("a12345678901234567890de")); + test(S("abcde"), 1, 3, "", S("ae")); + test(S("abcde"), 1, 3, "12345", S("a12345e")); + test(S("abcde"), 1, 3, "1234567890", S("a1234567890e")); + test(S("abcde"), 1, 3, "12345678901234567890", S("a12345678901234567890e")); + test(S("abcde"), 1, 4, "", S("a")); + test(S("abcde"), 1, 4, "12345", S("a12345")); + test(S("abcde"), 1, 4, "1234567890", S("a1234567890")); + test(S("abcde"), 1, 4, "12345678901234567890", S("a12345678901234567890")); + test(S("abcde"), 2, 0, "", S("abcde")); + test(S("abcde"), 2, 0, "12345", S("ab12345cde")); + test(S("abcde"), 2, 0, "1234567890", S("ab1234567890cde")); + test(S("abcde"), 2, 0, "12345678901234567890", S("ab12345678901234567890cde")); + test(S("abcde"), 2, 1, "", S("abde")); + test(S("abcde"), 2, 1, "12345", S("ab12345de")); + test(S("abcde"), 2, 1, "1234567890", S("ab1234567890de")); + test(S("abcde"), 2, 1, "12345678901234567890", S("ab12345678901234567890de")); + test(S("abcde"), 2, 2, "", S("abe")); + test(S("abcde"), 2, 2, "12345", S("ab12345e")); + test(S("abcde"), 2, 2, "1234567890", S("ab1234567890e")); + test(S("abcde"), 2, 2, "12345678901234567890", S("ab12345678901234567890e")); + test(S("abcde"), 2, 3, "", S("ab")); + test(S("abcde"), 2, 3, "12345", S("ab12345")); + test(S("abcde"), 2, 3, "1234567890", S("ab1234567890")); + test(S("abcde"), 2, 3, "12345678901234567890", S("ab12345678901234567890")); + test(S("abcde"), 4, 0, "", S("abcde")); + test(S("abcde"), 4, 0, "12345", S("abcd12345e")); + test(S("abcde"), 4, 0, "1234567890", S("abcd1234567890e")); + test(S("abcde"), 4, 0, "12345678901234567890", S("abcd12345678901234567890e")); + test(S("abcde"), 4, 1, "", S("abcd")); + test(S("abcde"), 4, 1, "12345", S("abcd12345")); + test(S("abcde"), 4, 1, "1234567890", S("abcd1234567890")); + test(S("abcde"), 4, 1, "12345678901234567890", S("abcd12345678901234567890")); + test(S("abcde"), 5, 0, "", S("abcde")); + test(S("abcde"), 5, 0, "12345", S("abcde12345")); + test(S("abcde"), 5, 0, "1234567890", S("abcde1234567890")); + test(S("abcde"), 5, 0, "12345678901234567890", S("abcde12345678901234567890")); + test(S("abcdefghij"), 0, 0, "", S("abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345", S("12345abcdefghij")); + test(S("abcdefghij"), 0, 0, "1234567890", S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345678901234567890", S("12345678901234567890abcdefghij")); + test(S("abcdefghij"), 0, 1, "", S("bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345", S("12345bcdefghij")); + test(S("abcdefghij"), 0, 1, "1234567890", S("1234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345678901234567890", S("12345678901234567890bcdefghij")); + test(S("abcdefghij"), 0, 5, "", S("fghij")); + test(S("abcdefghij"), 0, 5, "12345", S("12345fghij")); + test(S("abcdefghij"), 0, 5, "1234567890", S("1234567890fghij")); + test(S("abcdefghij"), 0, 5, "12345678901234567890", S("12345678901234567890fghij")); + test(S("abcdefghij"), 0, 9, "", S("j")); + test(S("abcdefghij"), 0, 9, "12345", S("12345j")); + test(S("abcdefghij"), 0, 9, "1234567890", S("1234567890j")); + test(S("abcdefghij"), 0, 9, "12345678901234567890", S("12345678901234567890j")); + test(S("abcdefghij"), 0, 10, "", S("")); + test(S("abcdefghij"), 0, 10, "12345", S("12345")); + test(S("abcdefghij"), 0, 10, "1234567890", S("1234567890")); + test(S("abcdefghij"), 0, 10, "12345678901234567890", S("12345678901234567890")); + test(S("abcdefghij"), 1, 0, "", S("abcdefghij")); + test(S("abcdefghij"), 1, 0, "12345", S("a12345bcdefghij")); + test(S("abcdefghij"), 1, 0, "1234567890", S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, "12345678901234567890", S("a12345678901234567890bcdefghij")); + test(S("abcdefghij"), 1, 1, "", S("acdefghij")); + test(S("abcdefghij"), 1, 1, "12345", S("a12345cdefghij")); + test(S("abcdefghij"), 1, 1, "1234567890", S("a1234567890cdefghij")); + test(S("abcdefghij"), 1, 1, "12345678901234567890", S("a12345678901234567890cdefghij")); +} + +template <class S> +void test1() +{ + test(S("abcdefghij"), 1, 4, "", S("afghij")); + test(S("abcdefghij"), 1, 4, "12345", S("a12345fghij")); + test(S("abcdefghij"), 1, 4, "1234567890", S("a1234567890fghij")); + test(S("abcdefghij"), 1, 4, "12345678901234567890", S("a12345678901234567890fghij")); + test(S("abcdefghij"), 1, 8, "", S("aj")); + test(S("abcdefghij"), 1, 8, "12345", S("a12345j")); + test(S("abcdefghij"), 1, 8, "1234567890", S("a1234567890j")); + test(S("abcdefghij"), 1, 8, "12345678901234567890", S("a12345678901234567890j")); + test(S("abcdefghij"), 1, 9, "", S("a")); + test(S("abcdefghij"), 1, 9, "12345", S("a12345")); + test(S("abcdefghij"), 1, 9, "1234567890", S("a1234567890")); + test(S("abcdefghij"), 1, 9, "12345678901234567890", S("a12345678901234567890")); + test(S("abcdefghij"), 5, 0, "", S("abcdefghij")); + test(S("abcdefghij"), 5, 0, "12345", S("abcde12345fghij")); + test(S("abcdefghij"), 5, 0, "1234567890", S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, 0, "12345678901234567890", S("abcde12345678901234567890fghij")); + test(S("abcdefghij"), 5, 1, "", S("abcdeghij")); + test(S("abcdefghij"), 5, 1, "12345", S("abcde12345ghij")); + test(S("abcdefghij"), 5, 1, "1234567890", S("abcde1234567890ghij")); + test(S("abcdefghij"), 5, 1, "12345678901234567890", S("abcde12345678901234567890ghij")); + test(S("abcdefghij"), 5, 2, "", S("abcdehij")); + test(S("abcdefghij"), 5, 2, "12345", S("abcde12345hij")); + test(S("abcdefghij"), 5, 2, "1234567890", S("abcde1234567890hij")); + test(S("abcdefghij"), 5, 2, "12345678901234567890", S("abcde12345678901234567890hij")); + test(S("abcdefghij"), 5, 4, "", S("abcdej")); + test(S("abcdefghij"), 5, 4, "12345", S("abcde12345j")); + test(S("abcdefghij"), 5, 4, "1234567890", S("abcde1234567890j")); + test(S("abcdefghij"), 5, 4, "12345678901234567890", S("abcde12345678901234567890j")); + test(S("abcdefghij"), 5, 5, "", S("abcde")); + test(S("abcdefghij"), 5, 5, "12345", S("abcde12345")); + test(S("abcdefghij"), 5, 5, "1234567890", S("abcde1234567890")); + test(S("abcdefghij"), 5, 5, "12345678901234567890", S("abcde12345678901234567890")); + test(S("abcdefghij"), 9, 0, "", S("abcdefghij")); + test(S("abcdefghij"), 9, 0, "12345", S("abcdefghi12345j")); + test(S("abcdefghij"), 9, 0, "1234567890", S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, 0, "12345678901234567890", S("abcdefghi12345678901234567890j")); + test(S("abcdefghij"), 9, 1, "", S("abcdefghi")); + test(S("abcdefghij"), 9, 1, "12345", S("abcdefghi12345")); + test(S("abcdefghij"), 9, 1, "1234567890", S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 1, "12345678901234567890", S("abcdefghi12345678901234567890")); + test(S("abcdefghij"), 10, 0, "", S("abcdefghij")); + test(S("abcdefghij"), 10, 0, "12345", S("abcdefghij12345")); + test(S("abcdefghij"), 10, 0, "1234567890", S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 0, "12345678901234567890", S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 0, 0, "", S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345", S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "", S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345", S("12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", S("1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", S("12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "", S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345", S("12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", S("1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", S("12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 19, "", S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345", S("12345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", S("1234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", S("12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 20, "", S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345", S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 0, "", S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345", S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "", S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345", S("a12345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", S("a1234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", S("a12345678901234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "", S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345", S("a12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", S("a1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", S("a12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 18, "", S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345", S("a12345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", S("a1234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", S("a12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 19, "", S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345", S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", S("a12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 0, "", S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345", S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "", S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345", S("abcdefghij12345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", S("abcdefghij1234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", S("abcdefghij12345678901234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "", S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345", S("abcdefghij12345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", S("abcdefghij1234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", S("abcdefghij12345678901234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 9, "", S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345", S("abcdefghij12345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", S("abcdefghij1234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", S("abcdefghij12345678901234567890t")); +} + +template <class S> +void test2() +{ + test(S("abcdefghijklmnopqrst"), 10, 10, "", S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345", S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 0, "", S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345", S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 1, "", S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345", S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, "", S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345", S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890")); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp new file mode 100644 index 000000000000..b1d6ab1ba579 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp @@ -0,0 +1,976 @@ +//===----------------------------------------------------------------------===// +// +// 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>& +// replace(const_iterator i1, const_iterator i2, const charT* s, size_type n); + +#include <stdio.h> + +#include <string> +#include <algorithm> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s, typename S::size_type pos1, typename S::size_type n1, const typename S::value_type* str, + typename S::size_type n2, S expected) +{ + typename S::size_type old_size = s.size(); + typename S::const_iterator first = s.begin() + pos1; + typename S::const_iterator last = s.begin() + pos1 + n1; + typename S::size_type xlen = last - first; + s.replace(first, last, str, n2); + assert(s.__invariants()); + assert(s == expected); + typename S::size_type rlen = n2; + assert(s.size() == old_size - xlen + rlen); +} + +template <class S> +void test0() +{ + test(S(""), 0, 0, "", 0, S("")); + test(S(""), 0, 0, "12345", 0, S("")); + test(S(""), 0, 0, "12345", 1, S("1")); + test(S(""), 0, 0, "12345", 2, S("12")); + test(S(""), 0, 0, "12345", 4, S("1234")); + test(S(""), 0, 0, "12345", 5, S("12345")); + test(S(""), 0, 0, "1234567890", 0, S("")); + test(S(""), 0, 0, "1234567890", 1, S("1")); + test(S(""), 0, 0, "1234567890", 5, S("12345")); + test(S(""), 0, 0, "1234567890", 9, S("123456789")); + test(S(""), 0, 0, "1234567890", 10, S("1234567890")); + test(S(""), 0, 0, "12345678901234567890", 0, S("")); + test(S(""), 0, 0, "12345678901234567890", 1, S("1")); + test(S(""), 0, 0, "12345678901234567890", 10, S("1234567890")); + test(S(""), 0, 0, "12345678901234567890", 19, S("1234567890123456789")); + test(S(""), 0, 0, "12345678901234567890", 20, S("12345678901234567890")); + test(S("abcde"), 0, 0, "", 0, S("abcde")); + test(S("abcde"), 0, 0, "12345", 0, S("abcde")); + test(S("abcde"), 0, 0, "12345", 1, S("1abcde")); + test(S("abcde"), 0, 0, "12345", 2, S("12abcde")); + test(S("abcde"), 0, 0, "12345", 4, S("1234abcde")); + test(S("abcde"), 0, 0, "12345", 5, S("12345abcde")); + test(S("abcde"), 0, 0, "1234567890", 0, S("abcde")); + test(S("abcde"), 0, 0, "1234567890", 1, S("1abcde")); + test(S("abcde"), 0, 0, "1234567890", 5, S("12345abcde")); + test(S("abcde"), 0, 0, "1234567890", 9, S("123456789abcde")); + test(S("abcde"), 0, 0, "1234567890", 10, S("1234567890abcde")); + test(S("abcde"), 0, 0, "12345678901234567890", 0, S("abcde")); + test(S("abcde"), 0, 0, "12345678901234567890", 1, S("1abcde")); + test(S("abcde"), 0, 0, "12345678901234567890", 10, S("1234567890abcde")); + test(S("abcde"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcde")); + test(S("abcde"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcde")); + test(S("abcde"), 0, 1, "", 0, S("bcde")); + test(S("abcde"), 0, 1, "12345", 0, S("bcde")); + test(S("abcde"), 0, 1, "12345", 1, S("1bcde")); + test(S("abcde"), 0, 1, "12345", 2, S("12bcde")); + test(S("abcde"), 0, 1, "12345", 4, S("1234bcde")); + test(S("abcde"), 0, 1, "12345", 5, S("12345bcde")); + test(S("abcde"), 0, 1, "1234567890", 0, S("bcde")); + test(S("abcde"), 0, 1, "1234567890", 1, S("1bcde")); + test(S("abcde"), 0, 1, "1234567890", 5, S("12345bcde")); + test(S("abcde"), 0, 1, "1234567890", 9, S("123456789bcde")); + test(S("abcde"), 0, 1, "1234567890", 10, S("1234567890bcde")); + test(S("abcde"), 0, 1, "12345678901234567890", 0, S("bcde")); + test(S("abcde"), 0, 1, "12345678901234567890", 1, S("1bcde")); + test(S("abcde"), 0, 1, "12345678901234567890", 10, S("1234567890bcde")); + test(S("abcde"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcde")); + test(S("abcde"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcde")); + test(S("abcde"), 0, 2, "", 0, S("cde")); + test(S("abcde"), 0, 2, "12345", 0, S("cde")); + test(S("abcde"), 0, 2, "12345", 1, S("1cde")); + test(S("abcde"), 0, 2, "12345", 2, S("12cde")); + test(S("abcde"), 0, 2, "12345", 4, S("1234cde")); + test(S("abcde"), 0, 2, "12345", 5, S("12345cde")); + test(S("abcde"), 0, 2, "1234567890", 0, S("cde")); + test(S("abcde"), 0, 2, "1234567890", 1, S("1cde")); + test(S("abcde"), 0, 2, "1234567890", 5, S("12345cde")); + test(S("abcde"), 0, 2, "1234567890", 9, S("123456789cde")); + test(S("abcde"), 0, 2, "1234567890", 10, S("1234567890cde")); + test(S("abcde"), 0, 2, "12345678901234567890", 0, S("cde")); + test(S("abcde"), 0, 2, "12345678901234567890", 1, S("1cde")); + test(S("abcde"), 0, 2, "12345678901234567890", 10, S("1234567890cde")); + test(S("abcde"), 0, 2, "12345678901234567890", 19, S("1234567890123456789cde")); + test(S("abcde"), 0, 2, "12345678901234567890", 20, S("12345678901234567890cde")); + test(S("abcde"), 0, 4, "", 0, S("e")); + test(S("abcde"), 0, 4, "12345", 0, S("e")); + test(S("abcde"), 0, 4, "12345", 1, S("1e")); + test(S("abcde"), 0, 4, "12345", 2, S("12e")); + test(S("abcde"), 0, 4, "12345", 4, S("1234e")); + test(S("abcde"), 0, 4, "12345", 5, S("12345e")); + test(S("abcde"), 0, 4, "1234567890", 0, S("e")); + test(S("abcde"), 0, 4, "1234567890", 1, S("1e")); + test(S("abcde"), 0, 4, "1234567890", 5, S("12345e")); + test(S("abcde"), 0, 4, "1234567890", 9, S("123456789e")); + test(S("abcde"), 0, 4, "1234567890", 10, S("1234567890e")); + test(S("abcde"), 0, 4, "12345678901234567890", 0, S("e")); + test(S("abcde"), 0, 4, "12345678901234567890", 1, S("1e")); + test(S("abcde"), 0, 4, "12345678901234567890", 10, S("1234567890e")); + test(S("abcde"), 0, 4, "12345678901234567890", 19, S("1234567890123456789e")); + test(S("abcde"), 0, 4, "12345678901234567890", 20, S("12345678901234567890e")); + test(S("abcde"), 0, 5, "", 0, S("")); + test(S("abcde"), 0, 5, "12345", 0, S("")); + test(S("abcde"), 0, 5, "12345", 1, S("1")); + test(S("abcde"), 0, 5, "12345", 2, S("12")); + test(S("abcde"), 0, 5, "12345", 4, S("1234")); + test(S("abcde"), 0, 5, "12345", 5, S("12345")); + test(S("abcde"), 0, 5, "1234567890", 0, S("")); + test(S("abcde"), 0, 5, "1234567890", 1, S("1")); + test(S("abcde"), 0, 5, "1234567890", 5, S("12345")); + test(S("abcde"), 0, 5, "1234567890", 9, S("123456789")); + test(S("abcde"), 0, 5, "1234567890", 10, S("1234567890")); + test(S("abcde"), 0, 5, "12345678901234567890", 0, S("")); + test(S("abcde"), 0, 5, "12345678901234567890", 1, S("1")); + test(S("abcde"), 0, 5, "12345678901234567890", 10, S("1234567890")); + test(S("abcde"), 0, 5, "12345678901234567890", 19, S("1234567890123456789")); + test(S("abcde"), 0, 5, "12345678901234567890", 20, S("12345678901234567890")); + test(S("abcde"), 1, 0, "", 0, S("abcde")); + test(S("abcde"), 1, 0, "12345", 0, S("abcde")); + test(S("abcde"), 1, 0, "12345", 1, S("a1bcde")); + test(S("abcde"), 1, 0, "12345", 2, S("a12bcde")); +} + +template <class S> +void test1() +{ + test(S("abcde"), 1, 0, "12345", 4, S("a1234bcde")); + test(S("abcde"), 1, 0, "12345", 5, S("a12345bcde")); + test(S("abcde"), 1, 0, "1234567890", 0, S("abcde")); + test(S("abcde"), 1, 0, "1234567890", 1, S("a1bcde")); + test(S("abcde"), 1, 0, "1234567890", 5, S("a12345bcde")); + test(S("abcde"), 1, 0, "1234567890", 9, S("a123456789bcde")); + test(S("abcde"), 1, 0, "1234567890", 10, S("a1234567890bcde")); + test(S("abcde"), 1, 0, "12345678901234567890", 0, S("abcde")); + test(S("abcde"), 1, 0, "12345678901234567890", 1, S("a1bcde")); + test(S("abcde"), 1, 0, "12345678901234567890", 10, S("a1234567890bcde")); + test(S("abcde"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcde")); + test(S("abcde"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcde")); + test(S("abcde"), 1, 1, "", 0, S("acde")); + test(S("abcde"), 1, 1, "12345", 0, S("acde")); + test(S("abcde"), 1, 1, "12345", 1, S("a1cde")); + test(S("abcde"), 1, 1, "12345", 2, S("a12cde")); + test(S("abcde"), 1, 1, "12345", 4, S("a1234cde")); + test(S("abcde"), 1, 1, "12345", 5, S("a12345cde")); + test(S("abcde"), 1, 1, "1234567890", 0, S("acde")); + test(S("abcde"), 1, 1, "1234567890", 1, S("a1cde")); + test(S("abcde"), 1, 1, "1234567890", 5, S("a12345cde")); + test(S("abcde"), 1, 1, "1234567890", 9, S("a123456789cde")); + test(S("abcde"), 1, 1, "1234567890", 10, S("a1234567890cde")); + test(S("abcde"), 1, 1, "12345678901234567890", 0, S("acde")); + test(S("abcde"), 1, 1, "12345678901234567890", 1, S("a1cde")); + test(S("abcde"), 1, 1, "12345678901234567890", 10, S("a1234567890cde")); + test(S("abcde"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cde")); + test(S("abcde"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cde")); + test(S("abcde"), 1, 2, "", 0, S("ade")); + test(S("abcde"), 1, 2, "12345", 0, S("ade")); + test(S("abcde"), 1, 2, "12345", 1, S("a1de")); + test(S("abcde"), 1, 2, "12345", 2, S("a12de")); + test(S("abcde"), 1, 2, "12345", 4, S("a1234de")); + test(S("abcde"), 1, 2, "12345", 5, S("a12345de")); + test(S("abcde"), 1, 2, "1234567890", 0, S("ade")); + test(S("abcde"), 1, 2, "1234567890", 1, S("a1de")); + test(S("abcde"), 1, 2, "1234567890", 5, S("a12345de")); + test(S("abcde"), 1, 2, "1234567890", 9, S("a123456789de")); + test(S("abcde"), 1, 2, "1234567890", 10, S("a1234567890de")); + test(S("abcde"), 1, 2, "12345678901234567890", 0, S("ade")); + test(S("abcde"), 1, 2, "12345678901234567890", 1, S("a1de")); + test(S("abcde"), 1, 2, "12345678901234567890", 10, S("a1234567890de")); + test(S("abcde"), 1, 2, "12345678901234567890", 19, S("a1234567890123456789de")); + test(S("abcde"), 1, 2, "12345678901234567890", 20, S("a12345678901234567890de")); + test(S("abcde"), 1, 3, "", 0, S("ae")); + test(S("abcde"), 1, 3, "12345", 0, S("ae")); + test(S("abcde"), 1, 3, "12345", 1, S("a1e")); + test(S("abcde"), 1, 3, "12345", 2, S("a12e")); + test(S("abcde"), 1, 3, "12345", 4, S("a1234e")); + test(S("abcde"), 1, 3, "12345", 5, S("a12345e")); + test(S("abcde"), 1, 3, "1234567890", 0, S("ae")); + test(S("abcde"), 1, 3, "1234567890", 1, S("a1e")); + test(S("abcde"), 1, 3, "1234567890", 5, S("a12345e")); + test(S("abcde"), 1, 3, "1234567890", 9, S("a123456789e")); + test(S("abcde"), 1, 3, "1234567890", 10, S("a1234567890e")); + test(S("abcde"), 1, 3, "12345678901234567890", 0, S("ae")); + test(S("abcde"), 1, 3, "12345678901234567890", 1, S("a1e")); + test(S("abcde"), 1, 3, "12345678901234567890", 10, S("a1234567890e")); + test(S("abcde"), 1, 3, "12345678901234567890", 19, S("a1234567890123456789e")); + test(S("abcde"), 1, 3, "12345678901234567890", 20, S("a12345678901234567890e")); + test(S("abcde"), 1, 4, "", 0, S("a")); + test(S("abcde"), 1, 4, "12345", 0, S("a")); + test(S("abcde"), 1, 4, "12345", 1, S("a1")); + test(S("abcde"), 1, 4, "12345", 2, S("a12")); + test(S("abcde"), 1, 4, "12345", 4, S("a1234")); + test(S("abcde"), 1, 4, "12345", 5, S("a12345")); + test(S("abcde"), 1, 4, "1234567890", 0, S("a")); + test(S("abcde"), 1, 4, "1234567890", 1, S("a1")); + test(S("abcde"), 1, 4, "1234567890", 5, S("a12345")); + test(S("abcde"), 1, 4, "1234567890", 9, S("a123456789")); + test(S("abcde"), 1, 4, "1234567890", 10, S("a1234567890")); + test(S("abcde"), 1, 4, "12345678901234567890", 0, S("a")); + test(S("abcde"), 1, 4, "12345678901234567890", 1, S("a1")); + test(S("abcde"), 1, 4, "12345678901234567890", 10, S("a1234567890")); + test(S("abcde"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789")); + test(S("abcde"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890")); + test(S("abcde"), 2, 0, "", 0, S("abcde")); + test(S("abcde"), 2, 0, "12345", 0, S("abcde")); + test(S("abcde"), 2, 0, "12345", 1, S("ab1cde")); + test(S("abcde"), 2, 0, "12345", 2, S("ab12cde")); + test(S("abcde"), 2, 0, "12345", 4, S("ab1234cde")); + test(S("abcde"), 2, 0, "12345", 5, S("ab12345cde")); + test(S("abcde"), 2, 0, "1234567890", 0, S("abcde")); + test(S("abcde"), 2, 0, "1234567890", 1, S("ab1cde")); + test(S("abcde"), 2, 0, "1234567890", 5, S("ab12345cde")); + test(S("abcde"), 2, 0, "1234567890", 9, S("ab123456789cde")); + test(S("abcde"), 2, 0, "1234567890", 10, S("ab1234567890cde")); + test(S("abcde"), 2, 0, "12345678901234567890", 0, S("abcde")); + test(S("abcde"), 2, 0, "12345678901234567890", 1, S("ab1cde")); + test(S("abcde"), 2, 0, "12345678901234567890", 10, S("ab1234567890cde")); + test(S("abcde"), 2, 0, "12345678901234567890", 19, S("ab1234567890123456789cde")); + test(S("abcde"), 2, 0, "12345678901234567890", 20, S("ab12345678901234567890cde")); + test(S("abcde"), 2, 1, "", 0, S("abde")); + test(S("abcde"), 2, 1, "12345", 0, S("abde")); + test(S("abcde"), 2, 1, "12345", 1, S("ab1de")); + test(S("abcde"), 2, 1, "12345", 2, S("ab12de")); + test(S("abcde"), 2, 1, "12345", 4, S("ab1234de")); + test(S("abcde"), 2, 1, "12345", 5, S("ab12345de")); + test(S("abcde"), 2, 1, "1234567890", 0, S("abde")); + test(S("abcde"), 2, 1, "1234567890", 1, S("ab1de")); +} + +template <class S> +void test2() +{ + test(S("abcde"), 2, 1, "1234567890", 5, S("ab12345de")); + test(S("abcde"), 2, 1, "1234567890", 9, S("ab123456789de")); + test(S("abcde"), 2, 1, "1234567890", 10, S("ab1234567890de")); + test(S("abcde"), 2, 1, "12345678901234567890", 0, S("abde")); + test(S("abcde"), 2, 1, "12345678901234567890", 1, S("ab1de")); + test(S("abcde"), 2, 1, "12345678901234567890", 10, S("ab1234567890de")); + test(S("abcde"), 2, 1, "12345678901234567890", 19, S("ab1234567890123456789de")); + test(S("abcde"), 2, 1, "12345678901234567890", 20, S("ab12345678901234567890de")); + test(S("abcde"), 2, 2, "", 0, S("abe")); + test(S("abcde"), 2, 2, "12345", 0, S("abe")); + test(S("abcde"), 2, 2, "12345", 1, S("ab1e")); + test(S("abcde"), 2, 2, "12345", 2, S("ab12e")); + test(S("abcde"), 2, 2, "12345", 4, S("ab1234e")); + test(S("abcde"), 2, 2, "12345", 5, S("ab12345e")); + test(S("abcde"), 2, 2, "1234567890", 0, S("abe")); + test(S("abcde"), 2, 2, "1234567890", 1, S("ab1e")); + test(S("abcde"), 2, 2, "1234567890", 5, S("ab12345e")); + test(S("abcde"), 2, 2, "1234567890", 9, S("ab123456789e")); + test(S("abcde"), 2, 2, "1234567890", 10, S("ab1234567890e")); + test(S("abcde"), 2, 2, "12345678901234567890", 0, S("abe")); + test(S("abcde"), 2, 2, "12345678901234567890", 1, S("ab1e")); + test(S("abcde"), 2, 2, "12345678901234567890", 10, S("ab1234567890e")); + test(S("abcde"), 2, 2, "12345678901234567890", 19, S("ab1234567890123456789e")); + test(S("abcde"), 2, 2, "12345678901234567890", 20, S("ab12345678901234567890e")); + test(S("abcde"), 2, 3, "", 0, S("ab")); + test(S("abcde"), 2, 3, "12345", 0, S("ab")); + test(S("abcde"), 2, 3, "12345", 1, S("ab1")); + test(S("abcde"), 2, 3, "12345", 2, S("ab12")); + test(S("abcde"), 2, 3, "12345", 4, S("ab1234")); + test(S("abcde"), 2, 3, "12345", 5, S("ab12345")); + test(S("abcde"), 2, 3, "1234567890", 0, S("ab")); + test(S("abcde"), 2, 3, "1234567890", 1, S("ab1")); + test(S("abcde"), 2, 3, "1234567890", 5, S("ab12345")); + test(S("abcde"), 2, 3, "1234567890", 9, S("ab123456789")); + test(S("abcde"), 2, 3, "1234567890", 10, S("ab1234567890")); + test(S("abcde"), 2, 3, "12345678901234567890", 0, S("ab")); + test(S("abcde"), 2, 3, "12345678901234567890", 1, S("ab1")); + test(S("abcde"), 2, 3, "12345678901234567890", 10, S("ab1234567890")); + test(S("abcde"), 2, 3, "12345678901234567890", 19, S("ab1234567890123456789")); + test(S("abcde"), 2, 3, "12345678901234567890", 20, S("ab12345678901234567890")); + test(S("abcde"), 4, 0, "", 0, S("abcde")); + test(S("abcde"), 4, 0, "12345", 0, S("abcde")); + test(S("abcde"), 4, 0, "12345", 1, S("abcd1e")); + test(S("abcde"), 4, 0, "12345", 2, S("abcd12e")); + test(S("abcde"), 4, 0, "12345", 4, S("abcd1234e")); + test(S("abcde"), 4, 0, "12345", 5, S("abcd12345e")); + test(S("abcde"), 4, 0, "1234567890", 0, S("abcde")); + test(S("abcde"), 4, 0, "1234567890", 1, S("abcd1e")); + test(S("abcde"), 4, 0, "1234567890", 5, S("abcd12345e")); + test(S("abcde"), 4, 0, "1234567890", 9, S("abcd123456789e")); + test(S("abcde"), 4, 0, "1234567890", 10, S("abcd1234567890e")); + test(S("abcde"), 4, 0, "12345678901234567890", 0, S("abcde")); + test(S("abcde"), 4, 0, "12345678901234567890", 1, S("abcd1e")); + test(S("abcde"), 4, 0, "12345678901234567890", 10, S("abcd1234567890e")); + test(S("abcde"), 4, 0, "12345678901234567890", 19, S("abcd1234567890123456789e")); + test(S("abcde"), 4, 0, "12345678901234567890", 20, S("abcd12345678901234567890e")); + test(S("abcde"), 4, 1, "", 0, S("abcd")); + test(S("abcde"), 4, 1, "12345", 0, S("abcd")); + test(S("abcde"), 4, 1, "12345", 1, S("abcd1")); + test(S("abcde"), 4, 1, "12345", 2, S("abcd12")); + test(S("abcde"), 4, 1, "12345", 4, S("abcd1234")); + test(S("abcde"), 4, 1, "12345", 5, S("abcd12345")); + test(S("abcde"), 4, 1, "1234567890", 0, S("abcd")); + test(S("abcde"), 4, 1, "1234567890", 1, S("abcd1")); + test(S("abcde"), 4, 1, "1234567890", 5, S("abcd12345")); + test(S("abcde"), 4, 1, "1234567890", 9, S("abcd123456789")); + test(S("abcde"), 4, 1, "1234567890", 10, S("abcd1234567890")); + test(S("abcde"), 4, 1, "12345678901234567890", 0, S("abcd")); + test(S("abcde"), 4, 1, "12345678901234567890", 1, S("abcd1")); + test(S("abcde"), 4, 1, "12345678901234567890", 10, S("abcd1234567890")); + test(S("abcde"), 4, 1, "12345678901234567890", 19, S("abcd1234567890123456789")); + test(S("abcde"), 4, 1, "12345678901234567890", 20, S("abcd12345678901234567890")); + test(S("abcde"), 5, 0, "", 0, S("abcde")); + test(S("abcde"), 5, 0, "12345", 0, S("abcde")); + test(S("abcde"), 5, 0, "12345", 1, S("abcde1")); + test(S("abcde"), 5, 0, "12345", 2, S("abcde12")); + test(S("abcde"), 5, 0, "12345", 4, S("abcde1234")); + test(S("abcde"), 5, 0, "12345", 5, S("abcde12345")); + test(S("abcde"), 5, 0, "1234567890", 0, S("abcde")); + test(S("abcde"), 5, 0, "1234567890", 1, S("abcde1")); + test(S("abcde"), 5, 0, "1234567890", 5, S("abcde12345")); + test(S("abcde"), 5, 0, "1234567890", 9, S("abcde123456789")); + test(S("abcde"), 5, 0, "1234567890", 10, S("abcde1234567890")); + test(S("abcde"), 5, 0, "12345678901234567890", 0, S("abcde")); + test(S("abcde"), 5, 0, "12345678901234567890", 1, S("abcde1")); + test(S("abcde"), 5, 0, "12345678901234567890", 10, S("abcde1234567890")); + test(S("abcde"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789")); + test(S("abcde"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890")); + test(S("abcdefghij"), 0, 0, "", 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345", 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345", 1, S("1abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345", 2, S("12abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345", 4, S("1234abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345", 5, S("12345abcdefghij")); + test(S("abcdefghij"), 0, 0, "1234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, "1234567890", 1, S("1abcdefghij")); + test(S("abcdefghij"), 0, 0, "1234567890", 5, S("12345abcdefghij")); + test(S("abcdefghij"), 0, 0, "1234567890", 9, S("123456789abcdefghij")); + test(S("abcdefghij"), 0, 0, "1234567890", 10, S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345678901234567890", 0, S("abcdefghij")); +} + +template <class S> +void test3() +{ + test(S("abcdefghij"), 0, 0, "12345678901234567890", 1, S("1abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij")); + test(S("abcdefghij"), 0, 1, "", 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345", 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345", 1, S("1bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345", 2, S("12bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345", 4, S("1234bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345", 5, S("12345bcdefghij")); + test(S("abcdefghij"), 0, 1, "1234567890", 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, "1234567890", 1, S("1bcdefghij")); + test(S("abcdefghij"), 0, 1, "1234567890", 5, S("12345bcdefghij")); + test(S("abcdefghij"), 0, 1, "1234567890", 9, S("123456789bcdefghij")); + test(S("abcdefghij"), 0, 1, "1234567890", 10, S("1234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345678901234567890", 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345678901234567890", 1, S("1bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghij")); + test(S("abcdefghij"), 0, 5, "", 0, S("fghij")); + test(S("abcdefghij"), 0, 5, "12345", 0, S("fghij")); + test(S("abcdefghij"), 0, 5, "12345", 1, S("1fghij")); + test(S("abcdefghij"), 0, 5, "12345", 2, S("12fghij")); + test(S("abcdefghij"), 0, 5, "12345", 4, S("1234fghij")); + test(S("abcdefghij"), 0, 5, "12345", 5, S("12345fghij")); + test(S("abcdefghij"), 0, 5, "1234567890", 0, S("fghij")); + test(S("abcdefghij"), 0, 5, "1234567890", 1, S("1fghij")); + test(S("abcdefghij"), 0, 5, "1234567890", 5, S("12345fghij")); + test(S("abcdefghij"), 0, 5, "1234567890", 9, S("123456789fghij")); + test(S("abcdefghij"), 0, 5, "1234567890", 10, S("1234567890fghij")); + test(S("abcdefghij"), 0, 5, "12345678901234567890", 0, S("fghij")); + test(S("abcdefghij"), 0, 5, "12345678901234567890", 1, S("1fghij")); + test(S("abcdefghij"), 0, 5, "12345678901234567890", 10, S("1234567890fghij")); + test(S("abcdefghij"), 0, 5, "12345678901234567890", 19, S("1234567890123456789fghij")); + test(S("abcdefghij"), 0, 5, "12345678901234567890", 20, S("12345678901234567890fghij")); + test(S("abcdefghij"), 0, 9, "", 0, S("j")); + test(S("abcdefghij"), 0, 9, "12345", 0, S("j")); + test(S("abcdefghij"), 0, 9, "12345", 1, S("1j")); + test(S("abcdefghij"), 0, 9, "12345", 2, S("12j")); + test(S("abcdefghij"), 0, 9, "12345", 4, S("1234j")); + test(S("abcdefghij"), 0, 9, "12345", 5, S("12345j")); + test(S("abcdefghij"), 0, 9, "1234567890", 0, S("j")); + test(S("abcdefghij"), 0, 9, "1234567890", 1, S("1j")); + test(S("abcdefghij"), 0, 9, "1234567890", 5, S("12345j")); + test(S("abcdefghij"), 0, 9, "1234567890", 9, S("123456789j")); + test(S("abcdefghij"), 0, 9, "1234567890", 10, S("1234567890j")); + test(S("abcdefghij"), 0, 9, "12345678901234567890", 0, S("j")); + test(S("abcdefghij"), 0, 9, "12345678901234567890", 1, S("1j")); + test(S("abcdefghij"), 0, 9, "12345678901234567890", 10, S("1234567890j")); + test(S("abcdefghij"), 0, 9, "12345678901234567890", 19, S("1234567890123456789j")); + test(S("abcdefghij"), 0, 9, "12345678901234567890", 20, S("12345678901234567890j")); + test(S("abcdefghij"), 0, 10, "", 0, S("")); + test(S("abcdefghij"), 0, 10, "12345", 0, S("")); + test(S("abcdefghij"), 0, 10, "12345", 1, S("1")); + test(S("abcdefghij"), 0, 10, "12345", 2, S("12")); + test(S("abcdefghij"), 0, 10, "12345", 4, S("1234")); + test(S("abcdefghij"), 0, 10, "12345", 5, S("12345")); + test(S("abcdefghij"), 0, 10, "1234567890", 0, S("")); + test(S("abcdefghij"), 0, 10, "1234567890", 1, S("1")); + test(S("abcdefghij"), 0, 10, "1234567890", 5, S("12345")); + test(S("abcdefghij"), 0, 10, "1234567890", 9, S("123456789")); + test(S("abcdefghij"), 0, 10, "1234567890", 10, S("1234567890")); + test(S("abcdefghij"), 0, 10, "12345678901234567890", 0, S("")); + test(S("abcdefghij"), 0, 10, "12345678901234567890", 1, S("1")); + test(S("abcdefghij"), 0, 10, "12345678901234567890", 10, S("1234567890")); + test(S("abcdefghij"), 0, 10, "12345678901234567890", 19, S("1234567890123456789")); + test(S("abcdefghij"), 0, 10, "12345678901234567890", 20, S("12345678901234567890")); + test(S("abcdefghij"), 1, 0, "", 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, "12345", 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, "12345", 1, S("a1bcdefghij")); + test(S("abcdefghij"), 1, 0, "12345", 2, S("a12bcdefghij")); + test(S("abcdefghij"), 1, 0, "12345", 4, S("a1234bcdefghij")); + test(S("abcdefghij"), 1, 0, "12345", 5, S("a12345bcdefghij")); + test(S("abcdefghij"), 1, 0, "1234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, "1234567890", 1, S("a1bcdefghij")); + test(S("abcdefghij"), 1, 0, "1234567890", 5, S("a12345bcdefghij")); + test(S("abcdefghij"), 1, 0, "1234567890", 9, S("a123456789bcdefghij")); + test(S("abcdefghij"), 1, 0, "1234567890", 10, S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, "12345678901234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, "12345678901234567890", 1, S("a1bcdefghij")); + test(S("abcdefghij"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghij")); + test(S("abcdefghij"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghij")); + test(S("abcdefghij"), 1, 1, "", 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, "12345", 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, "12345", 1, S("a1cdefghij")); + test(S("abcdefghij"), 1, 1, "12345", 2, S("a12cdefghij")); + test(S("abcdefghij"), 1, 1, "12345", 4, S("a1234cdefghij")); + test(S("abcdefghij"), 1, 1, "12345", 5, S("a12345cdefghij")); + test(S("abcdefghij"), 1, 1, "1234567890", 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, "1234567890", 1, S("a1cdefghij")); + test(S("abcdefghij"), 1, 1, "1234567890", 5, S("a12345cdefghij")); + test(S("abcdefghij"), 1, 1, "1234567890", 9, S("a123456789cdefghij")); + test(S("abcdefghij"), 1, 1, "1234567890", 10, S("a1234567890cdefghij")); + test(S("abcdefghij"), 1, 1, "12345678901234567890", 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, "12345678901234567890", 1, S("a1cdefghij")); + test(S("abcdefghij"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghij")); + test(S("abcdefghij"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghij")); + test(S("abcdefghij"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghij")); +} + +template <class S> +void test4() +{ + test(S("abcdefghij"), 1, 4, "", 0, S("afghij")); + test(S("abcdefghij"), 1, 4, "12345", 0, S("afghij")); + test(S("abcdefghij"), 1, 4, "12345", 1, S("a1fghij")); + test(S("abcdefghij"), 1, 4, "12345", 2, S("a12fghij")); + test(S("abcdefghij"), 1, 4, "12345", 4, S("a1234fghij")); + test(S("abcdefghij"), 1, 4, "12345", 5, S("a12345fghij")); + test(S("abcdefghij"), 1, 4, "1234567890", 0, S("afghij")); + test(S("abcdefghij"), 1, 4, "1234567890", 1, S("a1fghij")); + test(S("abcdefghij"), 1, 4, "1234567890", 5, S("a12345fghij")); + test(S("abcdefghij"), 1, 4, "1234567890", 9, S("a123456789fghij")); + test(S("abcdefghij"), 1, 4, "1234567890", 10, S("a1234567890fghij")); + test(S("abcdefghij"), 1, 4, "12345678901234567890", 0, S("afghij")); + test(S("abcdefghij"), 1, 4, "12345678901234567890", 1, S("a1fghij")); + test(S("abcdefghij"), 1, 4, "12345678901234567890", 10, S("a1234567890fghij")); + test(S("abcdefghij"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789fghij")); + test(S("abcdefghij"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890fghij")); + test(S("abcdefghij"), 1, 8, "", 0, S("aj")); + test(S("abcdefghij"), 1, 8, "12345", 0, S("aj")); + test(S("abcdefghij"), 1, 8, "12345", 1, S("a1j")); + test(S("abcdefghij"), 1, 8, "12345", 2, S("a12j")); + test(S("abcdefghij"), 1, 8, "12345", 4, S("a1234j")); + test(S("abcdefghij"), 1, 8, "12345", 5, S("a12345j")); + test(S("abcdefghij"), 1, 8, "1234567890", 0, S("aj")); + test(S("abcdefghij"), 1, 8, "1234567890", 1, S("a1j")); + test(S("abcdefghij"), 1, 8, "1234567890", 5, S("a12345j")); + test(S("abcdefghij"), 1, 8, "1234567890", 9, S("a123456789j")); + test(S("abcdefghij"), 1, 8, "1234567890", 10, S("a1234567890j")); + test(S("abcdefghij"), 1, 8, "12345678901234567890", 0, S("aj")); + test(S("abcdefghij"), 1, 8, "12345678901234567890", 1, S("a1j")); + test(S("abcdefghij"), 1, 8, "12345678901234567890", 10, S("a1234567890j")); + test(S("abcdefghij"), 1, 8, "12345678901234567890", 19, S("a1234567890123456789j")); + test(S("abcdefghij"), 1, 8, "12345678901234567890", 20, S("a12345678901234567890j")); + test(S("abcdefghij"), 1, 9, "", 0, S("a")); + test(S("abcdefghij"), 1, 9, "12345", 0, S("a")); + test(S("abcdefghij"), 1, 9, "12345", 1, S("a1")); + test(S("abcdefghij"), 1, 9, "12345", 2, S("a12")); + test(S("abcdefghij"), 1, 9, "12345", 4, S("a1234")); + test(S("abcdefghij"), 1, 9, "12345", 5, S("a12345")); + test(S("abcdefghij"), 1, 9, "1234567890", 0, S("a")); + test(S("abcdefghij"), 1, 9, "1234567890", 1, S("a1")); + test(S("abcdefghij"), 1, 9, "1234567890", 5, S("a12345")); + test(S("abcdefghij"), 1, 9, "1234567890", 9, S("a123456789")); + test(S("abcdefghij"), 1, 9, "1234567890", 10, S("a1234567890")); + test(S("abcdefghij"), 1, 9, "12345678901234567890", 0, S("a")); + test(S("abcdefghij"), 1, 9, "12345678901234567890", 1, S("a1")); + test(S("abcdefghij"), 1, 9, "12345678901234567890", 10, S("a1234567890")); + test(S("abcdefghij"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789")); + test(S("abcdefghij"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890")); + test(S("abcdefghij"), 5, 0, "", 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, "12345", 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, "12345", 1, S("abcde1fghij")); + test(S("abcdefghij"), 5, 0, "12345", 2, S("abcde12fghij")); + test(S("abcdefghij"), 5, 0, "12345", 4, S("abcde1234fghij")); + test(S("abcdefghij"), 5, 0, "12345", 5, S("abcde12345fghij")); + test(S("abcdefghij"), 5, 0, "1234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, "1234567890", 1, S("abcde1fghij")); + test(S("abcdefghij"), 5, 0, "1234567890", 5, S("abcde12345fghij")); + test(S("abcdefghij"), 5, 0, "1234567890", 9, S("abcde123456789fghij")); + test(S("abcdefghij"), 5, 0, "1234567890", 10, S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, 0, "12345678901234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, "12345678901234567890", 1, S("abcde1fghij")); + test(S("abcdefghij"), 5, 0, "12345678901234567890", 10, S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789fghij")); + test(S("abcdefghij"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890fghij")); + test(S("abcdefghij"), 5, 1, "", 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, "12345", 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, "12345", 1, S("abcde1ghij")); + test(S("abcdefghij"), 5, 1, "12345", 2, S("abcde12ghij")); + test(S("abcdefghij"), 5, 1, "12345", 4, S("abcde1234ghij")); + test(S("abcdefghij"), 5, 1, "12345", 5, S("abcde12345ghij")); + test(S("abcdefghij"), 5, 1, "1234567890", 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, "1234567890", 1, S("abcde1ghij")); + test(S("abcdefghij"), 5, 1, "1234567890", 5, S("abcde12345ghij")); + test(S("abcdefghij"), 5, 1, "1234567890", 9, S("abcde123456789ghij")); + test(S("abcdefghij"), 5, 1, "1234567890", 10, S("abcde1234567890ghij")); + test(S("abcdefghij"), 5, 1, "12345678901234567890", 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, "12345678901234567890", 1, S("abcde1ghij")); + test(S("abcdefghij"), 5, 1, "12345678901234567890", 10, S("abcde1234567890ghij")); + test(S("abcdefghij"), 5, 1, "12345678901234567890", 19, S("abcde1234567890123456789ghij")); + test(S("abcdefghij"), 5, 1, "12345678901234567890", 20, S("abcde12345678901234567890ghij")); + test(S("abcdefghij"), 5, 2, "", 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, "12345", 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, "12345", 1, S("abcde1hij")); + test(S("abcdefghij"), 5, 2, "12345", 2, S("abcde12hij")); + test(S("abcdefghij"), 5, 2, "12345", 4, S("abcde1234hij")); + test(S("abcdefghij"), 5, 2, "12345", 5, S("abcde12345hij")); + test(S("abcdefghij"), 5, 2, "1234567890", 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, "1234567890", 1, S("abcde1hij")); + test(S("abcdefghij"), 5, 2, "1234567890", 5, S("abcde12345hij")); + test(S("abcdefghij"), 5, 2, "1234567890", 9, S("abcde123456789hij")); + test(S("abcdefghij"), 5, 2, "1234567890", 10, S("abcde1234567890hij")); + test(S("abcdefghij"), 5, 2, "12345678901234567890", 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, "12345678901234567890", 1, S("abcde1hij")); + test(S("abcdefghij"), 5, 2, "12345678901234567890", 10, S("abcde1234567890hij")); + test(S("abcdefghij"), 5, 2, "12345678901234567890", 19, S("abcde1234567890123456789hij")); + test(S("abcdefghij"), 5, 2, "12345678901234567890", 20, S("abcde12345678901234567890hij")); + test(S("abcdefghij"), 5, 4, "", 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, "12345", 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, "12345", 1, S("abcde1j")); + test(S("abcdefghij"), 5, 4, "12345", 2, S("abcde12j")); +} + +template <class S> +void test5() +{ + test(S("abcdefghij"), 5, 4, "12345", 4, S("abcde1234j")); + test(S("abcdefghij"), 5, 4, "12345", 5, S("abcde12345j")); + test(S("abcdefghij"), 5, 4, "1234567890", 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, "1234567890", 1, S("abcde1j")); + test(S("abcdefghij"), 5, 4, "1234567890", 5, S("abcde12345j")); + test(S("abcdefghij"), 5, 4, "1234567890", 9, S("abcde123456789j")); + test(S("abcdefghij"), 5, 4, "1234567890", 10, S("abcde1234567890j")); + test(S("abcdefghij"), 5, 4, "12345678901234567890", 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, "12345678901234567890", 1, S("abcde1j")); + test(S("abcdefghij"), 5, 4, "12345678901234567890", 10, S("abcde1234567890j")); + test(S("abcdefghij"), 5, 4, "12345678901234567890", 19, S("abcde1234567890123456789j")); + test(S("abcdefghij"), 5, 4, "12345678901234567890", 20, S("abcde12345678901234567890j")); + test(S("abcdefghij"), 5, 5, "", 0, S("abcde")); + test(S("abcdefghij"), 5, 5, "12345", 0, S("abcde")); + test(S("abcdefghij"), 5, 5, "12345", 1, S("abcde1")); + test(S("abcdefghij"), 5, 5, "12345", 2, S("abcde12")); + test(S("abcdefghij"), 5, 5, "12345", 4, S("abcde1234")); + test(S("abcdefghij"), 5, 5, "12345", 5, S("abcde12345")); + test(S("abcdefghij"), 5, 5, "1234567890", 0, S("abcde")); + test(S("abcdefghij"), 5, 5, "1234567890", 1, S("abcde1")); + test(S("abcdefghij"), 5, 5, "1234567890", 5, S("abcde12345")); + test(S("abcdefghij"), 5, 5, "1234567890", 9, S("abcde123456789")); + test(S("abcdefghij"), 5, 5, "1234567890", 10, S("abcde1234567890")); + test(S("abcdefghij"), 5, 5, "12345678901234567890", 0, S("abcde")); + test(S("abcdefghij"), 5, 5, "12345678901234567890", 1, S("abcde1")); + test(S("abcdefghij"), 5, 5, "12345678901234567890", 10, S("abcde1234567890")); + test(S("abcdefghij"), 5, 5, "12345678901234567890", 19, S("abcde1234567890123456789")); + test(S("abcdefghij"), 5, 5, "12345678901234567890", 20, S("abcde12345678901234567890")); + test(S("abcdefghij"), 9, 0, "", 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, "12345", 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, "12345", 1, S("abcdefghi1j")); + test(S("abcdefghij"), 9, 0, "12345", 2, S("abcdefghi12j")); + test(S("abcdefghij"), 9, 0, "12345", 4, S("abcdefghi1234j")); + test(S("abcdefghij"), 9, 0, "12345", 5, S("abcdefghi12345j")); + test(S("abcdefghij"), 9, 0, "1234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, "1234567890", 1, S("abcdefghi1j")); + test(S("abcdefghij"), 9, 0, "1234567890", 5, S("abcdefghi12345j")); + test(S("abcdefghij"), 9, 0, "1234567890", 9, S("abcdefghi123456789j")); + test(S("abcdefghij"), 9, 0, "1234567890", 10, S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, 0, "12345678901234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, "12345678901234567890", 1, S("abcdefghi1j")); + test(S("abcdefghij"), 9, 0, "12345678901234567890", 10, S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, 0, "12345678901234567890", 19, S("abcdefghi1234567890123456789j")); + test(S("abcdefghij"), 9, 0, "12345678901234567890", 20, S("abcdefghi12345678901234567890j")); + test(S("abcdefghij"), 9, 1, "", 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, "12345", 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, "12345", 1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 1, "12345", 2, S("abcdefghi12")); + test(S("abcdefghij"), 9, 1, "12345", 4, S("abcdefghi1234")); + test(S("abcdefghij"), 9, 1, "12345", 5, S("abcdefghi12345")); + test(S("abcdefghij"), 9, 1, "1234567890", 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, "1234567890", 1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 1, "1234567890", 5, S("abcdefghi12345")); + test(S("abcdefghij"), 9, 1, "1234567890", 9, S("abcdefghi123456789")); + test(S("abcdefghij"), 9, 1, "1234567890", 10, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 1, "12345678901234567890", 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, "12345678901234567890", 1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 1, "12345678901234567890", 10, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 1, "12345678901234567890", 19, S("abcdefghi1234567890123456789")); + test(S("abcdefghij"), 9, 1, "12345678901234567890", 20, S("abcdefghi12345678901234567890")); + test(S("abcdefghij"), 10, 0, "", 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, "12345", 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, "12345", 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 0, "12345", 2, S("abcdefghij12")); + test(S("abcdefghij"), 10, 0, "12345", 4, S("abcdefghij1234")); + test(S("abcdefghij"), 10, 0, "12345", 5, S("abcdefghij12345")); + test(S("abcdefghij"), 10, 0, "1234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, "1234567890", 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 0, "1234567890", 5, S("abcdefghij12345")); + test(S("abcdefghij"), 10, 0, "1234567890", 9, S("abcdefghij123456789")); + test(S("abcdefghij"), 10, 0, "1234567890", 10, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 0, "12345678901234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, "12345678901234567890", 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789")); + test(S("abcdefghij"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 0, 0, "", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 1, S("1abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 2, S("12abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 4, S("1234abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 5, S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 1, S("1abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 5, S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "", 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 1, S("1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 2, S("12bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 4, S("1234bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 5, S("12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 1, S("1bcdefghijklmnopqrst")); +} + +template <class S> +void test6() +{ + test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 5, S("12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 9, S("123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 10, S("1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 1, S("1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "", 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 1, S("1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 2, S("12klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 4, S("1234klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 5, S("12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 1, S("1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 5, S("12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 9, S("123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 10, S("1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 1, S("1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 10, S("1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 19, S("1234567890123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 20, S("12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 19, "", 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 1, S("1t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 2, S("12t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 4, S("1234t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 5, S("12345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 1, S("1t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 5, S("12345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 9, S("123456789t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 10, S("1234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 1, S("1t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 10, S("1234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 19, S("1234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 20, S("12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 20, "", 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 2, S("12")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 4, S("1234")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 5, S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 5, S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 9, S("123456789")); + test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 10, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 10, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 19, S("1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 20, S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 0, "", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 1, S("a1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 2, S("a12bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 4, S("a1234bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 5, S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 1, S("a1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 5, S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 9, S("a123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "", 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 1, S("a1cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 2, S("a12cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 4, S("a1234cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 5, S("a12345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 1, S("a1cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 5, S("a12345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 9, S("a123456789cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 10, S("a1234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 1, S("a1cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "", 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 1, S("a1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 2, S("a12klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 4, S("a1234klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 5, S("a12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 1, S("a1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 5, S("a12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 9, S("a123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 10, S("a1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 0, S("aklmnopqrst")); +} + +template <class S> +void test7() +{ + test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 1, S("a1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 10, S("a1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 18, "", 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 1, S("a1t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 2, S("a12t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 4, S("a1234t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 5, S("a12345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 1, S("a1t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 5, S("a12345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 9, S("a123456789t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 10, S("a1234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 1, S("a1t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 10, S("a1234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 19, S("a1234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 20, S("a12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 19, "", 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 2, S("a12")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 4, S("a1234")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 5, S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 5, S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 9, S("a123456789")); + test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 10, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 10, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 19, S("a1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 20, S("a12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 0, "", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 1, S("abcdefghij1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 2, S("abcdefghij12klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 4, S("abcdefghij1234klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 5, S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 1, S("abcdefghij1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 5, S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 9, S("abcdefghij123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 10, S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 1, S("abcdefghij1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "", 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 1, S("abcdefghij1lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 2, S("abcdefghij12lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 4, S("abcdefghij1234lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 5, S("abcdefghij12345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 1, S("abcdefghij1lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 5, S("abcdefghij12345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 9, S("abcdefghij123456789lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 10, S("abcdefghij1234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 1, S("abcdefghij1lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 10, S("abcdefghij1234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 19, S("abcdefghij1234567890123456789lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 20, S("abcdefghij12345678901234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "", 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 1, S("abcdefghij1pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 2, S("abcdefghij12pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 4, S("abcdefghij1234pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 5, S("abcdefghij12345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 1, S("abcdefghij1pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 5, S("abcdefghij12345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 9, S("abcdefghij123456789pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 10, S("abcdefghij1234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 1, S("abcdefghij1pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 10, S("abcdefghij1234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 19, S("abcdefghij1234567890123456789pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 20, S("abcdefghij12345678901234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 9, "", 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 1, S("abcdefghij1t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 2, S("abcdefghij12t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 4, S("abcdefghij1234t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 5, S("abcdefghij12345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 1, S("abcdefghij1t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 5, S("abcdefghij12345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 9, S("abcdefghij123456789t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 10, S("abcdefghij1234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 1, S("abcdefghij1t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 10, S("abcdefghij1234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 19, S("abcdefghij1234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 20, S("abcdefghij12345678901234567890t")); +} + +template <class S> +void test8() +{ + test(S("abcdefghijklmnopqrst"), 10, 10, "", 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 2, S("abcdefghij12")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 4, S("abcdefghij1234")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 5, S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 5, S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 9, S("abcdefghij123456789")); + test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 10, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 10, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 0, "", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 1, S("abcdefghijklmnopqrs1t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 2, S("abcdefghijklmnopqrs12t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 4, S("abcdefghijklmnopqrs1234t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 5, S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 1, S("abcdefghijklmnopqrs1t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 5, S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 9, S("abcdefghijklmnopqrs123456789t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 1, "", 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 2, S("abcdefghijklmnopqrs12")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 4, S("abcdefghijklmnopqrs1234")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 5, S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 5, S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 9, S("abcdefghijklmnopqrs123456789")); + test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 10, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, "", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 2, S("abcdefghijklmnopqrst12")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 4, S("abcdefghijklmnopqrst1234")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 5, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 5, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 9, S("abcdefghijklmnopqrst123456789")); + test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 10, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890")); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + test4<S>(); + test5<S>(); + test6<S>(); + test7<S>(); + test8<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + test4<S>(); + test5<S>(); + test6<S>(); + test7<S>(); + test8<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp new file mode 100644 index 000000000000..b0e2234a7e53 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp @@ -0,0 +1,286 @@ +//===----------------------------------------------------------------------===// +// +// 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>& +// replace(const_iterator i1, const_iterator i2, size_type n, charT c); + +#include <stdio.h> + +#include <string> +#include <algorithm> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s, typename S::size_type pos1, typename S::size_type n1, typename S::size_type n2, + typename S::value_type c, S expected) +{ + typename S::size_type old_size = s.size(); + typename S::const_iterator first = s.begin() + pos1; + typename S::const_iterator last = s.begin() + pos1 + n1; + typename S::size_type xlen = last - first; + s.replace(first, last, n2, c); + assert(s.__invariants()); + assert(s == expected); + typename S::size_type rlen = n2; + assert(s.size() == old_size - xlen + rlen); +} + +template <class S> +void test0() +{ + test(S(""), 0, 0, 0, '3', S("")); + test(S(""), 0, 0, 5, '3', S("33333")); + test(S(""), 0, 0, 10, '3', S("3333333333")); + test(S(""), 0, 0, 20, '3', S("33333333333333333333")); + test(S("abcde"), 0, 0, 0, '3', S("abcde")); + test(S("abcde"), 0, 0, 5, '3', S("33333abcde")); + test(S("abcde"), 0, 0, 10, '3', S("3333333333abcde")); + test(S("abcde"), 0, 0, 20, '3', S("33333333333333333333abcde")); + test(S("abcde"), 0, 1, 0, '3', S("bcde")); + test(S("abcde"), 0, 1, 5, '3', S("33333bcde")); + test(S("abcde"), 0, 1, 10, '3', S("3333333333bcde")); + test(S("abcde"), 0, 1, 20, '3', S("33333333333333333333bcde")); + test(S("abcde"), 0, 2, 0, '3', S("cde")); + test(S("abcde"), 0, 2, 5, '3', S("33333cde")); + test(S("abcde"), 0, 2, 10, '3', S("3333333333cde")); + test(S("abcde"), 0, 2, 20, '3', S("33333333333333333333cde")); + test(S("abcde"), 0, 4, 0, '3', S("e")); + test(S("abcde"), 0, 4, 5, '3', S("33333e")); + test(S("abcde"), 0, 4, 10, '3', S("3333333333e")); + test(S("abcde"), 0, 4, 20, '3', S("33333333333333333333e")); + test(S("abcde"), 0, 5, 0, '3', S("")); + test(S("abcde"), 0, 5, 5, '3', S("33333")); + test(S("abcde"), 0, 5, 10, '3', S("3333333333")); + test(S("abcde"), 0, 5, 20, '3', S("33333333333333333333")); + test(S("abcde"), 1, 0, 0, '3', S("abcde")); + test(S("abcde"), 1, 0, 5, '3', S("a33333bcde")); + test(S("abcde"), 1, 0, 10, '3', S("a3333333333bcde")); + test(S("abcde"), 1, 0, 20, '3', S("a33333333333333333333bcde")); + test(S("abcde"), 1, 1, 0, '3', S("acde")); + test(S("abcde"), 1, 1, 5, '3', S("a33333cde")); + test(S("abcde"), 1, 1, 10, '3', S("a3333333333cde")); + test(S("abcde"), 1, 1, 20, '3', S("a33333333333333333333cde")); + test(S("abcde"), 1, 2, 0, '3', S("ade")); + test(S("abcde"), 1, 2, 5, '3', S("a33333de")); + test(S("abcde"), 1, 2, 10, '3', S("a3333333333de")); + test(S("abcde"), 1, 2, 20, '3', S("a33333333333333333333de")); + test(S("abcde"), 1, 3, 0, '3', S("ae")); + test(S("abcde"), 1, 3, 5, '3', S("a33333e")); + test(S("abcde"), 1, 3, 10, '3', S("a3333333333e")); + test(S("abcde"), 1, 3, 20, '3', S("a33333333333333333333e")); + test(S("abcde"), 1, 4, 0, '3', S("a")); + test(S("abcde"), 1, 4, 5, '3', S("a33333")); + test(S("abcde"), 1, 4, 10, '3', S("a3333333333")); + test(S("abcde"), 1, 4, 20, '3', S("a33333333333333333333")); + test(S("abcde"), 2, 0, 0, '3', S("abcde")); + test(S("abcde"), 2, 0, 5, '3', S("ab33333cde")); + test(S("abcde"), 2, 0, 10, '3', S("ab3333333333cde")); + test(S("abcde"), 2, 0, 20, '3', S("ab33333333333333333333cde")); + test(S("abcde"), 2, 1, 0, '3', S("abde")); + test(S("abcde"), 2, 1, 5, '3', S("ab33333de")); + test(S("abcde"), 2, 1, 10, '3', S("ab3333333333de")); + test(S("abcde"), 2, 1, 20, '3', S("ab33333333333333333333de")); + test(S("abcde"), 2, 2, 0, '3', S("abe")); + test(S("abcde"), 2, 2, 5, '3', S("ab33333e")); + test(S("abcde"), 2, 2, 10, '3', S("ab3333333333e")); + test(S("abcde"), 2, 2, 20, '3', S("ab33333333333333333333e")); + test(S("abcde"), 2, 3, 0, '3', S("ab")); + test(S("abcde"), 2, 3, 5, '3', S("ab33333")); + test(S("abcde"), 2, 3, 10, '3', S("ab3333333333")); + test(S("abcde"), 2, 3, 20, '3', S("ab33333333333333333333")); + test(S("abcde"), 4, 0, 0, '3', S("abcde")); + test(S("abcde"), 4, 0, 5, '3', S("abcd33333e")); + test(S("abcde"), 4, 0, 10, '3', S("abcd3333333333e")); + test(S("abcde"), 4, 0, 20, '3', S("abcd33333333333333333333e")); + test(S("abcde"), 4, 1, 0, '3', S("abcd")); + test(S("abcde"), 4, 1, 5, '3', S("abcd33333")); + test(S("abcde"), 4, 1, 10, '3', S("abcd3333333333")); + test(S("abcde"), 4, 1, 20, '3', S("abcd33333333333333333333")); + test(S("abcde"), 5, 0, 0, '3', S("abcde")); + test(S("abcde"), 5, 0, 5, '3', S("abcde33333")); + test(S("abcde"), 5, 0, 10, '3', S("abcde3333333333")); + test(S("abcde"), 5, 0, 20, '3', S("abcde33333333333333333333")); + test(S("abcdefghij"), 0, 0, 0, '3', S("abcdefghij")); + test(S("abcdefghij"), 0, 0, 5, '3', S("33333abcdefghij")); + test(S("abcdefghij"), 0, 0, 10, '3', S("3333333333abcdefghij")); + test(S("abcdefghij"), 0, 0, 20, '3', S("33333333333333333333abcdefghij")); + test(S("abcdefghij"), 0, 1, 0, '3', S("bcdefghij")); + test(S("abcdefghij"), 0, 1, 5, '3', S("33333bcdefghij")); + test(S("abcdefghij"), 0, 1, 10, '3', S("3333333333bcdefghij")); + test(S("abcdefghij"), 0, 1, 20, '3', S("33333333333333333333bcdefghij")); + test(S("abcdefghij"), 0, 5, 0, '3', S("fghij")); + test(S("abcdefghij"), 0, 5, 5, '3', S("33333fghij")); + test(S("abcdefghij"), 0, 5, 10, '3', S("3333333333fghij")); + test(S("abcdefghij"), 0, 5, 20, '3', S("33333333333333333333fghij")); + test(S("abcdefghij"), 0, 9, 0, '3', S("j")); + test(S("abcdefghij"), 0, 9, 5, '3', S("33333j")); + test(S("abcdefghij"), 0, 9, 10, '3', S("3333333333j")); + test(S("abcdefghij"), 0, 9, 20, '3', S("33333333333333333333j")); + test(S("abcdefghij"), 0, 10, 0, '3', S("")); + test(S("abcdefghij"), 0, 10, 5, '3', S("33333")); + test(S("abcdefghij"), 0, 10, 10, '3', S("3333333333")); + test(S("abcdefghij"), 0, 10, 20, '3', S("33333333333333333333")); + test(S("abcdefghij"), 1, 0, 0, '3', S("abcdefghij")); + test(S("abcdefghij"), 1, 0, 5, '3', S("a33333bcdefghij")); + test(S("abcdefghij"), 1, 0, 10, '3', S("a3333333333bcdefghij")); + test(S("abcdefghij"), 1, 0, 20, '3', S("a33333333333333333333bcdefghij")); + test(S("abcdefghij"), 1, 1, 0, '3', S("acdefghij")); + test(S("abcdefghij"), 1, 1, 5, '3', S("a33333cdefghij")); + test(S("abcdefghij"), 1, 1, 10, '3', S("a3333333333cdefghij")); + test(S("abcdefghij"), 1, 1, 20, '3', S("a33333333333333333333cdefghij")); +} + +template <class S> +void test1() +{ + test(S("abcdefghij"), 1, 4, 0, '3', S("afghij")); + test(S("abcdefghij"), 1, 4, 5, '3', S("a33333fghij")); + test(S("abcdefghij"), 1, 4, 10, '3', S("a3333333333fghij")); + test(S("abcdefghij"), 1, 4, 20, '3', S("a33333333333333333333fghij")); + test(S("abcdefghij"), 1, 8, 0, '3', S("aj")); + test(S("abcdefghij"), 1, 8, 5, '3', S("a33333j")); + test(S("abcdefghij"), 1, 8, 10, '3', S("a3333333333j")); + test(S("abcdefghij"), 1, 8, 20, '3', S("a33333333333333333333j")); + test(S("abcdefghij"), 1, 9, 0, '3', S("a")); + test(S("abcdefghij"), 1, 9, 5, '3', S("a33333")); + test(S("abcdefghij"), 1, 9, 10, '3', S("a3333333333")); + test(S("abcdefghij"), 1, 9, 20, '3', S("a33333333333333333333")); + test(S("abcdefghij"), 5, 0, 0, '3', S("abcdefghij")); + test(S("abcdefghij"), 5, 0, 5, '3', S("abcde33333fghij")); + test(S("abcdefghij"), 5, 0, 10, '3', S("abcde3333333333fghij")); + test(S("abcdefghij"), 5, 0, 20, '3', S("abcde33333333333333333333fghij")); + test(S("abcdefghij"), 5, 1, 0, '3', S("abcdeghij")); + test(S("abcdefghij"), 5, 1, 5, '3', S("abcde33333ghij")); + test(S("abcdefghij"), 5, 1, 10, '3', S("abcde3333333333ghij")); + test(S("abcdefghij"), 5, 1, 20, '3', S("abcde33333333333333333333ghij")); + test(S("abcdefghij"), 5, 2, 0, '3', S("abcdehij")); + test(S("abcdefghij"), 5, 2, 5, '3', S("abcde33333hij")); + test(S("abcdefghij"), 5, 2, 10, '3', S("abcde3333333333hij")); + test(S("abcdefghij"), 5, 2, 20, '3', S("abcde33333333333333333333hij")); + test(S("abcdefghij"), 5, 4, 0, '3', S("abcdej")); + test(S("abcdefghij"), 5, 4, 5, '3', S("abcde33333j")); + test(S("abcdefghij"), 5, 4, 10, '3', S("abcde3333333333j")); + test(S("abcdefghij"), 5, 4, 20, '3', S("abcde33333333333333333333j")); + test(S("abcdefghij"), 5, 5, 0, '3', S("abcde")); + test(S("abcdefghij"), 5, 5, 5, '3', S("abcde33333")); + test(S("abcdefghij"), 5, 5, 10, '3', S("abcde3333333333")); + test(S("abcdefghij"), 5, 5, 20, '3', S("abcde33333333333333333333")); + test(S("abcdefghij"), 9, 0, 0, '3', S("abcdefghij")); + test(S("abcdefghij"), 9, 0, 5, '3', S("abcdefghi33333j")); + test(S("abcdefghij"), 9, 0, 10, '3', S("abcdefghi3333333333j")); + test(S("abcdefghij"), 9, 0, 20, '3', S("abcdefghi33333333333333333333j")); + test(S("abcdefghij"), 9, 1, 0, '3', S("abcdefghi")); + test(S("abcdefghij"), 9, 1, 5, '3', S("abcdefghi33333")); + test(S("abcdefghij"), 9, 1, 10, '3', S("abcdefghi3333333333")); + test(S("abcdefghij"), 9, 1, 20, '3', S("abcdefghi33333333333333333333")); + test(S("abcdefghij"), 10, 0, 0, '3', S("abcdefghij")); + test(S("abcdefghij"), 10, 0, 5, '3', S("abcdefghij33333")); + test(S("abcdefghij"), 10, 0, 10, '3', S("abcdefghij3333333333")); + test(S("abcdefghij"), 10, 0, 20, '3', S("abcdefghij33333333333333333333")); + test(S("abcdefghijklmnopqrst"), 0, 0, 0, '3', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, 5, '3', S("33333abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, 10, '3', S("3333333333abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, 20, '3', S("33333333333333333333abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, 0, '3', S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, 5, '3', S("33333bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, 10, '3', S("3333333333bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, 20, '3', S("33333333333333333333bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, 0, '3', S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, 5, '3', S("33333klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, 10, '3', S("3333333333klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, 20, '3', S("33333333333333333333klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 19, 0, '3', S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, 5, '3', S("33333t")); + test(S("abcdefghijklmnopqrst"), 0, 19, 10, '3', S("3333333333t")); + test(S("abcdefghijklmnopqrst"), 0, 19, 20, '3', S("33333333333333333333t")); + test(S("abcdefghijklmnopqrst"), 0, 20, 0, '3', S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, 5, '3', S("33333")); + test(S("abcdefghijklmnopqrst"), 0, 20, 10, '3', S("3333333333")); + test(S("abcdefghijklmnopqrst"), 0, 20, 20, '3', S("33333333333333333333")); + test(S("abcdefghijklmnopqrst"), 1, 0, 0, '3', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, 5, '3', S("a33333bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, 10, '3', S("a3333333333bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, 20, '3', S("a33333333333333333333bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, 0, '3', S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, 5, '3', S("a33333cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, 10, '3', S("a3333333333cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, 20, '3', S("a33333333333333333333cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, 0, '3', S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, 5, '3', S("a33333klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, 10, '3', S("a3333333333klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, 20, '3', S("a33333333333333333333klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 18, 0, '3', S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, 5, '3', S("a33333t")); + test(S("abcdefghijklmnopqrst"), 1, 18, 10, '3', S("a3333333333t")); + test(S("abcdefghijklmnopqrst"), 1, 18, 20, '3', S("a33333333333333333333t")); + test(S("abcdefghijklmnopqrst"), 1, 19, 0, '3', S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, 5, '3', S("a33333")); + test(S("abcdefghijklmnopqrst"), 1, 19, 10, '3', S("a3333333333")); + test(S("abcdefghijklmnopqrst"), 1, 19, 20, '3', S("a33333333333333333333")); + test(S("abcdefghijklmnopqrst"), 10, 0, 0, '3', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, 5, '3', S("abcdefghij33333klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, 10, '3', S("abcdefghij3333333333klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, 20, '3', S("abcdefghij33333333333333333333klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, 0, '3', S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, 5, '3', S("abcdefghij33333lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, 10, '3', S("abcdefghij3333333333lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, 20, '3', S("abcdefghij33333333333333333333lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, 0, '3', S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, 5, '3', S("abcdefghij33333pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, 10, '3', S("abcdefghij3333333333pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, 20, '3', S("abcdefghij33333333333333333333pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 9, 0, '3', S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, 5, '3', S("abcdefghij33333t")); + test(S("abcdefghijklmnopqrst"), 10, 9, 10, '3', S("abcdefghij3333333333t")); + test(S("abcdefghijklmnopqrst"), 10, 9, 20, '3', S("abcdefghij33333333333333333333t")); +} + +template <class S> +void test2() +{ + test(S("abcdefghijklmnopqrst"), 10, 10, 0, '3', S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, 5, '3', S("abcdefghij33333")); + test(S("abcdefghijklmnopqrst"), 10, 10, 10, '3', S("abcdefghij3333333333")); + test(S("abcdefghijklmnopqrst"), 10, 10, 20, '3', S("abcdefghij33333333333333333333")); + test(S("abcdefghijklmnopqrst"), 19, 0, 0, '3', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, 5, '3', S("abcdefghijklmnopqrs33333t")); + test(S("abcdefghijklmnopqrst"), 19, 0, 10, '3', S("abcdefghijklmnopqrs3333333333t")); + test(S("abcdefghijklmnopqrst"), 19, 0, 20, '3', S("abcdefghijklmnopqrs33333333333333333333t")); + test(S("abcdefghijklmnopqrst"), 19, 1, 0, '3', S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, 5, '3', S("abcdefghijklmnopqrs33333")); + test(S("abcdefghijklmnopqrst"), 19, 1, 10, '3', S("abcdefghijklmnopqrs3333333333")); + test(S("abcdefghijklmnopqrst"), 19, 1, 20, '3', S("abcdefghijklmnopqrs33333333333333333333")); + test(S("abcdefghijklmnopqrst"), 20, 0, 0, '3', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, 5, '3', S("abcdefghijklmnopqrst33333")); + test(S("abcdefghijklmnopqrst"), 20, 0, 10, '3', S("abcdefghijklmnopqrst3333333333")); + test(S("abcdefghijklmnopqrst"), 20, 0, 20, '3', S("abcdefghijklmnopqrst33333333333333333333")); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp new file mode 100644 index 000000000000..0f95492fdb1a --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp @@ -0,0 +1,285 @@ +//===----------------------------------------------------------------------===// +// +// 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>& +// replace(const_iterator i1, const_iterator i2, const basic_string& str); + +#include <stdio.h> + +#include <string> +#include <algorithm> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s, typename S::size_type pos1, typename S::size_type n1, S str, S expected) +{ + typename S::size_type old_size = s.size(); + typename S::const_iterator first = s.begin() + pos1; + typename S::const_iterator last = s.begin() + pos1 + n1; + typename S::size_type xlen = last - first; + s.replace(first, last, str); + assert(s.__invariants()); + assert(s == expected); + typename S::size_type rlen = str.size(); + assert(s.size() == old_size - xlen + rlen); +} + +template <class S> +void test0() +{ + test(S(""), 0, 0, S(""), S("")); + test(S(""), 0, 0, S("12345"), S("12345")); + test(S(""), 0, 0, S("1234567890"), S("1234567890")); + test(S(""), 0, 0, S("12345678901234567890"), S("12345678901234567890")); + test(S("abcde"), 0, 0, S(""), S("abcde")); + test(S("abcde"), 0, 0, S("12345"), S("12345abcde")); + test(S("abcde"), 0, 0, S("1234567890"), S("1234567890abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcde")); + test(S("abcde"), 0, 1, S(""), S("bcde")); + test(S("abcde"), 0, 1, S("12345"), S("12345bcde")); + test(S("abcde"), 0, 1, S("1234567890"), S("1234567890bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcde")); + test(S("abcde"), 0, 2, S(""), S("cde")); + test(S("abcde"), 0, 2, S("12345"), S("12345cde")); + test(S("abcde"), 0, 2, S("1234567890"), S("1234567890cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), S("12345678901234567890cde")); + test(S("abcde"), 0, 4, S(""), S("e")); + test(S("abcde"), 0, 4, S("12345"), S("12345e")); + test(S("abcde"), 0, 4, S("1234567890"), S("1234567890e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), S("12345678901234567890e")); + test(S("abcde"), 0, 5, S(""), S("")); + test(S("abcde"), 0, 5, S("12345"), S("12345")); + test(S("abcde"), 0, 5, S("1234567890"), S("1234567890")); + test(S("abcde"), 0, 5, S("12345678901234567890"), S("12345678901234567890")); + test(S("abcde"), 1, 0, S(""), S("abcde")); + test(S("abcde"), 1, 0, S("12345"), S("a12345bcde")); + test(S("abcde"), 1, 0, S("1234567890"), S("a1234567890bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcde")); + test(S("abcde"), 1, 1, S(""), S("acde")); + test(S("abcde"), 1, 1, S("12345"), S("a12345cde")); + test(S("abcde"), 1, 1, S("1234567890"), S("a1234567890cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cde")); + test(S("abcde"), 1, 2, S(""), S("ade")); + test(S("abcde"), 1, 2, S("12345"), S("a12345de")); + test(S("abcde"), 1, 2, S("1234567890"), S("a1234567890de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), S("a12345678901234567890de")); + test(S("abcde"), 1, 3, S(""), S("ae")); + test(S("abcde"), 1, 3, S("12345"), S("a12345e")); + test(S("abcde"), 1, 3, S("1234567890"), S("a1234567890e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), S("a12345678901234567890e")); + test(S("abcde"), 1, 4, S(""), S("a")); + test(S("abcde"), 1, 4, S("12345"), S("a12345")); + test(S("abcde"), 1, 4, S("1234567890"), S("a1234567890")); + test(S("abcde"), 1, 4, S("12345678901234567890"), S("a12345678901234567890")); + test(S("abcde"), 2, 0, S(""), S("abcde")); + test(S("abcde"), 2, 0, S("12345"), S("ab12345cde")); + test(S("abcde"), 2, 0, S("1234567890"), S("ab1234567890cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), S("ab12345678901234567890cde")); + test(S("abcde"), 2, 1, S(""), S("abde")); + test(S("abcde"), 2, 1, S("12345"), S("ab12345de")); + test(S("abcde"), 2, 1, S("1234567890"), S("ab1234567890de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), S("ab12345678901234567890de")); + test(S("abcde"), 2, 2, S(""), S("abe")); + test(S("abcde"), 2, 2, S("12345"), S("ab12345e")); + test(S("abcde"), 2, 2, S("1234567890"), S("ab1234567890e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), S("ab12345678901234567890e")); + test(S("abcde"), 2, 3, S(""), S("ab")); + test(S("abcde"), 2, 3, S("12345"), S("ab12345")); + test(S("abcde"), 2, 3, S("1234567890"), S("ab1234567890")); + test(S("abcde"), 2, 3, S("12345678901234567890"), S("ab12345678901234567890")); + test(S("abcde"), 4, 0, S(""), S("abcde")); + test(S("abcde"), 4, 0, S("12345"), S("abcd12345e")); + test(S("abcde"), 4, 0, S("1234567890"), S("abcd1234567890e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), S("abcd12345678901234567890e")); + test(S("abcde"), 4, 1, S(""), S("abcd")); + test(S("abcde"), 4, 1, S("12345"), S("abcd12345")); + test(S("abcde"), 4, 1, S("1234567890"), S("abcd1234567890")); + test(S("abcde"), 4, 1, S("12345678901234567890"), S("abcd12345678901234567890")); + test(S("abcde"), 5, 0, S(""), S("abcde")); + test(S("abcde"), 5, 0, S("12345"), S("abcde12345")); + test(S("abcde"), 5, 0, S("1234567890"), S("abcde1234567890")); + test(S("abcde"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890")); + test(S("abcdefghij"), 0, 0, S(""), S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), S("12345abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghij")); + test(S("abcdefghij"), 0, 1, S(""), S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), S("12345bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), S("1234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghij")); + test(S("abcdefghij"), 0, 5, S(""), S("fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), S("12345fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), S("1234567890fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), S("12345678901234567890fghij")); + test(S("abcdefghij"), 0, 9, S(""), S("j")); + test(S("abcdefghij"), 0, 9, S("12345"), S("12345j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), S("1234567890j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), S("12345678901234567890j")); + test(S("abcdefghij"), 0, 10, S(""), S("")); + test(S("abcdefghij"), 0, 10, S("12345"), S("12345")); + test(S("abcdefghij"), 0, 10, S("1234567890"), S("1234567890")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), S("12345678901234567890")); + test(S("abcdefghij"), 1, 0, S(""), S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), S("a12345bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghij")); + test(S("abcdefghij"), 1, 1, S(""), S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), S("a12345cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), S("a1234567890cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghij")); +} + +template <class S> +void test1() +{ + test(S("abcdefghij"), 1, 4, S(""), S("afghij")); + test(S("abcdefghij"), 1, 4, S("12345"), S("a12345fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), S("a1234567890fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), S("a12345678901234567890fghij")); + test(S("abcdefghij"), 1, 8, S(""), S("aj")); + test(S("abcdefghij"), 1, 8, S("12345"), S("a12345j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), S("a1234567890j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), S("a12345678901234567890j")); + test(S("abcdefghij"), 1, 9, S(""), S("a")); + test(S("abcdefghij"), 1, 9, S("12345"), S("a12345")); + test(S("abcdefghij"), 1, 9, S("1234567890"), S("a1234567890")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), S("a12345678901234567890")); + test(S("abcdefghij"), 5, 0, S(""), S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("12345"), S("abcde12345fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890fghij")); + test(S("abcdefghij"), 5, 1, S(""), S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("12345"), S("abcde12345ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), S("abcde1234567890ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), S("abcde12345678901234567890ghij")); + test(S("abcdefghij"), 5, 2, S(""), S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("12345"), S("abcde12345hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), S("abcde1234567890hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), S("abcde12345678901234567890hij")); + test(S("abcdefghij"), 5, 4, S(""), S("abcdej")); + test(S("abcdefghij"), 5, 4, S("12345"), S("abcde12345j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), S("abcde1234567890j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), S("abcde12345678901234567890j")); + test(S("abcdefghij"), 5, 5, S(""), S("abcde")); + test(S("abcdefghij"), 5, 5, S("12345"), S("abcde12345")); + test(S("abcdefghij"), 5, 5, S("1234567890"), S("abcde1234567890")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), S("abcde12345678901234567890")); + test(S("abcdefghij"), 9, 0, S(""), S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("12345"), S("abcdefghi12345j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), S("abcdefghi12345678901234567890j")); + test(S("abcdefghij"), 9, 1, S(""), S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("12345"), S("abcdefghi12345")); + test(S("abcdefghij"), 9, 1, S("1234567890"), S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), S("abcdefghi12345678901234567890")); + test(S("abcdefghij"), 10, 0, S(""), S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("12345"), S("abcdefghij12345")); + test(S("abcdefghij"), 10, 0, S("1234567890"), S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 0, 0, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S(""), S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), S("12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), S("1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S(""), S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), S("12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), S("1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), S("12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 19, S(""), S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), S("12345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), S("1234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), S("12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 20, S(""), S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 0, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S(""), S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), S("a12345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), S("a1234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S(""), S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), S("a12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), S("a1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), S("a12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 18, S(""), S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), S("a12345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), S("a1234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), S("a12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 19, S(""), S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), S("a12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 0, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S(""), S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), S("abcdefghij12345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), S("abcdefghij1234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), S("abcdefghij12345678901234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S(""), S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), S("abcdefghij12345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), S("abcdefghij1234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), S("abcdefghij12345678901234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 9, S(""), S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), S("abcdefghij12345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), S("abcdefghij1234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), S("abcdefghij12345678901234567890t")); +} + +template <class S> +void test2() +{ + test(S("abcdefghijklmnopqrst"), 10, 10, S(""), S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 0, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 1, S(""), S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp new file mode 100644 index 000000000000..914081bbc456 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp @@ -0,0 +1,375 @@ +//===----------------------------------------------------------------------===// +// +// 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>& +// replace(size_type pos, size_type n1, const charT* s); + +#include <stdio.h> + +#include <string> +#include <stdexcept> +#include <algorithm> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s, typename S::size_type pos, typename S::size_type n1, + const typename S::value_type* str, S expected) +{ + typename S::size_type old_size = s.size(); + S s0 = s; + try + { + s.replace(pos, n1, str); + assert(s.__invariants()); + assert(pos <= old_size); + assert(s == expected); + typename S::size_type xlen = std::min(n1, old_size - pos); + typename S::size_type rlen = S::traits_type::length(str); + assert(s.size() == old_size - xlen + rlen); + } + catch (std::out_of_range&) + { + assert(pos > old_size); + assert(s == s0); + } +} + +template <class S> +void test0() +{ + test(S(""), 0, 0, "", S("")); + test(S(""), 0, 0, "12345", S("12345")); + test(S(""), 0, 0, "1234567890", S("1234567890")); + test(S(""), 0, 0, "12345678901234567890", S("12345678901234567890")); + test(S(""), 0, 1, "", S("")); + test(S(""), 0, 1, "12345", S("12345")); + test(S(""), 0, 1, "1234567890", S("1234567890")); + test(S(""), 0, 1, "12345678901234567890", S("12345678901234567890")); + test(S(""), 1, 0, "", S("can't happen")); + test(S(""), 1, 0, "12345", S("can't happen")); + test(S(""), 1, 0, "1234567890", S("can't happen")); + test(S(""), 1, 0, "12345678901234567890", S("can't happen")); + test(S("abcde"), 0, 0, "", S("abcde")); + test(S("abcde"), 0, 0, "12345", S("12345abcde")); + test(S("abcde"), 0, 0, "1234567890", S("1234567890abcde")); + test(S("abcde"), 0, 0, "12345678901234567890", S("12345678901234567890abcde")); + test(S("abcde"), 0, 1, "", S("bcde")); + test(S("abcde"), 0, 1, "12345", S("12345bcde")); + test(S("abcde"), 0, 1, "1234567890", S("1234567890bcde")); + test(S("abcde"), 0, 1, "12345678901234567890", S("12345678901234567890bcde")); + test(S("abcde"), 0, 2, "", S("cde")); + test(S("abcde"), 0, 2, "12345", S("12345cde")); + test(S("abcde"), 0, 2, "1234567890", S("1234567890cde")); + test(S("abcde"), 0, 2, "12345678901234567890", S("12345678901234567890cde")); + test(S("abcde"), 0, 4, "", S("e")); + test(S("abcde"), 0, 4, "12345", S("12345e")); + test(S("abcde"), 0, 4, "1234567890", S("1234567890e")); + test(S("abcde"), 0, 4, "12345678901234567890", S("12345678901234567890e")); + test(S("abcde"), 0, 5, "", S("")); + test(S("abcde"), 0, 5, "12345", S("12345")); + test(S("abcde"), 0, 5, "1234567890", S("1234567890")); + test(S("abcde"), 0, 5, "12345678901234567890", S("12345678901234567890")); + test(S("abcde"), 0, 6, "", S("")); + test(S("abcde"), 0, 6, "12345", S("12345")); + test(S("abcde"), 0, 6, "1234567890", S("1234567890")); + test(S("abcde"), 0, 6, "12345678901234567890", S("12345678901234567890")); + test(S("abcde"), 1, 0, "", S("abcde")); + test(S("abcde"), 1, 0, "12345", S("a12345bcde")); + test(S("abcde"), 1, 0, "1234567890", S("a1234567890bcde")); + test(S("abcde"), 1, 0, "12345678901234567890", S("a12345678901234567890bcde")); + test(S("abcde"), 1, 1, "", S("acde")); + test(S("abcde"), 1, 1, "12345", S("a12345cde")); + test(S("abcde"), 1, 1, "1234567890", S("a1234567890cde")); + test(S("abcde"), 1, 1, "12345678901234567890", S("a12345678901234567890cde")); + test(S("abcde"), 1, 2, "", S("ade")); + test(S("abcde"), 1, 2, "12345", S("a12345de")); + test(S("abcde"), 1, 2, "1234567890", S("a1234567890de")); + test(S("abcde"), 1, 2, "12345678901234567890", S("a12345678901234567890de")); + test(S("abcde"), 1, 3, "", S("ae")); + test(S("abcde"), 1, 3, "12345", S("a12345e")); + test(S("abcde"), 1, 3, "1234567890", S("a1234567890e")); + test(S("abcde"), 1, 3, "12345678901234567890", S("a12345678901234567890e")); + test(S("abcde"), 1, 4, "", S("a")); + test(S("abcde"), 1, 4, "12345", S("a12345")); + test(S("abcde"), 1, 4, "1234567890", S("a1234567890")); + test(S("abcde"), 1, 4, "12345678901234567890", S("a12345678901234567890")); + test(S("abcde"), 1, 5, "", S("a")); + test(S("abcde"), 1, 5, "12345", S("a12345")); + test(S("abcde"), 1, 5, "1234567890", S("a1234567890")); + test(S("abcde"), 1, 5, "12345678901234567890", S("a12345678901234567890")); + test(S("abcde"), 2, 0, "", S("abcde")); + test(S("abcde"), 2, 0, "12345", S("ab12345cde")); + test(S("abcde"), 2, 0, "1234567890", S("ab1234567890cde")); + test(S("abcde"), 2, 0, "12345678901234567890", S("ab12345678901234567890cde")); + test(S("abcde"), 2, 1, "", S("abde")); + test(S("abcde"), 2, 1, "12345", S("ab12345de")); + test(S("abcde"), 2, 1, "1234567890", S("ab1234567890de")); + test(S("abcde"), 2, 1, "12345678901234567890", S("ab12345678901234567890de")); + test(S("abcde"), 2, 2, "", S("abe")); + test(S("abcde"), 2, 2, "12345", S("ab12345e")); + test(S("abcde"), 2, 2, "1234567890", S("ab1234567890e")); + test(S("abcde"), 2, 2, "12345678901234567890", S("ab12345678901234567890e")); + test(S("abcde"), 2, 3, "", S("ab")); + test(S("abcde"), 2, 3, "12345", S("ab12345")); + test(S("abcde"), 2, 3, "1234567890", S("ab1234567890")); + test(S("abcde"), 2, 3, "12345678901234567890", S("ab12345678901234567890")); + test(S("abcde"), 2, 4, "", S("ab")); + test(S("abcde"), 2, 4, "12345", S("ab12345")); + test(S("abcde"), 2, 4, "1234567890", S("ab1234567890")); + test(S("abcde"), 2, 4, "12345678901234567890", S("ab12345678901234567890")); + test(S("abcde"), 4, 0, "", S("abcde")); + test(S("abcde"), 4, 0, "12345", S("abcd12345e")); + test(S("abcde"), 4, 0, "1234567890", S("abcd1234567890e")); + test(S("abcde"), 4, 0, "12345678901234567890", S("abcd12345678901234567890e")); + test(S("abcde"), 4, 1, "", S("abcd")); + test(S("abcde"), 4, 1, "12345", S("abcd12345")); + test(S("abcde"), 4, 1, "1234567890", S("abcd1234567890")); + test(S("abcde"), 4, 1, "12345678901234567890", S("abcd12345678901234567890")); + test(S("abcde"), 4, 2, "", S("abcd")); + test(S("abcde"), 4, 2, "12345", S("abcd12345")); + test(S("abcde"), 4, 2, "1234567890", S("abcd1234567890")); + test(S("abcde"), 4, 2, "12345678901234567890", S("abcd12345678901234567890")); + test(S("abcde"), 5, 0, "", S("abcde")); + test(S("abcde"), 5, 0, "12345", S("abcde12345")); + test(S("abcde"), 5, 0, "1234567890", S("abcde1234567890")); + test(S("abcde"), 5, 0, "12345678901234567890", S("abcde12345678901234567890")); + test(S("abcde"), 5, 1, "", S("abcde")); + test(S("abcde"), 5, 1, "12345", S("abcde12345")); + test(S("abcde"), 5, 1, "1234567890", S("abcde1234567890")); + test(S("abcde"), 5, 1, "12345678901234567890", S("abcde12345678901234567890")); +} + +template <class S> +void test1() +{ + test(S("abcde"), 6, 0, "", S("can't happen")); + test(S("abcde"), 6, 0, "12345", S("can't happen")); + test(S("abcde"), 6, 0, "1234567890", S("can't happen")); + test(S("abcde"), 6, 0, "12345678901234567890", S("can't happen")); + test(S("abcdefghij"), 0, 0, "", S("abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345", S("12345abcdefghij")); + test(S("abcdefghij"), 0, 0, "1234567890", S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345678901234567890", S("12345678901234567890abcdefghij")); + test(S("abcdefghij"), 0, 1, "", S("bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345", S("12345bcdefghij")); + test(S("abcdefghij"), 0, 1, "1234567890", S("1234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345678901234567890", S("12345678901234567890bcdefghij")); + test(S("abcdefghij"), 0, 5, "", S("fghij")); + test(S("abcdefghij"), 0, 5, "12345", S("12345fghij")); + test(S("abcdefghij"), 0, 5, "1234567890", S("1234567890fghij")); + test(S("abcdefghij"), 0, 5, "12345678901234567890", S("12345678901234567890fghij")); + test(S("abcdefghij"), 0, 9, "", S("j")); + test(S("abcdefghij"), 0, 9, "12345", S("12345j")); + test(S("abcdefghij"), 0, 9, "1234567890", S("1234567890j")); + test(S("abcdefghij"), 0, 9, "12345678901234567890", S("12345678901234567890j")); + test(S("abcdefghij"), 0, 10, "", S("")); + test(S("abcdefghij"), 0, 10, "12345", S("12345")); + test(S("abcdefghij"), 0, 10, "1234567890", S("1234567890")); + test(S("abcdefghij"), 0, 10, "12345678901234567890", S("12345678901234567890")); + test(S("abcdefghij"), 0, 11, "", S("")); + test(S("abcdefghij"), 0, 11, "12345", S("12345")); + test(S("abcdefghij"), 0, 11, "1234567890", S("1234567890")); + test(S("abcdefghij"), 0, 11, "12345678901234567890", S("12345678901234567890")); + test(S("abcdefghij"), 1, 0, "", S("abcdefghij")); + test(S("abcdefghij"), 1, 0, "12345", S("a12345bcdefghij")); + test(S("abcdefghij"), 1, 0, "1234567890", S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, "12345678901234567890", S("a12345678901234567890bcdefghij")); + test(S("abcdefghij"), 1, 1, "", S("acdefghij")); + test(S("abcdefghij"), 1, 1, "12345", S("a12345cdefghij")); + test(S("abcdefghij"), 1, 1, "1234567890", S("a1234567890cdefghij")); + test(S("abcdefghij"), 1, 1, "12345678901234567890", S("a12345678901234567890cdefghij")); + test(S("abcdefghij"), 1, 4, "", S("afghij")); + test(S("abcdefghij"), 1, 4, "12345", S("a12345fghij")); + test(S("abcdefghij"), 1, 4, "1234567890", S("a1234567890fghij")); + test(S("abcdefghij"), 1, 4, "12345678901234567890", S("a12345678901234567890fghij")); + test(S("abcdefghij"), 1, 8, "", S("aj")); + test(S("abcdefghij"), 1, 8, "12345", S("a12345j")); + test(S("abcdefghij"), 1, 8, "1234567890", S("a1234567890j")); + test(S("abcdefghij"), 1, 8, "12345678901234567890", S("a12345678901234567890j")); + test(S("abcdefghij"), 1, 9, "", S("a")); + test(S("abcdefghij"), 1, 9, "12345", S("a12345")); + test(S("abcdefghij"), 1, 9, "1234567890", S("a1234567890")); + test(S("abcdefghij"), 1, 9, "12345678901234567890", S("a12345678901234567890")); + test(S("abcdefghij"), 1, 10, "", S("a")); + test(S("abcdefghij"), 1, 10, "12345", S("a12345")); + test(S("abcdefghij"), 1, 10, "1234567890", S("a1234567890")); + test(S("abcdefghij"), 1, 10, "12345678901234567890", S("a12345678901234567890")); + test(S("abcdefghij"), 5, 0, "", S("abcdefghij")); + test(S("abcdefghij"), 5, 0, "12345", S("abcde12345fghij")); + test(S("abcdefghij"), 5, 0, "1234567890", S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, 0, "12345678901234567890", S("abcde12345678901234567890fghij")); + test(S("abcdefghij"), 5, 1, "", S("abcdeghij")); + test(S("abcdefghij"), 5, 1, "12345", S("abcde12345ghij")); + test(S("abcdefghij"), 5, 1, "1234567890", S("abcde1234567890ghij")); + test(S("abcdefghij"), 5, 1, "12345678901234567890", S("abcde12345678901234567890ghij")); + test(S("abcdefghij"), 5, 2, "", S("abcdehij")); + test(S("abcdefghij"), 5, 2, "12345", S("abcde12345hij")); + test(S("abcdefghij"), 5, 2, "1234567890", S("abcde1234567890hij")); + test(S("abcdefghij"), 5, 2, "12345678901234567890", S("abcde12345678901234567890hij")); + test(S("abcdefghij"), 5, 4, "", S("abcdej")); + test(S("abcdefghij"), 5, 4, "12345", S("abcde12345j")); + test(S("abcdefghij"), 5, 4, "1234567890", S("abcde1234567890j")); + test(S("abcdefghij"), 5, 4, "12345678901234567890", S("abcde12345678901234567890j")); + test(S("abcdefghij"), 5, 5, "", S("abcde")); + test(S("abcdefghij"), 5, 5, "12345", S("abcde12345")); + test(S("abcdefghij"), 5, 5, "1234567890", S("abcde1234567890")); + test(S("abcdefghij"), 5, 5, "12345678901234567890", S("abcde12345678901234567890")); + test(S("abcdefghij"), 5, 6, "", S("abcde")); + test(S("abcdefghij"), 5, 6, "12345", S("abcde12345")); + test(S("abcdefghij"), 5, 6, "1234567890", S("abcde1234567890")); + test(S("abcdefghij"), 5, 6, "12345678901234567890", S("abcde12345678901234567890")); + test(S("abcdefghij"), 9, 0, "", S("abcdefghij")); + test(S("abcdefghij"), 9, 0, "12345", S("abcdefghi12345j")); + test(S("abcdefghij"), 9, 0, "1234567890", S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, 0, "12345678901234567890", S("abcdefghi12345678901234567890j")); + test(S("abcdefghij"), 9, 1, "", S("abcdefghi")); + test(S("abcdefghij"), 9, 1, "12345", S("abcdefghi12345")); + test(S("abcdefghij"), 9, 1, "1234567890", S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 1, "12345678901234567890", S("abcdefghi12345678901234567890")); + test(S("abcdefghij"), 9, 2, "", S("abcdefghi")); + test(S("abcdefghij"), 9, 2, "12345", S("abcdefghi12345")); + test(S("abcdefghij"), 9, 2, "1234567890", S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 2, "12345678901234567890", S("abcdefghi12345678901234567890")); + test(S("abcdefghij"), 10, 0, "", S("abcdefghij")); + test(S("abcdefghij"), 10, 0, "12345", S("abcdefghij12345")); + test(S("abcdefghij"), 10, 0, "1234567890", S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 0, "12345678901234567890", S("abcdefghij12345678901234567890")); + test(S("abcdefghij"), 10, 1, "", S("abcdefghij")); + test(S("abcdefghij"), 10, 1, "12345", S("abcdefghij12345")); + test(S("abcdefghij"), 10, 1, "1234567890", S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 1, "12345678901234567890", S("abcdefghij12345678901234567890")); + test(S("abcdefghij"), 11, 0, "", S("can't happen")); + test(S("abcdefghij"), 11, 0, "12345", S("can't happen")); + test(S("abcdefghij"), 11, 0, "1234567890", S("can't happen")); + test(S("abcdefghij"), 11, 0, "12345678901234567890", S("can't happen")); +} + +template <class S> +void test2() +{ + test(S("abcdefghijklmnopqrst"), 0, 0, "", S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345", S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "", S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345", S("12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", S("1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", S("12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "", S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345", S("12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", S("1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", S("12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 19, "", S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345", S("12345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", S("1234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", S("12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 20, "", S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345", S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, "", S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, "12345", S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 0, "", S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345", S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "", S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345", S("a12345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", S("a1234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", S("a12345678901234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "", S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345", S("a12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", S("a1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", S("a12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 18, "", S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345", S("a12345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", S("a1234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", S("a12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 19, "", S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345", S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", S("a12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, "", S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, "12345", S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", S("a12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 0, "", S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345", S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "", S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345", S("abcdefghij12345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", S("abcdefghij1234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", S("abcdefghij12345678901234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "", S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345", S("abcdefghij12345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", S("abcdefghij1234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", S("abcdefghij12345678901234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 9, "", S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345", S("abcdefghij12345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", S("abcdefghij1234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", S("abcdefghij12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 10, "", S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345", S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, "", S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, "12345", S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 0, "", S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345", S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 1, "", S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345", S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, "", S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, "12345", S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, "", S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345", S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, "", S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, "12345", S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 21, 0, "", S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "12345", S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", S("can't happen")); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp new file mode 100644 index 000000000000..d98704287327 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp @@ -0,0 +1,1327 @@ +//===----------------------------------------------------------------------===// +// +// 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>& +// replace(size_type pos, size_type n1, const charT* s, size_type n2); + +#include <stdio.h> + +#include <string> +#include <stdexcept> +#include <algorithm> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s, typename S::size_type pos, typename S::size_type n1, + const typename S::value_type* str, typename S::size_type n2, + S expected) +{ + typename S::size_type old_size = s.size(); + S s0 = s; + try + { + s.replace(pos, n1, str, n2); + assert(s.__invariants()); + assert(pos <= old_size); + assert(s == expected); + typename S::size_type xlen = std::min(n1, old_size - pos); + typename S::size_type rlen = n2; + assert(s.size() == old_size - xlen + rlen); + } + catch (std::out_of_range&) + { + assert(pos > old_size); + assert(s == s0); + } +} + +template <class S> +void test0() +{ + test(S(""), 0, 0, "", 0, S("")); + test(S(""), 0, 0, "12345", 0, S("")); + test(S(""), 0, 0, "12345", 1, S("1")); + test(S(""), 0, 0, "12345", 2, S("12")); + test(S(""), 0, 0, "12345", 4, S("1234")); + test(S(""), 0, 0, "12345", 5, S("12345")); + test(S(""), 0, 0, "1234567890", 0, S("")); + test(S(""), 0, 0, "1234567890", 1, S("1")); + test(S(""), 0, 0, "1234567890", 5, S("12345")); + test(S(""), 0, 0, "1234567890", 9, S("123456789")); + test(S(""), 0, 0, "1234567890", 10, S("1234567890")); + test(S(""), 0, 0, "12345678901234567890", 0, S("")); + test(S(""), 0, 0, "12345678901234567890", 1, S("1")); + test(S(""), 0, 0, "12345678901234567890", 10, S("1234567890")); + test(S(""), 0, 0, "12345678901234567890", 19, S("1234567890123456789")); + test(S(""), 0, 0, "12345678901234567890", 20, S("12345678901234567890")); + test(S(""), 0, 1, "", 0, S("")); + test(S(""), 0, 1, "12345", 0, S("")); + test(S(""), 0, 1, "12345", 1, S("1")); + test(S(""), 0, 1, "12345", 2, S("12")); + test(S(""), 0, 1, "12345", 4, S("1234")); + test(S(""), 0, 1, "12345", 5, S("12345")); + test(S(""), 0, 1, "1234567890", 0, S("")); + test(S(""), 0, 1, "1234567890", 1, S("1")); + test(S(""), 0, 1, "1234567890", 5, S("12345")); + test(S(""), 0, 1, "1234567890", 9, S("123456789")); + test(S(""), 0, 1, "1234567890", 10, S("1234567890")); + test(S(""), 0, 1, "12345678901234567890", 0, S("")); + test(S(""), 0, 1, "12345678901234567890", 1, S("1")); + test(S(""), 0, 1, "12345678901234567890", 10, S("1234567890")); + test(S(""), 0, 1, "12345678901234567890", 19, S("1234567890123456789")); + test(S(""), 0, 1, "12345678901234567890", 20, S("12345678901234567890")); + test(S(""), 1, 0, "", 0, S("can't happen")); + test(S(""), 1, 0, "12345", 0, S("can't happen")); + test(S(""), 1, 0, "12345", 1, S("can't happen")); + test(S(""), 1, 0, "12345", 2, S("can't happen")); + test(S(""), 1, 0, "12345", 4, S("can't happen")); + test(S(""), 1, 0, "12345", 5, S("can't happen")); + test(S(""), 1, 0, "1234567890", 0, S("can't happen")); + test(S(""), 1, 0, "1234567890", 1, S("can't happen")); + test(S(""), 1, 0, "1234567890", 5, S("can't happen")); + test(S(""), 1, 0, "1234567890", 9, S("can't happen")); + test(S(""), 1, 0, "1234567890", 10, S("can't happen")); + test(S(""), 1, 0, "12345678901234567890", 0, S("can't happen")); + test(S(""), 1, 0, "12345678901234567890", 1, S("can't happen")); + test(S(""), 1, 0, "12345678901234567890", 10, S("can't happen")); + test(S(""), 1, 0, "12345678901234567890", 19, S("can't happen")); + test(S(""), 1, 0, "12345678901234567890", 20, S("can't happen")); + test(S("abcde"), 0, 0, "", 0, S("abcde")); + test(S("abcde"), 0, 0, "12345", 0, S("abcde")); + test(S("abcde"), 0, 0, "12345", 1, S("1abcde")); + test(S("abcde"), 0, 0, "12345", 2, S("12abcde")); + test(S("abcde"), 0, 0, "12345", 4, S("1234abcde")); + test(S("abcde"), 0, 0, "12345", 5, S("12345abcde")); + test(S("abcde"), 0, 0, "1234567890", 0, S("abcde")); + test(S("abcde"), 0, 0, "1234567890", 1, S("1abcde")); + test(S("abcde"), 0, 0, "1234567890", 5, S("12345abcde")); + test(S("abcde"), 0, 0, "1234567890", 9, S("123456789abcde")); + test(S("abcde"), 0, 0, "1234567890", 10, S("1234567890abcde")); + test(S("abcde"), 0, 0, "12345678901234567890", 0, S("abcde")); + test(S("abcde"), 0, 0, "12345678901234567890", 1, S("1abcde")); + test(S("abcde"), 0, 0, "12345678901234567890", 10, S("1234567890abcde")); + test(S("abcde"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcde")); + test(S("abcde"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcde")); + test(S("abcde"), 0, 1, "", 0, S("bcde")); + test(S("abcde"), 0, 1, "12345", 0, S("bcde")); + test(S("abcde"), 0, 1, "12345", 1, S("1bcde")); + test(S("abcde"), 0, 1, "12345", 2, S("12bcde")); + test(S("abcde"), 0, 1, "12345", 4, S("1234bcde")); + test(S("abcde"), 0, 1, "12345", 5, S("12345bcde")); + test(S("abcde"), 0, 1, "1234567890", 0, S("bcde")); + test(S("abcde"), 0, 1, "1234567890", 1, S("1bcde")); + test(S("abcde"), 0, 1, "1234567890", 5, S("12345bcde")); + test(S("abcde"), 0, 1, "1234567890", 9, S("123456789bcde")); + test(S("abcde"), 0, 1, "1234567890", 10, S("1234567890bcde")); + test(S("abcde"), 0, 1, "12345678901234567890", 0, S("bcde")); + test(S("abcde"), 0, 1, "12345678901234567890", 1, S("1bcde")); + test(S("abcde"), 0, 1, "12345678901234567890", 10, S("1234567890bcde")); + test(S("abcde"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcde")); + test(S("abcde"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcde")); + test(S("abcde"), 0, 2, "", 0, S("cde")); + test(S("abcde"), 0, 2, "12345", 0, S("cde")); + test(S("abcde"), 0, 2, "12345", 1, S("1cde")); + test(S("abcde"), 0, 2, "12345", 2, S("12cde")); + test(S("abcde"), 0, 2, "12345", 4, S("1234cde")); + test(S("abcde"), 0, 2, "12345", 5, S("12345cde")); + test(S("abcde"), 0, 2, "1234567890", 0, S("cde")); + test(S("abcde"), 0, 2, "1234567890", 1, S("1cde")); + test(S("abcde"), 0, 2, "1234567890", 5, S("12345cde")); + test(S("abcde"), 0, 2, "1234567890", 9, S("123456789cde")); + test(S("abcde"), 0, 2, "1234567890", 10, S("1234567890cde")); + test(S("abcde"), 0, 2, "12345678901234567890", 0, S("cde")); + test(S("abcde"), 0, 2, "12345678901234567890", 1, S("1cde")); + test(S("abcde"), 0, 2, "12345678901234567890", 10, S("1234567890cde")); + test(S("abcde"), 0, 2, "12345678901234567890", 19, S("1234567890123456789cde")); + test(S("abcde"), 0, 2, "12345678901234567890", 20, S("12345678901234567890cde")); + test(S("abcde"), 0, 4, "", 0, S("e")); + test(S("abcde"), 0, 4, "12345", 0, S("e")); + test(S("abcde"), 0, 4, "12345", 1, S("1e")); + test(S("abcde"), 0, 4, "12345", 2, S("12e")); +} + +template <class S> +void test1() +{ + test(S("abcde"), 0, 4, "12345", 4, S("1234e")); + test(S("abcde"), 0, 4, "12345", 5, S("12345e")); + test(S("abcde"), 0, 4, "1234567890", 0, S("e")); + test(S("abcde"), 0, 4, "1234567890", 1, S("1e")); + test(S("abcde"), 0, 4, "1234567890", 5, S("12345e")); + test(S("abcde"), 0, 4, "1234567890", 9, S("123456789e")); + test(S("abcde"), 0, 4, "1234567890", 10, S("1234567890e")); + test(S("abcde"), 0, 4, "12345678901234567890", 0, S("e")); + test(S("abcde"), 0, 4, "12345678901234567890", 1, S("1e")); + test(S("abcde"), 0, 4, "12345678901234567890", 10, S("1234567890e")); + test(S("abcde"), 0, 4, "12345678901234567890", 19, S("1234567890123456789e")); + test(S("abcde"), 0, 4, "12345678901234567890", 20, S("12345678901234567890e")); + test(S("abcde"), 0, 5, "", 0, S("")); + test(S("abcde"), 0, 5, "12345", 0, S("")); + test(S("abcde"), 0, 5, "12345", 1, S("1")); + test(S("abcde"), 0, 5, "12345", 2, S("12")); + test(S("abcde"), 0, 5, "12345", 4, S("1234")); + test(S("abcde"), 0, 5, "12345", 5, S("12345")); + test(S("abcde"), 0, 5, "1234567890", 0, S("")); + test(S("abcde"), 0, 5, "1234567890", 1, S("1")); + test(S("abcde"), 0, 5, "1234567890", 5, S("12345")); + test(S("abcde"), 0, 5, "1234567890", 9, S("123456789")); + test(S("abcde"), 0, 5, "1234567890", 10, S("1234567890")); + test(S("abcde"), 0, 5, "12345678901234567890", 0, S("")); + test(S("abcde"), 0, 5, "12345678901234567890", 1, S("1")); + test(S("abcde"), 0, 5, "12345678901234567890", 10, S("1234567890")); + test(S("abcde"), 0, 5, "12345678901234567890", 19, S("1234567890123456789")); + test(S("abcde"), 0, 5, "12345678901234567890", 20, S("12345678901234567890")); + test(S("abcde"), 0, 6, "", 0, S("")); + test(S("abcde"), 0, 6, "12345", 0, S("")); + test(S("abcde"), 0, 6, "12345", 1, S("1")); + test(S("abcde"), 0, 6, "12345", 2, S("12")); + test(S("abcde"), 0, 6, "12345", 4, S("1234")); + test(S("abcde"), 0, 6, "12345", 5, S("12345")); + test(S("abcde"), 0, 6, "1234567890", 0, S("")); + test(S("abcde"), 0, 6, "1234567890", 1, S("1")); + test(S("abcde"), 0, 6, "1234567890", 5, S("12345")); + test(S("abcde"), 0, 6, "1234567890", 9, S("123456789")); + test(S("abcde"), 0, 6, "1234567890", 10, S("1234567890")); + test(S("abcde"), 0, 6, "12345678901234567890", 0, S("")); + test(S("abcde"), 0, 6, "12345678901234567890", 1, S("1")); + test(S("abcde"), 0, 6, "12345678901234567890", 10, S("1234567890")); + test(S("abcde"), 0, 6, "12345678901234567890", 19, S("1234567890123456789")); + test(S("abcde"), 0, 6, "12345678901234567890", 20, S("12345678901234567890")); + test(S("abcde"), 1, 0, "", 0, S("abcde")); + test(S("abcde"), 1, 0, "12345", 0, S("abcde")); + test(S("abcde"), 1, 0, "12345", 1, S("a1bcde")); + test(S("abcde"), 1, 0, "12345", 2, S("a12bcde")); + test(S("abcde"), 1, 0, "12345", 4, S("a1234bcde")); + test(S("abcde"), 1, 0, "12345", 5, S("a12345bcde")); + test(S("abcde"), 1, 0, "1234567890", 0, S("abcde")); + test(S("abcde"), 1, 0, "1234567890", 1, S("a1bcde")); + test(S("abcde"), 1, 0, "1234567890", 5, S("a12345bcde")); + test(S("abcde"), 1, 0, "1234567890", 9, S("a123456789bcde")); + test(S("abcde"), 1, 0, "1234567890", 10, S("a1234567890bcde")); + test(S("abcde"), 1, 0, "12345678901234567890", 0, S("abcde")); + test(S("abcde"), 1, 0, "12345678901234567890", 1, S("a1bcde")); + test(S("abcde"), 1, 0, "12345678901234567890", 10, S("a1234567890bcde")); + test(S("abcde"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcde")); + test(S("abcde"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcde")); + test(S("abcde"), 1, 1, "", 0, S("acde")); + test(S("abcde"), 1, 1, "12345", 0, S("acde")); + test(S("abcde"), 1, 1, "12345", 1, S("a1cde")); + test(S("abcde"), 1, 1, "12345", 2, S("a12cde")); + test(S("abcde"), 1, 1, "12345", 4, S("a1234cde")); + test(S("abcde"), 1, 1, "12345", 5, S("a12345cde")); + test(S("abcde"), 1, 1, "1234567890", 0, S("acde")); + test(S("abcde"), 1, 1, "1234567890", 1, S("a1cde")); + test(S("abcde"), 1, 1, "1234567890", 5, S("a12345cde")); + test(S("abcde"), 1, 1, "1234567890", 9, S("a123456789cde")); + test(S("abcde"), 1, 1, "1234567890", 10, S("a1234567890cde")); + test(S("abcde"), 1, 1, "12345678901234567890", 0, S("acde")); + test(S("abcde"), 1, 1, "12345678901234567890", 1, S("a1cde")); + test(S("abcde"), 1, 1, "12345678901234567890", 10, S("a1234567890cde")); + test(S("abcde"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cde")); + test(S("abcde"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cde")); + test(S("abcde"), 1, 2, "", 0, S("ade")); + test(S("abcde"), 1, 2, "12345", 0, S("ade")); + test(S("abcde"), 1, 2, "12345", 1, S("a1de")); + test(S("abcde"), 1, 2, "12345", 2, S("a12de")); + test(S("abcde"), 1, 2, "12345", 4, S("a1234de")); + test(S("abcde"), 1, 2, "12345", 5, S("a12345de")); + test(S("abcde"), 1, 2, "1234567890", 0, S("ade")); + test(S("abcde"), 1, 2, "1234567890", 1, S("a1de")); + test(S("abcde"), 1, 2, "1234567890", 5, S("a12345de")); + test(S("abcde"), 1, 2, "1234567890", 9, S("a123456789de")); + test(S("abcde"), 1, 2, "1234567890", 10, S("a1234567890de")); + test(S("abcde"), 1, 2, "12345678901234567890", 0, S("ade")); + test(S("abcde"), 1, 2, "12345678901234567890", 1, S("a1de")); + test(S("abcde"), 1, 2, "12345678901234567890", 10, S("a1234567890de")); + test(S("abcde"), 1, 2, "12345678901234567890", 19, S("a1234567890123456789de")); + test(S("abcde"), 1, 2, "12345678901234567890", 20, S("a12345678901234567890de")); + test(S("abcde"), 1, 3, "", 0, S("ae")); + test(S("abcde"), 1, 3, "12345", 0, S("ae")); + test(S("abcde"), 1, 3, "12345", 1, S("a1e")); + test(S("abcde"), 1, 3, "12345", 2, S("a12e")); + test(S("abcde"), 1, 3, "12345", 4, S("a1234e")); + test(S("abcde"), 1, 3, "12345", 5, S("a12345e")); + test(S("abcde"), 1, 3, "1234567890", 0, S("ae")); + test(S("abcde"), 1, 3, "1234567890", 1, S("a1e")); +} + +template <class S> +void test2() +{ + test(S("abcde"), 1, 3, "1234567890", 5, S("a12345e")); + test(S("abcde"), 1, 3, "1234567890", 9, S("a123456789e")); + test(S("abcde"), 1, 3, "1234567890", 10, S("a1234567890e")); + test(S("abcde"), 1, 3, "12345678901234567890", 0, S("ae")); + test(S("abcde"), 1, 3, "12345678901234567890", 1, S("a1e")); + test(S("abcde"), 1, 3, "12345678901234567890", 10, S("a1234567890e")); + test(S("abcde"), 1, 3, "12345678901234567890", 19, S("a1234567890123456789e")); + test(S("abcde"), 1, 3, "12345678901234567890", 20, S("a12345678901234567890e")); + test(S("abcde"), 1, 4, "", 0, S("a")); + test(S("abcde"), 1, 4, "12345", 0, S("a")); + test(S("abcde"), 1, 4, "12345", 1, S("a1")); + test(S("abcde"), 1, 4, "12345", 2, S("a12")); + test(S("abcde"), 1, 4, "12345", 4, S("a1234")); + test(S("abcde"), 1, 4, "12345", 5, S("a12345")); + test(S("abcde"), 1, 4, "1234567890", 0, S("a")); + test(S("abcde"), 1, 4, "1234567890", 1, S("a1")); + test(S("abcde"), 1, 4, "1234567890", 5, S("a12345")); + test(S("abcde"), 1, 4, "1234567890", 9, S("a123456789")); + test(S("abcde"), 1, 4, "1234567890", 10, S("a1234567890")); + test(S("abcde"), 1, 4, "12345678901234567890", 0, S("a")); + test(S("abcde"), 1, 4, "12345678901234567890", 1, S("a1")); + test(S("abcde"), 1, 4, "12345678901234567890", 10, S("a1234567890")); + test(S("abcde"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789")); + test(S("abcde"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890")); + test(S("abcde"), 1, 5, "", 0, S("a")); + test(S("abcde"), 1, 5, "12345", 0, S("a")); + test(S("abcde"), 1, 5, "12345", 1, S("a1")); + test(S("abcde"), 1, 5, "12345", 2, S("a12")); + test(S("abcde"), 1, 5, "12345", 4, S("a1234")); + test(S("abcde"), 1, 5, "12345", 5, S("a12345")); + test(S("abcde"), 1, 5, "1234567890", 0, S("a")); + test(S("abcde"), 1, 5, "1234567890", 1, S("a1")); + test(S("abcde"), 1, 5, "1234567890", 5, S("a12345")); + test(S("abcde"), 1, 5, "1234567890", 9, S("a123456789")); + test(S("abcde"), 1, 5, "1234567890", 10, S("a1234567890")); + test(S("abcde"), 1, 5, "12345678901234567890", 0, S("a")); + test(S("abcde"), 1, 5, "12345678901234567890", 1, S("a1")); + test(S("abcde"), 1, 5, "12345678901234567890", 10, S("a1234567890")); + test(S("abcde"), 1, 5, "12345678901234567890", 19, S("a1234567890123456789")); + test(S("abcde"), 1, 5, "12345678901234567890", 20, S("a12345678901234567890")); + test(S("abcde"), 2, 0, "", 0, S("abcde")); + test(S("abcde"), 2, 0, "12345", 0, S("abcde")); + test(S("abcde"), 2, 0, "12345", 1, S("ab1cde")); + test(S("abcde"), 2, 0, "12345", 2, S("ab12cde")); + test(S("abcde"), 2, 0, "12345", 4, S("ab1234cde")); + test(S("abcde"), 2, 0, "12345", 5, S("ab12345cde")); + test(S("abcde"), 2, 0, "1234567890", 0, S("abcde")); + test(S("abcde"), 2, 0, "1234567890", 1, S("ab1cde")); + test(S("abcde"), 2, 0, "1234567890", 5, S("ab12345cde")); + test(S("abcde"), 2, 0, "1234567890", 9, S("ab123456789cde")); + test(S("abcde"), 2, 0, "1234567890", 10, S("ab1234567890cde")); + test(S("abcde"), 2, 0, "12345678901234567890", 0, S("abcde")); + test(S("abcde"), 2, 0, "12345678901234567890", 1, S("ab1cde")); + test(S("abcde"), 2, 0, "12345678901234567890", 10, S("ab1234567890cde")); + test(S("abcde"), 2, 0, "12345678901234567890", 19, S("ab1234567890123456789cde")); + test(S("abcde"), 2, 0, "12345678901234567890", 20, S("ab12345678901234567890cde")); + test(S("abcde"), 2, 1, "", 0, S("abde")); + test(S("abcde"), 2, 1, "12345", 0, S("abde")); + test(S("abcde"), 2, 1, "12345", 1, S("ab1de")); + test(S("abcde"), 2, 1, "12345", 2, S("ab12de")); + test(S("abcde"), 2, 1, "12345", 4, S("ab1234de")); + test(S("abcde"), 2, 1, "12345", 5, S("ab12345de")); + test(S("abcde"), 2, 1, "1234567890", 0, S("abde")); + test(S("abcde"), 2, 1, "1234567890", 1, S("ab1de")); + test(S("abcde"), 2, 1, "1234567890", 5, S("ab12345de")); + test(S("abcde"), 2, 1, "1234567890", 9, S("ab123456789de")); + test(S("abcde"), 2, 1, "1234567890", 10, S("ab1234567890de")); + test(S("abcde"), 2, 1, "12345678901234567890", 0, S("abde")); + test(S("abcde"), 2, 1, "12345678901234567890", 1, S("ab1de")); + test(S("abcde"), 2, 1, "12345678901234567890", 10, S("ab1234567890de")); + test(S("abcde"), 2, 1, "12345678901234567890", 19, S("ab1234567890123456789de")); + test(S("abcde"), 2, 1, "12345678901234567890", 20, S("ab12345678901234567890de")); + test(S("abcde"), 2, 2, "", 0, S("abe")); + test(S("abcde"), 2, 2, "12345", 0, S("abe")); + test(S("abcde"), 2, 2, "12345", 1, S("ab1e")); + test(S("abcde"), 2, 2, "12345", 2, S("ab12e")); + test(S("abcde"), 2, 2, "12345", 4, S("ab1234e")); + test(S("abcde"), 2, 2, "12345", 5, S("ab12345e")); + test(S("abcde"), 2, 2, "1234567890", 0, S("abe")); + test(S("abcde"), 2, 2, "1234567890", 1, S("ab1e")); + test(S("abcde"), 2, 2, "1234567890", 5, S("ab12345e")); + test(S("abcde"), 2, 2, "1234567890", 9, S("ab123456789e")); + test(S("abcde"), 2, 2, "1234567890", 10, S("ab1234567890e")); + test(S("abcde"), 2, 2, "12345678901234567890", 0, S("abe")); + test(S("abcde"), 2, 2, "12345678901234567890", 1, S("ab1e")); + test(S("abcde"), 2, 2, "12345678901234567890", 10, S("ab1234567890e")); + test(S("abcde"), 2, 2, "12345678901234567890", 19, S("ab1234567890123456789e")); + test(S("abcde"), 2, 2, "12345678901234567890", 20, S("ab12345678901234567890e")); + test(S("abcde"), 2, 3, "", 0, S("ab")); + test(S("abcde"), 2, 3, "12345", 0, S("ab")); + test(S("abcde"), 2, 3, "12345", 1, S("ab1")); + test(S("abcde"), 2, 3, "12345", 2, S("ab12")); + test(S("abcde"), 2, 3, "12345", 4, S("ab1234")); + test(S("abcde"), 2, 3, "12345", 5, S("ab12345")); + test(S("abcde"), 2, 3, "1234567890", 0, S("ab")); + test(S("abcde"), 2, 3, "1234567890", 1, S("ab1")); + test(S("abcde"), 2, 3, "1234567890", 5, S("ab12345")); + test(S("abcde"), 2, 3, "1234567890", 9, S("ab123456789")); + test(S("abcde"), 2, 3, "1234567890", 10, S("ab1234567890")); + test(S("abcde"), 2, 3, "12345678901234567890", 0, S("ab")); +} + +template <class S> +void test3() +{ + test(S("abcde"), 2, 3, "12345678901234567890", 1, S("ab1")); + test(S("abcde"), 2, 3, "12345678901234567890", 10, S("ab1234567890")); + test(S("abcde"), 2, 3, "12345678901234567890", 19, S("ab1234567890123456789")); + test(S("abcde"), 2, 3, "12345678901234567890", 20, S("ab12345678901234567890")); + test(S("abcde"), 2, 4, "", 0, S("ab")); + test(S("abcde"), 2, 4, "12345", 0, S("ab")); + test(S("abcde"), 2, 4, "12345", 1, S("ab1")); + test(S("abcde"), 2, 4, "12345", 2, S("ab12")); + test(S("abcde"), 2, 4, "12345", 4, S("ab1234")); + test(S("abcde"), 2, 4, "12345", 5, S("ab12345")); + test(S("abcde"), 2, 4, "1234567890", 0, S("ab")); + test(S("abcde"), 2, 4, "1234567890", 1, S("ab1")); + test(S("abcde"), 2, 4, "1234567890", 5, S("ab12345")); + test(S("abcde"), 2, 4, "1234567890", 9, S("ab123456789")); + test(S("abcde"), 2, 4, "1234567890", 10, S("ab1234567890")); + test(S("abcde"), 2, 4, "12345678901234567890", 0, S("ab")); + test(S("abcde"), 2, 4, "12345678901234567890", 1, S("ab1")); + test(S("abcde"), 2, 4, "12345678901234567890", 10, S("ab1234567890")); + test(S("abcde"), 2, 4, "12345678901234567890", 19, S("ab1234567890123456789")); + test(S("abcde"), 2, 4, "12345678901234567890", 20, S("ab12345678901234567890")); + test(S("abcde"), 4, 0, "", 0, S("abcde")); + test(S("abcde"), 4, 0, "12345", 0, S("abcde")); + test(S("abcde"), 4, 0, "12345", 1, S("abcd1e")); + test(S("abcde"), 4, 0, "12345", 2, S("abcd12e")); + test(S("abcde"), 4, 0, "12345", 4, S("abcd1234e")); + test(S("abcde"), 4, 0, "12345", 5, S("abcd12345e")); + test(S("abcde"), 4, 0, "1234567890", 0, S("abcde")); + test(S("abcde"), 4, 0, "1234567890", 1, S("abcd1e")); + test(S("abcde"), 4, 0, "1234567890", 5, S("abcd12345e")); + test(S("abcde"), 4, 0, "1234567890", 9, S("abcd123456789e")); + test(S("abcde"), 4, 0, "1234567890", 10, S("abcd1234567890e")); + test(S("abcde"), 4, 0, "12345678901234567890", 0, S("abcde")); + test(S("abcde"), 4, 0, "12345678901234567890", 1, S("abcd1e")); + test(S("abcde"), 4, 0, "12345678901234567890", 10, S("abcd1234567890e")); + test(S("abcde"), 4, 0, "12345678901234567890", 19, S("abcd1234567890123456789e")); + test(S("abcde"), 4, 0, "12345678901234567890", 20, S("abcd12345678901234567890e")); + test(S("abcde"), 4, 1, "", 0, S("abcd")); + test(S("abcde"), 4, 1, "12345", 0, S("abcd")); + test(S("abcde"), 4, 1, "12345", 1, S("abcd1")); + test(S("abcde"), 4, 1, "12345", 2, S("abcd12")); + test(S("abcde"), 4, 1, "12345", 4, S("abcd1234")); + test(S("abcde"), 4, 1, "12345", 5, S("abcd12345")); + test(S("abcde"), 4, 1, "1234567890", 0, S("abcd")); + test(S("abcde"), 4, 1, "1234567890", 1, S("abcd1")); + test(S("abcde"), 4, 1, "1234567890", 5, S("abcd12345")); + test(S("abcde"), 4, 1, "1234567890", 9, S("abcd123456789")); + test(S("abcde"), 4, 1, "1234567890", 10, S("abcd1234567890")); + test(S("abcde"), 4, 1, "12345678901234567890", 0, S("abcd")); + test(S("abcde"), 4, 1, "12345678901234567890", 1, S("abcd1")); + test(S("abcde"), 4, 1, "12345678901234567890", 10, S("abcd1234567890")); + test(S("abcde"), 4, 1, "12345678901234567890", 19, S("abcd1234567890123456789")); + test(S("abcde"), 4, 1, "12345678901234567890", 20, S("abcd12345678901234567890")); + test(S("abcde"), 4, 2, "", 0, S("abcd")); + test(S("abcde"), 4, 2, "12345", 0, S("abcd")); + test(S("abcde"), 4, 2, "12345", 1, S("abcd1")); + test(S("abcde"), 4, 2, "12345", 2, S("abcd12")); + test(S("abcde"), 4, 2, "12345", 4, S("abcd1234")); + test(S("abcde"), 4, 2, "12345", 5, S("abcd12345")); + test(S("abcde"), 4, 2, "1234567890", 0, S("abcd")); + test(S("abcde"), 4, 2, "1234567890", 1, S("abcd1")); + test(S("abcde"), 4, 2, "1234567890", 5, S("abcd12345")); + test(S("abcde"), 4, 2, "1234567890", 9, S("abcd123456789")); + test(S("abcde"), 4, 2, "1234567890", 10, S("abcd1234567890")); + test(S("abcde"), 4, 2, "12345678901234567890", 0, S("abcd")); + test(S("abcde"), 4, 2, "12345678901234567890", 1, S("abcd1")); + test(S("abcde"), 4, 2, "12345678901234567890", 10, S("abcd1234567890")); + test(S("abcde"), 4, 2, "12345678901234567890", 19, S("abcd1234567890123456789")); + test(S("abcde"), 4, 2, "12345678901234567890", 20, S("abcd12345678901234567890")); + test(S("abcde"), 5, 0, "", 0, S("abcde")); + test(S("abcde"), 5, 0, "12345", 0, S("abcde")); + test(S("abcde"), 5, 0, "12345", 1, S("abcde1")); + test(S("abcde"), 5, 0, "12345", 2, S("abcde12")); + test(S("abcde"), 5, 0, "12345", 4, S("abcde1234")); + test(S("abcde"), 5, 0, "12345", 5, S("abcde12345")); + test(S("abcde"), 5, 0, "1234567890", 0, S("abcde")); + test(S("abcde"), 5, 0, "1234567890", 1, S("abcde1")); + test(S("abcde"), 5, 0, "1234567890", 5, S("abcde12345")); + test(S("abcde"), 5, 0, "1234567890", 9, S("abcde123456789")); + test(S("abcde"), 5, 0, "1234567890", 10, S("abcde1234567890")); + test(S("abcde"), 5, 0, "12345678901234567890", 0, S("abcde")); + test(S("abcde"), 5, 0, "12345678901234567890", 1, S("abcde1")); + test(S("abcde"), 5, 0, "12345678901234567890", 10, S("abcde1234567890")); + test(S("abcde"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789")); + test(S("abcde"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890")); + test(S("abcde"), 5, 1, "", 0, S("abcde")); + test(S("abcde"), 5, 1, "12345", 0, S("abcde")); + test(S("abcde"), 5, 1, "12345", 1, S("abcde1")); + test(S("abcde"), 5, 1, "12345", 2, S("abcde12")); + test(S("abcde"), 5, 1, "12345", 4, S("abcde1234")); + test(S("abcde"), 5, 1, "12345", 5, S("abcde12345")); + test(S("abcde"), 5, 1, "1234567890", 0, S("abcde")); + test(S("abcde"), 5, 1, "1234567890", 1, S("abcde1")); + test(S("abcde"), 5, 1, "1234567890", 5, S("abcde12345")); + test(S("abcde"), 5, 1, "1234567890", 9, S("abcde123456789")); + test(S("abcde"), 5, 1, "1234567890", 10, S("abcde1234567890")); + test(S("abcde"), 5, 1, "12345678901234567890", 0, S("abcde")); + test(S("abcde"), 5, 1, "12345678901234567890", 1, S("abcde1")); + test(S("abcde"), 5, 1, "12345678901234567890", 10, S("abcde1234567890")); + test(S("abcde"), 5, 1, "12345678901234567890", 19, S("abcde1234567890123456789")); + test(S("abcde"), 5, 1, "12345678901234567890", 20, S("abcde12345678901234567890")); +} + +template <class S> +void test4() +{ + test(S("abcde"), 6, 0, "", 0, S("can't happen")); + test(S("abcde"), 6, 0, "12345", 0, S("can't happen")); + test(S("abcde"), 6, 0, "12345", 1, S("can't happen")); + test(S("abcde"), 6, 0, "12345", 2, S("can't happen")); + test(S("abcde"), 6, 0, "12345", 4, S("can't happen")); + test(S("abcde"), 6, 0, "12345", 5, S("can't happen")); + test(S("abcde"), 6, 0, "1234567890", 0, S("can't happen")); + test(S("abcde"), 6, 0, "1234567890", 1, S("can't happen")); + test(S("abcde"), 6, 0, "1234567890", 5, S("can't happen")); + test(S("abcde"), 6, 0, "1234567890", 9, S("can't happen")); + test(S("abcde"), 6, 0, "1234567890", 10, S("can't happen")); + test(S("abcde"), 6, 0, "12345678901234567890", 0, S("can't happen")); + test(S("abcde"), 6, 0, "12345678901234567890", 1, S("can't happen")); + test(S("abcde"), 6, 0, "12345678901234567890", 10, S("can't happen")); + test(S("abcde"), 6, 0, "12345678901234567890", 19, S("can't happen")); + test(S("abcde"), 6, 0, "12345678901234567890", 20, S("can't happen")); + test(S("abcdefghij"), 0, 0, "", 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345", 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345", 1, S("1abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345", 2, S("12abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345", 4, S("1234abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345", 5, S("12345abcdefghij")); + test(S("abcdefghij"), 0, 0, "1234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, "1234567890", 1, S("1abcdefghij")); + test(S("abcdefghij"), 0, 0, "1234567890", 5, S("12345abcdefghij")); + test(S("abcdefghij"), 0, 0, "1234567890", 9, S("123456789abcdefghij")); + test(S("abcdefghij"), 0, 0, "1234567890", 10, S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345678901234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345678901234567890", 1, S("1abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij")); + test(S("abcdefghij"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij")); + test(S("abcdefghij"), 0, 1, "", 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345", 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345", 1, S("1bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345", 2, S("12bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345", 4, S("1234bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345", 5, S("12345bcdefghij")); + test(S("abcdefghij"), 0, 1, "1234567890", 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, "1234567890", 1, S("1bcdefghij")); + test(S("abcdefghij"), 0, 1, "1234567890", 5, S("12345bcdefghij")); + test(S("abcdefghij"), 0, 1, "1234567890", 9, S("123456789bcdefghij")); + test(S("abcdefghij"), 0, 1, "1234567890", 10, S("1234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345678901234567890", 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345678901234567890", 1, S("1bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghij")); + test(S("abcdefghij"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghij")); + test(S("abcdefghij"), 0, 5, "", 0, S("fghij")); + test(S("abcdefghij"), 0, 5, "12345", 0, S("fghij")); + test(S("abcdefghij"), 0, 5, "12345", 1, S("1fghij")); + test(S("abcdefghij"), 0, 5, "12345", 2, S("12fghij")); + test(S("abcdefghij"), 0, 5, "12345", 4, S("1234fghij")); + test(S("abcdefghij"), 0, 5, "12345", 5, S("12345fghij")); + test(S("abcdefghij"), 0, 5, "1234567890", 0, S("fghij")); + test(S("abcdefghij"), 0, 5, "1234567890", 1, S("1fghij")); + test(S("abcdefghij"), 0, 5, "1234567890", 5, S("12345fghij")); + test(S("abcdefghij"), 0, 5, "1234567890", 9, S("123456789fghij")); + test(S("abcdefghij"), 0, 5, "1234567890", 10, S("1234567890fghij")); + test(S("abcdefghij"), 0, 5, "12345678901234567890", 0, S("fghij")); + test(S("abcdefghij"), 0, 5, "12345678901234567890", 1, S("1fghij")); + test(S("abcdefghij"), 0, 5, "12345678901234567890", 10, S("1234567890fghij")); + test(S("abcdefghij"), 0, 5, "12345678901234567890", 19, S("1234567890123456789fghij")); + test(S("abcdefghij"), 0, 5, "12345678901234567890", 20, S("12345678901234567890fghij")); + test(S("abcdefghij"), 0, 9, "", 0, S("j")); + test(S("abcdefghij"), 0, 9, "12345", 0, S("j")); + test(S("abcdefghij"), 0, 9, "12345", 1, S("1j")); + test(S("abcdefghij"), 0, 9, "12345", 2, S("12j")); + test(S("abcdefghij"), 0, 9, "12345", 4, S("1234j")); + test(S("abcdefghij"), 0, 9, "12345", 5, S("12345j")); + test(S("abcdefghij"), 0, 9, "1234567890", 0, S("j")); + test(S("abcdefghij"), 0, 9, "1234567890", 1, S("1j")); + test(S("abcdefghij"), 0, 9, "1234567890", 5, S("12345j")); + test(S("abcdefghij"), 0, 9, "1234567890", 9, S("123456789j")); + test(S("abcdefghij"), 0, 9, "1234567890", 10, S("1234567890j")); + test(S("abcdefghij"), 0, 9, "12345678901234567890", 0, S("j")); + test(S("abcdefghij"), 0, 9, "12345678901234567890", 1, S("1j")); + test(S("abcdefghij"), 0, 9, "12345678901234567890", 10, S("1234567890j")); + test(S("abcdefghij"), 0, 9, "12345678901234567890", 19, S("1234567890123456789j")); + test(S("abcdefghij"), 0, 9, "12345678901234567890", 20, S("12345678901234567890j")); + test(S("abcdefghij"), 0, 10, "", 0, S("")); + test(S("abcdefghij"), 0, 10, "12345", 0, S("")); + test(S("abcdefghij"), 0, 10, "12345", 1, S("1")); + test(S("abcdefghij"), 0, 10, "12345", 2, S("12")); + test(S("abcdefghij"), 0, 10, "12345", 4, S("1234")); + test(S("abcdefghij"), 0, 10, "12345", 5, S("12345")); + test(S("abcdefghij"), 0, 10, "1234567890", 0, S("")); + test(S("abcdefghij"), 0, 10, "1234567890", 1, S("1")); + test(S("abcdefghij"), 0, 10, "1234567890", 5, S("12345")); + test(S("abcdefghij"), 0, 10, "1234567890", 9, S("123456789")); + test(S("abcdefghij"), 0, 10, "1234567890", 10, S("1234567890")); + test(S("abcdefghij"), 0, 10, "12345678901234567890", 0, S("")); + test(S("abcdefghij"), 0, 10, "12345678901234567890", 1, S("1")); + test(S("abcdefghij"), 0, 10, "12345678901234567890", 10, S("1234567890")); + test(S("abcdefghij"), 0, 10, "12345678901234567890", 19, S("1234567890123456789")); + test(S("abcdefghij"), 0, 10, "12345678901234567890", 20, S("12345678901234567890")); + test(S("abcdefghij"), 0, 11, "", 0, S("")); + test(S("abcdefghij"), 0, 11, "12345", 0, S("")); + test(S("abcdefghij"), 0, 11, "12345", 1, S("1")); + test(S("abcdefghij"), 0, 11, "12345", 2, S("12")); +} + +template <class S> +void test5() +{ + test(S("abcdefghij"), 0, 11, "12345", 4, S("1234")); + test(S("abcdefghij"), 0, 11, "12345", 5, S("12345")); + test(S("abcdefghij"), 0, 11, "1234567890", 0, S("")); + test(S("abcdefghij"), 0, 11, "1234567890", 1, S("1")); + test(S("abcdefghij"), 0, 11, "1234567890", 5, S("12345")); + test(S("abcdefghij"), 0, 11, "1234567890", 9, S("123456789")); + test(S("abcdefghij"), 0, 11, "1234567890", 10, S("1234567890")); + test(S("abcdefghij"), 0, 11, "12345678901234567890", 0, S("")); + test(S("abcdefghij"), 0, 11, "12345678901234567890", 1, S("1")); + test(S("abcdefghij"), 0, 11, "12345678901234567890", 10, S("1234567890")); + test(S("abcdefghij"), 0, 11, "12345678901234567890", 19, S("1234567890123456789")); + test(S("abcdefghij"), 0, 11, "12345678901234567890", 20, S("12345678901234567890")); + test(S("abcdefghij"), 1, 0, "", 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, "12345", 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, "12345", 1, S("a1bcdefghij")); + test(S("abcdefghij"), 1, 0, "12345", 2, S("a12bcdefghij")); + test(S("abcdefghij"), 1, 0, "12345", 4, S("a1234bcdefghij")); + test(S("abcdefghij"), 1, 0, "12345", 5, S("a12345bcdefghij")); + test(S("abcdefghij"), 1, 0, "1234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, "1234567890", 1, S("a1bcdefghij")); + test(S("abcdefghij"), 1, 0, "1234567890", 5, S("a12345bcdefghij")); + test(S("abcdefghij"), 1, 0, "1234567890", 9, S("a123456789bcdefghij")); + test(S("abcdefghij"), 1, 0, "1234567890", 10, S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, "12345678901234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, "12345678901234567890", 1, S("a1bcdefghij")); + test(S("abcdefghij"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghij")); + test(S("abcdefghij"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghij")); + test(S("abcdefghij"), 1, 1, "", 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, "12345", 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, "12345", 1, S("a1cdefghij")); + test(S("abcdefghij"), 1, 1, "12345", 2, S("a12cdefghij")); + test(S("abcdefghij"), 1, 1, "12345", 4, S("a1234cdefghij")); + test(S("abcdefghij"), 1, 1, "12345", 5, S("a12345cdefghij")); + test(S("abcdefghij"), 1, 1, "1234567890", 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, "1234567890", 1, S("a1cdefghij")); + test(S("abcdefghij"), 1, 1, "1234567890", 5, S("a12345cdefghij")); + test(S("abcdefghij"), 1, 1, "1234567890", 9, S("a123456789cdefghij")); + test(S("abcdefghij"), 1, 1, "1234567890", 10, S("a1234567890cdefghij")); + test(S("abcdefghij"), 1, 1, "12345678901234567890", 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, "12345678901234567890", 1, S("a1cdefghij")); + test(S("abcdefghij"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghij")); + test(S("abcdefghij"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghij")); + test(S("abcdefghij"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghij")); + test(S("abcdefghij"), 1, 4, "", 0, S("afghij")); + test(S("abcdefghij"), 1, 4, "12345", 0, S("afghij")); + test(S("abcdefghij"), 1, 4, "12345", 1, S("a1fghij")); + test(S("abcdefghij"), 1, 4, "12345", 2, S("a12fghij")); + test(S("abcdefghij"), 1, 4, "12345", 4, S("a1234fghij")); + test(S("abcdefghij"), 1, 4, "12345", 5, S("a12345fghij")); + test(S("abcdefghij"), 1, 4, "1234567890", 0, S("afghij")); + test(S("abcdefghij"), 1, 4, "1234567890", 1, S("a1fghij")); + test(S("abcdefghij"), 1, 4, "1234567890", 5, S("a12345fghij")); + test(S("abcdefghij"), 1, 4, "1234567890", 9, S("a123456789fghij")); + test(S("abcdefghij"), 1, 4, "1234567890", 10, S("a1234567890fghij")); + test(S("abcdefghij"), 1, 4, "12345678901234567890", 0, S("afghij")); + test(S("abcdefghij"), 1, 4, "12345678901234567890", 1, S("a1fghij")); + test(S("abcdefghij"), 1, 4, "12345678901234567890", 10, S("a1234567890fghij")); + test(S("abcdefghij"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789fghij")); + test(S("abcdefghij"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890fghij")); + test(S("abcdefghij"), 1, 8, "", 0, S("aj")); + test(S("abcdefghij"), 1, 8, "12345", 0, S("aj")); + test(S("abcdefghij"), 1, 8, "12345", 1, S("a1j")); + test(S("abcdefghij"), 1, 8, "12345", 2, S("a12j")); + test(S("abcdefghij"), 1, 8, "12345", 4, S("a1234j")); + test(S("abcdefghij"), 1, 8, "12345", 5, S("a12345j")); + test(S("abcdefghij"), 1, 8, "1234567890", 0, S("aj")); + test(S("abcdefghij"), 1, 8, "1234567890", 1, S("a1j")); + test(S("abcdefghij"), 1, 8, "1234567890", 5, S("a12345j")); + test(S("abcdefghij"), 1, 8, "1234567890", 9, S("a123456789j")); + test(S("abcdefghij"), 1, 8, "1234567890", 10, S("a1234567890j")); + test(S("abcdefghij"), 1, 8, "12345678901234567890", 0, S("aj")); + test(S("abcdefghij"), 1, 8, "12345678901234567890", 1, S("a1j")); + test(S("abcdefghij"), 1, 8, "12345678901234567890", 10, S("a1234567890j")); + test(S("abcdefghij"), 1, 8, "12345678901234567890", 19, S("a1234567890123456789j")); + test(S("abcdefghij"), 1, 8, "12345678901234567890", 20, S("a12345678901234567890j")); + test(S("abcdefghij"), 1, 9, "", 0, S("a")); + test(S("abcdefghij"), 1, 9, "12345", 0, S("a")); + test(S("abcdefghij"), 1, 9, "12345", 1, S("a1")); + test(S("abcdefghij"), 1, 9, "12345", 2, S("a12")); + test(S("abcdefghij"), 1, 9, "12345", 4, S("a1234")); + test(S("abcdefghij"), 1, 9, "12345", 5, S("a12345")); + test(S("abcdefghij"), 1, 9, "1234567890", 0, S("a")); + test(S("abcdefghij"), 1, 9, "1234567890", 1, S("a1")); + test(S("abcdefghij"), 1, 9, "1234567890", 5, S("a12345")); + test(S("abcdefghij"), 1, 9, "1234567890", 9, S("a123456789")); + test(S("abcdefghij"), 1, 9, "1234567890", 10, S("a1234567890")); + test(S("abcdefghij"), 1, 9, "12345678901234567890", 0, S("a")); + test(S("abcdefghij"), 1, 9, "12345678901234567890", 1, S("a1")); + test(S("abcdefghij"), 1, 9, "12345678901234567890", 10, S("a1234567890")); + test(S("abcdefghij"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789")); + test(S("abcdefghij"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890")); + test(S("abcdefghij"), 1, 10, "", 0, S("a")); + test(S("abcdefghij"), 1, 10, "12345", 0, S("a")); + test(S("abcdefghij"), 1, 10, "12345", 1, S("a1")); + test(S("abcdefghij"), 1, 10, "12345", 2, S("a12")); + test(S("abcdefghij"), 1, 10, "12345", 4, S("a1234")); + test(S("abcdefghij"), 1, 10, "12345", 5, S("a12345")); + test(S("abcdefghij"), 1, 10, "1234567890", 0, S("a")); + test(S("abcdefghij"), 1, 10, "1234567890", 1, S("a1")); +} + +template <class S> +void test6() +{ + test(S("abcdefghij"), 1, 10, "1234567890", 5, S("a12345")); + test(S("abcdefghij"), 1, 10, "1234567890", 9, S("a123456789")); + test(S("abcdefghij"), 1, 10, "1234567890", 10, S("a1234567890")); + test(S("abcdefghij"), 1, 10, "12345678901234567890", 0, S("a")); + test(S("abcdefghij"), 1, 10, "12345678901234567890", 1, S("a1")); + test(S("abcdefghij"), 1, 10, "12345678901234567890", 10, S("a1234567890")); + test(S("abcdefghij"), 1, 10, "12345678901234567890", 19, S("a1234567890123456789")); + test(S("abcdefghij"), 1, 10, "12345678901234567890", 20, S("a12345678901234567890")); + test(S("abcdefghij"), 5, 0, "", 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, "12345", 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, "12345", 1, S("abcde1fghij")); + test(S("abcdefghij"), 5, 0, "12345", 2, S("abcde12fghij")); + test(S("abcdefghij"), 5, 0, "12345", 4, S("abcde1234fghij")); + test(S("abcdefghij"), 5, 0, "12345", 5, S("abcde12345fghij")); + test(S("abcdefghij"), 5, 0, "1234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, "1234567890", 1, S("abcde1fghij")); + test(S("abcdefghij"), 5, 0, "1234567890", 5, S("abcde12345fghij")); + test(S("abcdefghij"), 5, 0, "1234567890", 9, S("abcde123456789fghij")); + test(S("abcdefghij"), 5, 0, "1234567890", 10, S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, 0, "12345678901234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, "12345678901234567890", 1, S("abcde1fghij")); + test(S("abcdefghij"), 5, 0, "12345678901234567890", 10, S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789fghij")); + test(S("abcdefghij"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890fghij")); + test(S("abcdefghij"), 5, 1, "", 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, "12345", 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, "12345", 1, S("abcde1ghij")); + test(S("abcdefghij"), 5, 1, "12345", 2, S("abcde12ghij")); + test(S("abcdefghij"), 5, 1, "12345", 4, S("abcde1234ghij")); + test(S("abcdefghij"), 5, 1, "12345", 5, S("abcde12345ghij")); + test(S("abcdefghij"), 5, 1, "1234567890", 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, "1234567890", 1, S("abcde1ghij")); + test(S("abcdefghij"), 5, 1, "1234567890", 5, S("abcde12345ghij")); + test(S("abcdefghij"), 5, 1, "1234567890", 9, S("abcde123456789ghij")); + test(S("abcdefghij"), 5, 1, "1234567890", 10, S("abcde1234567890ghij")); + test(S("abcdefghij"), 5, 1, "12345678901234567890", 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, "12345678901234567890", 1, S("abcde1ghij")); + test(S("abcdefghij"), 5, 1, "12345678901234567890", 10, S("abcde1234567890ghij")); + test(S("abcdefghij"), 5, 1, "12345678901234567890", 19, S("abcde1234567890123456789ghij")); + test(S("abcdefghij"), 5, 1, "12345678901234567890", 20, S("abcde12345678901234567890ghij")); + test(S("abcdefghij"), 5, 2, "", 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, "12345", 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, "12345", 1, S("abcde1hij")); + test(S("abcdefghij"), 5, 2, "12345", 2, S("abcde12hij")); + test(S("abcdefghij"), 5, 2, "12345", 4, S("abcde1234hij")); + test(S("abcdefghij"), 5, 2, "12345", 5, S("abcde12345hij")); + test(S("abcdefghij"), 5, 2, "1234567890", 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, "1234567890", 1, S("abcde1hij")); + test(S("abcdefghij"), 5, 2, "1234567890", 5, S("abcde12345hij")); + test(S("abcdefghij"), 5, 2, "1234567890", 9, S("abcde123456789hij")); + test(S("abcdefghij"), 5, 2, "1234567890", 10, S("abcde1234567890hij")); + test(S("abcdefghij"), 5, 2, "12345678901234567890", 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, "12345678901234567890", 1, S("abcde1hij")); + test(S("abcdefghij"), 5, 2, "12345678901234567890", 10, S("abcde1234567890hij")); + test(S("abcdefghij"), 5, 2, "12345678901234567890", 19, S("abcde1234567890123456789hij")); + test(S("abcdefghij"), 5, 2, "12345678901234567890", 20, S("abcde12345678901234567890hij")); + test(S("abcdefghij"), 5, 4, "", 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, "12345", 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, "12345", 1, S("abcde1j")); + test(S("abcdefghij"), 5, 4, "12345", 2, S("abcde12j")); + test(S("abcdefghij"), 5, 4, "12345", 4, S("abcde1234j")); + test(S("abcdefghij"), 5, 4, "12345", 5, S("abcde12345j")); + test(S("abcdefghij"), 5, 4, "1234567890", 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, "1234567890", 1, S("abcde1j")); + test(S("abcdefghij"), 5, 4, "1234567890", 5, S("abcde12345j")); + test(S("abcdefghij"), 5, 4, "1234567890", 9, S("abcde123456789j")); + test(S("abcdefghij"), 5, 4, "1234567890", 10, S("abcde1234567890j")); + test(S("abcdefghij"), 5, 4, "12345678901234567890", 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, "12345678901234567890", 1, S("abcde1j")); + test(S("abcdefghij"), 5, 4, "12345678901234567890", 10, S("abcde1234567890j")); + test(S("abcdefghij"), 5, 4, "12345678901234567890", 19, S("abcde1234567890123456789j")); + test(S("abcdefghij"), 5, 4, "12345678901234567890", 20, S("abcde12345678901234567890j")); + test(S("abcdefghij"), 5, 5, "", 0, S("abcde")); + test(S("abcdefghij"), 5, 5, "12345", 0, S("abcde")); + test(S("abcdefghij"), 5, 5, "12345", 1, S("abcde1")); + test(S("abcdefghij"), 5, 5, "12345", 2, S("abcde12")); + test(S("abcdefghij"), 5, 5, "12345", 4, S("abcde1234")); + test(S("abcdefghij"), 5, 5, "12345", 5, S("abcde12345")); + test(S("abcdefghij"), 5, 5, "1234567890", 0, S("abcde")); + test(S("abcdefghij"), 5, 5, "1234567890", 1, S("abcde1")); + test(S("abcdefghij"), 5, 5, "1234567890", 5, S("abcde12345")); + test(S("abcdefghij"), 5, 5, "1234567890", 9, S("abcde123456789")); + test(S("abcdefghij"), 5, 5, "1234567890", 10, S("abcde1234567890")); + test(S("abcdefghij"), 5, 5, "12345678901234567890", 0, S("abcde")); + test(S("abcdefghij"), 5, 5, "12345678901234567890", 1, S("abcde1")); + test(S("abcdefghij"), 5, 5, "12345678901234567890", 10, S("abcde1234567890")); + test(S("abcdefghij"), 5, 5, "12345678901234567890", 19, S("abcde1234567890123456789")); + test(S("abcdefghij"), 5, 5, "12345678901234567890", 20, S("abcde12345678901234567890")); + test(S("abcdefghij"), 5, 6, "", 0, S("abcde")); + test(S("abcdefghij"), 5, 6, "12345", 0, S("abcde")); + test(S("abcdefghij"), 5, 6, "12345", 1, S("abcde1")); + test(S("abcdefghij"), 5, 6, "12345", 2, S("abcde12")); + test(S("abcdefghij"), 5, 6, "12345", 4, S("abcde1234")); + test(S("abcdefghij"), 5, 6, "12345", 5, S("abcde12345")); + test(S("abcdefghij"), 5, 6, "1234567890", 0, S("abcde")); + test(S("abcdefghij"), 5, 6, "1234567890", 1, S("abcde1")); + test(S("abcdefghij"), 5, 6, "1234567890", 5, S("abcde12345")); + test(S("abcdefghij"), 5, 6, "1234567890", 9, S("abcde123456789")); + test(S("abcdefghij"), 5, 6, "1234567890", 10, S("abcde1234567890")); + test(S("abcdefghij"), 5, 6, "12345678901234567890", 0, S("abcde")); +} + +template <class S> +void test7() +{ + test(S("abcdefghij"), 5, 6, "12345678901234567890", 1, S("abcde1")); + test(S("abcdefghij"), 5, 6, "12345678901234567890", 10, S("abcde1234567890")); + test(S("abcdefghij"), 5, 6, "12345678901234567890", 19, S("abcde1234567890123456789")); + test(S("abcdefghij"), 5, 6, "12345678901234567890", 20, S("abcde12345678901234567890")); + test(S("abcdefghij"), 9, 0, "", 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, "12345", 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, "12345", 1, S("abcdefghi1j")); + test(S("abcdefghij"), 9, 0, "12345", 2, S("abcdefghi12j")); + test(S("abcdefghij"), 9, 0, "12345", 4, S("abcdefghi1234j")); + test(S("abcdefghij"), 9, 0, "12345", 5, S("abcdefghi12345j")); + test(S("abcdefghij"), 9, 0, "1234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, "1234567890", 1, S("abcdefghi1j")); + test(S("abcdefghij"), 9, 0, "1234567890", 5, S("abcdefghi12345j")); + test(S("abcdefghij"), 9, 0, "1234567890", 9, S("abcdefghi123456789j")); + test(S("abcdefghij"), 9, 0, "1234567890", 10, S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, 0, "12345678901234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, "12345678901234567890", 1, S("abcdefghi1j")); + test(S("abcdefghij"), 9, 0, "12345678901234567890", 10, S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, 0, "12345678901234567890", 19, S("abcdefghi1234567890123456789j")); + test(S("abcdefghij"), 9, 0, "12345678901234567890", 20, S("abcdefghi12345678901234567890j")); + test(S("abcdefghij"), 9, 1, "", 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, "12345", 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, "12345", 1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 1, "12345", 2, S("abcdefghi12")); + test(S("abcdefghij"), 9, 1, "12345", 4, S("abcdefghi1234")); + test(S("abcdefghij"), 9, 1, "12345", 5, S("abcdefghi12345")); + test(S("abcdefghij"), 9, 1, "1234567890", 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, "1234567890", 1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 1, "1234567890", 5, S("abcdefghi12345")); + test(S("abcdefghij"), 9, 1, "1234567890", 9, S("abcdefghi123456789")); + test(S("abcdefghij"), 9, 1, "1234567890", 10, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 1, "12345678901234567890", 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, "12345678901234567890", 1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 1, "12345678901234567890", 10, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 1, "12345678901234567890", 19, S("abcdefghi1234567890123456789")); + test(S("abcdefghij"), 9, 1, "12345678901234567890", 20, S("abcdefghi12345678901234567890")); + test(S("abcdefghij"), 9, 2, "", 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, "12345", 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, "12345", 1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 2, "12345", 2, S("abcdefghi12")); + test(S("abcdefghij"), 9, 2, "12345", 4, S("abcdefghi1234")); + test(S("abcdefghij"), 9, 2, "12345", 5, S("abcdefghi12345")); + test(S("abcdefghij"), 9, 2, "1234567890", 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, "1234567890", 1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 2, "1234567890", 5, S("abcdefghi12345")); + test(S("abcdefghij"), 9, 2, "1234567890", 9, S("abcdefghi123456789")); + test(S("abcdefghij"), 9, 2, "1234567890", 10, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 2, "12345678901234567890", 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, "12345678901234567890", 1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 2, "12345678901234567890", 10, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 2, "12345678901234567890", 19, S("abcdefghi1234567890123456789")); + test(S("abcdefghij"), 9, 2, "12345678901234567890", 20, S("abcdefghi12345678901234567890")); + test(S("abcdefghij"), 10, 0, "", 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, "12345", 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, "12345", 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 0, "12345", 2, S("abcdefghij12")); + test(S("abcdefghij"), 10, 0, "12345", 4, S("abcdefghij1234")); + test(S("abcdefghij"), 10, 0, "12345", 5, S("abcdefghij12345")); + test(S("abcdefghij"), 10, 0, "1234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, "1234567890", 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 0, "1234567890", 5, S("abcdefghij12345")); + test(S("abcdefghij"), 10, 0, "1234567890", 9, S("abcdefghij123456789")); + test(S("abcdefghij"), 10, 0, "1234567890", 10, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 0, "12345678901234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, "12345678901234567890", 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789")); + test(S("abcdefghij"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890")); + test(S("abcdefghij"), 10, 1, "", 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, "12345", 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, "12345", 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 1, "12345", 2, S("abcdefghij12")); + test(S("abcdefghij"), 10, 1, "12345", 4, S("abcdefghij1234")); + test(S("abcdefghij"), 10, 1, "12345", 5, S("abcdefghij12345")); + test(S("abcdefghij"), 10, 1, "1234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, "1234567890", 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 1, "1234567890", 5, S("abcdefghij12345")); + test(S("abcdefghij"), 10, 1, "1234567890", 9, S("abcdefghij123456789")); + test(S("abcdefghij"), 10, 1, "1234567890", 10, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 1, "12345678901234567890", 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, "12345678901234567890", 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 1, "12345678901234567890", 10, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 1, "12345678901234567890", 19, S("abcdefghij1234567890123456789")); + test(S("abcdefghij"), 10, 1, "12345678901234567890", 20, S("abcdefghij12345678901234567890")); + test(S("abcdefghij"), 11, 0, "", 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, "12345", 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, "12345", 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, "12345", 2, S("can't happen")); + test(S("abcdefghij"), 11, 0, "12345", 4, S("can't happen")); + test(S("abcdefghij"), 11, 0, "12345", 5, S("can't happen")); + test(S("abcdefghij"), 11, 0, "1234567890", 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, "1234567890", 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, "1234567890", 5, S("can't happen")); + test(S("abcdefghij"), 11, 0, "1234567890", 9, S("can't happen")); + test(S("abcdefghij"), 11, 0, "1234567890", 10, S("can't happen")); + test(S("abcdefghij"), 11, 0, "12345678901234567890", 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, "12345678901234567890", 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, "12345678901234567890", 10, S("can't happen")); + test(S("abcdefghij"), 11, 0, "12345678901234567890", 19, S("can't happen")); + test(S("abcdefghij"), 11, 0, "12345678901234567890", 20, S("can't happen")); +} + +template <class S> +void test8() +{ + test(S("abcdefghijklmnopqrst"), 0, 0, "", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 1, S("1abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 2, S("12abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 4, S("1234abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 5, S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 1, S("1abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 5, S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "", 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 1, S("1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 2, S("12bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 4, S("1234bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 5, S("12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 1, S("1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 5, S("12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 9, S("123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 10, S("1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 1, S("1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "", 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 1, S("1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 2, S("12klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 4, S("1234klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 5, S("12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 1, S("1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 5, S("12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 9, S("123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 10, S("1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 1, S("1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 10, S("1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 19, S("1234567890123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 20, S("12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 19, "", 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 1, S("1t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 2, S("12t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 4, S("1234t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 5, S("12345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 1, S("1t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 5, S("12345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 9, S("123456789t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 10, S("1234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 1, S("1t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 10, S("1234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 19, S("1234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 20, S("12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 20, "", 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 2, S("12")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 4, S("1234")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 5, S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 5, S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 9, S("123456789")); + test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 10, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 10, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 19, S("1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 20, S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, "", 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 2, S("12")); + test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 4, S("1234")); + test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 5, S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 5, S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 9, S("123456789")); + test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 10, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 10, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 19, S("1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 20, S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 0, "", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 1, S("a1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 2, S("a12bcdefghijklmnopqrst")); +} + +template <class S> +void test9() +{ + test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 4, S("a1234bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 5, S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 1, S("a1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 5, S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 9, S("a123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "", 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 1, S("a1cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 2, S("a12cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 4, S("a1234cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 5, S("a12345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 1, S("a1cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 5, S("a12345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 9, S("a123456789cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 10, S("a1234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 1, S("a1cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "", 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 1, S("a1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 2, S("a12klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 4, S("a1234klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 5, S("a12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 1, S("a1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 5, S("a12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 9, S("a123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 10, S("a1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 1, S("a1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 10, S("a1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 18, "", 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 1, S("a1t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 2, S("a12t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 4, S("a1234t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 5, S("a12345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 1, S("a1t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 5, S("a12345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 9, S("a123456789t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 10, S("a1234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 1, S("a1t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 10, S("a1234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 19, S("a1234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 20, S("a12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 19, "", 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 2, S("a12")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 4, S("a1234")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 5, S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 5, S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 9, S("a123456789")); + test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 10, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 10, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 19, S("a1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 20, S("a12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, "", 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 2, S("a12")); + test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 4, S("a1234")); + test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 5, S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 5, S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 9, S("a123456789")); + test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 10, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 10, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 19, S("a1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 20, S("a12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 0, "", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 1, S("abcdefghij1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 2, S("abcdefghij12klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 4, S("abcdefghij1234klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 5, S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 1, S("abcdefghij1klmnopqrst")); +} + +template <class S> +void test10() +{ + test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 5, S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 9, S("abcdefghij123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 10, S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 1, S("abcdefghij1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "", 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 1, S("abcdefghij1lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 2, S("abcdefghij12lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 4, S("abcdefghij1234lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 5, S("abcdefghij12345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 1, S("abcdefghij1lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 5, S("abcdefghij12345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 9, S("abcdefghij123456789lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 10, S("abcdefghij1234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 1, S("abcdefghij1lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 10, S("abcdefghij1234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 19, S("abcdefghij1234567890123456789lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 20, S("abcdefghij12345678901234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "", 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 1, S("abcdefghij1pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 2, S("abcdefghij12pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 4, S("abcdefghij1234pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 5, S("abcdefghij12345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 1, S("abcdefghij1pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 5, S("abcdefghij12345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 9, S("abcdefghij123456789pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 10, S("abcdefghij1234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 1, S("abcdefghij1pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 10, S("abcdefghij1234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 19, S("abcdefghij1234567890123456789pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 20, S("abcdefghij12345678901234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 9, "", 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 1, S("abcdefghij1t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 2, S("abcdefghij12t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 4, S("abcdefghij1234t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 5, S("abcdefghij12345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 1, S("abcdefghij1t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 5, S("abcdefghij12345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 9, S("abcdefghij123456789t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 10, S("abcdefghij1234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 1, S("abcdefghij1t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 10, S("abcdefghij1234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 19, S("abcdefghij1234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 20, S("abcdefghij12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 10, "", 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 2, S("abcdefghij12")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 4, S("abcdefghij1234")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 5, S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 5, S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 9, S("abcdefghij123456789")); + test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 10, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 10, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, "", 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 2, S("abcdefghij12")); + test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 4, S("abcdefghij1234")); + test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 5, S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 5, S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 9, S("abcdefghij123456789")); + test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 10, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 10, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 19, S("abcdefghij1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 20, S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 0, "", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 1, S("abcdefghijklmnopqrs1t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 2, S("abcdefghijklmnopqrs12t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 4, S("abcdefghijklmnopqrs1234t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 5, S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 1, S("abcdefghijklmnopqrs1t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 5, S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 9, S("abcdefghijklmnopqrs123456789t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); +} + +template <class S> +void test11() +{ + test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 1, "", 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 2, S("abcdefghijklmnopqrs12")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 4, S("abcdefghijklmnopqrs1234")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 5, S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 5, S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 9, S("abcdefghijklmnopqrs123456789")); + test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 10, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, "", 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 2, S("abcdefghijklmnopqrs12")); + test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 4, S("abcdefghijklmnopqrs1234")); + test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 5, S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 5, S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 9, S("abcdefghijklmnopqrs123456789")); + test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 10, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, "", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 2, S("abcdefghijklmnopqrst12")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 4, S("abcdefghijklmnopqrst1234")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 5, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 5, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 9, S("abcdefghijklmnopqrst123456789")); + test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 10, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, "", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 2, S("abcdefghijklmnopqrst12")); + test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 4, S("abcdefghijklmnopqrst1234")); + test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 5, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 5, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 9, S("abcdefghijklmnopqrst123456789")); + test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 10, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 21, 0, "", 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 2, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 4, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 5, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 5, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 9, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 10, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 10, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 19, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 20, S("can't happen")); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + test4<S>(); + test5<S>(); + test6<S>(); + test7<S>(); + test8<S>(); + test9<S>(); + test10<S>(); + test11<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + test4<S>(); + test5<S>(); + test6<S>(); + test7<S>(); + test8<S>(); + test9<S>(); + test10<S>(); + test11<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp new file mode 100644 index 000000000000..33f57fd3b86c --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp @@ -0,0 +1,374 @@ +//===----------------------------------------------------------------------===// +// +// 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>& +// replace(size_type pos, size_type n1, size_type n2, charT c); + +#include <string> +#include <stdexcept> +#include <algorithm> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s, typename S::size_type pos, typename S::size_type n1, + typename S::size_type n2, typename S::value_type c, + S expected) +{ + typename S::size_type old_size = s.size(); + S s0 = s; + try + { + s.replace(pos, n1, n2, c); + assert(s.__invariants()); + assert(pos <= old_size); + assert(s == expected); + typename S::size_type xlen = std::min(n1, old_size - pos); + typename S::size_type rlen = n2; + assert(s.size() == old_size - xlen + rlen); + } + catch (std::out_of_range&) + { + assert(pos > old_size); + assert(s == s0); + } +} + +template <class S> +void test0() +{ + test(S(""), 0, 0, 0, '2', S("")); + test(S(""), 0, 0, 5, '2', S("22222")); + test(S(""), 0, 0, 10, '2', S("2222222222")); + test(S(""), 0, 0, 20, '2', S("22222222222222222222")); + test(S(""), 0, 1, 0, '2', S("")); + test(S(""), 0, 1, 5, '2', S("22222")); + test(S(""), 0, 1, 10, '2', S("2222222222")); + test(S(""), 0, 1, 20, '2', S("22222222222222222222")); + test(S(""), 1, 0, 0, '2', S("can't happen")); + test(S(""), 1, 0, 5, '2', S("can't happen")); + test(S(""), 1, 0, 10, '2', S("can't happen")); + test(S(""), 1, 0, 20, '2', S("can't happen")); + test(S("abcde"), 0, 0, 0, '2', S("abcde")); + test(S("abcde"), 0, 0, 5, '2', S("22222abcde")); + test(S("abcde"), 0, 0, 10, '2', S("2222222222abcde")); + test(S("abcde"), 0, 0, 20, '2', S("22222222222222222222abcde")); + test(S("abcde"), 0, 1, 0, '2', S("bcde")); + test(S("abcde"), 0, 1, 5, '2', S("22222bcde")); + test(S("abcde"), 0, 1, 10, '2', S("2222222222bcde")); + test(S("abcde"), 0, 1, 20, '2', S("22222222222222222222bcde")); + test(S("abcde"), 0, 2, 0, '2', S("cde")); + test(S("abcde"), 0, 2, 5, '2', S("22222cde")); + test(S("abcde"), 0, 2, 10, '2', S("2222222222cde")); + test(S("abcde"), 0, 2, 20, '2', S("22222222222222222222cde")); + test(S("abcde"), 0, 4, 0, '2', S("e")); + test(S("abcde"), 0, 4, 5, '2', S("22222e")); + test(S("abcde"), 0, 4, 10, '2', S("2222222222e")); + test(S("abcde"), 0, 4, 20, '2', S("22222222222222222222e")); + test(S("abcde"), 0, 5, 0, '2', S("")); + test(S("abcde"), 0, 5, 5, '2', S("22222")); + test(S("abcde"), 0, 5, 10, '2', S("2222222222")); + test(S("abcde"), 0, 5, 20, '2', S("22222222222222222222")); + test(S("abcde"), 0, 6, 0, '2', S("")); + test(S("abcde"), 0, 6, 5, '2', S("22222")); + test(S("abcde"), 0, 6, 10, '2', S("2222222222")); + test(S("abcde"), 0, 6, 20, '2', S("22222222222222222222")); + test(S("abcde"), 1, 0, 0, '2', S("abcde")); + test(S("abcde"), 1, 0, 5, '2', S("a22222bcde")); + test(S("abcde"), 1, 0, 10, '2', S("a2222222222bcde")); + test(S("abcde"), 1, 0, 20, '2', S("a22222222222222222222bcde")); + test(S("abcde"), 1, 1, 0, '2', S("acde")); + test(S("abcde"), 1, 1, 5, '2', S("a22222cde")); + test(S("abcde"), 1, 1, 10, '2', S("a2222222222cde")); + test(S("abcde"), 1, 1, 20, '2', S("a22222222222222222222cde")); + test(S("abcde"), 1, 2, 0, '2', S("ade")); + test(S("abcde"), 1, 2, 5, '2', S("a22222de")); + test(S("abcde"), 1, 2, 10, '2', S("a2222222222de")); + test(S("abcde"), 1, 2, 20, '2', S("a22222222222222222222de")); + test(S("abcde"), 1, 3, 0, '2', S("ae")); + test(S("abcde"), 1, 3, 5, '2', S("a22222e")); + test(S("abcde"), 1, 3, 10, '2', S("a2222222222e")); + test(S("abcde"), 1, 3, 20, '2', S("a22222222222222222222e")); + test(S("abcde"), 1, 4, 0, '2', S("a")); + test(S("abcde"), 1, 4, 5, '2', S("a22222")); + test(S("abcde"), 1, 4, 10, '2', S("a2222222222")); + test(S("abcde"), 1, 4, 20, '2', S("a22222222222222222222")); + test(S("abcde"), 1, 5, 0, '2', S("a")); + test(S("abcde"), 1, 5, 5, '2', S("a22222")); + test(S("abcde"), 1, 5, 10, '2', S("a2222222222")); + test(S("abcde"), 1, 5, 20, '2', S("a22222222222222222222")); + test(S("abcde"), 2, 0, 0, '2', S("abcde")); + test(S("abcde"), 2, 0, 5, '2', S("ab22222cde")); + test(S("abcde"), 2, 0, 10, '2', S("ab2222222222cde")); + test(S("abcde"), 2, 0, 20, '2', S("ab22222222222222222222cde")); + test(S("abcde"), 2, 1, 0, '2', S("abde")); + test(S("abcde"), 2, 1, 5, '2', S("ab22222de")); + test(S("abcde"), 2, 1, 10, '2', S("ab2222222222de")); + test(S("abcde"), 2, 1, 20, '2', S("ab22222222222222222222de")); + test(S("abcde"), 2, 2, 0, '2', S("abe")); + test(S("abcde"), 2, 2, 5, '2', S("ab22222e")); + test(S("abcde"), 2, 2, 10, '2', S("ab2222222222e")); + test(S("abcde"), 2, 2, 20, '2', S("ab22222222222222222222e")); + test(S("abcde"), 2, 3, 0, '2', S("ab")); + test(S("abcde"), 2, 3, 5, '2', S("ab22222")); + test(S("abcde"), 2, 3, 10, '2', S("ab2222222222")); + test(S("abcde"), 2, 3, 20, '2', S("ab22222222222222222222")); + test(S("abcde"), 2, 4, 0, '2', S("ab")); + test(S("abcde"), 2, 4, 5, '2', S("ab22222")); + test(S("abcde"), 2, 4, 10, '2', S("ab2222222222")); + test(S("abcde"), 2, 4, 20, '2', S("ab22222222222222222222")); + test(S("abcde"), 4, 0, 0, '2', S("abcde")); + test(S("abcde"), 4, 0, 5, '2', S("abcd22222e")); + test(S("abcde"), 4, 0, 10, '2', S("abcd2222222222e")); + test(S("abcde"), 4, 0, 20, '2', S("abcd22222222222222222222e")); + test(S("abcde"), 4, 1, 0, '2', S("abcd")); + test(S("abcde"), 4, 1, 5, '2', S("abcd22222")); + test(S("abcde"), 4, 1, 10, '2', S("abcd2222222222")); + test(S("abcde"), 4, 1, 20, '2', S("abcd22222222222222222222")); + test(S("abcde"), 4, 2, 0, '2', S("abcd")); + test(S("abcde"), 4, 2, 5, '2', S("abcd22222")); + test(S("abcde"), 4, 2, 10, '2', S("abcd2222222222")); + test(S("abcde"), 4, 2, 20, '2', S("abcd22222222222222222222")); + test(S("abcde"), 5, 0, 0, '2', S("abcde")); + test(S("abcde"), 5, 0, 5, '2', S("abcde22222")); + test(S("abcde"), 5, 0, 10, '2', S("abcde2222222222")); + test(S("abcde"), 5, 0, 20, '2', S("abcde22222222222222222222")); + test(S("abcde"), 5, 1, 0, '2', S("abcde")); + test(S("abcde"), 5, 1, 5, '2', S("abcde22222")); + test(S("abcde"), 5, 1, 10, '2', S("abcde2222222222")); + test(S("abcde"), 5, 1, 20, '2', S("abcde22222222222222222222")); +} + +template <class S> +void test1() +{ + test(S("abcde"), 6, 0, 0, '2', S("can't happen")); + test(S("abcde"), 6, 0, 5, '2', S("can't happen")); + test(S("abcde"), 6, 0, 10, '2', S("can't happen")); + test(S("abcde"), 6, 0, 20, '2', S("can't happen")); + test(S("abcdefghij"), 0, 0, 0, '2', S("abcdefghij")); + test(S("abcdefghij"), 0, 0, 5, '2', S("22222abcdefghij")); + test(S("abcdefghij"), 0, 0, 10, '2', S("2222222222abcdefghij")); + test(S("abcdefghij"), 0, 0, 20, '2', S("22222222222222222222abcdefghij")); + test(S("abcdefghij"), 0, 1, 0, '2', S("bcdefghij")); + test(S("abcdefghij"), 0, 1, 5, '2', S("22222bcdefghij")); + test(S("abcdefghij"), 0, 1, 10, '2', S("2222222222bcdefghij")); + test(S("abcdefghij"), 0, 1, 20, '2', S("22222222222222222222bcdefghij")); + test(S("abcdefghij"), 0, 5, 0, '2', S("fghij")); + test(S("abcdefghij"), 0, 5, 5, '2', S("22222fghij")); + test(S("abcdefghij"), 0, 5, 10, '2', S("2222222222fghij")); + test(S("abcdefghij"), 0, 5, 20, '2', S("22222222222222222222fghij")); + test(S("abcdefghij"), 0, 9, 0, '2', S("j")); + test(S("abcdefghij"), 0, 9, 5, '2', S("22222j")); + test(S("abcdefghij"), 0, 9, 10, '2', S("2222222222j")); + test(S("abcdefghij"), 0, 9, 20, '2', S("22222222222222222222j")); + test(S("abcdefghij"), 0, 10, 0, '2', S("")); + test(S("abcdefghij"), 0, 10, 5, '2', S("22222")); + test(S("abcdefghij"), 0, 10, 10, '2', S("2222222222")); + test(S("abcdefghij"), 0, 10, 20, '2', S("22222222222222222222")); + test(S("abcdefghij"), 0, 11, 0, '2', S("")); + test(S("abcdefghij"), 0, 11, 5, '2', S("22222")); + test(S("abcdefghij"), 0, 11, 10, '2', S("2222222222")); + test(S("abcdefghij"), 0, 11, 20, '2', S("22222222222222222222")); + test(S("abcdefghij"), 1, 0, 0, '2', S("abcdefghij")); + test(S("abcdefghij"), 1, 0, 5, '2', S("a22222bcdefghij")); + test(S("abcdefghij"), 1, 0, 10, '2', S("a2222222222bcdefghij")); + test(S("abcdefghij"), 1, 0, 20, '2', S("a22222222222222222222bcdefghij")); + test(S("abcdefghij"), 1, 1, 0, '2', S("acdefghij")); + test(S("abcdefghij"), 1, 1, 5, '2', S("a22222cdefghij")); + test(S("abcdefghij"), 1, 1, 10, '2', S("a2222222222cdefghij")); + test(S("abcdefghij"), 1, 1, 20, '2', S("a22222222222222222222cdefghij")); + test(S("abcdefghij"), 1, 4, 0, '2', S("afghij")); + test(S("abcdefghij"), 1, 4, 5, '2', S("a22222fghij")); + test(S("abcdefghij"), 1, 4, 10, '2', S("a2222222222fghij")); + test(S("abcdefghij"), 1, 4, 20, '2', S("a22222222222222222222fghij")); + test(S("abcdefghij"), 1, 8, 0, '2', S("aj")); + test(S("abcdefghij"), 1, 8, 5, '2', S("a22222j")); + test(S("abcdefghij"), 1, 8, 10, '2', S("a2222222222j")); + test(S("abcdefghij"), 1, 8, 20, '2', S("a22222222222222222222j")); + test(S("abcdefghij"), 1, 9, 0, '2', S("a")); + test(S("abcdefghij"), 1, 9, 5, '2', S("a22222")); + test(S("abcdefghij"), 1, 9, 10, '2', S("a2222222222")); + test(S("abcdefghij"), 1, 9, 20, '2', S("a22222222222222222222")); + test(S("abcdefghij"), 1, 10, 0, '2', S("a")); + test(S("abcdefghij"), 1, 10, 5, '2', S("a22222")); + test(S("abcdefghij"), 1, 10, 10, '2', S("a2222222222")); + test(S("abcdefghij"), 1, 10, 20, '2', S("a22222222222222222222")); + test(S("abcdefghij"), 5, 0, 0, '2', S("abcdefghij")); + test(S("abcdefghij"), 5, 0, 5, '2', S("abcde22222fghij")); + test(S("abcdefghij"), 5, 0, 10, '2', S("abcde2222222222fghij")); + test(S("abcdefghij"), 5, 0, 20, '2', S("abcde22222222222222222222fghij")); + test(S("abcdefghij"), 5, 1, 0, '2', S("abcdeghij")); + test(S("abcdefghij"), 5, 1, 5, '2', S("abcde22222ghij")); + test(S("abcdefghij"), 5, 1, 10, '2', S("abcde2222222222ghij")); + test(S("abcdefghij"), 5, 1, 20, '2', S("abcde22222222222222222222ghij")); + test(S("abcdefghij"), 5, 2, 0, '2', S("abcdehij")); + test(S("abcdefghij"), 5, 2, 5, '2', S("abcde22222hij")); + test(S("abcdefghij"), 5, 2, 10, '2', S("abcde2222222222hij")); + test(S("abcdefghij"), 5, 2, 20, '2', S("abcde22222222222222222222hij")); + test(S("abcdefghij"), 5, 4, 0, '2', S("abcdej")); + test(S("abcdefghij"), 5, 4, 5, '2', S("abcde22222j")); + test(S("abcdefghij"), 5, 4, 10, '2', S("abcde2222222222j")); + test(S("abcdefghij"), 5, 4, 20, '2', S("abcde22222222222222222222j")); + test(S("abcdefghij"), 5, 5, 0, '2', S("abcde")); + test(S("abcdefghij"), 5, 5, 5, '2', S("abcde22222")); + test(S("abcdefghij"), 5, 5, 10, '2', S("abcde2222222222")); + test(S("abcdefghij"), 5, 5, 20, '2', S("abcde22222222222222222222")); + test(S("abcdefghij"), 5, 6, 0, '2', S("abcde")); + test(S("abcdefghij"), 5, 6, 5, '2', S("abcde22222")); + test(S("abcdefghij"), 5, 6, 10, '2', S("abcde2222222222")); + test(S("abcdefghij"), 5, 6, 20, '2', S("abcde22222222222222222222")); + test(S("abcdefghij"), 9, 0, 0, '2', S("abcdefghij")); + test(S("abcdefghij"), 9, 0, 5, '2', S("abcdefghi22222j")); + test(S("abcdefghij"), 9, 0, 10, '2', S("abcdefghi2222222222j")); + test(S("abcdefghij"), 9, 0, 20, '2', S("abcdefghi22222222222222222222j")); + test(S("abcdefghij"), 9, 1, 0, '2', S("abcdefghi")); + test(S("abcdefghij"), 9, 1, 5, '2', S("abcdefghi22222")); + test(S("abcdefghij"), 9, 1, 10, '2', S("abcdefghi2222222222")); + test(S("abcdefghij"), 9, 1, 20, '2', S("abcdefghi22222222222222222222")); + test(S("abcdefghij"), 9, 2, 0, '2', S("abcdefghi")); + test(S("abcdefghij"), 9, 2, 5, '2', S("abcdefghi22222")); + test(S("abcdefghij"), 9, 2, 10, '2', S("abcdefghi2222222222")); + test(S("abcdefghij"), 9, 2, 20, '2', S("abcdefghi22222222222222222222")); + test(S("abcdefghij"), 10, 0, 0, '2', S("abcdefghij")); + test(S("abcdefghij"), 10, 0, 5, '2', S("abcdefghij22222")); + test(S("abcdefghij"), 10, 0, 10, '2', S("abcdefghij2222222222")); + test(S("abcdefghij"), 10, 0, 20, '2', S("abcdefghij22222222222222222222")); + test(S("abcdefghij"), 10, 1, 0, '2', S("abcdefghij")); + test(S("abcdefghij"), 10, 1, 5, '2', S("abcdefghij22222")); + test(S("abcdefghij"), 10, 1, 10, '2', S("abcdefghij2222222222")); + test(S("abcdefghij"), 10, 1, 20, '2', S("abcdefghij22222222222222222222")); + test(S("abcdefghij"), 11, 0, 0, '2', S("can't happen")); + test(S("abcdefghij"), 11, 0, 5, '2', S("can't happen")); + test(S("abcdefghij"), 11, 0, 10, '2', S("can't happen")); + test(S("abcdefghij"), 11, 0, 20, '2', S("can't happen")); +} + +template <class S> +void test2() +{ + test(S("abcdefghijklmnopqrst"), 0, 0, 0, '2', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, 5, '2', S("22222abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, 10, '2', S("2222222222abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, 20, '2', S("22222222222222222222abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, 0, '2', S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, 5, '2', S("22222bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, 10, '2', S("2222222222bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, 20, '2', S("22222222222222222222bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, 0, '2', S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, 5, '2', S("22222klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, 10, '2', S("2222222222klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, 20, '2', S("22222222222222222222klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 19, 0, '2', S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, 5, '2', S("22222t")); + test(S("abcdefghijklmnopqrst"), 0, 19, 10, '2', S("2222222222t")); + test(S("abcdefghijklmnopqrst"), 0, 19, 20, '2', S("22222222222222222222t")); + test(S("abcdefghijklmnopqrst"), 0, 20, 0, '2', S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, 5, '2', S("22222")); + test(S("abcdefghijklmnopqrst"), 0, 20, 10, '2', S("2222222222")); + test(S("abcdefghijklmnopqrst"), 0, 20, 20, '2', S("22222222222222222222")); + test(S("abcdefghijklmnopqrst"), 0, 21, 0, '2', S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, 5, '2', S("22222")); + test(S("abcdefghijklmnopqrst"), 0, 21, 10, '2', S("2222222222")); + test(S("abcdefghijklmnopqrst"), 0, 21, 20, '2', S("22222222222222222222")); + test(S("abcdefghijklmnopqrst"), 1, 0, 0, '2', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, 5, '2', S("a22222bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, 10, '2', S("a2222222222bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, 20, '2', S("a22222222222222222222bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, 0, '2', S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, 5, '2', S("a22222cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, 10, '2', S("a2222222222cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, 20, '2', S("a22222222222222222222cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, 0, '2', S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, 5, '2', S("a22222klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, 10, '2', S("a2222222222klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, 20, '2', S("a22222222222222222222klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 18, 0, '2', S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, 5, '2', S("a22222t")); + test(S("abcdefghijklmnopqrst"), 1, 18, 10, '2', S("a2222222222t")); + test(S("abcdefghijklmnopqrst"), 1, 18, 20, '2', S("a22222222222222222222t")); + test(S("abcdefghijklmnopqrst"), 1, 19, 0, '2', S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, 5, '2', S("a22222")); + test(S("abcdefghijklmnopqrst"), 1, 19, 10, '2', S("a2222222222")); + test(S("abcdefghijklmnopqrst"), 1, 19, 20, '2', S("a22222222222222222222")); + test(S("abcdefghijklmnopqrst"), 1, 20, 0, '2', S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, 5, '2', S("a22222")); + test(S("abcdefghijklmnopqrst"), 1, 20, 10, '2', S("a2222222222")); + test(S("abcdefghijklmnopqrst"), 1, 20, 20, '2', S("a22222222222222222222")); + test(S("abcdefghijklmnopqrst"), 10, 0, 0, '2', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, 5, '2', S("abcdefghij22222klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, 10, '2', S("abcdefghij2222222222klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, 20, '2', S("abcdefghij22222222222222222222klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, 0, '2', S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, 5, '2', S("abcdefghij22222lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, 10, '2', S("abcdefghij2222222222lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, 20, '2', S("abcdefghij22222222222222222222lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, 0, '2', S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, 5, '2', S("abcdefghij22222pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, 10, '2', S("abcdefghij2222222222pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, 20, '2', S("abcdefghij22222222222222222222pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 9, 0, '2', S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, 5, '2', S("abcdefghij22222t")); + test(S("abcdefghijklmnopqrst"), 10, 9, 10, '2', S("abcdefghij2222222222t")); + test(S("abcdefghijklmnopqrst"), 10, 9, 20, '2', S("abcdefghij22222222222222222222t")); + test(S("abcdefghijklmnopqrst"), 10, 10, 0, '2', S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, 5, '2', S("abcdefghij22222")); + test(S("abcdefghijklmnopqrst"), 10, 10, 10, '2', S("abcdefghij2222222222")); + test(S("abcdefghijklmnopqrst"), 10, 10, 20, '2', S("abcdefghij22222222222222222222")); + test(S("abcdefghijklmnopqrst"), 10, 11, 0, '2', S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, 5, '2', S("abcdefghij22222")); + test(S("abcdefghijklmnopqrst"), 10, 11, 10, '2', S("abcdefghij2222222222")); + test(S("abcdefghijklmnopqrst"), 10, 11, 20, '2', S("abcdefghij22222222222222222222")); + test(S("abcdefghijklmnopqrst"), 19, 0, 0, '2', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, 5, '2', S("abcdefghijklmnopqrs22222t")); + test(S("abcdefghijklmnopqrst"), 19, 0, 10, '2', S("abcdefghijklmnopqrs2222222222t")); + test(S("abcdefghijklmnopqrst"), 19, 0, 20, '2', S("abcdefghijklmnopqrs22222222222222222222t")); + test(S("abcdefghijklmnopqrst"), 19, 1, 0, '2', S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, 5, '2', S("abcdefghijklmnopqrs22222")); + test(S("abcdefghijklmnopqrst"), 19, 1, 10, '2', S("abcdefghijklmnopqrs2222222222")); + test(S("abcdefghijklmnopqrst"), 19, 1, 20, '2', S("abcdefghijklmnopqrs22222222222222222222")); + test(S("abcdefghijklmnopqrst"), 19, 2, 0, '2', S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, 5, '2', S("abcdefghijklmnopqrs22222")); + test(S("abcdefghijklmnopqrst"), 19, 2, 10, '2', S("abcdefghijklmnopqrs2222222222")); + test(S("abcdefghijklmnopqrst"), 19, 2, 20, '2', S("abcdefghijklmnopqrs22222222222222222222")); + test(S("abcdefghijklmnopqrst"), 20, 0, 0, '2', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, 5, '2', S("abcdefghijklmnopqrst22222")); + test(S("abcdefghijklmnopqrst"), 20, 0, 10, '2', S("abcdefghijklmnopqrst2222222222")); + test(S("abcdefghijklmnopqrst"), 20, 0, 20, '2', S("abcdefghijklmnopqrst22222222222222222222")); + test(S("abcdefghijklmnopqrst"), 20, 1, 0, '2', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, 5, '2', S("abcdefghijklmnopqrst22222")); + test(S("abcdefghijklmnopqrst"), 20, 1, 10, '2', S("abcdefghijklmnopqrst2222222222")); + test(S("abcdefghijklmnopqrst"), 20, 1, 20, '2', S("abcdefghijklmnopqrst22222222222222222222")); + test(S("abcdefghijklmnopqrst"), 21, 0, 0, '2', S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, 5, '2', S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, 10, '2', S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, 20, '2', S("can't happen")); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp new file mode 100644 index 000000000000..c130780dc9d1 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp @@ -0,0 +1,372 @@ +//===----------------------------------------------------------------------===// +// +// 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>& +// replace(size_type pos1, size_type n1, const basic_string<charT,traits,Allocator>& str); + +#include <string> +#include <stdexcept> +#include <algorithm> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s, typename S::size_type pos1, typename S::size_type n1, S str, S expected) +{ + typename S::size_type old_size = s.size(); + S s0 = s; + try + { + s.replace(pos1, n1, str); + assert(s.__invariants()); + assert(pos1 <= old_size); + assert(s == expected); + typename S::size_type xlen = std::min(n1, old_size - pos1); + typename S::size_type rlen = str.size(); + assert(s.size() == old_size - xlen + rlen); + } + catch (std::out_of_range&) + { + assert(pos1 > old_size); + assert(s == s0); + } +} + +template <class S> +void test0() +{ + test(S(""), 0, 0, S(""), S("")); + test(S(""), 0, 0, S("12345"), S("12345")); + test(S(""), 0, 0, S("1234567890"), S("1234567890")); + test(S(""), 0, 0, S("12345678901234567890"), S("12345678901234567890")); + test(S(""), 0, 1, S(""), S("")); + test(S(""), 0, 1, S("12345"), S("12345")); + test(S(""), 0, 1, S("1234567890"), S("1234567890")); + test(S(""), 0, 1, S("12345678901234567890"), S("12345678901234567890")); + test(S(""), 1, 0, S(""), S("can't happen")); + test(S(""), 1, 0, S("12345"), S("can't happen")); + test(S(""), 1, 0, S("1234567890"), S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), S("can't happen")); + test(S("abcde"), 0, 0, S(""), S("abcde")); + test(S("abcde"), 0, 0, S("12345"), S("12345abcde")); + test(S("abcde"), 0, 0, S("1234567890"), S("1234567890abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcde")); + test(S("abcde"), 0, 1, S(""), S("bcde")); + test(S("abcde"), 0, 1, S("12345"), S("12345bcde")); + test(S("abcde"), 0, 1, S("1234567890"), S("1234567890bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcde")); + test(S("abcde"), 0, 2, S(""), S("cde")); + test(S("abcde"), 0, 2, S("12345"), S("12345cde")); + test(S("abcde"), 0, 2, S("1234567890"), S("1234567890cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), S("12345678901234567890cde")); + test(S("abcde"), 0, 4, S(""), S("e")); + test(S("abcde"), 0, 4, S("12345"), S("12345e")); + test(S("abcde"), 0, 4, S("1234567890"), S("1234567890e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), S("12345678901234567890e")); + test(S("abcde"), 0, 5, S(""), S("")); + test(S("abcde"), 0, 5, S("12345"), S("12345")); + test(S("abcde"), 0, 5, S("1234567890"), S("1234567890")); + test(S("abcde"), 0, 5, S("12345678901234567890"), S("12345678901234567890")); + test(S("abcde"), 0, 6, S(""), S("")); + test(S("abcde"), 0, 6, S("12345"), S("12345")); + test(S("abcde"), 0, 6, S("1234567890"), S("1234567890")); + test(S("abcde"), 0, 6, S("12345678901234567890"), S("12345678901234567890")); + test(S("abcde"), 1, 0, S(""), S("abcde")); + test(S("abcde"), 1, 0, S("12345"), S("a12345bcde")); + test(S("abcde"), 1, 0, S("1234567890"), S("a1234567890bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcde")); + test(S("abcde"), 1, 1, S(""), S("acde")); + test(S("abcde"), 1, 1, S("12345"), S("a12345cde")); + test(S("abcde"), 1, 1, S("1234567890"), S("a1234567890cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cde")); + test(S("abcde"), 1, 2, S(""), S("ade")); + test(S("abcde"), 1, 2, S("12345"), S("a12345de")); + test(S("abcde"), 1, 2, S("1234567890"), S("a1234567890de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), S("a12345678901234567890de")); + test(S("abcde"), 1, 3, S(""), S("ae")); + test(S("abcde"), 1, 3, S("12345"), S("a12345e")); + test(S("abcde"), 1, 3, S("1234567890"), S("a1234567890e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), S("a12345678901234567890e")); + test(S("abcde"), 1, 4, S(""), S("a")); + test(S("abcde"), 1, 4, S("12345"), S("a12345")); + test(S("abcde"), 1, 4, S("1234567890"), S("a1234567890")); + test(S("abcde"), 1, 4, S("12345678901234567890"), S("a12345678901234567890")); + test(S("abcde"), 1, 5, S(""), S("a")); + test(S("abcde"), 1, 5, S("12345"), S("a12345")); + test(S("abcde"), 1, 5, S("1234567890"), S("a1234567890")); + test(S("abcde"), 1, 5, S("12345678901234567890"), S("a12345678901234567890")); + test(S("abcde"), 2, 0, S(""), S("abcde")); + test(S("abcde"), 2, 0, S("12345"), S("ab12345cde")); + test(S("abcde"), 2, 0, S("1234567890"), S("ab1234567890cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), S("ab12345678901234567890cde")); + test(S("abcde"), 2, 1, S(""), S("abde")); + test(S("abcde"), 2, 1, S("12345"), S("ab12345de")); + test(S("abcde"), 2, 1, S("1234567890"), S("ab1234567890de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), S("ab12345678901234567890de")); + test(S("abcde"), 2, 2, S(""), S("abe")); + test(S("abcde"), 2, 2, S("12345"), S("ab12345e")); + test(S("abcde"), 2, 2, S("1234567890"), S("ab1234567890e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), S("ab12345678901234567890e")); + test(S("abcde"), 2, 3, S(""), S("ab")); + test(S("abcde"), 2, 3, S("12345"), S("ab12345")); + test(S("abcde"), 2, 3, S("1234567890"), S("ab1234567890")); + test(S("abcde"), 2, 3, S("12345678901234567890"), S("ab12345678901234567890")); + test(S("abcde"), 2, 4, S(""), S("ab")); + test(S("abcde"), 2, 4, S("12345"), S("ab12345")); + test(S("abcde"), 2, 4, S("1234567890"), S("ab1234567890")); + test(S("abcde"), 2, 4, S("12345678901234567890"), S("ab12345678901234567890")); + test(S("abcde"), 4, 0, S(""), S("abcde")); + test(S("abcde"), 4, 0, S("12345"), S("abcd12345e")); + test(S("abcde"), 4, 0, S("1234567890"), S("abcd1234567890e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), S("abcd12345678901234567890e")); + test(S("abcde"), 4, 1, S(""), S("abcd")); + test(S("abcde"), 4, 1, S("12345"), S("abcd12345")); + test(S("abcde"), 4, 1, S("1234567890"), S("abcd1234567890")); + test(S("abcde"), 4, 1, S("12345678901234567890"), S("abcd12345678901234567890")); + test(S("abcde"), 4, 2, S(""), S("abcd")); + test(S("abcde"), 4, 2, S("12345"), S("abcd12345")); + test(S("abcde"), 4, 2, S("1234567890"), S("abcd1234567890")); + test(S("abcde"), 4, 2, S("12345678901234567890"), S("abcd12345678901234567890")); + test(S("abcde"), 5, 0, S(""), S("abcde")); + test(S("abcde"), 5, 0, S("12345"), S("abcde12345")); + test(S("abcde"), 5, 0, S("1234567890"), S("abcde1234567890")); + test(S("abcde"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890")); + test(S("abcde"), 5, 1, S(""), S("abcde")); + test(S("abcde"), 5, 1, S("12345"), S("abcde12345")); + test(S("abcde"), 5, 1, S("1234567890"), S("abcde1234567890")); + test(S("abcde"), 5, 1, S("12345678901234567890"), S("abcde12345678901234567890")); +} + +template <class S> +void test1() +{ + test(S("abcde"), 6, 0, S(""), S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), S("can't happen")); + test(S("abcdefghij"), 0, 0, S(""), S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), S("12345abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghij")); + test(S("abcdefghij"), 0, 1, S(""), S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), S("12345bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), S("1234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghij")); + test(S("abcdefghij"), 0, 5, S(""), S("fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), S("12345fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), S("1234567890fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), S("12345678901234567890fghij")); + test(S("abcdefghij"), 0, 9, S(""), S("j")); + test(S("abcdefghij"), 0, 9, S("12345"), S("12345j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), S("1234567890j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), S("12345678901234567890j")); + test(S("abcdefghij"), 0, 10, S(""), S("")); + test(S("abcdefghij"), 0, 10, S("12345"), S("12345")); + test(S("abcdefghij"), 0, 10, S("1234567890"), S("1234567890")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), S("12345678901234567890")); + test(S("abcdefghij"), 0, 11, S(""), S("")); + test(S("abcdefghij"), 0, 11, S("12345"), S("12345")); + test(S("abcdefghij"), 0, 11, S("1234567890"), S("1234567890")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), S("12345678901234567890")); + test(S("abcdefghij"), 1, 0, S(""), S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), S("a12345bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghij")); + test(S("abcdefghij"), 1, 1, S(""), S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), S("a12345cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), S("a1234567890cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghij")); + test(S("abcdefghij"), 1, 4, S(""), S("afghij")); + test(S("abcdefghij"), 1, 4, S("12345"), S("a12345fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), S("a1234567890fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), S("a12345678901234567890fghij")); + test(S("abcdefghij"), 1, 8, S(""), S("aj")); + test(S("abcdefghij"), 1, 8, S("12345"), S("a12345j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), S("a1234567890j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), S("a12345678901234567890j")); + test(S("abcdefghij"), 1, 9, S(""), S("a")); + test(S("abcdefghij"), 1, 9, S("12345"), S("a12345")); + test(S("abcdefghij"), 1, 9, S("1234567890"), S("a1234567890")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), S("a12345678901234567890")); + test(S("abcdefghij"), 1, 10, S(""), S("a")); + test(S("abcdefghij"), 1, 10, S("12345"), S("a12345")); + test(S("abcdefghij"), 1, 10, S("1234567890"), S("a1234567890")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), S("a12345678901234567890")); + test(S("abcdefghij"), 5, 0, S(""), S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("12345"), S("abcde12345fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890fghij")); + test(S("abcdefghij"), 5, 1, S(""), S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("12345"), S("abcde12345ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), S("abcde1234567890ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), S("abcde12345678901234567890ghij")); + test(S("abcdefghij"), 5, 2, S(""), S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("12345"), S("abcde12345hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), S("abcde1234567890hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), S("abcde12345678901234567890hij")); + test(S("abcdefghij"), 5, 4, S(""), S("abcdej")); + test(S("abcdefghij"), 5, 4, S("12345"), S("abcde12345j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), S("abcde1234567890j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), S("abcde12345678901234567890j")); + test(S("abcdefghij"), 5, 5, S(""), S("abcde")); + test(S("abcdefghij"), 5, 5, S("12345"), S("abcde12345")); + test(S("abcdefghij"), 5, 5, S("1234567890"), S("abcde1234567890")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), S("abcde12345678901234567890")); + test(S("abcdefghij"), 5, 6, S(""), S("abcde")); + test(S("abcdefghij"), 5, 6, S("12345"), S("abcde12345")); + test(S("abcdefghij"), 5, 6, S("1234567890"), S("abcde1234567890")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), S("abcde12345678901234567890")); + test(S("abcdefghij"), 9, 0, S(""), S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("12345"), S("abcdefghi12345j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), S("abcdefghi12345678901234567890j")); + test(S("abcdefghij"), 9, 1, S(""), S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("12345"), S("abcdefghi12345")); + test(S("abcdefghij"), 9, 1, S("1234567890"), S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), S("abcdefghi12345678901234567890")); + test(S("abcdefghij"), 9, 2, S(""), S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("12345"), S("abcdefghi12345")); + test(S("abcdefghij"), 9, 2, S("1234567890"), S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), S("abcdefghi12345678901234567890")); + test(S("abcdefghij"), 10, 0, S(""), S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("12345"), S("abcdefghij12345")); + test(S("abcdefghij"), 10, 0, S("1234567890"), S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test(S("abcdefghij"), 10, 1, S(""), S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("12345"), S("abcdefghij12345")); + test(S("abcdefghij"), 10, 1, S("1234567890"), S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test(S("abcdefghij"), 11, 0, S(""), S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), S("can't happen")); +} + +template <class S> +void test2() +{ + test(S("abcdefghijklmnopqrst"), 0, 0, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S(""), S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), S("12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), S("1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S(""), S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), S("12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), S("1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), S("12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 19, S(""), S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), S("12345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), S("1234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), S("12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 20, S(""), S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, S(""), S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 0, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S(""), S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), S("a12345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), S("a1234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S(""), S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), S("a12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), S("a1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), S("a12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 18, S(""), S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), S("a12345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), S("a1234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), S("a12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 19, S(""), S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), S("a12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, S(""), S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), S("a12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 0, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S(""), S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), S("abcdefghij12345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), S("abcdefghij1234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), S("abcdefghij12345678901234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S(""), S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), S("abcdefghij12345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), S("abcdefghij1234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), S("abcdefghij12345678901234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 9, S(""), S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), S("abcdefghij12345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), S("abcdefghij1234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), S("abcdefghij12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 10, S(""), S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, S(""), S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 0, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 1, S(""), S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, S(""), S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 21, 0, S(""), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), S("can't happen")); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp new file mode 100644 index 000000000000..ef0de8975eda --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp @@ -0,0 +1,5966 @@ +//===----------------------------------------------------------------------===// +// +// 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>& +// replace(size_type pos1, size_type n1, const basic_string<charT,traits,Allocator>& str, +// size_type pos2, size_type n2=npos); +// the "=npos" was added in C++14 + +#include <string> +#include <stdexcept> +#include <algorithm> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s, typename S::size_type pos1, typename S::size_type n1, + S str, typename S::size_type pos2, typename S::size_type n2, + S expected) +{ + typename S::size_type old_size = s.size(); + S s0 = s; + try + { + s.replace(pos1, n1, str, pos2, n2); + assert(s.__invariants()); + assert(pos1 <= old_size && pos2 <= str.size()); + assert(s == expected); + typename S::size_type xlen = std::min(n1, old_size - pos1); + typename S::size_type rlen = std::min(n2, str.size() - pos2); + assert(s.size() == old_size - xlen + rlen); + } + catch (std::out_of_range&) + { + assert(pos1 > old_size || pos2 > str.size()); + assert(s == s0); + } +} + +template <class S> +void +test_npos(S s, typename S::size_type pos1, typename S::size_type n1, + S str, typename S::size_type pos2, + S expected) +{ + typename S::size_type old_size = s.size(); + S s0 = s; + try + { + s.replace(pos1, n1, str, pos2); + assert(s.__invariants()); + assert(pos1 <= old_size && pos2 <= str.size()); + assert(s == expected); + typename S::size_type xlen = std::min(n1, old_size - pos1); + typename S::size_type rlen = std::min(S::npos, str.size() - pos2); + assert(s.size() == old_size - xlen + rlen); + } + catch (std::out_of_range&) + { + assert(pos1 > old_size || pos2 > str.size()); + assert(s == s0); + } +} + + +template <class S> +void test0() +{ + test(S(""), 0, 0, S(""), 0, 0, S("")); + test(S(""), 0, 0, S(""), 0, 1, S("")); + test(S(""), 0, 0, S(""), 1, 0, S("can't happen")); + test(S(""), 0, 0, S("12345"), 0, 0, S("")); + test(S(""), 0, 0, S("12345"), 0, 1, S("1")); + test(S(""), 0, 0, S("12345"), 0, 2, S("12")); + test(S(""), 0, 0, S("12345"), 0, 4, S("1234")); + test(S(""), 0, 0, S("12345"), 0, 5, S("12345")); + test(S(""), 0, 0, S("12345"), 0, 6, S("12345")); + test(S(""), 0, 0, S("12345"), 1, 0, S("")); + test(S(""), 0, 0, S("12345"), 1, 1, S("2")); + test(S(""), 0, 0, S("12345"), 1, 2, S("23")); + test(S(""), 0, 0, S("12345"), 1, 3, S("234")); + test(S(""), 0, 0, S("12345"), 1, 4, S("2345")); + test(S(""), 0, 0, S("12345"), 1, 5, S("2345")); + test(S(""), 0, 0, S("12345"), 2, 0, S("")); + test(S(""), 0, 0, S("12345"), 2, 1, S("3")); + test(S(""), 0, 0, S("12345"), 2, 2, S("34")); + test(S(""), 0, 0, S("12345"), 2, 3, S("345")); + test(S(""), 0, 0, S("12345"), 2, 4, S("345")); + test(S(""), 0, 0, S("12345"), 4, 0, S("")); + test(S(""), 0, 0, S("12345"), 4, 1, S("5")); + test(S(""), 0, 0, S("12345"), 4, 2, S("5")); + test(S(""), 0, 0, S("12345"), 5, 0, S("")); + test(S(""), 0, 0, S("12345"), 5, 1, S("")); + test(S(""), 0, 0, S("12345"), 6, 0, S("can't happen")); + test(S(""), 0, 0, S("1234567890"), 0, 0, S("")); + test(S(""), 0, 0, S("1234567890"), 0, 1, S("1")); + test(S(""), 0, 0, S("1234567890"), 0, 5, S("12345")); + test(S(""), 0, 0, S("1234567890"), 0, 9, S("123456789")); + test(S(""), 0, 0, S("1234567890"), 0, 10, S("1234567890")); + test(S(""), 0, 0, S("1234567890"), 0, 11, S("1234567890")); + test(S(""), 0, 0, S("1234567890"), 1, 0, S("")); + test(S(""), 0, 0, S("1234567890"), 1, 1, S("2")); + test(S(""), 0, 0, S("1234567890"), 1, 4, S("2345")); + test(S(""), 0, 0, S("1234567890"), 1, 8, S("23456789")); + test(S(""), 0, 0, S("1234567890"), 1, 9, S("234567890")); + test(S(""), 0, 0, S("1234567890"), 1, 10, S("234567890")); + test(S(""), 0, 0, S("1234567890"), 5, 0, S("")); + test(S(""), 0, 0, S("1234567890"), 5, 1, S("6")); + test(S(""), 0, 0, S("1234567890"), 5, 2, S("67")); + test(S(""), 0, 0, S("1234567890"), 5, 4, S("6789")); + test(S(""), 0, 0, S("1234567890"), 5, 5, S("67890")); + test(S(""), 0, 0, S("1234567890"), 5, 6, S("67890")); + test(S(""), 0, 0, S("1234567890"), 9, 0, S("")); + test(S(""), 0, 0, S("1234567890"), 9, 1, S("0")); + test(S(""), 0, 0, S("1234567890"), 9, 2, S("0")); + test(S(""), 0, 0, S("1234567890"), 10, 0, S("")); + test(S(""), 0, 0, S("1234567890"), 10, 1, S("")); + test(S(""), 0, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S(""), 0, 0, S("12345678901234567890"), 0, 0, S("")); + test(S(""), 0, 0, S("12345678901234567890"), 0, 1, S("1")); + test(S(""), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890")); + test(S(""), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789")); + test(S(""), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890")); + test(S(""), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890")); + test(S(""), 0, 0, S("12345678901234567890"), 1, 0, S("")); + test(S(""), 0, 0, S("12345678901234567890"), 1, 1, S("2")); + test(S(""), 0, 0, S("12345678901234567890"), 1, 9, S("234567890")); + test(S(""), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789")); + test(S(""), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890")); + test(S(""), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890")); + test(S(""), 0, 0, S("12345678901234567890"), 10, 0, S("")); + test(S(""), 0, 0, S("12345678901234567890"), 10, 1, S("1")); + test(S(""), 0, 0, S("12345678901234567890"), 10, 5, S("12345")); + test(S(""), 0, 0, S("12345678901234567890"), 10, 9, S("123456789")); + test(S(""), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890")); + test(S(""), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890")); + test(S(""), 0, 0, S("12345678901234567890"), 19, 0, S("")); + test(S(""), 0, 0, S("12345678901234567890"), 19, 1, S("0")); + test(S(""), 0, 0, S("12345678901234567890"), 19, 2, S("0")); + test(S(""), 0, 0, S("12345678901234567890"), 20, 0, S("")); + test(S(""), 0, 0, S("12345678901234567890"), 20, 1, S("")); + test(S(""), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S(""), 0, 1, S(""), 0, 0, S("")); + test(S(""), 0, 1, S(""), 0, 1, S("")); + test(S(""), 0, 1, S(""), 1, 0, S("can't happen")); + test(S(""), 0, 1, S("12345"), 0, 0, S("")); + test(S(""), 0, 1, S("12345"), 0, 1, S("1")); + test(S(""), 0, 1, S("12345"), 0, 2, S("12")); + test(S(""), 0, 1, S("12345"), 0, 4, S("1234")); + test(S(""), 0, 1, S("12345"), 0, 5, S("12345")); + test(S(""), 0, 1, S("12345"), 0, 6, S("12345")); + test(S(""), 0, 1, S("12345"), 1, 0, S("")); + test(S(""), 0, 1, S("12345"), 1, 1, S("2")); + test(S(""), 0, 1, S("12345"), 1, 2, S("23")); + test(S(""), 0, 1, S("12345"), 1, 3, S("234")); + test(S(""), 0, 1, S("12345"), 1, 4, S("2345")); + test(S(""), 0, 1, S("12345"), 1, 5, S("2345")); + test(S(""), 0, 1, S("12345"), 2, 0, S("")); + test(S(""), 0, 1, S("12345"), 2, 1, S("3")); + test(S(""), 0, 1, S("12345"), 2, 2, S("34")); + test(S(""), 0, 1, S("12345"), 2, 3, S("345")); + test(S(""), 0, 1, S("12345"), 2, 4, S("345")); + test(S(""), 0, 1, S("12345"), 4, 0, S("")); + test(S(""), 0, 1, S("12345"), 4, 1, S("5")); + test(S(""), 0, 1, S("12345"), 4, 2, S("5")); + test(S(""), 0, 1, S("12345"), 5, 0, S("")); + test(S(""), 0, 1, S("12345"), 5, 1, S("")); + test(S(""), 0, 1, S("12345"), 6, 0, S("can't happen")); +} + +template <class S> +void test1() +{ + test(S(""), 0, 1, S("1234567890"), 0, 0, S("")); + test(S(""), 0, 1, S("1234567890"), 0, 1, S("1")); + test(S(""), 0, 1, S("1234567890"), 0, 5, S("12345")); + test(S(""), 0, 1, S("1234567890"), 0, 9, S("123456789")); + test(S(""), 0, 1, S("1234567890"), 0, 10, S("1234567890")); + test(S(""), 0, 1, S("1234567890"), 0, 11, S("1234567890")); + test(S(""), 0, 1, S("1234567890"), 1, 0, S("")); + test(S(""), 0, 1, S("1234567890"), 1, 1, S("2")); + test(S(""), 0, 1, S("1234567890"), 1, 4, S("2345")); + test(S(""), 0, 1, S("1234567890"), 1, 8, S("23456789")); + test(S(""), 0, 1, S("1234567890"), 1, 9, S("234567890")); + test(S(""), 0, 1, S("1234567890"), 1, 10, S("234567890")); + test(S(""), 0, 1, S("1234567890"), 5, 0, S("")); + test(S(""), 0, 1, S("1234567890"), 5, 1, S("6")); + test(S(""), 0, 1, S("1234567890"), 5, 2, S("67")); + test(S(""), 0, 1, S("1234567890"), 5, 4, S("6789")); + test(S(""), 0, 1, S("1234567890"), 5, 5, S("67890")); + test(S(""), 0, 1, S("1234567890"), 5, 6, S("67890")); + test(S(""), 0, 1, S("1234567890"), 9, 0, S("")); + test(S(""), 0, 1, S("1234567890"), 9, 1, S("0")); + test(S(""), 0, 1, S("1234567890"), 9, 2, S("0")); + test(S(""), 0, 1, S("1234567890"), 10, 0, S("")); + test(S(""), 0, 1, S("1234567890"), 10, 1, S("")); + test(S(""), 0, 1, S("1234567890"), 11, 0, S("can't happen")); + test(S(""), 0, 1, S("12345678901234567890"), 0, 0, S("")); + test(S(""), 0, 1, S("12345678901234567890"), 0, 1, S("1")); + test(S(""), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890")); + test(S(""), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789")); + test(S(""), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890")); + test(S(""), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890")); + test(S(""), 0, 1, S("12345678901234567890"), 1, 0, S("")); + test(S(""), 0, 1, S("12345678901234567890"), 1, 1, S("2")); + test(S(""), 0, 1, S("12345678901234567890"), 1, 9, S("234567890")); + test(S(""), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789")); + test(S(""), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890")); + test(S(""), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890")); + test(S(""), 0, 1, S("12345678901234567890"), 10, 0, S("")); + test(S(""), 0, 1, S("12345678901234567890"), 10, 1, S("1")); + test(S(""), 0, 1, S("12345678901234567890"), 10, 5, S("12345")); + test(S(""), 0, 1, S("12345678901234567890"), 10, 9, S("123456789")); + test(S(""), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890")); + test(S(""), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890")); + test(S(""), 0, 1, S("12345678901234567890"), 19, 0, S("")); + test(S(""), 0, 1, S("12345678901234567890"), 19, 1, S("0")); + test(S(""), 0, 1, S("12345678901234567890"), 19, 2, S("0")); + test(S(""), 0, 1, S("12345678901234567890"), 20, 0, S("")); + test(S(""), 0, 1, S("12345678901234567890"), 20, 1, S("")); + test(S(""), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S(""), 1, 0, S(""), 0, 0, S("can't happen")); + test(S(""), 1, 0, S(""), 0, 1, S("can't happen")); + test(S(""), 1, 0, S(""), 1, 0, S("can't happen")); + test(S(""), 1, 0, S("12345"), 0, 0, S("can't happen")); + test(S(""), 1, 0, S("12345"), 0, 1, S("can't happen")); + test(S(""), 1, 0, S("12345"), 0, 2, S("can't happen")); + test(S(""), 1, 0, S("12345"), 0, 4, S("can't happen")); + test(S(""), 1, 0, S("12345"), 0, 5, S("can't happen")); + test(S(""), 1, 0, S("12345"), 0, 6, S("can't happen")); + test(S(""), 1, 0, S("12345"), 1, 0, S("can't happen")); + test(S(""), 1, 0, S("12345"), 1, 1, S("can't happen")); + test(S(""), 1, 0, S("12345"), 1, 2, S("can't happen")); + test(S(""), 1, 0, S("12345"), 1, 3, S("can't happen")); + test(S(""), 1, 0, S("12345"), 1, 4, S("can't happen")); + test(S(""), 1, 0, S("12345"), 1, 5, S("can't happen")); + test(S(""), 1, 0, S("12345"), 2, 0, S("can't happen")); + test(S(""), 1, 0, S("12345"), 2, 1, S("can't happen")); + test(S(""), 1, 0, S("12345"), 2, 2, S("can't happen")); + test(S(""), 1, 0, S("12345"), 2, 3, S("can't happen")); + test(S(""), 1, 0, S("12345"), 2, 4, S("can't happen")); + test(S(""), 1, 0, S("12345"), 4, 0, S("can't happen")); + test(S(""), 1, 0, S("12345"), 4, 1, S("can't happen")); + test(S(""), 1, 0, S("12345"), 4, 2, S("can't happen")); + test(S(""), 1, 0, S("12345"), 5, 0, S("can't happen")); + test(S(""), 1, 0, S("12345"), 5, 1, S("can't happen")); + test(S(""), 1, 0, S("12345"), 6, 0, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 0, 0, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 0, 1, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 0, 5, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 0, 9, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 0, 10, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 0, 11, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 1, 0, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 1, 1, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 1, 4, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 1, 8, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 1, 9, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 1, 10, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 5, 0, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 5, 1, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 5, 2, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 5, 4, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 5, 5, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 5, 6, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 9, 0, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 9, 1, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 9, 2, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 10, 0, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 10, 1, S("can't happen")); + test(S(""), 1, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 0, 0, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 0, 1, S("can't happen")); +} + +template <class S> +void test2() +{ + test(S(""), 1, 0, S("12345678901234567890"), 0, 10, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 0, 19, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 0, 20, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 0, 21, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 1, 0, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 1, 1, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 1, 9, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 1, 18, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 1, 19, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 1, 20, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 10, 0, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 10, 1, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 10, 5, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 10, 9, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 10, 10, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 10, 11, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 19, 0, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 19, 1, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 19, 2, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 20, 0, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 20, 1, S("can't happen")); + test(S(""), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 0, 0, S(""), 0, 0, S("abcde")); + test(S("abcde"), 0, 0, S(""), 0, 1, S("abcde")); + test(S("abcde"), 0, 0, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 0, 0, S("12345"), 0, 0, S("abcde")); + test(S("abcde"), 0, 0, S("12345"), 0, 1, S("1abcde")); + test(S("abcde"), 0, 0, S("12345"), 0, 2, S("12abcde")); + test(S("abcde"), 0, 0, S("12345"), 0, 4, S("1234abcde")); + test(S("abcde"), 0, 0, S("12345"), 0, 5, S("12345abcde")); + test(S("abcde"), 0, 0, S("12345"), 0, 6, S("12345abcde")); + test(S("abcde"), 0, 0, S("12345"), 1, 0, S("abcde")); + test(S("abcde"), 0, 0, S("12345"), 1, 1, S("2abcde")); + test(S("abcde"), 0, 0, S("12345"), 1, 2, S("23abcde")); + test(S("abcde"), 0, 0, S("12345"), 1, 3, S("234abcde")); + test(S("abcde"), 0, 0, S("12345"), 1, 4, S("2345abcde")); + test(S("abcde"), 0, 0, S("12345"), 1, 5, S("2345abcde")); + test(S("abcde"), 0, 0, S("12345"), 2, 0, S("abcde")); + test(S("abcde"), 0, 0, S("12345"), 2, 1, S("3abcde")); + test(S("abcde"), 0, 0, S("12345"), 2, 2, S("34abcde")); + test(S("abcde"), 0, 0, S("12345"), 2, 3, S("345abcde")); + test(S("abcde"), 0, 0, S("12345"), 2, 4, S("345abcde")); + test(S("abcde"), 0, 0, S("12345"), 4, 0, S("abcde")); + test(S("abcde"), 0, 0, S("12345"), 4, 1, S("5abcde")); + test(S("abcde"), 0, 0, S("12345"), 4, 2, S("5abcde")); + test(S("abcde"), 0, 0, S("12345"), 5, 0, S("abcde")); + test(S("abcde"), 0, 0, S("12345"), 5, 1, S("abcde")); + test(S("abcde"), 0, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 0, 0, S("1234567890"), 0, 0, S("abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 0, 1, S("1abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 0, 5, S("12345abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 0, 9, S("123456789abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 0, 10, S("1234567890abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 0, 11, S("1234567890abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 1, 0, S("abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 1, 1, S("2abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 1, 4, S("2345abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 1, 8, S("23456789abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 1, 9, S("234567890abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 1, 10, S("234567890abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 5, 0, S("abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 5, 1, S("6abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 5, 2, S("67abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 5, 4, S("6789abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 5, 5, S("67890abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 5, 6, S("67890abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 9, 0, S("abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 9, 1, S("0abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 9, 2, S("0abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 10, 0, S("abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 10, 1, S("abcde")); + test(S("abcde"), 0, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 0, S("abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 1, S("1abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 0, S("abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 1, S("2abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 9, S("234567890abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 0, S("abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 1, S("1abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 5, S("12345abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 9, S("123456789abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 19, 0, S("abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 19, 1, S("0abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 19, 2, S("0abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 20, 0, S("abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 20, 1, S("abcde")); + test(S("abcde"), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 0, 1, S(""), 0, 0, S("bcde")); + test(S("abcde"), 0, 1, S(""), 0, 1, S("bcde")); + test(S("abcde"), 0, 1, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 0, 1, S("12345"), 0, 0, S("bcde")); +} + +template <class S> +void test3() +{ + test(S("abcde"), 0, 1, S("12345"), 0, 1, S("1bcde")); + test(S("abcde"), 0, 1, S("12345"), 0, 2, S("12bcde")); + test(S("abcde"), 0, 1, S("12345"), 0, 4, S("1234bcde")); + test(S("abcde"), 0, 1, S("12345"), 0, 5, S("12345bcde")); + test(S("abcde"), 0, 1, S("12345"), 0, 6, S("12345bcde")); + test(S("abcde"), 0, 1, S("12345"), 1, 0, S("bcde")); + test(S("abcde"), 0, 1, S("12345"), 1, 1, S("2bcde")); + test(S("abcde"), 0, 1, S("12345"), 1, 2, S("23bcde")); + test(S("abcde"), 0, 1, S("12345"), 1, 3, S("234bcde")); + test(S("abcde"), 0, 1, S("12345"), 1, 4, S("2345bcde")); + test(S("abcde"), 0, 1, S("12345"), 1, 5, S("2345bcde")); + test(S("abcde"), 0, 1, S("12345"), 2, 0, S("bcde")); + test(S("abcde"), 0, 1, S("12345"), 2, 1, S("3bcde")); + test(S("abcde"), 0, 1, S("12345"), 2, 2, S("34bcde")); + test(S("abcde"), 0, 1, S("12345"), 2, 3, S("345bcde")); + test(S("abcde"), 0, 1, S("12345"), 2, 4, S("345bcde")); + test(S("abcde"), 0, 1, S("12345"), 4, 0, S("bcde")); + test(S("abcde"), 0, 1, S("12345"), 4, 1, S("5bcde")); + test(S("abcde"), 0, 1, S("12345"), 4, 2, S("5bcde")); + test(S("abcde"), 0, 1, S("12345"), 5, 0, S("bcde")); + test(S("abcde"), 0, 1, S("12345"), 5, 1, S("bcde")); + test(S("abcde"), 0, 1, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 0, 1, S("1234567890"), 0, 0, S("bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 0, 1, S("1bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 0, 5, S("12345bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 0, 9, S("123456789bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 0, 10, S("1234567890bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 0, 11, S("1234567890bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 1, 0, S("bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 1, 1, S("2bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 1, 4, S("2345bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 1, 8, S("23456789bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 1, 9, S("234567890bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 1, 10, S("234567890bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 5, 0, S("bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 5, 1, S("6bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 5, 2, S("67bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 5, 4, S("6789bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 5, 5, S("67890bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 5, 6, S("67890bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 9, 0, S("bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 9, 1, S("0bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 9, 2, S("0bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 10, 0, S("bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 10, 1, S("bcde")); + test(S("abcde"), 0, 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 0, S("bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 1, S("1bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 0, S("bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 1, S("2bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 9, S("234567890bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 0, S("bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 1, S("1bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 5, S("12345bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 9, S("123456789bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 19, 0, S("bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 19, 1, S("0bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 19, 2, S("0bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 20, 0, S("bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 20, 1, S("bcde")); + test(S("abcde"), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 0, 2, S(""), 0, 0, S("cde")); + test(S("abcde"), 0, 2, S(""), 0, 1, S("cde")); + test(S("abcde"), 0, 2, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 0, 2, S("12345"), 0, 0, S("cde")); + test(S("abcde"), 0, 2, S("12345"), 0, 1, S("1cde")); + test(S("abcde"), 0, 2, S("12345"), 0, 2, S("12cde")); + test(S("abcde"), 0, 2, S("12345"), 0, 4, S("1234cde")); + test(S("abcde"), 0, 2, S("12345"), 0, 5, S("12345cde")); + test(S("abcde"), 0, 2, S("12345"), 0, 6, S("12345cde")); + test(S("abcde"), 0, 2, S("12345"), 1, 0, S("cde")); + test(S("abcde"), 0, 2, S("12345"), 1, 1, S("2cde")); + test(S("abcde"), 0, 2, S("12345"), 1, 2, S("23cde")); + test(S("abcde"), 0, 2, S("12345"), 1, 3, S("234cde")); + test(S("abcde"), 0, 2, S("12345"), 1, 4, S("2345cde")); + test(S("abcde"), 0, 2, S("12345"), 1, 5, S("2345cde")); + test(S("abcde"), 0, 2, S("12345"), 2, 0, S("cde")); + test(S("abcde"), 0, 2, S("12345"), 2, 1, S("3cde")); + test(S("abcde"), 0, 2, S("12345"), 2, 2, S("34cde")); + test(S("abcde"), 0, 2, S("12345"), 2, 3, S("345cde")); + test(S("abcde"), 0, 2, S("12345"), 2, 4, S("345cde")); + test(S("abcde"), 0, 2, S("12345"), 4, 0, S("cde")); + test(S("abcde"), 0, 2, S("12345"), 4, 1, S("5cde")); + test(S("abcde"), 0, 2, S("12345"), 4, 2, S("5cde")); + test(S("abcde"), 0, 2, S("12345"), 5, 0, S("cde")); + test(S("abcde"), 0, 2, S("12345"), 5, 1, S("cde")); + test(S("abcde"), 0, 2, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 0, 2, S("1234567890"), 0, 0, S("cde")); + test(S("abcde"), 0, 2, S("1234567890"), 0, 1, S("1cde")); + test(S("abcde"), 0, 2, S("1234567890"), 0, 5, S("12345cde")); + test(S("abcde"), 0, 2, S("1234567890"), 0, 9, S("123456789cde")); +} + +template <class S> +void test4() +{ + test(S("abcde"), 0, 2, S("1234567890"), 0, 10, S("1234567890cde")); + test(S("abcde"), 0, 2, S("1234567890"), 0, 11, S("1234567890cde")); + test(S("abcde"), 0, 2, S("1234567890"), 1, 0, S("cde")); + test(S("abcde"), 0, 2, S("1234567890"), 1, 1, S("2cde")); + test(S("abcde"), 0, 2, S("1234567890"), 1, 4, S("2345cde")); + test(S("abcde"), 0, 2, S("1234567890"), 1, 8, S("23456789cde")); + test(S("abcde"), 0, 2, S("1234567890"), 1, 9, S("234567890cde")); + test(S("abcde"), 0, 2, S("1234567890"), 1, 10, S("234567890cde")); + test(S("abcde"), 0, 2, S("1234567890"), 5, 0, S("cde")); + test(S("abcde"), 0, 2, S("1234567890"), 5, 1, S("6cde")); + test(S("abcde"), 0, 2, S("1234567890"), 5, 2, S("67cde")); + test(S("abcde"), 0, 2, S("1234567890"), 5, 4, S("6789cde")); + test(S("abcde"), 0, 2, S("1234567890"), 5, 5, S("67890cde")); + test(S("abcde"), 0, 2, S("1234567890"), 5, 6, S("67890cde")); + test(S("abcde"), 0, 2, S("1234567890"), 9, 0, S("cde")); + test(S("abcde"), 0, 2, S("1234567890"), 9, 1, S("0cde")); + test(S("abcde"), 0, 2, S("1234567890"), 9, 2, S("0cde")); + test(S("abcde"), 0, 2, S("1234567890"), 10, 0, S("cde")); + test(S("abcde"), 0, 2, S("1234567890"), 10, 1, S("cde")); + test(S("abcde"), 0, 2, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 0, S("cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 1, S("1cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 10, S("1234567890cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 19, S("1234567890123456789cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 20, S("12345678901234567890cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 21, S("12345678901234567890cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 0, S("cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 1, S("2cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 9, S("234567890cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 18, S("234567890123456789cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 19, S("2345678901234567890cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 20, S("2345678901234567890cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 0, S("cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 1, S("1cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 5, S("12345cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 9, S("123456789cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 10, S("1234567890cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 11, S("1234567890cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 19, 0, S("cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 19, 1, S("0cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 19, 2, S("0cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 20, 0, S("cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 20, 1, S("cde")); + test(S("abcde"), 0, 2, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 0, 4, S(""), 0, 0, S("e")); + test(S("abcde"), 0, 4, S(""), 0, 1, S("e")); + test(S("abcde"), 0, 4, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 0, 4, S("12345"), 0, 0, S("e")); + test(S("abcde"), 0, 4, S("12345"), 0, 1, S("1e")); + test(S("abcde"), 0, 4, S("12345"), 0, 2, S("12e")); + test(S("abcde"), 0, 4, S("12345"), 0, 4, S("1234e")); + test(S("abcde"), 0, 4, S("12345"), 0, 5, S("12345e")); + test(S("abcde"), 0, 4, S("12345"), 0, 6, S("12345e")); + test(S("abcde"), 0, 4, S("12345"), 1, 0, S("e")); + test(S("abcde"), 0, 4, S("12345"), 1, 1, S("2e")); + test(S("abcde"), 0, 4, S("12345"), 1, 2, S("23e")); + test(S("abcde"), 0, 4, S("12345"), 1, 3, S("234e")); + test(S("abcde"), 0, 4, S("12345"), 1, 4, S("2345e")); + test(S("abcde"), 0, 4, S("12345"), 1, 5, S("2345e")); + test(S("abcde"), 0, 4, S("12345"), 2, 0, S("e")); + test(S("abcde"), 0, 4, S("12345"), 2, 1, S("3e")); + test(S("abcde"), 0, 4, S("12345"), 2, 2, S("34e")); + test(S("abcde"), 0, 4, S("12345"), 2, 3, S("345e")); + test(S("abcde"), 0, 4, S("12345"), 2, 4, S("345e")); + test(S("abcde"), 0, 4, S("12345"), 4, 0, S("e")); + test(S("abcde"), 0, 4, S("12345"), 4, 1, S("5e")); + test(S("abcde"), 0, 4, S("12345"), 4, 2, S("5e")); + test(S("abcde"), 0, 4, S("12345"), 5, 0, S("e")); + test(S("abcde"), 0, 4, S("12345"), 5, 1, S("e")); + test(S("abcde"), 0, 4, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 0, 4, S("1234567890"), 0, 0, S("e")); + test(S("abcde"), 0, 4, S("1234567890"), 0, 1, S("1e")); + test(S("abcde"), 0, 4, S("1234567890"), 0, 5, S("12345e")); + test(S("abcde"), 0, 4, S("1234567890"), 0, 9, S("123456789e")); + test(S("abcde"), 0, 4, S("1234567890"), 0, 10, S("1234567890e")); + test(S("abcde"), 0, 4, S("1234567890"), 0, 11, S("1234567890e")); + test(S("abcde"), 0, 4, S("1234567890"), 1, 0, S("e")); + test(S("abcde"), 0, 4, S("1234567890"), 1, 1, S("2e")); + test(S("abcde"), 0, 4, S("1234567890"), 1, 4, S("2345e")); + test(S("abcde"), 0, 4, S("1234567890"), 1, 8, S("23456789e")); + test(S("abcde"), 0, 4, S("1234567890"), 1, 9, S("234567890e")); + test(S("abcde"), 0, 4, S("1234567890"), 1, 10, S("234567890e")); + test(S("abcde"), 0, 4, S("1234567890"), 5, 0, S("e")); + test(S("abcde"), 0, 4, S("1234567890"), 5, 1, S("6e")); + test(S("abcde"), 0, 4, S("1234567890"), 5, 2, S("67e")); + test(S("abcde"), 0, 4, S("1234567890"), 5, 4, S("6789e")); + test(S("abcde"), 0, 4, S("1234567890"), 5, 5, S("67890e")); + test(S("abcde"), 0, 4, S("1234567890"), 5, 6, S("67890e")); + test(S("abcde"), 0, 4, S("1234567890"), 9, 0, S("e")); + test(S("abcde"), 0, 4, S("1234567890"), 9, 1, S("0e")); + test(S("abcde"), 0, 4, S("1234567890"), 9, 2, S("0e")); + test(S("abcde"), 0, 4, S("1234567890"), 10, 0, S("e")); + test(S("abcde"), 0, 4, S("1234567890"), 10, 1, S("e")); + test(S("abcde"), 0, 4, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 0, S("e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 1, S("1e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 10, S("1234567890e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 19, S("1234567890123456789e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 20, S("12345678901234567890e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 21, S("12345678901234567890e")); +} + +template <class S> +void test5() +{ + test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 0, S("e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 1, S("2e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 9, S("234567890e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 18, S("234567890123456789e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 19, S("2345678901234567890e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 20, S("2345678901234567890e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 0, S("e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 1, S("1e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 5, S("12345e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 9, S("123456789e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 10, S("1234567890e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 11, S("1234567890e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 19, 0, S("e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 19, 1, S("0e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 19, 2, S("0e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 20, 0, S("e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 20, 1, S("e")); + test(S("abcde"), 0, 4, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 0, 5, S(""), 0, 0, S("")); + test(S("abcde"), 0, 5, S(""), 0, 1, S("")); + test(S("abcde"), 0, 5, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 0, 5, S("12345"), 0, 0, S("")); + test(S("abcde"), 0, 5, S("12345"), 0, 1, S("1")); + test(S("abcde"), 0, 5, S("12345"), 0, 2, S("12")); + test(S("abcde"), 0, 5, S("12345"), 0, 4, S("1234")); + test(S("abcde"), 0, 5, S("12345"), 0, 5, S("12345")); + test(S("abcde"), 0, 5, S("12345"), 0, 6, S("12345")); + test(S("abcde"), 0, 5, S("12345"), 1, 0, S("")); + test(S("abcde"), 0, 5, S("12345"), 1, 1, S("2")); + test(S("abcde"), 0, 5, S("12345"), 1, 2, S("23")); + test(S("abcde"), 0, 5, S("12345"), 1, 3, S("234")); + test(S("abcde"), 0, 5, S("12345"), 1, 4, S("2345")); + test(S("abcde"), 0, 5, S("12345"), 1, 5, S("2345")); + test(S("abcde"), 0, 5, S("12345"), 2, 0, S("")); + test(S("abcde"), 0, 5, S("12345"), 2, 1, S("3")); + test(S("abcde"), 0, 5, S("12345"), 2, 2, S("34")); + test(S("abcde"), 0, 5, S("12345"), 2, 3, S("345")); + test(S("abcde"), 0, 5, S("12345"), 2, 4, S("345")); + test(S("abcde"), 0, 5, S("12345"), 4, 0, S("")); + test(S("abcde"), 0, 5, S("12345"), 4, 1, S("5")); + test(S("abcde"), 0, 5, S("12345"), 4, 2, S("5")); + test(S("abcde"), 0, 5, S("12345"), 5, 0, S("")); + test(S("abcde"), 0, 5, S("12345"), 5, 1, S("")); + test(S("abcde"), 0, 5, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 0, 5, S("1234567890"), 0, 0, S("")); + test(S("abcde"), 0, 5, S("1234567890"), 0, 1, S("1")); + test(S("abcde"), 0, 5, S("1234567890"), 0, 5, S("12345")); + test(S("abcde"), 0, 5, S("1234567890"), 0, 9, S("123456789")); + test(S("abcde"), 0, 5, S("1234567890"), 0, 10, S("1234567890")); + test(S("abcde"), 0, 5, S("1234567890"), 0, 11, S("1234567890")); + test(S("abcde"), 0, 5, S("1234567890"), 1, 0, S("")); + test(S("abcde"), 0, 5, S("1234567890"), 1, 1, S("2")); + test(S("abcde"), 0, 5, S("1234567890"), 1, 4, S("2345")); + test(S("abcde"), 0, 5, S("1234567890"), 1, 8, S("23456789")); + test(S("abcde"), 0, 5, S("1234567890"), 1, 9, S("234567890")); + test(S("abcde"), 0, 5, S("1234567890"), 1, 10, S("234567890")); + test(S("abcde"), 0, 5, S("1234567890"), 5, 0, S("")); + test(S("abcde"), 0, 5, S("1234567890"), 5, 1, S("6")); + test(S("abcde"), 0, 5, S("1234567890"), 5, 2, S("67")); + test(S("abcde"), 0, 5, S("1234567890"), 5, 4, S("6789")); + test(S("abcde"), 0, 5, S("1234567890"), 5, 5, S("67890")); + test(S("abcde"), 0, 5, S("1234567890"), 5, 6, S("67890")); + test(S("abcde"), 0, 5, S("1234567890"), 9, 0, S("")); + test(S("abcde"), 0, 5, S("1234567890"), 9, 1, S("0")); + test(S("abcde"), 0, 5, S("1234567890"), 9, 2, S("0")); + test(S("abcde"), 0, 5, S("1234567890"), 10, 0, S("")); + test(S("abcde"), 0, 5, S("1234567890"), 10, 1, S("")); + test(S("abcde"), 0, 5, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 0, S("")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 1, S("1")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 10, S("1234567890")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 19, S("1234567890123456789")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 20, S("12345678901234567890")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 21, S("12345678901234567890")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 0, S("")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 1, S("2")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 9, S("234567890")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 18, S("234567890123456789")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 19, S("2345678901234567890")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 20, S("2345678901234567890")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 0, S("")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 1, S("1")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 5, S("12345")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 9, S("123456789")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 10, S("1234567890")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 11, S("1234567890")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 19, 0, S("")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 19, 1, S("0")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 19, 2, S("0")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 20, 0, S("")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 20, 1, S("")); + test(S("abcde"), 0, 5, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 0, 6, S(""), 0, 0, S("")); + test(S("abcde"), 0, 6, S(""), 0, 1, S("")); + test(S("abcde"), 0, 6, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 0, 6, S("12345"), 0, 0, S("")); + test(S("abcde"), 0, 6, S("12345"), 0, 1, S("1")); + test(S("abcde"), 0, 6, S("12345"), 0, 2, S("12")); + test(S("abcde"), 0, 6, S("12345"), 0, 4, S("1234")); + test(S("abcde"), 0, 6, S("12345"), 0, 5, S("12345")); +} + +template <class S> +void test6() +{ + test(S("abcde"), 0, 6, S("12345"), 0, 6, S("12345")); + test(S("abcde"), 0, 6, S("12345"), 1, 0, S("")); + test(S("abcde"), 0, 6, S("12345"), 1, 1, S("2")); + test(S("abcde"), 0, 6, S("12345"), 1, 2, S("23")); + test(S("abcde"), 0, 6, S("12345"), 1, 3, S("234")); + test(S("abcde"), 0, 6, S("12345"), 1, 4, S("2345")); + test(S("abcde"), 0, 6, S("12345"), 1, 5, S("2345")); + test(S("abcde"), 0, 6, S("12345"), 2, 0, S("")); + test(S("abcde"), 0, 6, S("12345"), 2, 1, S("3")); + test(S("abcde"), 0, 6, S("12345"), 2, 2, S("34")); + test(S("abcde"), 0, 6, S("12345"), 2, 3, S("345")); + test(S("abcde"), 0, 6, S("12345"), 2, 4, S("345")); + test(S("abcde"), 0, 6, S("12345"), 4, 0, S("")); + test(S("abcde"), 0, 6, S("12345"), 4, 1, S("5")); + test(S("abcde"), 0, 6, S("12345"), 4, 2, S("5")); + test(S("abcde"), 0, 6, S("12345"), 5, 0, S("")); + test(S("abcde"), 0, 6, S("12345"), 5, 1, S("")); + test(S("abcde"), 0, 6, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 0, 6, S("1234567890"), 0, 0, S("")); + test(S("abcde"), 0, 6, S("1234567890"), 0, 1, S("1")); + test(S("abcde"), 0, 6, S("1234567890"), 0, 5, S("12345")); + test(S("abcde"), 0, 6, S("1234567890"), 0, 9, S("123456789")); + test(S("abcde"), 0, 6, S("1234567890"), 0, 10, S("1234567890")); + test(S("abcde"), 0, 6, S("1234567890"), 0, 11, S("1234567890")); + test(S("abcde"), 0, 6, S("1234567890"), 1, 0, S("")); + test(S("abcde"), 0, 6, S("1234567890"), 1, 1, S("2")); + test(S("abcde"), 0, 6, S("1234567890"), 1, 4, S("2345")); + test(S("abcde"), 0, 6, S("1234567890"), 1, 8, S("23456789")); + test(S("abcde"), 0, 6, S("1234567890"), 1, 9, S("234567890")); + test(S("abcde"), 0, 6, S("1234567890"), 1, 10, S("234567890")); + test(S("abcde"), 0, 6, S("1234567890"), 5, 0, S("")); + test(S("abcde"), 0, 6, S("1234567890"), 5, 1, S("6")); + test(S("abcde"), 0, 6, S("1234567890"), 5, 2, S("67")); + test(S("abcde"), 0, 6, S("1234567890"), 5, 4, S("6789")); + test(S("abcde"), 0, 6, S("1234567890"), 5, 5, S("67890")); + test(S("abcde"), 0, 6, S("1234567890"), 5, 6, S("67890")); + test(S("abcde"), 0, 6, S("1234567890"), 9, 0, S("")); + test(S("abcde"), 0, 6, S("1234567890"), 9, 1, S("0")); + test(S("abcde"), 0, 6, S("1234567890"), 9, 2, S("0")); + test(S("abcde"), 0, 6, S("1234567890"), 10, 0, S("")); + test(S("abcde"), 0, 6, S("1234567890"), 10, 1, S("")); + test(S("abcde"), 0, 6, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 0, S("")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 1, S("1")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 10, S("1234567890")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 19, S("1234567890123456789")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 20, S("12345678901234567890")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 21, S("12345678901234567890")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 0, S("")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 1, S("2")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 9, S("234567890")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 18, S("234567890123456789")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 19, S("2345678901234567890")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 20, S("2345678901234567890")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 0, S("")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 1, S("1")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 5, S("12345")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 9, S("123456789")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 10, S("1234567890")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 11, S("1234567890")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 19, 0, S("")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 19, 1, S("0")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 19, 2, S("0")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 20, 0, S("")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 20, 1, S("")); + test(S("abcde"), 0, 6, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 1, 0, S(""), 0, 0, S("abcde")); + test(S("abcde"), 1, 0, S(""), 0, 1, S("abcde")); + test(S("abcde"), 1, 0, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 1, 0, S("12345"), 0, 0, S("abcde")); + test(S("abcde"), 1, 0, S("12345"), 0, 1, S("a1bcde")); + test(S("abcde"), 1, 0, S("12345"), 0, 2, S("a12bcde")); + test(S("abcde"), 1, 0, S("12345"), 0, 4, S("a1234bcde")); + test(S("abcde"), 1, 0, S("12345"), 0, 5, S("a12345bcde")); + test(S("abcde"), 1, 0, S("12345"), 0, 6, S("a12345bcde")); + test(S("abcde"), 1, 0, S("12345"), 1, 0, S("abcde")); + test(S("abcde"), 1, 0, S("12345"), 1, 1, S("a2bcde")); + test(S("abcde"), 1, 0, S("12345"), 1, 2, S("a23bcde")); + test(S("abcde"), 1, 0, S("12345"), 1, 3, S("a234bcde")); + test(S("abcde"), 1, 0, S("12345"), 1, 4, S("a2345bcde")); + test(S("abcde"), 1, 0, S("12345"), 1, 5, S("a2345bcde")); + test(S("abcde"), 1, 0, S("12345"), 2, 0, S("abcde")); + test(S("abcde"), 1, 0, S("12345"), 2, 1, S("a3bcde")); + test(S("abcde"), 1, 0, S("12345"), 2, 2, S("a34bcde")); + test(S("abcde"), 1, 0, S("12345"), 2, 3, S("a345bcde")); + test(S("abcde"), 1, 0, S("12345"), 2, 4, S("a345bcde")); + test(S("abcde"), 1, 0, S("12345"), 4, 0, S("abcde")); + test(S("abcde"), 1, 0, S("12345"), 4, 1, S("a5bcde")); + test(S("abcde"), 1, 0, S("12345"), 4, 2, S("a5bcde")); + test(S("abcde"), 1, 0, S("12345"), 5, 0, S("abcde")); + test(S("abcde"), 1, 0, S("12345"), 5, 1, S("abcde")); + test(S("abcde"), 1, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 1, 0, S("1234567890"), 0, 0, S("abcde")); + test(S("abcde"), 1, 0, S("1234567890"), 0, 1, S("a1bcde")); + test(S("abcde"), 1, 0, S("1234567890"), 0, 5, S("a12345bcde")); + test(S("abcde"), 1, 0, S("1234567890"), 0, 9, S("a123456789bcde")); + test(S("abcde"), 1, 0, S("1234567890"), 0, 10, S("a1234567890bcde")); + test(S("abcde"), 1, 0, S("1234567890"), 0, 11, S("a1234567890bcde")); + test(S("abcde"), 1, 0, S("1234567890"), 1, 0, S("abcde")); + test(S("abcde"), 1, 0, S("1234567890"), 1, 1, S("a2bcde")); +} + +template <class S> +void test7() +{ + test(S("abcde"), 1, 0, S("1234567890"), 1, 4, S("a2345bcde")); + test(S("abcde"), 1, 0, S("1234567890"), 1, 8, S("a23456789bcde")); + test(S("abcde"), 1, 0, S("1234567890"), 1, 9, S("a234567890bcde")); + test(S("abcde"), 1, 0, S("1234567890"), 1, 10, S("a234567890bcde")); + test(S("abcde"), 1, 0, S("1234567890"), 5, 0, S("abcde")); + test(S("abcde"), 1, 0, S("1234567890"), 5, 1, S("a6bcde")); + test(S("abcde"), 1, 0, S("1234567890"), 5, 2, S("a67bcde")); + test(S("abcde"), 1, 0, S("1234567890"), 5, 4, S("a6789bcde")); + test(S("abcde"), 1, 0, S("1234567890"), 5, 5, S("a67890bcde")); + test(S("abcde"), 1, 0, S("1234567890"), 5, 6, S("a67890bcde")); + test(S("abcde"), 1, 0, S("1234567890"), 9, 0, S("abcde")); + test(S("abcde"), 1, 0, S("1234567890"), 9, 1, S("a0bcde")); + test(S("abcde"), 1, 0, S("1234567890"), 9, 2, S("a0bcde")); + test(S("abcde"), 1, 0, S("1234567890"), 10, 0, S("abcde")); + test(S("abcde"), 1, 0, S("1234567890"), 10, 1, S("abcde")); + test(S("abcde"), 1, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 0, S("abcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 1, S("a1bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 10, S("a1234567890bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 0, S("abcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 1, S("a2bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 9, S("a234567890bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 18, S("a234567890123456789bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 0, S("abcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 1, S("a1bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 5, S("a12345bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 9, S("a123456789bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 10, S("a1234567890bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 11, S("a1234567890bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 19, 0, S("abcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 19, 1, S("a0bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 19, 2, S("a0bcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 20, 0, S("abcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 20, 1, S("abcde")); + test(S("abcde"), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 1, 1, S(""), 0, 0, S("acde")); + test(S("abcde"), 1, 1, S(""), 0, 1, S("acde")); + test(S("abcde"), 1, 1, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 1, 1, S("12345"), 0, 0, S("acde")); + test(S("abcde"), 1, 1, S("12345"), 0, 1, S("a1cde")); + test(S("abcde"), 1, 1, S("12345"), 0, 2, S("a12cde")); + test(S("abcde"), 1, 1, S("12345"), 0, 4, S("a1234cde")); + test(S("abcde"), 1, 1, S("12345"), 0, 5, S("a12345cde")); + test(S("abcde"), 1, 1, S("12345"), 0, 6, S("a12345cde")); + test(S("abcde"), 1, 1, S("12345"), 1, 0, S("acde")); + test(S("abcde"), 1, 1, S("12345"), 1, 1, S("a2cde")); + test(S("abcde"), 1, 1, S("12345"), 1, 2, S("a23cde")); + test(S("abcde"), 1, 1, S("12345"), 1, 3, S("a234cde")); + test(S("abcde"), 1, 1, S("12345"), 1, 4, S("a2345cde")); + test(S("abcde"), 1, 1, S("12345"), 1, 5, S("a2345cde")); + test(S("abcde"), 1, 1, S("12345"), 2, 0, S("acde")); + test(S("abcde"), 1, 1, S("12345"), 2, 1, S("a3cde")); + test(S("abcde"), 1, 1, S("12345"), 2, 2, S("a34cde")); + test(S("abcde"), 1, 1, S("12345"), 2, 3, S("a345cde")); + test(S("abcde"), 1, 1, S("12345"), 2, 4, S("a345cde")); + test(S("abcde"), 1, 1, S("12345"), 4, 0, S("acde")); + test(S("abcde"), 1, 1, S("12345"), 4, 1, S("a5cde")); + test(S("abcde"), 1, 1, S("12345"), 4, 2, S("a5cde")); + test(S("abcde"), 1, 1, S("12345"), 5, 0, S("acde")); + test(S("abcde"), 1, 1, S("12345"), 5, 1, S("acde")); + test(S("abcde"), 1, 1, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 1, 1, S("1234567890"), 0, 0, S("acde")); + test(S("abcde"), 1, 1, S("1234567890"), 0, 1, S("a1cde")); + test(S("abcde"), 1, 1, S("1234567890"), 0, 5, S("a12345cde")); + test(S("abcde"), 1, 1, S("1234567890"), 0, 9, S("a123456789cde")); + test(S("abcde"), 1, 1, S("1234567890"), 0, 10, S("a1234567890cde")); + test(S("abcde"), 1, 1, S("1234567890"), 0, 11, S("a1234567890cde")); + test(S("abcde"), 1, 1, S("1234567890"), 1, 0, S("acde")); + test(S("abcde"), 1, 1, S("1234567890"), 1, 1, S("a2cde")); + test(S("abcde"), 1, 1, S("1234567890"), 1, 4, S("a2345cde")); + test(S("abcde"), 1, 1, S("1234567890"), 1, 8, S("a23456789cde")); + test(S("abcde"), 1, 1, S("1234567890"), 1, 9, S("a234567890cde")); + test(S("abcde"), 1, 1, S("1234567890"), 1, 10, S("a234567890cde")); + test(S("abcde"), 1, 1, S("1234567890"), 5, 0, S("acde")); + test(S("abcde"), 1, 1, S("1234567890"), 5, 1, S("a6cde")); + test(S("abcde"), 1, 1, S("1234567890"), 5, 2, S("a67cde")); + test(S("abcde"), 1, 1, S("1234567890"), 5, 4, S("a6789cde")); + test(S("abcde"), 1, 1, S("1234567890"), 5, 5, S("a67890cde")); + test(S("abcde"), 1, 1, S("1234567890"), 5, 6, S("a67890cde")); + test(S("abcde"), 1, 1, S("1234567890"), 9, 0, S("acde")); + test(S("abcde"), 1, 1, S("1234567890"), 9, 1, S("a0cde")); + test(S("abcde"), 1, 1, S("1234567890"), 9, 2, S("a0cde")); + test(S("abcde"), 1, 1, S("1234567890"), 10, 0, S("acde")); + test(S("abcde"), 1, 1, S("1234567890"), 10, 1, S("acde")); + test(S("abcde"), 1, 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 0, S("acde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 1, S("a1cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 10, S("a1234567890cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 0, S("acde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 1, S("a2cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 9, S("a234567890cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 18, S("a234567890123456789cde")); +} + +template <class S> +void test8() +{ + test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 0, S("acde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 1, S("a1cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 5, S("a12345cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 9, S("a123456789cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 10, S("a1234567890cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 11, S("a1234567890cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 19, 0, S("acde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 19, 1, S("a0cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 19, 2, S("a0cde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 20, 0, S("acde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 20, 1, S("acde")); + test(S("abcde"), 1, 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 1, 2, S(""), 0, 0, S("ade")); + test(S("abcde"), 1, 2, S(""), 0, 1, S("ade")); + test(S("abcde"), 1, 2, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 1, 2, S("12345"), 0, 0, S("ade")); + test(S("abcde"), 1, 2, S("12345"), 0, 1, S("a1de")); + test(S("abcde"), 1, 2, S("12345"), 0, 2, S("a12de")); + test(S("abcde"), 1, 2, S("12345"), 0, 4, S("a1234de")); + test(S("abcde"), 1, 2, S("12345"), 0, 5, S("a12345de")); + test(S("abcde"), 1, 2, S("12345"), 0, 6, S("a12345de")); + test(S("abcde"), 1, 2, S("12345"), 1, 0, S("ade")); + test(S("abcde"), 1, 2, S("12345"), 1, 1, S("a2de")); + test(S("abcde"), 1, 2, S("12345"), 1, 2, S("a23de")); + test(S("abcde"), 1, 2, S("12345"), 1, 3, S("a234de")); + test(S("abcde"), 1, 2, S("12345"), 1, 4, S("a2345de")); + test(S("abcde"), 1, 2, S("12345"), 1, 5, S("a2345de")); + test(S("abcde"), 1, 2, S("12345"), 2, 0, S("ade")); + test(S("abcde"), 1, 2, S("12345"), 2, 1, S("a3de")); + test(S("abcde"), 1, 2, S("12345"), 2, 2, S("a34de")); + test(S("abcde"), 1, 2, S("12345"), 2, 3, S("a345de")); + test(S("abcde"), 1, 2, S("12345"), 2, 4, S("a345de")); + test(S("abcde"), 1, 2, S("12345"), 4, 0, S("ade")); + test(S("abcde"), 1, 2, S("12345"), 4, 1, S("a5de")); + test(S("abcde"), 1, 2, S("12345"), 4, 2, S("a5de")); + test(S("abcde"), 1, 2, S("12345"), 5, 0, S("ade")); + test(S("abcde"), 1, 2, S("12345"), 5, 1, S("ade")); + test(S("abcde"), 1, 2, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 1, 2, S("1234567890"), 0, 0, S("ade")); + test(S("abcde"), 1, 2, S("1234567890"), 0, 1, S("a1de")); + test(S("abcde"), 1, 2, S("1234567890"), 0, 5, S("a12345de")); + test(S("abcde"), 1, 2, S("1234567890"), 0, 9, S("a123456789de")); + test(S("abcde"), 1, 2, S("1234567890"), 0, 10, S("a1234567890de")); + test(S("abcde"), 1, 2, S("1234567890"), 0, 11, S("a1234567890de")); + test(S("abcde"), 1, 2, S("1234567890"), 1, 0, S("ade")); + test(S("abcde"), 1, 2, S("1234567890"), 1, 1, S("a2de")); + test(S("abcde"), 1, 2, S("1234567890"), 1, 4, S("a2345de")); + test(S("abcde"), 1, 2, S("1234567890"), 1, 8, S("a23456789de")); + test(S("abcde"), 1, 2, S("1234567890"), 1, 9, S("a234567890de")); + test(S("abcde"), 1, 2, S("1234567890"), 1, 10, S("a234567890de")); + test(S("abcde"), 1, 2, S("1234567890"), 5, 0, S("ade")); + test(S("abcde"), 1, 2, S("1234567890"), 5, 1, S("a6de")); + test(S("abcde"), 1, 2, S("1234567890"), 5, 2, S("a67de")); + test(S("abcde"), 1, 2, S("1234567890"), 5, 4, S("a6789de")); + test(S("abcde"), 1, 2, S("1234567890"), 5, 5, S("a67890de")); + test(S("abcde"), 1, 2, S("1234567890"), 5, 6, S("a67890de")); + test(S("abcde"), 1, 2, S("1234567890"), 9, 0, S("ade")); + test(S("abcde"), 1, 2, S("1234567890"), 9, 1, S("a0de")); + test(S("abcde"), 1, 2, S("1234567890"), 9, 2, S("a0de")); + test(S("abcde"), 1, 2, S("1234567890"), 10, 0, S("ade")); + test(S("abcde"), 1, 2, S("1234567890"), 10, 1, S("ade")); + test(S("abcde"), 1, 2, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 0, S("ade")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 1, S("a1de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 10, S("a1234567890de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 19, S("a1234567890123456789de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 20, S("a12345678901234567890de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 21, S("a12345678901234567890de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 0, S("ade")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 1, S("a2de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 9, S("a234567890de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 18, S("a234567890123456789de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 19, S("a2345678901234567890de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 20, S("a2345678901234567890de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 0, S("ade")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 1, S("a1de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 5, S("a12345de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 9, S("a123456789de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 10, S("a1234567890de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 11, S("a1234567890de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 19, 0, S("ade")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 19, 1, S("a0de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 19, 2, S("a0de")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 20, 0, S("ade")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 20, 1, S("ade")); + test(S("abcde"), 1, 2, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 1, 3, S(""), 0, 0, S("ae")); + test(S("abcde"), 1, 3, S(""), 0, 1, S("ae")); + test(S("abcde"), 1, 3, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 1, 3, S("12345"), 0, 0, S("ae")); + test(S("abcde"), 1, 3, S("12345"), 0, 1, S("a1e")); + test(S("abcde"), 1, 3, S("12345"), 0, 2, S("a12e")); + test(S("abcde"), 1, 3, S("12345"), 0, 4, S("a1234e")); + test(S("abcde"), 1, 3, S("12345"), 0, 5, S("a12345e")); + test(S("abcde"), 1, 3, S("12345"), 0, 6, S("a12345e")); + test(S("abcde"), 1, 3, S("12345"), 1, 0, S("ae")); + test(S("abcde"), 1, 3, S("12345"), 1, 1, S("a2e")); + test(S("abcde"), 1, 3, S("12345"), 1, 2, S("a23e")); +} + +template <class S> +void test9() +{ + test(S("abcde"), 1, 3, S("12345"), 1, 3, S("a234e")); + test(S("abcde"), 1, 3, S("12345"), 1, 4, S("a2345e")); + test(S("abcde"), 1, 3, S("12345"), 1, 5, S("a2345e")); + test(S("abcde"), 1, 3, S("12345"), 2, 0, S("ae")); + test(S("abcde"), 1, 3, S("12345"), 2, 1, S("a3e")); + test(S("abcde"), 1, 3, S("12345"), 2, 2, S("a34e")); + test(S("abcde"), 1, 3, S("12345"), 2, 3, S("a345e")); + test(S("abcde"), 1, 3, S("12345"), 2, 4, S("a345e")); + test(S("abcde"), 1, 3, S("12345"), 4, 0, S("ae")); + test(S("abcde"), 1, 3, S("12345"), 4, 1, S("a5e")); + test(S("abcde"), 1, 3, S("12345"), 4, 2, S("a5e")); + test(S("abcde"), 1, 3, S("12345"), 5, 0, S("ae")); + test(S("abcde"), 1, 3, S("12345"), 5, 1, S("ae")); + test(S("abcde"), 1, 3, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 1, 3, S("1234567890"), 0, 0, S("ae")); + test(S("abcde"), 1, 3, S("1234567890"), 0, 1, S("a1e")); + test(S("abcde"), 1, 3, S("1234567890"), 0, 5, S("a12345e")); + test(S("abcde"), 1, 3, S("1234567890"), 0, 9, S("a123456789e")); + test(S("abcde"), 1, 3, S("1234567890"), 0, 10, S("a1234567890e")); + test(S("abcde"), 1, 3, S("1234567890"), 0, 11, S("a1234567890e")); + test(S("abcde"), 1, 3, S("1234567890"), 1, 0, S("ae")); + test(S("abcde"), 1, 3, S("1234567890"), 1, 1, S("a2e")); + test(S("abcde"), 1, 3, S("1234567890"), 1, 4, S("a2345e")); + test(S("abcde"), 1, 3, S("1234567890"), 1, 8, S("a23456789e")); + test(S("abcde"), 1, 3, S("1234567890"), 1, 9, S("a234567890e")); + test(S("abcde"), 1, 3, S("1234567890"), 1, 10, S("a234567890e")); + test(S("abcde"), 1, 3, S("1234567890"), 5, 0, S("ae")); + test(S("abcde"), 1, 3, S("1234567890"), 5, 1, S("a6e")); + test(S("abcde"), 1, 3, S("1234567890"), 5, 2, S("a67e")); + test(S("abcde"), 1, 3, S("1234567890"), 5, 4, S("a6789e")); + test(S("abcde"), 1, 3, S("1234567890"), 5, 5, S("a67890e")); + test(S("abcde"), 1, 3, S("1234567890"), 5, 6, S("a67890e")); + test(S("abcde"), 1, 3, S("1234567890"), 9, 0, S("ae")); + test(S("abcde"), 1, 3, S("1234567890"), 9, 1, S("a0e")); + test(S("abcde"), 1, 3, S("1234567890"), 9, 2, S("a0e")); + test(S("abcde"), 1, 3, S("1234567890"), 10, 0, S("ae")); + test(S("abcde"), 1, 3, S("1234567890"), 10, 1, S("ae")); + test(S("abcde"), 1, 3, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 0, S("ae")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 1, S("a1e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 10, S("a1234567890e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 19, S("a1234567890123456789e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 20, S("a12345678901234567890e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 21, S("a12345678901234567890e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 0, S("ae")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 1, S("a2e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 9, S("a234567890e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 18, S("a234567890123456789e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 19, S("a2345678901234567890e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 20, S("a2345678901234567890e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 0, S("ae")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 1, S("a1e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 5, S("a12345e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 9, S("a123456789e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 10, S("a1234567890e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 11, S("a1234567890e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 19, 0, S("ae")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 19, 1, S("a0e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 19, 2, S("a0e")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 20, 0, S("ae")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 20, 1, S("ae")); + test(S("abcde"), 1, 3, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 1, 4, S(""), 0, 0, S("a")); + test(S("abcde"), 1, 4, S(""), 0, 1, S("a")); + test(S("abcde"), 1, 4, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 1, 4, S("12345"), 0, 0, S("a")); + test(S("abcde"), 1, 4, S("12345"), 0, 1, S("a1")); + test(S("abcde"), 1, 4, S("12345"), 0, 2, S("a12")); + test(S("abcde"), 1, 4, S("12345"), 0, 4, S("a1234")); + test(S("abcde"), 1, 4, S("12345"), 0, 5, S("a12345")); + test(S("abcde"), 1, 4, S("12345"), 0, 6, S("a12345")); + test(S("abcde"), 1, 4, S("12345"), 1, 0, S("a")); + test(S("abcde"), 1, 4, S("12345"), 1, 1, S("a2")); + test(S("abcde"), 1, 4, S("12345"), 1, 2, S("a23")); + test(S("abcde"), 1, 4, S("12345"), 1, 3, S("a234")); + test(S("abcde"), 1, 4, S("12345"), 1, 4, S("a2345")); + test(S("abcde"), 1, 4, S("12345"), 1, 5, S("a2345")); + test(S("abcde"), 1, 4, S("12345"), 2, 0, S("a")); + test(S("abcde"), 1, 4, S("12345"), 2, 1, S("a3")); + test(S("abcde"), 1, 4, S("12345"), 2, 2, S("a34")); + test(S("abcde"), 1, 4, S("12345"), 2, 3, S("a345")); + test(S("abcde"), 1, 4, S("12345"), 2, 4, S("a345")); + test(S("abcde"), 1, 4, S("12345"), 4, 0, S("a")); + test(S("abcde"), 1, 4, S("12345"), 4, 1, S("a5")); + test(S("abcde"), 1, 4, S("12345"), 4, 2, S("a5")); + test(S("abcde"), 1, 4, S("12345"), 5, 0, S("a")); + test(S("abcde"), 1, 4, S("12345"), 5, 1, S("a")); + test(S("abcde"), 1, 4, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 1, 4, S("1234567890"), 0, 0, S("a")); + test(S("abcde"), 1, 4, S("1234567890"), 0, 1, S("a1")); + test(S("abcde"), 1, 4, S("1234567890"), 0, 5, S("a12345")); + test(S("abcde"), 1, 4, S("1234567890"), 0, 9, S("a123456789")); + test(S("abcde"), 1, 4, S("1234567890"), 0, 10, S("a1234567890")); + test(S("abcde"), 1, 4, S("1234567890"), 0, 11, S("a1234567890")); + test(S("abcde"), 1, 4, S("1234567890"), 1, 0, S("a")); + test(S("abcde"), 1, 4, S("1234567890"), 1, 1, S("a2")); + test(S("abcde"), 1, 4, S("1234567890"), 1, 4, S("a2345")); + test(S("abcde"), 1, 4, S("1234567890"), 1, 8, S("a23456789")); + test(S("abcde"), 1, 4, S("1234567890"), 1, 9, S("a234567890")); + test(S("abcde"), 1, 4, S("1234567890"), 1, 10, S("a234567890")); +} + +template <class S> +void test10() +{ + test(S("abcde"), 1, 4, S("1234567890"), 5, 0, S("a")); + test(S("abcde"), 1, 4, S("1234567890"), 5, 1, S("a6")); + test(S("abcde"), 1, 4, S("1234567890"), 5, 2, S("a67")); + test(S("abcde"), 1, 4, S("1234567890"), 5, 4, S("a6789")); + test(S("abcde"), 1, 4, S("1234567890"), 5, 5, S("a67890")); + test(S("abcde"), 1, 4, S("1234567890"), 5, 6, S("a67890")); + test(S("abcde"), 1, 4, S("1234567890"), 9, 0, S("a")); + test(S("abcde"), 1, 4, S("1234567890"), 9, 1, S("a0")); + test(S("abcde"), 1, 4, S("1234567890"), 9, 2, S("a0")); + test(S("abcde"), 1, 4, S("1234567890"), 10, 0, S("a")); + test(S("abcde"), 1, 4, S("1234567890"), 10, 1, S("a")); + test(S("abcde"), 1, 4, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 0, S("a")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 1, S("a1")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 10, S("a1234567890")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 19, S("a1234567890123456789")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 20, S("a12345678901234567890")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 21, S("a12345678901234567890")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 0, S("a")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 1, S("a2")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 9, S("a234567890")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 18, S("a234567890123456789")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 19, S("a2345678901234567890")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 20, S("a2345678901234567890")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 0, S("a")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 1, S("a1")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 5, S("a12345")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 9, S("a123456789")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 10, S("a1234567890")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 11, S("a1234567890")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 19, 0, S("a")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 19, 1, S("a0")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 19, 2, S("a0")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 20, 0, S("a")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 20, 1, S("a")); + test(S("abcde"), 1, 4, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 1, 5, S(""), 0, 0, S("a")); + test(S("abcde"), 1, 5, S(""), 0, 1, S("a")); + test(S("abcde"), 1, 5, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 1, 5, S("12345"), 0, 0, S("a")); + test(S("abcde"), 1, 5, S("12345"), 0, 1, S("a1")); + test(S("abcde"), 1, 5, S("12345"), 0, 2, S("a12")); + test(S("abcde"), 1, 5, S("12345"), 0, 4, S("a1234")); + test(S("abcde"), 1, 5, S("12345"), 0, 5, S("a12345")); + test(S("abcde"), 1, 5, S("12345"), 0, 6, S("a12345")); + test(S("abcde"), 1, 5, S("12345"), 1, 0, S("a")); + test(S("abcde"), 1, 5, S("12345"), 1, 1, S("a2")); + test(S("abcde"), 1, 5, S("12345"), 1, 2, S("a23")); + test(S("abcde"), 1, 5, S("12345"), 1, 3, S("a234")); + test(S("abcde"), 1, 5, S("12345"), 1, 4, S("a2345")); + test(S("abcde"), 1, 5, S("12345"), 1, 5, S("a2345")); + test(S("abcde"), 1, 5, S("12345"), 2, 0, S("a")); + test(S("abcde"), 1, 5, S("12345"), 2, 1, S("a3")); + test(S("abcde"), 1, 5, S("12345"), 2, 2, S("a34")); + test(S("abcde"), 1, 5, S("12345"), 2, 3, S("a345")); + test(S("abcde"), 1, 5, S("12345"), 2, 4, S("a345")); + test(S("abcde"), 1, 5, S("12345"), 4, 0, S("a")); + test(S("abcde"), 1, 5, S("12345"), 4, 1, S("a5")); + test(S("abcde"), 1, 5, S("12345"), 4, 2, S("a5")); + test(S("abcde"), 1, 5, S("12345"), 5, 0, S("a")); + test(S("abcde"), 1, 5, S("12345"), 5, 1, S("a")); + test(S("abcde"), 1, 5, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 1, 5, S("1234567890"), 0, 0, S("a")); + test(S("abcde"), 1, 5, S("1234567890"), 0, 1, S("a1")); + test(S("abcde"), 1, 5, S("1234567890"), 0, 5, S("a12345")); + test(S("abcde"), 1, 5, S("1234567890"), 0, 9, S("a123456789")); + test(S("abcde"), 1, 5, S("1234567890"), 0, 10, S("a1234567890")); + test(S("abcde"), 1, 5, S("1234567890"), 0, 11, S("a1234567890")); + test(S("abcde"), 1, 5, S("1234567890"), 1, 0, S("a")); + test(S("abcde"), 1, 5, S("1234567890"), 1, 1, S("a2")); + test(S("abcde"), 1, 5, S("1234567890"), 1, 4, S("a2345")); + test(S("abcde"), 1, 5, S("1234567890"), 1, 8, S("a23456789")); + test(S("abcde"), 1, 5, S("1234567890"), 1, 9, S("a234567890")); + test(S("abcde"), 1, 5, S("1234567890"), 1, 10, S("a234567890")); + test(S("abcde"), 1, 5, S("1234567890"), 5, 0, S("a")); + test(S("abcde"), 1, 5, S("1234567890"), 5, 1, S("a6")); + test(S("abcde"), 1, 5, S("1234567890"), 5, 2, S("a67")); + test(S("abcde"), 1, 5, S("1234567890"), 5, 4, S("a6789")); + test(S("abcde"), 1, 5, S("1234567890"), 5, 5, S("a67890")); + test(S("abcde"), 1, 5, S("1234567890"), 5, 6, S("a67890")); + test(S("abcde"), 1, 5, S("1234567890"), 9, 0, S("a")); + test(S("abcde"), 1, 5, S("1234567890"), 9, 1, S("a0")); + test(S("abcde"), 1, 5, S("1234567890"), 9, 2, S("a0")); + test(S("abcde"), 1, 5, S("1234567890"), 10, 0, S("a")); + test(S("abcde"), 1, 5, S("1234567890"), 10, 1, S("a")); + test(S("abcde"), 1, 5, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 0, S("a")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 1, S("a1")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 10, S("a1234567890")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 19, S("a1234567890123456789")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 20, S("a12345678901234567890")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 21, S("a12345678901234567890")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 0, S("a")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 1, S("a2")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 9, S("a234567890")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 18, S("a234567890123456789")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 19, S("a2345678901234567890")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 20, S("a2345678901234567890")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 0, S("a")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 1, S("a1")); +} + +template <class S> +void test11() +{ + test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 5, S("a12345")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 9, S("a123456789")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 10, S("a1234567890")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 11, S("a1234567890")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 19, 0, S("a")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 19, 1, S("a0")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 19, 2, S("a0")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 20, 0, S("a")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 20, 1, S("a")); + test(S("abcde"), 1, 5, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 2, 0, S(""), 0, 0, S("abcde")); + test(S("abcde"), 2, 0, S(""), 0, 1, S("abcde")); + test(S("abcde"), 2, 0, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 2, 0, S("12345"), 0, 0, S("abcde")); + test(S("abcde"), 2, 0, S("12345"), 0, 1, S("ab1cde")); + test(S("abcde"), 2, 0, S("12345"), 0, 2, S("ab12cde")); + test(S("abcde"), 2, 0, S("12345"), 0, 4, S("ab1234cde")); + test(S("abcde"), 2, 0, S("12345"), 0, 5, S("ab12345cde")); + test(S("abcde"), 2, 0, S("12345"), 0, 6, S("ab12345cde")); + test(S("abcde"), 2, 0, S("12345"), 1, 0, S("abcde")); + test(S("abcde"), 2, 0, S("12345"), 1, 1, S("ab2cde")); + test(S("abcde"), 2, 0, S("12345"), 1, 2, S("ab23cde")); + test(S("abcde"), 2, 0, S("12345"), 1, 3, S("ab234cde")); + test(S("abcde"), 2, 0, S("12345"), 1, 4, S("ab2345cde")); + test(S("abcde"), 2, 0, S("12345"), 1, 5, S("ab2345cde")); + test(S("abcde"), 2, 0, S("12345"), 2, 0, S("abcde")); + test(S("abcde"), 2, 0, S("12345"), 2, 1, S("ab3cde")); + test(S("abcde"), 2, 0, S("12345"), 2, 2, S("ab34cde")); + test(S("abcde"), 2, 0, S("12345"), 2, 3, S("ab345cde")); + test(S("abcde"), 2, 0, S("12345"), 2, 4, S("ab345cde")); + test(S("abcde"), 2, 0, S("12345"), 4, 0, S("abcde")); + test(S("abcde"), 2, 0, S("12345"), 4, 1, S("ab5cde")); + test(S("abcde"), 2, 0, S("12345"), 4, 2, S("ab5cde")); + test(S("abcde"), 2, 0, S("12345"), 5, 0, S("abcde")); + test(S("abcde"), 2, 0, S("12345"), 5, 1, S("abcde")); + test(S("abcde"), 2, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 2, 0, S("1234567890"), 0, 0, S("abcde")); + test(S("abcde"), 2, 0, S("1234567890"), 0, 1, S("ab1cde")); + test(S("abcde"), 2, 0, S("1234567890"), 0, 5, S("ab12345cde")); + test(S("abcde"), 2, 0, S("1234567890"), 0, 9, S("ab123456789cde")); + test(S("abcde"), 2, 0, S("1234567890"), 0, 10, S("ab1234567890cde")); + test(S("abcde"), 2, 0, S("1234567890"), 0, 11, S("ab1234567890cde")); + test(S("abcde"), 2, 0, S("1234567890"), 1, 0, S("abcde")); + test(S("abcde"), 2, 0, S("1234567890"), 1, 1, S("ab2cde")); + test(S("abcde"), 2, 0, S("1234567890"), 1, 4, S("ab2345cde")); + test(S("abcde"), 2, 0, S("1234567890"), 1, 8, S("ab23456789cde")); + test(S("abcde"), 2, 0, S("1234567890"), 1, 9, S("ab234567890cde")); + test(S("abcde"), 2, 0, S("1234567890"), 1, 10, S("ab234567890cde")); + test(S("abcde"), 2, 0, S("1234567890"), 5, 0, S("abcde")); + test(S("abcde"), 2, 0, S("1234567890"), 5, 1, S("ab6cde")); + test(S("abcde"), 2, 0, S("1234567890"), 5, 2, S("ab67cde")); + test(S("abcde"), 2, 0, S("1234567890"), 5, 4, S("ab6789cde")); + test(S("abcde"), 2, 0, S("1234567890"), 5, 5, S("ab67890cde")); + test(S("abcde"), 2, 0, S("1234567890"), 5, 6, S("ab67890cde")); + test(S("abcde"), 2, 0, S("1234567890"), 9, 0, S("abcde")); + test(S("abcde"), 2, 0, S("1234567890"), 9, 1, S("ab0cde")); + test(S("abcde"), 2, 0, S("1234567890"), 9, 2, S("ab0cde")); + test(S("abcde"), 2, 0, S("1234567890"), 10, 0, S("abcde")); + test(S("abcde"), 2, 0, S("1234567890"), 10, 1, S("abcde")); + test(S("abcde"), 2, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 0, S("abcde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 1, S("ab1cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 10, S("ab1234567890cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 19, S("ab1234567890123456789cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 20, S("ab12345678901234567890cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 21, S("ab12345678901234567890cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 0, S("abcde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 1, S("ab2cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 9, S("ab234567890cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 18, S("ab234567890123456789cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 19, S("ab2345678901234567890cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 20, S("ab2345678901234567890cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 0, S("abcde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 1, S("ab1cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 5, S("ab12345cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 9, S("ab123456789cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 10, S("ab1234567890cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 11, S("ab1234567890cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 19, 0, S("abcde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 19, 1, S("ab0cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 19, 2, S("ab0cde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 20, 0, S("abcde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 20, 1, S("abcde")); + test(S("abcde"), 2, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 2, 1, S(""), 0, 0, S("abde")); + test(S("abcde"), 2, 1, S(""), 0, 1, S("abde")); + test(S("abcde"), 2, 1, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 2, 1, S("12345"), 0, 0, S("abde")); + test(S("abcde"), 2, 1, S("12345"), 0, 1, S("ab1de")); + test(S("abcde"), 2, 1, S("12345"), 0, 2, S("ab12de")); + test(S("abcde"), 2, 1, S("12345"), 0, 4, S("ab1234de")); + test(S("abcde"), 2, 1, S("12345"), 0, 5, S("ab12345de")); + test(S("abcde"), 2, 1, S("12345"), 0, 6, S("ab12345de")); + test(S("abcde"), 2, 1, S("12345"), 1, 0, S("abde")); + test(S("abcde"), 2, 1, S("12345"), 1, 1, S("ab2de")); + test(S("abcde"), 2, 1, S("12345"), 1, 2, S("ab23de")); + test(S("abcde"), 2, 1, S("12345"), 1, 3, S("ab234de")); + test(S("abcde"), 2, 1, S("12345"), 1, 4, S("ab2345de")); + test(S("abcde"), 2, 1, S("12345"), 1, 5, S("ab2345de")); + test(S("abcde"), 2, 1, S("12345"), 2, 0, S("abde")); +} + +template <class S> +void test12() +{ + test(S("abcde"), 2, 1, S("12345"), 2, 1, S("ab3de")); + test(S("abcde"), 2, 1, S("12345"), 2, 2, S("ab34de")); + test(S("abcde"), 2, 1, S("12345"), 2, 3, S("ab345de")); + test(S("abcde"), 2, 1, S("12345"), 2, 4, S("ab345de")); + test(S("abcde"), 2, 1, S("12345"), 4, 0, S("abde")); + test(S("abcde"), 2, 1, S("12345"), 4, 1, S("ab5de")); + test(S("abcde"), 2, 1, S("12345"), 4, 2, S("ab5de")); + test(S("abcde"), 2, 1, S("12345"), 5, 0, S("abde")); + test(S("abcde"), 2, 1, S("12345"), 5, 1, S("abde")); + test(S("abcde"), 2, 1, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 2, 1, S("1234567890"), 0, 0, S("abde")); + test(S("abcde"), 2, 1, S("1234567890"), 0, 1, S("ab1de")); + test(S("abcde"), 2, 1, S("1234567890"), 0, 5, S("ab12345de")); + test(S("abcde"), 2, 1, S("1234567890"), 0, 9, S("ab123456789de")); + test(S("abcde"), 2, 1, S("1234567890"), 0, 10, S("ab1234567890de")); + test(S("abcde"), 2, 1, S("1234567890"), 0, 11, S("ab1234567890de")); + test(S("abcde"), 2, 1, S("1234567890"), 1, 0, S("abde")); + test(S("abcde"), 2, 1, S("1234567890"), 1, 1, S("ab2de")); + test(S("abcde"), 2, 1, S("1234567890"), 1, 4, S("ab2345de")); + test(S("abcde"), 2, 1, S("1234567890"), 1, 8, S("ab23456789de")); + test(S("abcde"), 2, 1, S("1234567890"), 1, 9, S("ab234567890de")); + test(S("abcde"), 2, 1, S("1234567890"), 1, 10, S("ab234567890de")); + test(S("abcde"), 2, 1, S("1234567890"), 5, 0, S("abde")); + test(S("abcde"), 2, 1, S("1234567890"), 5, 1, S("ab6de")); + test(S("abcde"), 2, 1, S("1234567890"), 5, 2, S("ab67de")); + test(S("abcde"), 2, 1, S("1234567890"), 5, 4, S("ab6789de")); + test(S("abcde"), 2, 1, S("1234567890"), 5, 5, S("ab67890de")); + test(S("abcde"), 2, 1, S("1234567890"), 5, 6, S("ab67890de")); + test(S("abcde"), 2, 1, S("1234567890"), 9, 0, S("abde")); + test(S("abcde"), 2, 1, S("1234567890"), 9, 1, S("ab0de")); + test(S("abcde"), 2, 1, S("1234567890"), 9, 2, S("ab0de")); + test(S("abcde"), 2, 1, S("1234567890"), 10, 0, S("abde")); + test(S("abcde"), 2, 1, S("1234567890"), 10, 1, S("abde")); + test(S("abcde"), 2, 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 0, S("abde")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 1, S("ab1de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 10, S("ab1234567890de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 19, S("ab1234567890123456789de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 20, S("ab12345678901234567890de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 21, S("ab12345678901234567890de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 0, S("abde")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 1, S("ab2de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 9, S("ab234567890de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 18, S("ab234567890123456789de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 19, S("ab2345678901234567890de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 20, S("ab2345678901234567890de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 0, S("abde")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 1, S("ab1de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 5, S("ab12345de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 9, S("ab123456789de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 10, S("ab1234567890de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 11, S("ab1234567890de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 19, 0, S("abde")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 19, 1, S("ab0de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 19, 2, S("ab0de")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 20, 0, S("abde")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 20, 1, S("abde")); + test(S("abcde"), 2, 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 2, 2, S(""), 0, 0, S("abe")); + test(S("abcde"), 2, 2, S(""), 0, 1, S("abe")); + test(S("abcde"), 2, 2, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 2, 2, S("12345"), 0, 0, S("abe")); + test(S("abcde"), 2, 2, S("12345"), 0, 1, S("ab1e")); + test(S("abcde"), 2, 2, S("12345"), 0, 2, S("ab12e")); + test(S("abcde"), 2, 2, S("12345"), 0, 4, S("ab1234e")); + test(S("abcde"), 2, 2, S("12345"), 0, 5, S("ab12345e")); + test(S("abcde"), 2, 2, S("12345"), 0, 6, S("ab12345e")); + test(S("abcde"), 2, 2, S("12345"), 1, 0, S("abe")); + test(S("abcde"), 2, 2, S("12345"), 1, 1, S("ab2e")); + test(S("abcde"), 2, 2, S("12345"), 1, 2, S("ab23e")); + test(S("abcde"), 2, 2, S("12345"), 1, 3, S("ab234e")); + test(S("abcde"), 2, 2, S("12345"), 1, 4, S("ab2345e")); + test(S("abcde"), 2, 2, S("12345"), 1, 5, S("ab2345e")); + test(S("abcde"), 2, 2, S("12345"), 2, 0, S("abe")); + test(S("abcde"), 2, 2, S("12345"), 2, 1, S("ab3e")); + test(S("abcde"), 2, 2, S("12345"), 2, 2, S("ab34e")); + test(S("abcde"), 2, 2, S("12345"), 2, 3, S("ab345e")); + test(S("abcde"), 2, 2, S("12345"), 2, 4, S("ab345e")); + test(S("abcde"), 2, 2, S("12345"), 4, 0, S("abe")); + test(S("abcde"), 2, 2, S("12345"), 4, 1, S("ab5e")); + test(S("abcde"), 2, 2, S("12345"), 4, 2, S("ab5e")); + test(S("abcde"), 2, 2, S("12345"), 5, 0, S("abe")); + test(S("abcde"), 2, 2, S("12345"), 5, 1, S("abe")); + test(S("abcde"), 2, 2, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 2, 2, S("1234567890"), 0, 0, S("abe")); + test(S("abcde"), 2, 2, S("1234567890"), 0, 1, S("ab1e")); + test(S("abcde"), 2, 2, S("1234567890"), 0, 5, S("ab12345e")); + test(S("abcde"), 2, 2, S("1234567890"), 0, 9, S("ab123456789e")); + test(S("abcde"), 2, 2, S("1234567890"), 0, 10, S("ab1234567890e")); + test(S("abcde"), 2, 2, S("1234567890"), 0, 11, S("ab1234567890e")); + test(S("abcde"), 2, 2, S("1234567890"), 1, 0, S("abe")); + test(S("abcde"), 2, 2, S("1234567890"), 1, 1, S("ab2e")); + test(S("abcde"), 2, 2, S("1234567890"), 1, 4, S("ab2345e")); + test(S("abcde"), 2, 2, S("1234567890"), 1, 8, S("ab23456789e")); + test(S("abcde"), 2, 2, S("1234567890"), 1, 9, S("ab234567890e")); + test(S("abcde"), 2, 2, S("1234567890"), 1, 10, S("ab234567890e")); + test(S("abcde"), 2, 2, S("1234567890"), 5, 0, S("abe")); + test(S("abcde"), 2, 2, S("1234567890"), 5, 1, S("ab6e")); + test(S("abcde"), 2, 2, S("1234567890"), 5, 2, S("ab67e")); + test(S("abcde"), 2, 2, S("1234567890"), 5, 4, S("ab6789e")); +} + +template <class S> +void test13() +{ + test(S("abcde"), 2, 2, S("1234567890"), 5, 5, S("ab67890e")); + test(S("abcde"), 2, 2, S("1234567890"), 5, 6, S("ab67890e")); + test(S("abcde"), 2, 2, S("1234567890"), 9, 0, S("abe")); + test(S("abcde"), 2, 2, S("1234567890"), 9, 1, S("ab0e")); + test(S("abcde"), 2, 2, S("1234567890"), 9, 2, S("ab0e")); + test(S("abcde"), 2, 2, S("1234567890"), 10, 0, S("abe")); + test(S("abcde"), 2, 2, S("1234567890"), 10, 1, S("abe")); + test(S("abcde"), 2, 2, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 0, S("abe")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 1, S("ab1e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 10, S("ab1234567890e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 19, S("ab1234567890123456789e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 20, S("ab12345678901234567890e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 21, S("ab12345678901234567890e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 0, S("abe")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 1, S("ab2e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 9, S("ab234567890e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 18, S("ab234567890123456789e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 19, S("ab2345678901234567890e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 20, S("ab2345678901234567890e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 0, S("abe")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 1, S("ab1e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 5, S("ab12345e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 9, S("ab123456789e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 10, S("ab1234567890e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 11, S("ab1234567890e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 19, 0, S("abe")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 19, 1, S("ab0e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 19, 2, S("ab0e")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 20, 0, S("abe")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 20, 1, S("abe")); + test(S("abcde"), 2, 2, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 2, 3, S(""), 0, 0, S("ab")); + test(S("abcde"), 2, 3, S(""), 0, 1, S("ab")); + test(S("abcde"), 2, 3, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 2, 3, S("12345"), 0, 0, S("ab")); + test(S("abcde"), 2, 3, S("12345"), 0, 1, S("ab1")); + test(S("abcde"), 2, 3, S("12345"), 0, 2, S("ab12")); + test(S("abcde"), 2, 3, S("12345"), 0, 4, S("ab1234")); + test(S("abcde"), 2, 3, S("12345"), 0, 5, S("ab12345")); + test(S("abcde"), 2, 3, S("12345"), 0, 6, S("ab12345")); + test(S("abcde"), 2, 3, S("12345"), 1, 0, S("ab")); + test(S("abcde"), 2, 3, S("12345"), 1, 1, S("ab2")); + test(S("abcde"), 2, 3, S("12345"), 1, 2, S("ab23")); + test(S("abcde"), 2, 3, S("12345"), 1, 3, S("ab234")); + test(S("abcde"), 2, 3, S("12345"), 1, 4, S("ab2345")); + test(S("abcde"), 2, 3, S("12345"), 1, 5, S("ab2345")); + test(S("abcde"), 2, 3, S("12345"), 2, 0, S("ab")); + test(S("abcde"), 2, 3, S("12345"), 2, 1, S("ab3")); + test(S("abcde"), 2, 3, S("12345"), 2, 2, S("ab34")); + test(S("abcde"), 2, 3, S("12345"), 2, 3, S("ab345")); + test(S("abcde"), 2, 3, S("12345"), 2, 4, S("ab345")); + test(S("abcde"), 2, 3, S("12345"), 4, 0, S("ab")); + test(S("abcde"), 2, 3, S("12345"), 4, 1, S("ab5")); + test(S("abcde"), 2, 3, S("12345"), 4, 2, S("ab5")); + test(S("abcde"), 2, 3, S("12345"), 5, 0, S("ab")); + test(S("abcde"), 2, 3, S("12345"), 5, 1, S("ab")); + test(S("abcde"), 2, 3, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 2, 3, S("1234567890"), 0, 0, S("ab")); + test(S("abcde"), 2, 3, S("1234567890"), 0, 1, S("ab1")); + test(S("abcde"), 2, 3, S("1234567890"), 0, 5, S("ab12345")); + test(S("abcde"), 2, 3, S("1234567890"), 0, 9, S("ab123456789")); + test(S("abcde"), 2, 3, S("1234567890"), 0, 10, S("ab1234567890")); + test(S("abcde"), 2, 3, S("1234567890"), 0, 11, S("ab1234567890")); + test(S("abcde"), 2, 3, S("1234567890"), 1, 0, S("ab")); + test(S("abcde"), 2, 3, S("1234567890"), 1, 1, S("ab2")); + test(S("abcde"), 2, 3, S("1234567890"), 1, 4, S("ab2345")); + test(S("abcde"), 2, 3, S("1234567890"), 1, 8, S("ab23456789")); + test(S("abcde"), 2, 3, S("1234567890"), 1, 9, S("ab234567890")); + test(S("abcde"), 2, 3, S("1234567890"), 1, 10, S("ab234567890")); + test(S("abcde"), 2, 3, S("1234567890"), 5, 0, S("ab")); + test(S("abcde"), 2, 3, S("1234567890"), 5, 1, S("ab6")); + test(S("abcde"), 2, 3, S("1234567890"), 5, 2, S("ab67")); + test(S("abcde"), 2, 3, S("1234567890"), 5, 4, S("ab6789")); + test(S("abcde"), 2, 3, S("1234567890"), 5, 5, S("ab67890")); + test(S("abcde"), 2, 3, S("1234567890"), 5, 6, S("ab67890")); + test(S("abcde"), 2, 3, S("1234567890"), 9, 0, S("ab")); + test(S("abcde"), 2, 3, S("1234567890"), 9, 1, S("ab0")); + test(S("abcde"), 2, 3, S("1234567890"), 9, 2, S("ab0")); + test(S("abcde"), 2, 3, S("1234567890"), 10, 0, S("ab")); + test(S("abcde"), 2, 3, S("1234567890"), 10, 1, S("ab")); + test(S("abcde"), 2, 3, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 0, S("ab")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 1, S("ab1")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 10, S("ab1234567890")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 19, S("ab1234567890123456789")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 20, S("ab12345678901234567890")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 21, S("ab12345678901234567890")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 0, S("ab")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 1, S("ab2")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 9, S("ab234567890")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 18, S("ab234567890123456789")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 19, S("ab2345678901234567890")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 20, S("ab2345678901234567890")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 0, S("ab")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 1, S("ab1")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 5, S("ab12345")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 9, S("ab123456789")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 10, S("ab1234567890")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 11, S("ab1234567890")); +} + +template <class S> +void test14() +{ + test(S("abcde"), 2, 3, S("12345678901234567890"), 19, 0, S("ab")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 19, 1, S("ab0")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 19, 2, S("ab0")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 20, 0, S("ab")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 20, 1, S("ab")); + test(S("abcde"), 2, 3, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 2, 4, S(""), 0, 0, S("ab")); + test(S("abcde"), 2, 4, S(""), 0, 1, S("ab")); + test(S("abcde"), 2, 4, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 2, 4, S("12345"), 0, 0, S("ab")); + test(S("abcde"), 2, 4, S("12345"), 0, 1, S("ab1")); + test(S("abcde"), 2, 4, S("12345"), 0, 2, S("ab12")); + test(S("abcde"), 2, 4, S("12345"), 0, 4, S("ab1234")); + test(S("abcde"), 2, 4, S("12345"), 0, 5, S("ab12345")); + test(S("abcde"), 2, 4, S("12345"), 0, 6, S("ab12345")); + test(S("abcde"), 2, 4, S("12345"), 1, 0, S("ab")); + test(S("abcde"), 2, 4, S("12345"), 1, 1, S("ab2")); + test(S("abcde"), 2, 4, S("12345"), 1, 2, S("ab23")); + test(S("abcde"), 2, 4, S("12345"), 1, 3, S("ab234")); + test(S("abcde"), 2, 4, S("12345"), 1, 4, S("ab2345")); + test(S("abcde"), 2, 4, S("12345"), 1, 5, S("ab2345")); + test(S("abcde"), 2, 4, S("12345"), 2, 0, S("ab")); + test(S("abcde"), 2, 4, S("12345"), 2, 1, S("ab3")); + test(S("abcde"), 2, 4, S("12345"), 2, 2, S("ab34")); + test(S("abcde"), 2, 4, S("12345"), 2, 3, S("ab345")); + test(S("abcde"), 2, 4, S("12345"), 2, 4, S("ab345")); + test(S("abcde"), 2, 4, S("12345"), 4, 0, S("ab")); + test(S("abcde"), 2, 4, S("12345"), 4, 1, S("ab5")); + test(S("abcde"), 2, 4, S("12345"), 4, 2, S("ab5")); + test(S("abcde"), 2, 4, S("12345"), 5, 0, S("ab")); + test(S("abcde"), 2, 4, S("12345"), 5, 1, S("ab")); + test(S("abcde"), 2, 4, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 2, 4, S("1234567890"), 0, 0, S("ab")); + test(S("abcde"), 2, 4, S("1234567890"), 0, 1, S("ab1")); + test(S("abcde"), 2, 4, S("1234567890"), 0, 5, S("ab12345")); + test(S("abcde"), 2, 4, S("1234567890"), 0, 9, S("ab123456789")); + test(S("abcde"), 2, 4, S("1234567890"), 0, 10, S("ab1234567890")); + test(S("abcde"), 2, 4, S("1234567890"), 0, 11, S("ab1234567890")); + test(S("abcde"), 2, 4, S("1234567890"), 1, 0, S("ab")); + test(S("abcde"), 2, 4, S("1234567890"), 1, 1, S("ab2")); + test(S("abcde"), 2, 4, S("1234567890"), 1, 4, S("ab2345")); + test(S("abcde"), 2, 4, S("1234567890"), 1, 8, S("ab23456789")); + test(S("abcde"), 2, 4, S("1234567890"), 1, 9, S("ab234567890")); + test(S("abcde"), 2, 4, S("1234567890"), 1, 10, S("ab234567890")); + test(S("abcde"), 2, 4, S("1234567890"), 5, 0, S("ab")); + test(S("abcde"), 2, 4, S("1234567890"), 5, 1, S("ab6")); + test(S("abcde"), 2, 4, S("1234567890"), 5, 2, S("ab67")); + test(S("abcde"), 2, 4, S("1234567890"), 5, 4, S("ab6789")); + test(S("abcde"), 2, 4, S("1234567890"), 5, 5, S("ab67890")); + test(S("abcde"), 2, 4, S("1234567890"), 5, 6, S("ab67890")); + test(S("abcde"), 2, 4, S("1234567890"), 9, 0, S("ab")); + test(S("abcde"), 2, 4, S("1234567890"), 9, 1, S("ab0")); + test(S("abcde"), 2, 4, S("1234567890"), 9, 2, S("ab0")); + test(S("abcde"), 2, 4, S("1234567890"), 10, 0, S("ab")); + test(S("abcde"), 2, 4, S("1234567890"), 10, 1, S("ab")); + test(S("abcde"), 2, 4, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 0, S("ab")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 1, S("ab1")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 10, S("ab1234567890")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 19, S("ab1234567890123456789")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 20, S("ab12345678901234567890")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 21, S("ab12345678901234567890")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 0, S("ab")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 1, S("ab2")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 9, S("ab234567890")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 18, S("ab234567890123456789")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 19, S("ab2345678901234567890")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 20, S("ab2345678901234567890")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 0, S("ab")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 1, S("ab1")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 5, S("ab12345")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 9, S("ab123456789")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 10, S("ab1234567890")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 11, S("ab1234567890")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 19, 0, S("ab")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 19, 1, S("ab0")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 19, 2, S("ab0")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 20, 0, S("ab")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 20, 1, S("ab")); + test(S("abcde"), 2, 4, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 4, 0, S(""), 0, 0, S("abcde")); + test(S("abcde"), 4, 0, S(""), 0, 1, S("abcde")); + test(S("abcde"), 4, 0, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 4, 0, S("12345"), 0, 0, S("abcde")); + test(S("abcde"), 4, 0, S("12345"), 0, 1, S("abcd1e")); + test(S("abcde"), 4, 0, S("12345"), 0, 2, S("abcd12e")); + test(S("abcde"), 4, 0, S("12345"), 0, 4, S("abcd1234e")); + test(S("abcde"), 4, 0, S("12345"), 0, 5, S("abcd12345e")); + test(S("abcde"), 4, 0, S("12345"), 0, 6, S("abcd12345e")); + test(S("abcde"), 4, 0, S("12345"), 1, 0, S("abcde")); + test(S("abcde"), 4, 0, S("12345"), 1, 1, S("abcd2e")); + test(S("abcde"), 4, 0, S("12345"), 1, 2, S("abcd23e")); + test(S("abcde"), 4, 0, S("12345"), 1, 3, S("abcd234e")); + test(S("abcde"), 4, 0, S("12345"), 1, 4, S("abcd2345e")); + test(S("abcde"), 4, 0, S("12345"), 1, 5, S("abcd2345e")); + test(S("abcde"), 4, 0, S("12345"), 2, 0, S("abcde")); + test(S("abcde"), 4, 0, S("12345"), 2, 1, S("abcd3e")); + test(S("abcde"), 4, 0, S("12345"), 2, 2, S("abcd34e")); + test(S("abcde"), 4, 0, S("12345"), 2, 3, S("abcd345e")); + test(S("abcde"), 4, 0, S("12345"), 2, 4, S("abcd345e")); +} + +template <class S> +void test15() +{ + test(S("abcde"), 4, 0, S("12345"), 4, 0, S("abcde")); + test(S("abcde"), 4, 0, S("12345"), 4, 1, S("abcd5e")); + test(S("abcde"), 4, 0, S("12345"), 4, 2, S("abcd5e")); + test(S("abcde"), 4, 0, S("12345"), 5, 0, S("abcde")); + test(S("abcde"), 4, 0, S("12345"), 5, 1, S("abcde")); + test(S("abcde"), 4, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 4, 0, S("1234567890"), 0, 0, S("abcde")); + test(S("abcde"), 4, 0, S("1234567890"), 0, 1, S("abcd1e")); + test(S("abcde"), 4, 0, S("1234567890"), 0, 5, S("abcd12345e")); + test(S("abcde"), 4, 0, S("1234567890"), 0, 9, S("abcd123456789e")); + test(S("abcde"), 4, 0, S("1234567890"), 0, 10, S("abcd1234567890e")); + test(S("abcde"), 4, 0, S("1234567890"), 0, 11, S("abcd1234567890e")); + test(S("abcde"), 4, 0, S("1234567890"), 1, 0, S("abcde")); + test(S("abcde"), 4, 0, S("1234567890"), 1, 1, S("abcd2e")); + test(S("abcde"), 4, 0, S("1234567890"), 1, 4, S("abcd2345e")); + test(S("abcde"), 4, 0, S("1234567890"), 1, 8, S("abcd23456789e")); + test(S("abcde"), 4, 0, S("1234567890"), 1, 9, S("abcd234567890e")); + test(S("abcde"), 4, 0, S("1234567890"), 1, 10, S("abcd234567890e")); + test(S("abcde"), 4, 0, S("1234567890"), 5, 0, S("abcde")); + test(S("abcde"), 4, 0, S("1234567890"), 5, 1, S("abcd6e")); + test(S("abcde"), 4, 0, S("1234567890"), 5, 2, S("abcd67e")); + test(S("abcde"), 4, 0, S("1234567890"), 5, 4, S("abcd6789e")); + test(S("abcde"), 4, 0, S("1234567890"), 5, 5, S("abcd67890e")); + test(S("abcde"), 4, 0, S("1234567890"), 5, 6, S("abcd67890e")); + test(S("abcde"), 4, 0, S("1234567890"), 9, 0, S("abcde")); + test(S("abcde"), 4, 0, S("1234567890"), 9, 1, S("abcd0e")); + test(S("abcde"), 4, 0, S("1234567890"), 9, 2, S("abcd0e")); + test(S("abcde"), 4, 0, S("1234567890"), 10, 0, S("abcde")); + test(S("abcde"), 4, 0, S("1234567890"), 10, 1, S("abcde")); + test(S("abcde"), 4, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 0, S("abcde")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 1, S("abcd1e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 10, S("abcd1234567890e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 0, S("abcde")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 1, S("abcd2e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 9, S("abcd234567890e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 18, S("abcd234567890123456789e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 0, S("abcde")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 1, S("abcd1e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 5, S("abcd12345e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 9, S("abcd123456789e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 10, S("abcd1234567890e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 11, S("abcd1234567890e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 19, 0, S("abcde")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 19, 1, S("abcd0e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 19, 2, S("abcd0e")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 20, 0, S("abcde")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 20, 1, S("abcde")); + test(S("abcde"), 4, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 4, 1, S(""), 0, 0, S("abcd")); + test(S("abcde"), 4, 1, S(""), 0, 1, S("abcd")); + test(S("abcde"), 4, 1, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 4, 1, S("12345"), 0, 0, S("abcd")); + test(S("abcde"), 4, 1, S("12345"), 0, 1, S("abcd1")); + test(S("abcde"), 4, 1, S("12345"), 0, 2, S("abcd12")); + test(S("abcde"), 4, 1, S("12345"), 0, 4, S("abcd1234")); + test(S("abcde"), 4, 1, S("12345"), 0, 5, S("abcd12345")); + test(S("abcde"), 4, 1, S("12345"), 0, 6, S("abcd12345")); + test(S("abcde"), 4, 1, S("12345"), 1, 0, S("abcd")); + test(S("abcde"), 4, 1, S("12345"), 1, 1, S("abcd2")); + test(S("abcde"), 4, 1, S("12345"), 1, 2, S("abcd23")); + test(S("abcde"), 4, 1, S("12345"), 1, 3, S("abcd234")); + test(S("abcde"), 4, 1, S("12345"), 1, 4, S("abcd2345")); + test(S("abcde"), 4, 1, S("12345"), 1, 5, S("abcd2345")); + test(S("abcde"), 4, 1, S("12345"), 2, 0, S("abcd")); + test(S("abcde"), 4, 1, S("12345"), 2, 1, S("abcd3")); + test(S("abcde"), 4, 1, S("12345"), 2, 2, S("abcd34")); + test(S("abcde"), 4, 1, S("12345"), 2, 3, S("abcd345")); + test(S("abcde"), 4, 1, S("12345"), 2, 4, S("abcd345")); + test(S("abcde"), 4, 1, S("12345"), 4, 0, S("abcd")); + test(S("abcde"), 4, 1, S("12345"), 4, 1, S("abcd5")); + test(S("abcde"), 4, 1, S("12345"), 4, 2, S("abcd5")); + test(S("abcde"), 4, 1, S("12345"), 5, 0, S("abcd")); + test(S("abcde"), 4, 1, S("12345"), 5, 1, S("abcd")); + test(S("abcde"), 4, 1, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 4, 1, S("1234567890"), 0, 0, S("abcd")); + test(S("abcde"), 4, 1, S("1234567890"), 0, 1, S("abcd1")); + test(S("abcde"), 4, 1, S("1234567890"), 0, 5, S("abcd12345")); + test(S("abcde"), 4, 1, S("1234567890"), 0, 9, S("abcd123456789")); + test(S("abcde"), 4, 1, S("1234567890"), 0, 10, S("abcd1234567890")); + test(S("abcde"), 4, 1, S("1234567890"), 0, 11, S("abcd1234567890")); + test(S("abcde"), 4, 1, S("1234567890"), 1, 0, S("abcd")); + test(S("abcde"), 4, 1, S("1234567890"), 1, 1, S("abcd2")); + test(S("abcde"), 4, 1, S("1234567890"), 1, 4, S("abcd2345")); + test(S("abcde"), 4, 1, S("1234567890"), 1, 8, S("abcd23456789")); + test(S("abcde"), 4, 1, S("1234567890"), 1, 9, S("abcd234567890")); + test(S("abcde"), 4, 1, S("1234567890"), 1, 10, S("abcd234567890")); + test(S("abcde"), 4, 1, S("1234567890"), 5, 0, S("abcd")); + test(S("abcde"), 4, 1, S("1234567890"), 5, 1, S("abcd6")); + test(S("abcde"), 4, 1, S("1234567890"), 5, 2, S("abcd67")); + test(S("abcde"), 4, 1, S("1234567890"), 5, 4, S("abcd6789")); + test(S("abcde"), 4, 1, S("1234567890"), 5, 5, S("abcd67890")); + test(S("abcde"), 4, 1, S("1234567890"), 5, 6, S("abcd67890")); + test(S("abcde"), 4, 1, S("1234567890"), 9, 0, S("abcd")); + test(S("abcde"), 4, 1, S("1234567890"), 9, 1, S("abcd0")); +} + +template <class S> +void test16() +{ + test(S("abcde"), 4, 1, S("1234567890"), 9, 2, S("abcd0")); + test(S("abcde"), 4, 1, S("1234567890"), 10, 0, S("abcd")); + test(S("abcde"), 4, 1, S("1234567890"), 10, 1, S("abcd")); + test(S("abcde"), 4, 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 0, S("abcd")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 1, S("abcd1")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 10, S("abcd1234567890")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 0, S("abcd")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 1, S("abcd2")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 9, S("abcd234567890")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 18, S("abcd234567890123456789")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 0, S("abcd")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 1, S("abcd1")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 5, S("abcd12345")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 9, S("abcd123456789")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 10, S("abcd1234567890")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 11, S("abcd1234567890")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 19, 0, S("abcd")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 19, 1, S("abcd0")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 19, 2, S("abcd0")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 20, 0, S("abcd")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 20, 1, S("abcd")); + test(S("abcde"), 4, 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 4, 2, S(""), 0, 0, S("abcd")); + test(S("abcde"), 4, 2, S(""), 0, 1, S("abcd")); + test(S("abcde"), 4, 2, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 4, 2, S("12345"), 0, 0, S("abcd")); + test(S("abcde"), 4, 2, S("12345"), 0, 1, S("abcd1")); + test(S("abcde"), 4, 2, S("12345"), 0, 2, S("abcd12")); + test(S("abcde"), 4, 2, S("12345"), 0, 4, S("abcd1234")); + test(S("abcde"), 4, 2, S("12345"), 0, 5, S("abcd12345")); + test(S("abcde"), 4, 2, S("12345"), 0, 6, S("abcd12345")); + test(S("abcde"), 4, 2, S("12345"), 1, 0, S("abcd")); + test(S("abcde"), 4, 2, S("12345"), 1, 1, S("abcd2")); + test(S("abcde"), 4, 2, S("12345"), 1, 2, S("abcd23")); + test(S("abcde"), 4, 2, S("12345"), 1, 3, S("abcd234")); + test(S("abcde"), 4, 2, S("12345"), 1, 4, S("abcd2345")); + test(S("abcde"), 4, 2, S("12345"), 1, 5, S("abcd2345")); + test(S("abcde"), 4, 2, S("12345"), 2, 0, S("abcd")); + test(S("abcde"), 4, 2, S("12345"), 2, 1, S("abcd3")); + test(S("abcde"), 4, 2, S("12345"), 2, 2, S("abcd34")); + test(S("abcde"), 4, 2, S("12345"), 2, 3, S("abcd345")); + test(S("abcde"), 4, 2, S("12345"), 2, 4, S("abcd345")); + test(S("abcde"), 4, 2, S("12345"), 4, 0, S("abcd")); + test(S("abcde"), 4, 2, S("12345"), 4, 1, S("abcd5")); + test(S("abcde"), 4, 2, S("12345"), 4, 2, S("abcd5")); + test(S("abcde"), 4, 2, S("12345"), 5, 0, S("abcd")); + test(S("abcde"), 4, 2, S("12345"), 5, 1, S("abcd")); + test(S("abcde"), 4, 2, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 4, 2, S("1234567890"), 0, 0, S("abcd")); + test(S("abcde"), 4, 2, S("1234567890"), 0, 1, S("abcd1")); + test(S("abcde"), 4, 2, S("1234567890"), 0, 5, S("abcd12345")); + test(S("abcde"), 4, 2, S("1234567890"), 0, 9, S("abcd123456789")); + test(S("abcde"), 4, 2, S("1234567890"), 0, 10, S("abcd1234567890")); + test(S("abcde"), 4, 2, S("1234567890"), 0, 11, S("abcd1234567890")); + test(S("abcde"), 4, 2, S("1234567890"), 1, 0, S("abcd")); + test(S("abcde"), 4, 2, S("1234567890"), 1, 1, S("abcd2")); + test(S("abcde"), 4, 2, S("1234567890"), 1, 4, S("abcd2345")); + test(S("abcde"), 4, 2, S("1234567890"), 1, 8, S("abcd23456789")); + test(S("abcde"), 4, 2, S("1234567890"), 1, 9, S("abcd234567890")); + test(S("abcde"), 4, 2, S("1234567890"), 1, 10, S("abcd234567890")); + test(S("abcde"), 4, 2, S("1234567890"), 5, 0, S("abcd")); + test(S("abcde"), 4, 2, S("1234567890"), 5, 1, S("abcd6")); + test(S("abcde"), 4, 2, S("1234567890"), 5, 2, S("abcd67")); + test(S("abcde"), 4, 2, S("1234567890"), 5, 4, S("abcd6789")); + test(S("abcde"), 4, 2, S("1234567890"), 5, 5, S("abcd67890")); + test(S("abcde"), 4, 2, S("1234567890"), 5, 6, S("abcd67890")); + test(S("abcde"), 4, 2, S("1234567890"), 9, 0, S("abcd")); + test(S("abcde"), 4, 2, S("1234567890"), 9, 1, S("abcd0")); + test(S("abcde"), 4, 2, S("1234567890"), 9, 2, S("abcd0")); + test(S("abcde"), 4, 2, S("1234567890"), 10, 0, S("abcd")); + test(S("abcde"), 4, 2, S("1234567890"), 10, 1, S("abcd")); + test(S("abcde"), 4, 2, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 0, S("abcd")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 1, S("abcd1")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 10, S("abcd1234567890")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 0, S("abcd")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 1, S("abcd2")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 9, S("abcd234567890")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 18, S("abcd234567890123456789")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 0, S("abcd")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 1, S("abcd1")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 5, S("abcd12345")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 9, S("abcd123456789")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 10, S("abcd1234567890")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 11, S("abcd1234567890")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 19, 0, S("abcd")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 19, 1, S("abcd0")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 19, 2, S("abcd0")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 20, 0, S("abcd")); +} + +template <class S> +void test17() +{ + test(S("abcde"), 4, 2, S("12345678901234567890"), 20, 1, S("abcd")); + test(S("abcde"), 4, 2, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 5, 0, S(""), 0, 0, S("abcde")); + test(S("abcde"), 5, 0, S(""), 0, 1, S("abcde")); + test(S("abcde"), 5, 0, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 5, 0, S("12345"), 0, 0, S("abcde")); + test(S("abcde"), 5, 0, S("12345"), 0, 1, S("abcde1")); + test(S("abcde"), 5, 0, S("12345"), 0, 2, S("abcde12")); + test(S("abcde"), 5, 0, S("12345"), 0, 4, S("abcde1234")); + test(S("abcde"), 5, 0, S("12345"), 0, 5, S("abcde12345")); + test(S("abcde"), 5, 0, S("12345"), 0, 6, S("abcde12345")); + test(S("abcde"), 5, 0, S("12345"), 1, 0, S("abcde")); + test(S("abcde"), 5, 0, S("12345"), 1, 1, S("abcde2")); + test(S("abcde"), 5, 0, S("12345"), 1, 2, S("abcde23")); + test(S("abcde"), 5, 0, S("12345"), 1, 3, S("abcde234")); + test(S("abcde"), 5, 0, S("12345"), 1, 4, S("abcde2345")); + test(S("abcde"), 5, 0, S("12345"), 1, 5, S("abcde2345")); + test(S("abcde"), 5, 0, S("12345"), 2, 0, S("abcde")); + test(S("abcde"), 5, 0, S("12345"), 2, 1, S("abcde3")); + test(S("abcde"), 5, 0, S("12345"), 2, 2, S("abcde34")); + test(S("abcde"), 5, 0, S("12345"), 2, 3, S("abcde345")); + test(S("abcde"), 5, 0, S("12345"), 2, 4, S("abcde345")); + test(S("abcde"), 5, 0, S("12345"), 4, 0, S("abcde")); + test(S("abcde"), 5, 0, S("12345"), 4, 1, S("abcde5")); + test(S("abcde"), 5, 0, S("12345"), 4, 2, S("abcde5")); + test(S("abcde"), 5, 0, S("12345"), 5, 0, S("abcde")); + test(S("abcde"), 5, 0, S("12345"), 5, 1, S("abcde")); + test(S("abcde"), 5, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 5, 0, S("1234567890"), 0, 0, S("abcde")); + test(S("abcde"), 5, 0, S("1234567890"), 0, 1, S("abcde1")); + test(S("abcde"), 5, 0, S("1234567890"), 0, 5, S("abcde12345")); + test(S("abcde"), 5, 0, S("1234567890"), 0, 9, S("abcde123456789")); + test(S("abcde"), 5, 0, S("1234567890"), 0, 10, S("abcde1234567890")); + test(S("abcde"), 5, 0, S("1234567890"), 0, 11, S("abcde1234567890")); + test(S("abcde"), 5, 0, S("1234567890"), 1, 0, S("abcde")); + test(S("abcde"), 5, 0, S("1234567890"), 1, 1, S("abcde2")); + test(S("abcde"), 5, 0, S("1234567890"), 1, 4, S("abcde2345")); + test(S("abcde"), 5, 0, S("1234567890"), 1, 8, S("abcde23456789")); + test(S("abcde"), 5, 0, S("1234567890"), 1, 9, S("abcde234567890")); + test(S("abcde"), 5, 0, S("1234567890"), 1, 10, S("abcde234567890")); + test(S("abcde"), 5, 0, S("1234567890"), 5, 0, S("abcde")); + test(S("abcde"), 5, 0, S("1234567890"), 5, 1, S("abcde6")); + test(S("abcde"), 5, 0, S("1234567890"), 5, 2, S("abcde67")); + test(S("abcde"), 5, 0, S("1234567890"), 5, 4, S("abcde6789")); + test(S("abcde"), 5, 0, S("1234567890"), 5, 5, S("abcde67890")); + test(S("abcde"), 5, 0, S("1234567890"), 5, 6, S("abcde67890")); + test(S("abcde"), 5, 0, S("1234567890"), 9, 0, S("abcde")); + test(S("abcde"), 5, 0, S("1234567890"), 9, 1, S("abcde0")); + test(S("abcde"), 5, 0, S("1234567890"), 9, 2, S("abcde0")); + test(S("abcde"), 5, 0, S("1234567890"), 10, 0, S("abcde")); + test(S("abcde"), 5, 0, S("1234567890"), 10, 1, S("abcde")); + test(S("abcde"), 5, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 0, S("abcde")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 1, S("abcde1")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 10, S("abcde1234567890")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 0, S("abcde")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 1, S("abcde2")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 9, S("abcde234567890")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 18, S("abcde234567890123456789")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 0, S("abcde")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 1, S("abcde1")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 5, S("abcde12345")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 9, S("abcde123456789")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 10, S("abcde1234567890")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 11, S("abcde1234567890")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 19, 0, S("abcde")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 19, 1, S("abcde0")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 19, 2, S("abcde0")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 20, 0, S("abcde")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 20, 1, S("abcde")); + test(S("abcde"), 5, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 5, 1, S(""), 0, 0, S("abcde")); + test(S("abcde"), 5, 1, S(""), 0, 1, S("abcde")); + test(S("abcde"), 5, 1, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 5, 1, S("12345"), 0, 0, S("abcde")); + test(S("abcde"), 5, 1, S("12345"), 0, 1, S("abcde1")); + test(S("abcde"), 5, 1, S("12345"), 0, 2, S("abcde12")); + test(S("abcde"), 5, 1, S("12345"), 0, 4, S("abcde1234")); + test(S("abcde"), 5, 1, S("12345"), 0, 5, S("abcde12345")); + test(S("abcde"), 5, 1, S("12345"), 0, 6, S("abcde12345")); + test(S("abcde"), 5, 1, S("12345"), 1, 0, S("abcde")); + test(S("abcde"), 5, 1, S("12345"), 1, 1, S("abcde2")); + test(S("abcde"), 5, 1, S("12345"), 1, 2, S("abcde23")); + test(S("abcde"), 5, 1, S("12345"), 1, 3, S("abcde234")); + test(S("abcde"), 5, 1, S("12345"), 1, 4, S("abcde2345")); + test(S("abcde"), 5, 1, S("12345"), 1, 5, S("abcde2345")); + test(S("abcde"), 5, 1, S("12345"), 2, 0, S("abcde")); + test(S("abcde"), 5, 1, S("12345"), 2, 1, S("abcde3")); + test(S("abcde"), 5, 1, S("12345"), 2, 2, S("abcde34")); + test(S("abcde"), 5, 1, S("12345"), 2, 3, S("abcde345")); + test(S("abcde"), 5, 1, S("12345"), 2, 4, S("abcde345")); + test(S("abcde"), 5, 1, S("12345"), 4, 0, S("abcde")); + test(S("abcde"), 5, 1, S("12345"), 4, 1, S("abcde5")); + test(S("abcde"), 5, 1, S("12345"), 4, 2, S("abcde5")); + test(S("abcde"), 5, 1, S("12345"), 5, 0, S("abcde")); +} + +template <class S> +void test18() +{ + test(S("abcde"), 5, 1, S("12345"), 5, 1, S("abcde")); + test(S("abcde"), 5, 1, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 5, 1, S("1234567890"), 0, 0, S("abcde")); + test(S("abcde"), 5, 1, S("1234567890"), 0, 1, S("abcde1")); + test(S("abcde"), 5, 1, S("1234567890"), 0, 5, S("abcde12345")); + test(S("abcde"), 5, 1, S("1234567890"), 0, 9, S("abcde123456789")); + test(S("abcde"), 5, 1, S("1234567890"), 0, 10, S("abcde1234567890")); + test(S("abcde"), 5, 1, S("1234567890"), 0, 11, S("abcde1234567890")); + test(S("abcde"), 5, 1, S("1234567890"), 1, 0, S("abcde")); + test(S("abcde"), 5, 1, S("1234567890"), 1, 1, S("abcde2")); + test(S("abcde"), 5, 1, S("1234567890"), 1, 4, S("abcde2345")); + test(S("abcde"), 5, 1, S("1234567890"), 1, 8, S("abcde23456789")); + test(S("abcde"), 5, 1, S("1234567890"), 1, 9, S("abcde234567890")); + test(S("abcde"), 5, 1, S("1234567890"), 1, 10, S("abcde234567890")); + test(S("abcde"), 5, 1, S("1234567890"), 5, 0, S("abcde")); + test(S("abcde"), 5, 1, S("1234567890"), 5, 1, S("abcde6")); + test(S("abcde"), 5, 1, S("1234567890"), 5, 2, S("abcde67")); + test(S("abcde"), 5, 1, S("1234567890"), 5, 4, S("abcde6789")); + test(S("abcde"), 5, 1, S("1234567890"), 5, 5, S("abcde67890")); + test(S("abcde"), 5, 1, S("1234567890"), 5, 6, S("abcde67890")); + test(S("abcde"), 5, 1, S("1234567890"), 9, 0, S("abcde")); + test(S("abcde"), 5, 1, S("1234567890"), 9, 1, S("abcde0")); + test(S("abcde"), 5, 1, S("1234567890"), 9, 2, S("abcde0")); + test(S("abcde"), 5, 1, S("1234567890"), 10, 0, S("abcde")); + test(S("abcde"), 5, 1, S("1234567890"), 10, 1, S("abcde")); + test(S("abcde"), 5, 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 0, S("abcde")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 1, S("abcde1")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 10, S("abcde1234567890")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 0, S("abcde")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 1, S("abcde2")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 9, S("abcde234567890")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 18, S("abcde234567890123456789")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 0, S("abcde")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 1, S("abcde1")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 5, S("abcde12345")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 9, S("abcde123456789")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 10, S("abcde1234567890")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 11, S("abcde1234567890")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 19, 0, S("abcde")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 19, 1, S("abcde0")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 19, 2, S("abcde0")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 20, 0, S("abcde")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 20, 1, S("abcde")); + test(S("abcde"), 5, 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcde"), 6, 0, S(""), 0, 0, S("can't happen")); + test(S("abcde"), 6, 0, S(""), 0, 1, S("can't happen")); + test(S("abcde"), 6, 0, S(""), 1, 0, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 0, 0, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 0, 1, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 0, 2, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 0, 4, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 0, 5, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 0, 6, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 1, 0, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 1, 1, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 1, 2, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 1, 3, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 1, 4, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 1, 5, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 2, 0, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 2, 1, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 2, 2, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 2, 3, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 2, 4, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 4, 0, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 4, 1, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 4, 2, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 5, 0, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 5, 1, S("can't happen")); + test(S("abcde"), 6, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 0, 0, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 0, 1, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 0, 5, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 0, 9, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 0, 10, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 0, 11, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 1, 0, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 1, 1, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 1, 4, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 1, 8, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 1, 9, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 1, 10, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 5, 0, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 5, 1, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 5, 2, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 5, 4, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 5, 5, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 5, 6, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 9, 0, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 9, 1, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 9, 2, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 10, 0, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 10, 1, S("can't happen")); + test(S("abcde"), 6, 0, S("1234567890"), 11, 0, S("can't happen")); +} + +template <class S> +void test19() +{ + test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 0, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 1, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 10, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 19, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 20, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 21, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 0, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 1, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 9, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 18, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 19, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 20, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 0, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 1, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 5, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 9, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 10, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 11, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 19, 0, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 19, 1, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 19, 2, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 20, 0, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 20, 1, S("can't happen")); + test(S("abcde"), 6, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 0, 0, S(""), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S(""), 0, 1, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 0, 0, S("12345"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 0, 1, S("1abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 0, 2, S("12abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 0, 4, S("1234abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 0, 5, S("12345abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 0, 6, S("12345abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 1, 1, S("2abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 1, 2, S("23abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 1, 3, S("234abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 1, 4, S("2345abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 1, 5, S("2345abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 2, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 2, 1, S("3abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 2, 2, S("34abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 2, 3, S("345abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 2, 4, S("345abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 4, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 4, 1, S("5abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 4, 2, S("5abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 5, 1, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 1, S("1abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 5, S("12345abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 9, S("123456789abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 10, S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 11, S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 1, S("2abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 4, S("2345abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 8, S("23456789abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 9, S("234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 10, S("234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 1, S("6abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 2, S("67abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 4, S("6789abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 5, S("67890abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 6, S("67890abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 9, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 9, 1, S("0abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 9, 2, S("0abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 10, 1, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 1, S("1abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 1, S("2abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 1, S("1abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 5, S("12345abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 19, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 19, 1, S("0abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 19, 2, S("0abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 20, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 20, 1, S("abcdefghij")); + test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 0, 1, S(""), 0, 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S(""), 0, 1, S("bcdefghij")); +} + +template <class S> +void test20() +{ + test(S("abcdefghij"), 0, 1, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 0, 1, S("12345"), 0, 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 0, 1, S("1bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 0, 2, S("12bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 0, 4, S("1234bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 0, 5, S("12345bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 0, 6, S("12345bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 1, 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 1, 1, S("2bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 1, 2, S("23bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 1, 3, S("234bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 1, 4, S("2345bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 1, 5, S("2345bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 2, 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 2, 1, S("3bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 2, 2, S("34bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 2, 3, S("345bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 2, 4, S("345bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 4, 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 4, 1, S("5bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 4, 2, S("5bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 5, 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 5, 1, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 1, S("1bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 5, S("12345bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 9, S("123456789bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 10, S("1234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 11, S("1234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 1, S("2bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 4, S("2345bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 8, S("23456789bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 9, S("234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 10, S("234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 1, S("6bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 2, S("67bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 4, S("6789bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 5, S("67890bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 6, S("67890bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 9, 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 9, 1, S("0bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 9, 2, S("0bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 10, 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 10, 1, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 1, S("1bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 1, S("2bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 9, S("234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 1, S("1bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 5, S("12345bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 9, S("123456789bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 19, 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 19, 1, S("0bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 19, 2, S("0bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 20, 0, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 20, 1, S("bcdefghij")); + test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 0, 5, S(""), 0, 0, S("fghij")); + test(S("abcdefghij"), 0, 5, S(""), 0, 1, S("fghij")); + test(S("abcdefghij"), 0, 5, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 0, 5, S("12345"), 0, 0, S("fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 0, 1, S("1fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 0, 2, S("12fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 0, 4, S("1234fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 0, 5, S("12345fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 0, 6, S("12345fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 1, 0, S("fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 1, 1, S("2fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 1, 2, S("23fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 1, 3, S("234fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 1, 4, S("2345fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 1, 5, S("2345fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 2, 0, S("fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 2, 1, S("3fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 2, 2, S("34fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 2, 3, S("345fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 2, 4, S("345fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 4, 0, S("fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 4, 1, S("5fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 4, 2, S("5fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 5, 0, S("fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 5, 1, S("fghij")); + test(S("abcdefghij"), 0, 5, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 0, S("fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 1, S("1fghij")); +} + +template <class S> +void test21() +{ + test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 5, S("12345fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 9, S("123456789fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 10, S("1234567890fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 11, S("1234567890fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 0, S("fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 1, S("2fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 4, S("2345fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 8, S("23456789fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 9, S("234567890fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 10, S("234567890fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 0, S("fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 1, S("6fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 2, S("67fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 4, S("6789fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 5, S("67890fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 6, S("67890fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 9, 0, S("fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 9, 1, S("0fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 9, 2, S("0fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 10, 0, S("fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 10, 1, S("fghij")); + test(S("abcdefghij"), 0, 5, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 0, S("fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 1, S("1fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 10, S("1234567890fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 19, S("1234567890123456789fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 20, S("12345678901234567890fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 21, S("12345678901234567890fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 0, S("fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 1, S("2fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 9, S("234567890fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 18, S("234567890123456789fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 19, S("2345678901234567890fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 20, S("2345678901234567890fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 0, S("fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 1, S("1fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 5, S("12345fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 9, S("123456789fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 10, S("1234567890fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 11, S("1234567890fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 19, 0, S("fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 19, 1, S("0fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 19, 2, S("0fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 20, 0, S("fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 20, 1, S("fghij")); + test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 0, 9, S(""), 0, 0, S("j")); + test(S("abcdefghij"), 0, 9, S(""), 0, 1, S("j")); + test(S("abcdefghij"), 0, 9, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 0, 9, S("12345"), 0, 0, S("j")); + test(S("abcdefghij"), 0, 9, S("12345"), 0, 1, S("1j")); + test(S("abcdefghij"), 0, 9, S("12345"), 0, 2, S("12j")); + test(S("abcdefghij"), 0, 9, S("12345"), 0, 4, S("1234j")); + test(S("abcdefghij"), 0, 9, S("12345"), 0, 5, S("12345j")); + test(S("abcdefghij"), 0, 9, S("12345"), 0, 6, S("12345j")); + test(S("abcdefghij"), 0, 9, S("12345"), 1, 0, S("j")); + test(S("abcdefghij"), 0, 9, S("12345"), 1, 1, S("2j")); + test(S("abcdefghij"), 0, 9, S("12345"), 1, 2, S("23j")); + test(S("abcdefghij"), 0, 9, S("12345"), 1, 3, S("234j")); + test(S("abcdefghij"), 0, 9, S("12345"), 1, 4, S("2345j")); + test(S("abcdefghij"), 0, 9, S("12345"), 1, 5, S("2345j")); + test(S("abcdefghij"), 0, 9, S("12345"), 2, 0, S("j")); + test(S("abcdefghij"), 0, 9, S("12345"), 2, 1, S("3j")); + test(S("abcdefghij"), 0, 9, S("12345"), 2, 2, S("34j")); + test(S("abcdefghij"), 0, 9, S("12345"), 2, 3, S("345j")); + test(S("abcdefghij"), 0, 9, S("12345"), 2, 4, S("345j")); + test(S("abcdefghij"), 0, 9, S("12345"), 4, 0, S("j")); + test(S("abcdefghij"), 0, 9, S("12345"), 4, 1, S("5j")); + test(S("abcdefghij"), 0, 9, S("12345"), 4, 2, S("5j")); + test(S("abcdefghij"), 0, 9, S("12345"), 5, 0, S("j")); + test(S("abcdefghij"), 0, 9, S("12345"), 5, 1, S("j")); + test(S("abcdefghij"), 0, 9, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 0, S("j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 1, S("1j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 5, S("12345j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 9, S("123456789j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 10, S("1234567890j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 11, S("1234567890j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 0, S("j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 1, S("2j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 4, S("2345j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 8, S("23456789j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 9, S("234567890j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 10, S("234567890j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 0, S("j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 1, S("6j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 2, S("67j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 4, S("6789j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 5, S("67890j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 6, S("67890j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 9, 0, S("j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 9, 1, S("0j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 9, 2, S("0j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 10, 0, S("j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 10, 1, S("j")); + test(S("abcdefghij"), 0, 9, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 0, S("j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 1, S("1j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 10, S("1234567890j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 19, S("1234567890123456789j")); +} + +template <class S> +void test22() +{ + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 20, S("12345678901234567890j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 21, S("12345678901234567890j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 0, S("j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 1, S("2j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 9, S("234567890j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 18, S("234567890123456789j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 19, S("2345678901234567890j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 20, S("2345678901234567890j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 0, S("j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 1, S("1j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 5, S("12345j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 9, S("123456789j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 10, S("1234567890j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 11, S("1234567890j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 19, 0, S("j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 19, 1, S("0j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 19, 2, S("0j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 20, 0, S("j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 20, 1, S("j")); + test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 0, 10, S(""), 0, 0, S("")); + test(S("abcdefghij"), 0, 10, S(""), 0, 1, S("")); + test(S("abcdefghij"), 0, 10, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 0, 10, S("12345"), 0, 0, S("")); + test(S("abcdefghij"), 0, 10, S("12345"), 0, 1, S("1")); + test(S("abcdefghij"), 0, 10, S("12345"), 0, 2, S("12")); + test(S("abcdefghij"), 0, 10, S("12345"), 0, 4, S("1234")); + test(S("abcdefghij"), 0, 10, S("12345"), 0, 5, S("12345")); + test(S("abcdefghij"), 0, 10, S("12345"), 0, 6, S("12345")); + test(S("abcdefghij"), 0, 10, S("12345"), 1, 0, S("")); + test(S("abcdefghij"), 0, 10, S("12345"), 1, 1, S("2")); + test(S("abcdefghij"), 0, 10, S("12345"), 1, 2, S("23")); + test(S("abcdefghij"), 0, 10, S("12345"), 1, 3, S("234")); + test(S("abcdefghij"), 0, 10, S("12345"), 1, 4, S("2345")); + test(S("abcdefghij"), 0, 10, S("12345"), 1, 5, S("2345")); + test(S("abcdefghij"), 0, 10, S("12345"), 2, 0, S("")); + test(S("abcdefghij"), 0, 10, S("12345"), 2, 1, S("3")); + test(S("abcdefghij"), 0, 10, S("12345"), 2, 2, S("34")); + test(S("abcdefghij"), 0, 10, S("12345"), 2, 3, S("345")); + test(S("abcdefghij"), 0, 10, S("12345"), 2, 4, S("345")); + test(S("abcdefghij"), 0, 10, S("12345"), 4, 0, S("")); + test(S("abcdefghij"), 0, 10, S("12345"), 4, 1, S("5")); + test(S("abcdefghij"), 0, 10, S("12345"), 4, 2, S("5")); + test(S("abcdefghij"), 0, 10, S("12345"), 5, 0, S("")); + test(S("abcdefghij"), 0, 10, S("12345"), 5, 1, S("")); + test(S("abcdefghij"), 0, 10, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 0, S("")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 1, S("1")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 5, S("12345")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 9, S("123456789")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 10, S("1234567890")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 11, S("1234567890")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 0, S("")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 1, S("2")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 4, S("2345")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 8, S("23456789")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 9, S("234567890")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 10, S("234567890")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 0, S("")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 1, S("6")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 2, S("67")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 4, S("6789")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 5, S("67890")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 6, S("67890")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 9, 0, S("")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 9, 1, S("0")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 9, 2, S("0")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 10, 0, S("")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 10, 1, S("")); + test(S("abcdefghij"), 0, 10, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 0, S("")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 1, S("1")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 10, S("1234567890")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 19, S("1234567890123456789")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 20, S("12345678901234567890")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 21, S("12345678901234567890")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 0, S("")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 1, S("2")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 9, S("234567890")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 18, S("234567890123456789")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 19, S("2345678901234567890")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 20, S("2345678901234567890")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 0, S("")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 1, S("1")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 5, S("12345")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 9, S("123456789")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 10, S("1234567890")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 11, S("1234567890")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 19, 0, S("")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 19, 1, S("0")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 19, 2, S("0")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 20, 0, S("")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 20, 1, S("")); + test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 0, 11, S(""), 0, 0, S("")); + test(S("abcdefghij"), 0, 11, S(""), 0, 1, S("")); + test(S("abcdefghij"), 0, 11, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 0, 11, S("12345"), 0, 0, S("")); + test(S("abcdefghij"), 0, 11, S("12345"), 0, 1, S("1")); + test(S("abcdefghij"), 0, 11, S("12345"), 0, 2, S("12")); +} + +template <class S> +void test23() +{ + test(S("abcdefghij"), 0, 11, S("12345"), 0, 4, S("1234")); + test(S("abcdefghij"), 0, 11, S("12345"), 0, 5, S("12345")); + test(S("abcdefghij"), 0, 11, S("12345"), 0, 6, S("12345")); + test(S("abcdefghij"), 0, 11, S("12345"), 1, 0, S("")); + test(S("abcdefghij"), 0, 11, S("12345"), 1, 1, S("2")); + test(S("abcdefghij"), 0, 11, S("12345"), 1, 2, S("23")); + test(S("abcdefghij"), 0, 11, S("12345"), 1, 3, S("234")); + test(S("abcdefghij"), 0, 11, S("12345"), 1, 4, S("2345")); + test(S("abcdefghij"), 0, 11, S("12345"), 1, 5, S("2345")); + test(S("abcdefghij"), 0, 11, S("12345"), 2, 0, S("")); + test(S("abcdefghij"), 0, 11, S("12345"), 2, 1, S("3")); + test(S("abcdefghij"), 0, 11, S("12345"), 2, 2, S("34")); + test(S("abcdefghij"), 0, 11, S("12345"), 2, 3, S("345")); + test(S("abcdefghij"), 0, 11, S("12345"), 2, 4, S("345")); + test(S("abcdefghij"), 0, 11, S("12345"), 4, 0, S("")); + test(S("abcdefghij"), 0, 11, S("12345"), 4, 1, S("5")); + test(S("abcdefghij"), 0, 11, S("12345"), 4, 2, S("5")); + test(S("abcdefghij"), 0, 11, S("12345"), 5, 0, S("")); + test(S("abcdefghij"), 0, 11, S("12345"), 5, 1, S("")); + test(S("abcdefghij"), 0, 11, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 0, S("")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 1, S("1")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 5, S("12345")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 9, S("123456789")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 10, S("1234567890")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 11, S("1234567890")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 0, S("")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 1, S("2")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 4, S("2345")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 8, S("23456789")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 9, S("234567890")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 10, S("234567890")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 0, S("")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 1, S("6")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 2, S("67")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 4, S("6789")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 5, S("67890")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 6, S("67890")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 9, 0, S("")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 9, 1, S("0")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 9, 2, S("0")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 10, 0, S("")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 10, 1, S("")); + test(S("abcdefghij"), 0, 11, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 0, S("")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 1, S("1")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 10, S("1234567890")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 19, S("1234567890123456789")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 20, S("12345678901234567890")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 21, S("12345678901234567890")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 0, S("")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 1, S("2")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 9, S("234567890")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 18, S("234567890123456789")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 19, S("2345678901234567890")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 20, S("2345678901234567890")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 0, S("")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 1, S("1")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 5, S("12345")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 9, S("123456789")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 10, S("1234567890")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 11, S("1234567890")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 19, 0, S("")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 19, 1, S("0")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 19, 2, S("0")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 20, 0, S("")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 20, 1, S("")); + test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 1, 0, S(""), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S(""), 0, 1, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 1, 0, S("12345"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 0, 1, S("a1bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 0, 2, S("a12bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 0, 4, S("a1234bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 0, 5, S("a12345bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 0, 6, S("a12345bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 1, 1, S("a2bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 1, 2, S("a23bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 1, 3, S("a234bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 1, 4, S("a2345bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 1, 5, S("a2345bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 2, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 2, 1, S("a3bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 2, 2, S("a34bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 2, 3, S("a345bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 2, 4, S("a345bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 4, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 4, 1, S("a5bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 4, 2, S("a5bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 5, 1, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 1, S("a1bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 5, S("a12345bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 9, S("a123456789bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 10, S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 11, S("a1234567890bcdefghij")); +} + +template <class S> +void test24() +{ + test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 1, S("a2bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 4, S("a2345bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 8, S("a23456789bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 9, S("a234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 10, S("a234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 1, S("a6bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 2, S("a67bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 4, S("a6789bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 5, S("a67890bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 6, S("a67890bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 9, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 9, 1, S("a0bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 9, 2, S("a0bcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 10, 1, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 1, S("a1bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 1, S("a2bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 9, S("a234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 1, S("a1bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 5, S("a12345bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 9, S("a123456789bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 19, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 19, 1, S("a0bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 19, 2, S("a0bcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 20, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 20, 1, S("abcdefghij")); + test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 1, 1, S(""), 0, 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S(""), 0, 1, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 1, 1, S("12345"), 0, 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 0, 1, S("a1cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 0, 2, S("a12cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 0, 4, S("a1234cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 0, 5, S("a12345cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 0, 6, S("a12345cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 1, 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 1, 1, S("a2cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 1, 2, S("a23cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 1, 3, S("a234cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 1, 4, S("a2345cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 1, 5, S("a2345cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 2, 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 2, 1, S("a3cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 2, 2, S("a34cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 2, 3, S("a345cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 2, 4, S("a345cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 4, 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 4, 1, S("a5cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 4, 2, S("a5cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 5, 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 5, 1, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 1, S("a1cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 5, S("a12345cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 9, S("a123456789cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 10, S("a1234567890cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 11, S("a1234567890cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 1, S("a2cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 4, S("a2345cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 8, S("a23456789cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 9, S("a234567890cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 10, S("a234567890cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 1, S("a6cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 2, S("a67cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 4, S("a6789cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 5, S("a67890cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 6, S("a67890cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 9, 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 9, 1, S("a0cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 9, 2, S("a0cdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 10, 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 10, 1, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 1, S("a1cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 10, S("a1234567890cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 1, S("a2cdefghij")); +} + +template <class S> +void test25() +{ + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 9, S("a234567890cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 18, S("a234567890123456789cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 1, S("a1cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 5, S("a12345cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 9, S("a123456789cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 10, S("a1234567890cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 11, S("a1234567890cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 19, 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 19, 1, S("a0cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 19, 2, S("a0cdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 20, 0, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 20, 1, S("acdefghij")); + test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 1, 4, S(""), 0, 0, S("afghij")); + test(S("abcdefghij"), 1, 4, S(""), 0, 1, S("afghij")); + test(S("abcdefghij"), 1, 4, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 1, 4, S("12345"), 0, 0, S("afghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 0, 1, S("a1fghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 0, 2, S("a12fghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 0, 4, S("a1234fghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 0, 5, S("a12345fghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 0, 6, S("a12345fghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 1, 0, S("afghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 1, 1, S("a2fghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 1, 2, S("a23fghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 1, 3, S("a234fghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 1, 4, S("a2345fghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 1, 5, S("a2345fghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 2, 0, S("afghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 2, 1, S("a3fghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 2, 2, S("a34fghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 2, 3, S("a345fghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 2, 4, S("a345fghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 4, 0, S("afghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 4, 1, S("a5fghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 4, 2, S("a5fghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 5, 0, S("afghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 5, 1, S("afghij")); + test(S("abcdefghij"), 1, 4, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 0, S("afghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 1, S("a1fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 5, S("a12345fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 9, S("a123456789fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 10, S("a1234567890fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 11, S("a1234567890fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 0, S("afghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 1, S("a2fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 4, S("a2345fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 8, S("a23456789fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 9, S("a234567890fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 10, S("a234567890fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 0, S("afghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 1, S("a6fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 2, S("a67fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 4, S("a6789fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 5, S("a67890fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 6, S("a67890fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 9, 0, S("afghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 9, 1, S("a0fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 9, 2, S("a0fghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 10, 0, S("afghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 10, 1, S("afghij")); + test(S("abcdefghij"), 1, 4, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 0, S("afghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 1, S("a1fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 10, S("a1234567890fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 19, S("a1234567890123456789fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 20, S("a12345678901234567890fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 21, S("a12345678901234567890fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 0, S("afghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 1, S("a2fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 9, S("a234567890fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 18, S("a234567890123456789fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 19, S("a2345678901234567890fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 20, S("a2345678901234567890fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 0, S("afghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 1, S("a1fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 5, S("a12345fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 9, S("a123456789fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 10, S("a1234567890fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 11, S("a1234567890fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 19, 0, S("afghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 19, 1, S("a0fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 19, 2, S("a0fghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 20, 0, S("afghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 20, 1, S("afghij")); + test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 1, 8, S(""), 0, 0, S("aj")); + test(S("abcdefghij"), 1, 8, S(""), 0, 1, S("aj")); + test(S("abcdefghij"), 1, 8, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 1, 8, S("12345"), 0, 0, S("aj")); + test(S("abcdefghij"), 1, 8, S("12345"), 0, 1, S("a1j")); + test(S("abcdefghij"), 1, 8, S("12345"), 0, 2, S("a12j")); + test(S("abcdefghij"), 1, 8, S("12345"), 0, 4, S("a1234j")); + test(S("abcdefghij"), 1, 8, S("12345"), 0, 5, S("a12345j")); + test(S("abcdefghij"), 1, 8, S("12345"), 0, 6, S("a12345j")); + test(S("abcdefghij"), 1, 8, S("12345"), 1, 0, S("aj")); +} + +template <class S> +void test26() +{ + test(S("abcdefghij"), 1, 8, S("12345"), 1, 1, S("a2j")); + test(S("abcdefghij"), 1, 8, S("12345"), 1, 2, S("a23j")); + test(S("abcdefghij"), 1, 8, S("12345"), 1, 3, S("a234j")); + test(S("abcdefghij"), 1, 8, S("12345"), 1, 4, S("a2345j")); + test(S("abcdefghij"), 1, 8, S("12345"), 1, 5, S("a2345j")); + test(S("abcdefghij"), 1, 8, S("12345"), 2, 0, S("aj")); + test(S("abcdefghij"), 1, 8, S("12345"), 2, 1, S("a3j")); + test(S("abcdefghij"), 1, 8, S("12345"), 2, 2, S("a34j")); + test(S("abcdefghij"), 1, 8, S("12345"), 2, 3, S("a345j")); + test(S("abcdefghij"), 1, 8, S("12345"), 2, 4, S("a345j")); + test(S("abcdefghij"), 1, 8, S("12345"), 4, 0, S("aj")); + test(S("abcdefghij"), 1, 8, S("12345"), 4, 1, S("a5j")); + test(S("abcdefghij"), 1, 8, S("12345"), 4, 2, S("a5j")); + test(S("abcdefghij"), 1, 8, S("12345"), 5, 0, S("aj")); + test(S("abcdefghij"), 1, 8, S("12345"), 5, 1, S("aj")); + test(S("abcdefghij"), 1, 8, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 0, S("aj")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 1, S("a1j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 5, S("a12345j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 9, S("a123456789j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 10, S("a1234567890j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 11, S("a1234567890j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 0, S("aj")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 1, S("a2j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 4, S("a2345j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 8, S("a23456789j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 9, S("a234567890j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 10, S("a234567890j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 0, S("aj")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 1, S("a6j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 2, S("a67j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 4, S("a6789j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 5, S("a67890j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 6, S("a67890j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 9, 0, S("aj")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 9, 1, S("a0j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 9, 2, S("a0j")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 10, 0, S("aj")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 10, 1, S("aj")); + test(S("abcdefghij"), 1, 8, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 0, S("aj")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 1, S("a1j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 10, S("a1234567890j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 19, S("a1234567890123456789j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 20, S("a12345678901234567890j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 21, S("a12345678901234567890j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 0, S("aj")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 1, S("a2j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 9, S("a234567890j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 18, S("a234567890123456789j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 19, S("a2345678901234567890j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 20, S("a2345678901234567890j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 0, S("aj")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 1, S("a1j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 5, S("a12345j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 9, S("a123456789j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 10, S("a1234567890j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 11, S("a1234567890j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 19, 0, S("aj")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 19, 1, S("a0j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 19, 2, S("a0j")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 20, 0, S("aj")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 20, 1, S("aj")); + test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 1, 9, S(""), 0, 0, S("a")); + test(S("abcdefghij"), 1, 9, S(""), 0, 1, S("a")); + test(S("abcdefghij"), 1, 9, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 1, 9, S("12345"), 0, 0, S("a")); + test(S("abcdefghij"), 1, 9, S("12345"), 0, 1, S("a1")); + test(S("abcdefghij"), 1, 9, S("12345"), 0, 2, S("a12")); + test(S("abcdefghij"), 1, 9, S("12345"), 0, 4, S("a1234")); + test(S("abcdefghij"), 1, 9, S("12345"), 0, 5, S("a12345")); + test(S("abcdefghij"), 1, 9, S("12345"), 0, 6, S("a12345")); + test(S("abcdefghij"), 1, 9, S("12345"), 1, 0, S("a")); + test(S("abcdefghij"), 1, 9, S("12345"), 1, 1, S("a2")); + test(S("abcdefghij"), 1, 9, S("12345"), 1, 2, S("a23")); + test(S("abcdefghij"), 1, 9, S("12345"), 1, 3, S("a234")); + test(S("abcdefghij"), 1, 9, S("12345"), 1, 4, S("a2345")); + test(S("abcdefghij"), 1, 9, S("12345"), 1, 5, S("a2345")); + test(S("abcdefghij"), 1, 9, S("12345"), 2, 0, S("a")); + test(S("abcdefghij"), 1, 9, S("12345"), 2, 1, S("a3")); + test(S("abcdefghij"), 1, 9, S("12345"), 2, 2, S("a34")); + test(S("abcdefghij"), 1, 9, S("12345"), 2, 3, S("a345")); + test(S("abcdefghij"), 1, 9, S("12345"), 2, 4, S("a345")); + test(S("abcdefghij"), 1, 9, S("12345"), 4, 0, S("a")); + test(S("abcdefghij"), 1, 9, S("12345"), 4, 1, S("a5")); + test(S("abcdefghij"), 1, 9, S("12345"), 4, 2, S("a5")); + test(S("abcdefghij"), 1, 9, S("12345"), 5, 0, S("a")); + test(S("abcdefghij"), 1, 9, S("12345"), 5, 1, S("a")); + test(S("abcdefghij"), 1, 9, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 0, S("a")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 1, S("a1")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 5, S("a12345")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 9, S("a123456789")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 10, S("a1234567890")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 11, S("a1234567890")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 0, S("a")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 1, S("a2")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 4, S("a2345")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 8, S("a23456789")); +} + +template <class S> +void test27() +{ + test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 9, S("a234567890")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 10, S("a234567890")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 0, S("a")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 1, S("a6")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 2, S("a67")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 4, S("a6789")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 5, S("a67890")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 6, S("a67890")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 9, 0, S("a")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 9, 1, S("a0")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 9, 2, S("a0")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 10, 0, S("a")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 10, 1, S("a")); + test(S("abcdefghij"), 1, 9, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 0, S("a")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 1, S("a1")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 10, S("a1234567890")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 19, S("a1234567890123456789")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 20, S("a12345678901234567890")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 21, S("a12345678901234567890")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 0, S("a")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 1, S("a2")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 9, S("a234567890")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 18, S("a234567890123456789")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 19, S("a2345678901234567890")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 20, S("a2345678901234567890")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 0, S("a")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 1, S("a1")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 5, S("a12345")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 9, S("a123456789")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 10, S("a1234567890")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 11, S("a1234567890")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 19, 0, S("a")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 19, 1, S("a0")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 19, 2, S("a0")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 20, 0, S("a")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 20, 1, S("a")); + test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 1, 10, S(""), 0, 0, S("a")); + test(S("abcdefghij"), 1, 10, S(""), 0, 1, S("a")); + test(S("abcdefghij"), 1, 10, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 1, 10, S("12345"), 0, 0, S("a")); + test(S("abcdefghij"), 1, 10, S("12345"), 0, 1, S("a1")); + test(S("abcdefghij"), 1, 10, S("12345"), 0, 2, S("a12")); + test(S("abcdefghij"), 1, 10, S("12345"), 0, 4, S("a1234")); + test(S("abcdefghij"), 1, 10, S("12345"), 0, 5, S("a12345")); + test(S("abcdefghij"), 1, 10, S("12345"), 0, 6, S("a12345")); + test(S("abcdefghij"), 1, 10, S("12345"), 1, 0, S("a")); + test(S("abcdefghij"), 1, 10, S("12345"), 1, 1, S("a2")); + test(S("abcdefghij"), 1, 10, S("12345"), 1, 2, S("a23")); + test(S("abcdefghij"), 1, 10, S("12345"), 1, 3, S("a234")); + test(S("abcdefghij"), 1, 10, S("12345"), 1, 4, S("a2345")); + test(S("abcdefghij"), 1, 10, S("12345"), 1, 5, S("a2345")); + test(S("abcdefghij"), 1, 10, S("12345"), 2, 0, S("a")); + test(S("abcdefghij"), 1, 10, S("12345"), 2, 1, S("a3")); + test(S("abcdefghij"), 1, 10, S("12345"), 2, 2, S("a34")); + test(S("abcdefghij"), 1, 10, S("12345"), 2, 3, S("a345")); + test(S("abcdefghij"), 1, 10, S("12345"), 2, 4, S("a345")); + test(S("abcdefghij"), 1, 10, S("12345"), 4, 0, S("a")); + test(S("abcdefghij"), 1, 10, S("12345"), 4, 1, S("a5")); + test(S("abcdefghij"), 1, 10, S("12345"), 4, 2, S("a5")); + test(S("abcdefghij"), 1, 10, S("12345"), 5, 0, S("a")); + test(S("abcdefghij"), 1, 10, S("12345"), 5, 1, S("a")); + test(S("abcdefghij"), 1, 10, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 0, S("a")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 1, S("a1")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 5, S("a12345")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 9, S("a123456789")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 10, S("a1234567890")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 11, S("a1234567890")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 0, S("a")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 1, S("a2")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 4, S("a2345")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 8, S("a23456789")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 9, S("a234567890")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 10, S("a234567890")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 0, S("a")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 1, S("a6")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 2, S("a67")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 4, S("a6789")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 5, S("a67890")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 6, S("a67890")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 9, 0, S("a")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 9, 1, S("a0")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 9, 2, S("a0")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 10, 0, S("a")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 10, 1, S("a")); + test(S("abcdefghij"), 1, 10, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 0, S("a")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 1, S("a1")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 10, S("a1234567890")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 19, S("a1234567890123456789")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 20, S("a12345678901234567890")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 21, S("a12345678901234567890")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 0, S("a")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 1, S("a2")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 9, S("a234567890")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 18, S("a234567890123456789")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 19, S("a2345678901234567890")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 20, S("a2345678901234567890")); +} + +template <class S> +void test28() +{ + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 0, S("a")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 1, S("a1")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 5, S("a12345")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 9, S("a123456789")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 10, S("a1234567890")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 11, S("a1234567890")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 19, 0, S("a")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 19, 1, S("a0")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 19, 2, S("a0")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 20, 0, S("a")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 20, 1, S("a")); + test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 5, 0, S(""), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S(""), 0, 1, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 5, 0, S("12345"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 0, 1, S("abcde1fghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 0, 2, S("abcde12fghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 0, 4, S("abcde1234fghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 0, 5, S("abcde12345fghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 0, 6, S("abcde12345fghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 1, 1, S("abcde2fghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 1, 2, S("abcde23fghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 1, 3, S("abcde234fghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 1, 4, S("abcde2345fghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 1, 5, S("abcde2345fghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 2, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 2, 1, S("abcde3fghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 2, 2, S("abcde34fghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 2, 3, S("abcde345fghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 2, 4, S("abcde345fghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 4, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 4, 1, S("abcde5fghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 4, 2, S("abcde5fghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 5, 1, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 1, S("abcde1fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 5, S("abcde12345fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 9, S("abcde123456789fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 10, S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 11, S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 1, S("abcde2fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 4, S("abcde2345fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 8, S("abcde23456789fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 9, S("abcde234567890fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 10, S("abcde234567890fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 1, S("abcde6fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 2, S("abcde67fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 4, S("abcde6789fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 5, S("abcde67890fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 6, S("abcde67890fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 9, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 9, 1, S("abcde0fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 9, 2, S("abcde0fghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 10, 1, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 1, S("abcde1fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 10, S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 1, S("abcde2fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 9, S("abcde234567890fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 18, S("abcde234567890123456789fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 1, S("abcde1fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 5, S("abcde12345fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 9, S("abcde123456789fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 10, S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 11, S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 19, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 19, 1, S("abcde0fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 19, 2, S("abcde0fghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 20, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 20, 1, S("abcdefghij")); + test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 5, 1, S(""), 0, 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S(""), 0, 1, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 5, 1, S("12345"), 0, 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 0, 1, S("abcde1ghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 0, 2, S("abcde12ghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 0, 4, S("abcde1234ghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 0, 5, S("abcde12345ghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 0, 6, S("abcde12345ghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 1, 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 1, 1, S("abcde2ghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 1, 2, S("abcde23ghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 1, 3, S("abcde234ghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 1, 4, S("abcde2345ghij")); +} + +template <class S> +void test29() +{ + test(S("abcdefghij"), 5, 1, S("12345"), 1, 5, S("abcde2345ghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 2, 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 2, 1, S("abcde3ghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 2, 2, S("abcde34ghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 2, 3, S("abcde345ghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 2, 4, S("abcde345ghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 4, 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 4, 1, S("abcde5ghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 4, 2, S("abcde5ghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 5, 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 5, 1, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 1, S("abcde1ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 5, S("abcde12345ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 9, S("abcde123456789ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 10, S("abcde1234567890ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 11, S("abcde1234567890ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 1, S("abcde2ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 4, S("abcde2345ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 8, S("abcde23456789ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 9, S("abcde234567890ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 10, S("abcde234567890ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 1, S("abcde6ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 2, S("abcde67ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 4, S("abcde6789ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 5, S("abcde67890ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 6, S("abcde67890ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 9, 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 9, 1, S("abcde0ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 9, 2, S("abcde0ghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 10, 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 10, 1, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 1, S("abcde1ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 10, S("abcde1234567890ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 1, S("abcde2ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 9, S("abcde234567890ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 18, S("abcde234567890123456789ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 1, S("abcde1ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 5, S("abcde12345ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 9, S("abcde123456789ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 10, S("abcde1234567890ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 11, S("abcde1234567890ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 19, 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 19, 1, S("abcde0ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 19, 2, S("abcde0ghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 20, 0, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 20, 1, S("abcdeghij")); + test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 5, 2, S(""), 0, 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S(""), 0, 1, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 5, 2, S("12345"), 0, 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("12345"), 0, 1, S("abcde1hij")); + test(S("abcdefghij"), 5, 2, S("12345"), 0, 2, S("abcde12hij")); + test(S("abcdefghij"), 5, 2, S("12345"), 0, 4, S("abcde1234hij")); + test(S("abcdefghij"), 5, 2, S("12345"), 0, 5, S("abcde12345hij")); + test(S("abcdefghij"), 5, 2, S("12345"), 0, 6, S("abcde12345hij")); + test(S("abcdefghij"), 5, 2, S("12345"), 1, 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("12345"), 1, 1, S("abcde2hij")); + test(S("abcdefghij"), 5, 2, S("12345"), 1, 2, S("abcde23hij")); + test(S("abcdefghij"), 5, 2, S("12345"), 1, 3, S("abcde234hij")); + test(S("abcdefghij"), 5, 2, S("12345"), 1, 4, S("abcde2345hij")); + test(S("abcdefghij"), 5, 2, S("12345"), 1, 5, S("abcde2345hij")); + test(S("abcdefghij"), 5, 2, S("12345"), 2, 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("12345"), 2, 1, S("abcde3hij")); + test(S("abcdefghij"), 5, 2, S("12345"), 2, 2, S("abcde34hij")); + test(S("abcdefghij"), 5, 2, S("12345"), 2, 3, S("abcde345hij")); + test(S("abcdefghij"), 5, 2, S("12345"), 2, 4, S("abcde345hij")); + test(S("abcdefghij"), 5, 2, S("12345"), 4, 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("12345"), 4, 1, S("abcde5hij")); + test(S("abcdefghij"), 5, 2, S("12345"), 4, 2, S("abcde5hij")); + test(S("abcdefghij"), 5, 2, S("12345"), 5, 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("12345"), 5, 1, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 1, S("abcde1hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 5, S("abcde12345hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 9, S("abcde123456789hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 10, S("abcde1234567890hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 11, S("abcde1234567890hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 1, S("abcde2hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 4, S("abcde2345hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 8, S("abcde23456789hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 9, S("abcde234567890hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 10, S("abcde234567890hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 1, S("abcde6hij")); +} + +template <class S> +void test30() +{ + test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 2, S("abcde67hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 4, S("abcde6789hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 5, S("abcde67890hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 6, S("abcde67890hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 9, 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 9, 1, S("abcde0hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 9, 2, S("abcde0hij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 10, 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 10, 1, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 1, S("abcde1hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 10, S("abcde1234567890hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 1, S("abcde2hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 9, S("abcde234567890hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 18, S("abcde234567890123456789hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 1, S("abcde1hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 5, S("abcde12345hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 9, S("abcde123456789hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 10, S("abcde1234567890hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 11, S("abcde1234567890hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 19, 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 19, 1, S("abcde0hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 19, 2, S("abcde0hij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 20, 0, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 20, 1, S("abcdehij")); + test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 5, 4, S(""), 0, 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, S(""), 0, 1, S("abcdej")); + test(S("abcdefghij"), 5, 4, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 5, 4, S("12345"), 0, 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("12345"), 0, 1, S("abcde1j")); + test(S("abcdefghij"), 5, 4, S("12345"), 0, 2, S("abcde12j")); + test(S("abcdefghij"), 5, 4, S("12345"), 0, 4, S("abcde1234j")); + test(S("abcdefghij"), 5, 4, S("12345"), 0, 5, S("abcde12345j")); + test(S("abcdefghij"), 5, 4, S("12345"), 0, 6, S("abcde12345j")); + test(S("abcdefghij"), 5, 4, S("12345"), 1, 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("12345"), 1, 1, S("abcde2j")); + test(S("abcdefghij"), 5, 4, S("12345"), 1, 2, S("abcde23j")); + test(S("abcdefghij"), 5, 4, S("12345"), 1, 3, S("abcde234j")); + test(S("abcdefghij"), 5, 4, S("12345"), 1, 4, S("abcde2345j")); + test(S("abcdefghij"), 5, 4, S("12345"), 1, 5, S("abcde2345j")); + test(S("abcdefghij"), 5, 4, S("12345"), 2, 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("12345"), 2, 1, S("abcde3j")); + test(S("abcdefghij"), 5, 4, S("12345"), 2, 2, S("abcde34j")); + test(S("abcdefghij"), 5, 4, S("12345"), 2, 3, S("abcde345j")); + test(S("abcdefghij"), 5, 4, S("12345"), 2, 4, S("abcde345j")); + test(S("abcdefghij"), 5, 4, S("12345"), 4, 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("12345"), 4, 1, S("abcde5j")); + test(S("abcdefghij"), 5, 4, S("12345"), 4, 2, S("abcde5j")); + test(S("abcdefghij"), 5, 4, S("12345"), 5, 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("12345"), 5, 1, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 1, S("abcde1j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 5, S("abcde12345j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 9, S("abcde123456789j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 10, S("abcde1234567890j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 11, S("abcde1234567890j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 1, S("abcde2j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 4, S("abcde2345j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 8, S("abcde23456789j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 9, S("abcde234567890j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 10, S("abcde234567890j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 1, S("abcde6j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 2, S("abcde67j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 4, S("abcde6789j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 5, S("abcde67890j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 6, S("abcde67890j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 9, 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 9, 1, S("abcde0j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 9, 2, S("abcde0j")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 10, 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 10, 1, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 1, S("abcde1j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 10, S("abcde1234567890j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 1, S("abcde2j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 9, S("abcde234567890j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 18, S("abcde234567890123456789j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 1, S("abcde1j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 5, S("abcde12345j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 9, S("abcde123456789j")); +} + +template <class S> +void test31() +{ + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 10, S("abcde1234567890j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 11, S("abcde1234567890j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 19, 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 19, 1, S("abcde0j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 19, 2, S("abcde0j")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 20, 0, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 20, 1, S("abcdej")); + test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 5, 5, S(""), 0, 0, S("abcde")); + test(S("abcdefghij"), 5, 5, S(""), 0, 1, S("abcde")); + test(S("abcdefghij"), 5, 5, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 5, 5, S("12345"), 0, 0, S("abcde")); + test(S("abcdefghij"), 5, 5, S("12345"), 0, 1, S("abcde1")); + test(S("abcdefghij"), 5, 5, S("12345"), 0, 2, S("abcde12")); + test(S("abcdefghij"), 5, 5, S("12345"), 0, 4, S("abcde1234")); + test(S("abcdefghij"), 5, 5, S("12345"), 0, 5, S("abcde12345")); + test(S("abcdefghij"), 5, 5, S("12345"), 0, 6, S("abcde12345")); + test(S("abcdefghij"), 5, 5, S("12345"), 1, 0, S("abcde")); + test(S("abcdefghij"), 5, 5, S("12345"), 1, 1, S("abcde2")); + test(S("abcdefghij"), 5, 5, S("12345"), 1, 2, S("abcde23")); + test(S("abcdefghij"), 5, 5, S("12345"), 1, 3, S("abcde234")); + test(S("abcdefghij"), 5, 5, S("12345"), 1, 4, S("abcde2345")); + test(S("abcdefghij"), 5, 5, S("12345"), 1, 5, S("abcde2345")); + test(S("abcdefghij"), 5, 5, S("12345"), 2, 0, S("abcde")); + test(S("abcdefghij"), 5, 5, S("12345"), 2, 1, S("abcde3")); + test(S("abcdefghij"), 5, 5, S("12345"), 2, 2, S("abcde34")); + test(S("abcdefghij"), 5, 5, S("12345"), 2, 3, S("abcde345")); + test(S("abcdefghij"), 5, 5, S("12345"), 2, 4, S("abcde345")); + test(S("abcdefghij"), 5, 5, S("12345"), 4, 0, S("abcde")); + test(S("abcdefghij"), 5, 5, S("12345"), 4, 1, S("abcde5")); + test(S("abcdefghij"), 5, 5, S("12345"), 4, 2, S("abcde5")); + test(S("abcdefghij"), 5, 5, S("12345"), 5, 0, S("abcde")); + test(S("abcdefghij"), 5, 5, S("12345"), 5, 1, S("abcde")); + test(S("abcdefghij"), 5, 5, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 0, S("abcde")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 1, S("abcde1")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 5, S("abcde12345")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 9, S("abcde123456789")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 10, S("abcde1234567890")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 11, S("abcde1234567890")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 0, S("abcde")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 1, S("abcde2")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 4, S("abcde2345")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 8, S("abcde23456789")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 9, S("abcde234567890")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 10, S("abcde234567890")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 0, S("abcde")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 1, S("abcde6")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 2, S("abcde67")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 4, S("abcde6789")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 5, S("abcde67890")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 6, S("abcde67890")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 9, 0, S("abcde")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 9, 1, S("abcde0")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 9, 2, S("abcde0")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 10, 0, S("abcde")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 10, 1, S("abcde")); + test(S("abcdefghij"), 5, 5, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 0, S("abcde")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 1, S("abcde1")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 10, S("abcde1234567890")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 0, S("abcde")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 1, S("abcde2")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 9, S("abcde234567890")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 18, S("abcde234567890123456789")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 0, S("abcde")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 1, S("abcde1")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 5, S("abcde12345")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 9, S("abcde123456789")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 10, S("abcde1234567890")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 11, S("abcde1234567890")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 19, 0, S("abcde")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 19, 1, S("abcde0")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 19, 2, S("abcde0")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 20, 0, S("abcde")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 20, 1, S("abcde")); + test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 5, 6, S(""), 0, 0, S("abcde")); + test(S("abcdefghij"), 5, 6, S(""), 0, 1, S("abcde")); + test(S("abcdefghij"), 5, 6, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 5, 6, S("12345"), 0, 0, S("abcde")); + test(S("abcdefghij"), 5, 6, S("12345"), 0, 1, S("abcde1")); + test(S("abcdefghij"), 5, 6, S("12345"), 0, 2, S("abcde12")); + test(S("abcdefghij"), 5, 6, S("12345"), 0, 4, S("abcde1234")); + test(S("abcdefghij"), 5, 6, S("12345"), 0, 5, S("abcde12345")); + test(S("abcdefghij"), 5, 6, S("12345"), 0, 6, S("abcde12345")); + test(S("abcdefghij"), 5, 6, S("12345"), 1, 0, S("abcde")); + test(S("abcdefghij"), 5, 6, S("12345"), 1, 1, S("abcde2")); + test(S("abcdefghij"), 5, 6, S("12345"), 1, 2, S("abcde23")); + test(S("abcdefghij"), 5, 6, S("12345"), 1, 3, S("abcde234")); + test(S("abcdefghij"), 5, 6, S("12345"), 1, 4, S("abcde2345")); + test(S("abcdefghij"), 5, 6, S("12345"), 1, 5, S("abcde2345")); + test(S("abcdefghij"), 5, 6, S("12345"), 2, 0, S("abcde")); + test(S("abcdefghij"), 5, 6, S("12345"), 2, 1, S("abcde3")); + test(S("abcdefghij"), 5, 6, S("12345"), 2, 2, S("abcde34")); +} + +template <class S> +void test32() +{ + test(S("abcdefghij"), 5, 6, S("12345"), 2, 3, S("abcde345")); + test(S("abcdefghij"), 5, 6, S("12345"), 2, 4, S("abcde345")); + test(S("abcdefghij"), 5, 6, S("12345"), 4, 0, S("abcde")); + test(S("abcdefghij"), 5, 6, S("12345"), 4, 1, S("abcde5")); + test(S("abcdefghij"), 5, 6, S("12345"), 4, 2, S("abcde5")); + test(S("abcdefghij"), 5, 6, S("12345"), 5, 0, S("abcde")); + test(S("abcdefghij"), 5, 6, S("12345"), 5, 1, S("abcde")); + test(S("abcdefghij"), 5, 6, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 0, S("abcde")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 1, S("abcde1")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 5, S("abcde12345")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 9, S("abcde123456789")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 10, S("abcde1234567890")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 11, S("abcde1234567890")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 0, S("abcde")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 1, S("abcde2")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 4, S("abcde2345")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 8, S("abcde23456789")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 9, S("abcde234567890")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 10, S("abcde234567890")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 0, S("abcde")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 1, S("abcde6")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 2, S("abcde67")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 4, S("abcde6789")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 5, S("abcde67890")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 6, S("abcde67890")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 9, 0, S("abcde")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 9, 1, S("abcde0")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 9, 2, S("abcde0")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 10, 0, S("abcde")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 10, 1, S("abcde")); + test(S("abcdefghij"), 5, 6, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 0, S("abcde")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 1, S("abcde1")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 10, S("abcde1234567890")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 0, S("abcde")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 1, S("abcde2")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 9, S("abcde234567890")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 18, S("abcde234567890123456789")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 0, S("abcde")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 1, S("abcde1")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 5, S("abcde12345")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 9, S("abcde123456789")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 10, S("abcde1234567890")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 11, S("abcde1234567890")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 19, 0, S("abcde")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 19, 1, S("abcde0")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 19, 2, S("abcde0")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 20, 0, S("abcde")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 20, 1, S("abcde")); + test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 9, 0, S(""), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S(""), 0, 1, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 9, 0, S("12345"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("12345"), 0, 1, S("abcdefghi1j")); + test(S("abcdefghij"), 9, 0, S("12345"), 0, 2, S("abcdefghi12j")); + test(S("abcdefghij"), 9, 0, S("12345"), 0, 4, S("abcdefghi1234j")); + test(S("abcdefghij"), 9, 0, S("12345"), 0, 5, S("abcdefghi12345j")); + test(S("abcdefghij"), 9, 0, S("12345"), 0, 6, S("abcdefghi12345j")); + test(S("abcdefghij"), 9, 0, S("12345"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("12345"), 1, 1, S("abcdefghi2j")); + test(S("abcdefghij"), 9, 0, S("12345"), 1, 2, S("abcdefghi23j")); + test(S("abcdefghij"), 9, 0, S("12345"), 1, 3, S("abcdefghi234j")); + test(S("abcdefghij"), 9, 0, S("12345"), 1, 4, S("abcdefghi2345j")); + test(S("abcdefghij"), 9, 0, S("12345"), 1, 5, S("abcdefghi2345j")); + test(S("abcdefghij"), 9, 0, S("12345"), 2, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("12345"), 2, 1, S("abcdefghi3j")); + test(S("abcdefghij"), 9, 0, S("12345"), 2, 2, S("abcdefghi34j")); + test(S("abcdefghij"), 9, 0, S("12345"), 2, 3, S("abcdefghi345j")); + test(S("abcdefghij"), 9, 0, S("12345"), 2, 4, S("abcdefghi345j")); + test(S("abcdefghij"), 9, 0, S("12345"), 4, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("12345"), 4, 1, S("abcdefghi5j")); + test(S("abcdefghij"), 9, 0, S("12345"), 4, 2, S("abcdefghi5j")); + test(S("abcdefghij"), 9, 0, S("12345"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("12345"), 5, 1, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 1, S("abcdefghi1j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 5, S("abcdefghi12345j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 9, S("abcdefghi123456789j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 10, S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 11, S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 1, S("abcdefghi2j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 4, S("abcdefghi2345j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 8, S("abcdefghi23456789j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 9, S("abcdefghi234567890j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 10, S("abcdefghi234567890j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 1, S("abcdefghi6j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 2, S("abcdefghi67j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 4, S("abcdefghi6789j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 5, S("abcdefghi67890j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 6, S("abcdefghi67890j")); +} + +template <class S> +void test33() +{ + test(S("abcdefghij"), 9, 0, S("1234567890"), 9, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 9, 1, S("abcdefghi0j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 9, 2, S("abcdefghi0j")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 10, 1, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 1, S("abcdefghi1j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 1, S("abcdefghi2j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 9, S("abcdefghi234567890j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 1, S("abcdefghi1j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 5, S("abcdefghi12345j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 9, S("abcdefghi123456789j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 19, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 19, 1, S("abcdefghi0j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 19, 2, S("abcdefghi0j")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 20, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 20, 1, S("abcdefghij")); + test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 9, 1, S(""), 0, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S(""), 0, 1, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 9, 1, S("12345"), 0, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("12345"), 0, 1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 1, S("12345"), 0, 2, S("abcdefghi12")); + test(S("abcdefghij"), 9, 1, S("12345"), 0, 4, S("abcdefghi1234")); + test(S("abcdefghij"), 9, 1, S("12345"), 0, 5, S("abcdefghi12345")); + test(S("abcdefghij"), 9, 1, S("12345"), 0, 6, S("abcdefghi12345")); + test(S("abcdefghij"), 9, 1, S("12345"), 1, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("12345"), 1, 1, S("abcdefghi2")); + test(S("abcdefghij"), 9, 1, S("12345"), 1, 2, S("abcdefghi23")); + test(S("abcdefghij"), 9, 1, S("12345"), 1, 3, S("abcdefghi234")); + test(S("abcdefghij"), 9, 1, S("12345"), 1, 4, S("abcdefghi2345")); + test(S("abcdefghij"), 9, 1, S("12345"), 1, 5, S("abcdefghi2345")); + test(S("abcdefghij"), 9, 1, S("12345"), 2, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("12345"), 2, 1, S("abcdefghi3")); + test(S("abcdefghij"), 9, 1, S("12345"), 2, 2, S("abcdefghi34")); + test(S("abcdefghij"), 9, 1, S("12345"), 2, 3, S("abcdefghi345")); + test(S("abcdefghij"), 9, 1, S("12345"), 2, 4, S("abcdefghi345")); + test(S("abcdefghij"), 9, 1, S("12345"), 4, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("12345"), 4, 1, S("abcdefghi5")); + test(S("abcdefghij"), 9, 1, S("12345"), 4, 2, S("abcdefghi5")); + test(S("abcdefghij"), 9, 1, S("12345"), 5, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("12345"), 5, 1, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 5, S("abcdefghi12345")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 9, S("abcdefghi123456789")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 10, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 11, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 1, S("abcdefghi2")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 4, S("abcdefghi2345")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 8, S("abcdefghi23456789")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 9, S("abcdefghi234567890")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 10, S("abcdefghi234567890")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 1, S("abcdefghi6")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 2, S("abcdefghi67")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 4, S("abcdefghi6789")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 5, S("abcdefghi67890")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 6, S("abcdefghi67890")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 9, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 9, 1, S("abcdefghi0")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 9, 2, S("abcdefghi0")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 10, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 10, 1, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 1, S("abcdefghi2")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 9, S("abcdefghi234567890")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 5, S("abcdefghi12345")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 9, S("abcdefghi123456789")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, 1, S("abcdefghi0")); +} + +template <class S> +void test34() +{ + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, 2, S("abcdefghi0")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, 1, S("abcdefghi")); + test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 9, 2, S(""), 0, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S(""), 0, 1, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 9, 2, S("12345"), 0, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("12345"), 0, 1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 2, S("12345"), 0, 2, S("abcdefghi12")); + test(S("abcdefghij"), 9, 2, S("12345"), 0, 4, S("abcdefghi1234")); + test(S("abcdefghij"), 9, 2, S("12345"), 0, 5, S("abcdefghi12345")); + test(S("abcdefghij"), 9, 2, S("12345"), 0, 6, S("abcdefghi12345")); + test(S("abcdefghij"), 9, 2, S("12345"), 1, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("12345"), 1, 1, S("abcdefghi2")); + test(S("abcdefghij"), 9, 2, S("12345"), 1, 2, S("abcdefghi23")); + test(S("abcdefghij"), 9, 2, S("12345"), 1, 3, S("abcdefghi234")); + test(S("abcdefghij"), 9, 2, S("12345"), 1, 4, S("abcdefghi2345")); + test(S("abcdefghij"), 9, 2, S("12345"), 1, 5, S("abcdefghi2345")); + test(S("abcdefghij"), 9, 2, S("12345"), 2, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("12345"), 2, 1, S("abcdefghi3")); + test(S("abcdefghij"), 9, 2, S("12345"), 2, 2, S("abcdefghi34")); + test(S("abcdefghij"), 9, 2, S("12345"), 2, 3, S("abcdefghi345")); + test(S("abcdefghij"), 9, 2, S("12345"), 2, 4, S("abcdefghi345")); + test(S("abcdefghij"), 9, 2, S("12345"), 4, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("12345"), 4, 1, S("abcdefghi5")); + test(S("abcdefghij"), 9, 2, S("12345"), 4, 2, S("abcdefghi5")); + test(S("abcdefghij"), 9, 2, S("12345"), 5, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("12345"), 5, 1, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 5, S("abcdefghi12345")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 9, S("abcdefghi123456789")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 10, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 11, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 1, S("abcdefghi2")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 4, S("abcdefghi2345")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 8, S("abcdefghi23456789")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 9, S("abcdefghi234567890")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 10, S("abcdefghi234567890")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 1, S("abcdefghi6")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 2, S("abcdefghi67")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 4, S("abcdefghi6789")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 5, S("abcdefghi67890")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 6, S("abcdefghi67890")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 9, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 9, 1, S("abcdefghi0")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 9, 2, S("abcdefghi0")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 10, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 10, 1, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 1, S("abcdefghi2")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 9, S("abcdefghi234567890")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 1, S("abcdefghi1")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 5, S("abcdefghi12345")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 9, S("abcdefghi123456789")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 19, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 19, 1, S("abcdefghi0")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 19, 2, S("abcdefghi0")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 20, 0, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 20, 1, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 10, 0, S(""), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S(""), 0, 1, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 10, 0, S("12345"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("12345"), 0, 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 0, S("12345"), 0, 2, S("abcdefghij12")); + test(S("abcdefghij"), 10, 0, S("12345"), 0, 4, S("abcdefghij1234")); + test(S("abcdefghij"), 10, 0, S("12345"), 0, 5, S("abcdefghij12345")); + test(S("abcdefghij"), 10, 0, S("12345"), 0, 6, S("abcdefghij12345")); + test(S("abcdefghij"), 10, 0, S("12345"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("12345"), 1, 1, S("abcdefghij2")); + test(S("abcdefghij"), 10, 0, S("12345"), 1, 2, S("abcdefghij23")); + test(S("abcdefghij"), 10, 0, S("12345"), 1, 3, S("abcdefghij234")); + test(S("abcdefghij"), 10, 0, S("12345"), 1, 4, S("abcdefghij2345")); + test(S("abcdefghij"), 10, 0, S("12345"), 1, 5, S("abcdefghij2345")); + test(S("abcdefghij"), 10, 0, S("12345"), 2, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("12345"), 2, 1, S("abcdefghij3")); + test(S("abcdefghij"), 10, 0, S("12345"), 2, 2, S("abcdefghij34")); + test(S("abcdefghij"), 10, 0, S("12345"), 2, 3, S("abcdefghij345")); + test(S("abcdefghij"), 10, 0, S("12345"), 2, 4, S("abcdefghij345")); + test(S("abcdefghij"), 10, 0, S("12345"), 4, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("12345"), 4, 1, S("abcdefghij5")); +} + +template <class S> +void test35() +{ + test(S("abcdefghij"), 10, 0, S("12345"), 4, 2, S("abcdefghij5")); + test(S("abcdefghij"), 10, 0, S("12345"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("12345"), 5, 1, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 5, S("abcdefghij12345")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 9, S("abcdefghij123456789")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 10, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 11, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 1, S("abcdefghij2")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 4, S("abcdefghij2345")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 8, S("abcdefghij23456789")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 9, S("abcdefghij234567890")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 10, S("abcdefghij234567890")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 1, S("abcdefghij6")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 2, S("abcdefghij67")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 4, S("abcdefghij6789")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 5, S("abcdefghij67890")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 6, S("abcdefghij67890")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 9, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 9, 1, S("abcdefghij0")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 9, 2, S("abcdefghij0")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 10, 1, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 1, S("abcdefghij2")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 9, S("abcdefghij234567890")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 5, S("abcdefghij12345")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 9, S("abcdefghij123456789")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 19, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 19, 1, S("abcdefghij0")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 19, 2, S("abcdefghij0")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 20, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 20, 1, S("abcdefghij")); + test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 10, 1, S(""), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S(""), 0, 1, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 10, 1, S("12345"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("12345"), 0, 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 1, S("12345"), 0, 2, S("abcdefghij12")); + test(S("abcdefghij"), 10, 1, S("12345"), 0, 4, S("abcdefghij1234")); + test(S("abcdefghij"), 10, 1, S("12345"), 0, 5, S("abcdefghij12345")); + test(S("abcdefghij"), 10, 1, S("12345"), 0, 6, S("abcdefghij12345")); + test(S("abcdefghij"), 10, 1, S("12345"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("12345"), 1, 1, S("abcdefghij2")); + test(S("abcdefghij"), 10, 1, S("12345"), 1, 2, S("abcdefghij23")); + test(S("abcdefghij"), 10, 1, S("12345"), 1, 3, S("abcdefghij234")); + test(S("abcdefghij"), 10, 1, S("12345"), 1, 4, S("abcdefghij2345")); + test(S("abcdefghij"), 10, 1, S("12345"), 1, 5, S("abcdefghij2345")); + test(S("abcdefghij"), 10, 1, S("12345"), 2, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("12345"), 2, 1, S("abcdefghij3")); + test(S("abcdefghij"), 10, 1, S("12345"), 2, 2, S("abcdefghij34")); + test(S("abcdefghij"), 10, 1, S("12345"), 2, 3, S("abcdefghij345")); + test(S("abcdefghij"), 10, 1, S("12345"), 2, 4, S("abcdefghij345")); + test(S("abcdefghij"), 10, 1, S("12345"), 4, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("12345"), 4, 1, S("abcdefghij5")); + test(S("abcdefghij"), 10, 1, S("12345"), 4, 2, S("abcdefghij5")); + test(S("abcdefghij"), 10, 1, S("12345"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("12345"), 5, 1, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 5, S("abcdefghij12345")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 9, S("abcdefghij123456789")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 10, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 11, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 1, S("abcdefghij2")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 4, S("abcdefghij2345")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 8, S("abcdefghij23456789")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 9, S("abcdefghij234567890")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 10, S("abcdefghij234567890")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 1, S("abcdefghij6")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 2, S("abcdefghij67")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 4, S("abcdefghij6789")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 5, S("abcdefghij67890")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 6, S("abcdefghij67890")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 9, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 9, 1, S("abcdefghij0")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 9, 2, S("abcdefghij0")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 10, 0, S("abcdefghij")); +} + +template <class S> +void test36() +{ + test(S("abcdefghij"), 10, 1, S("1234567890"), 10, 1, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 1, S("abcdefghij2")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 9, S("abcdefghij234567890")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 1, S("abcdefghij1")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 5, S("abcdefghij12345")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 9, S("abcdefghij123456789")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 19, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 19, 1, S("abcdefghij0")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 19, 2, S("abcdefghij0")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 20, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 20, 1, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S(""), 0, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S(""), 0, 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, S(""), 1, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 0, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 0, 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 0, 2, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 0, 4, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 0, 5, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 0, 6, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 1, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 1, 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 1, 2, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 1, 3, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 1, 4, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 1, 5, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 2, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 2, 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 2, 2, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 2, 3, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 2, 4, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 4, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 4, 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 4, 2, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 5, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 5, 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 5, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 9, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 10, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 11, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 4, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 8, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 9, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 10, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 2, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 4, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 5, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 6, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 9, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 9, 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 9, 2, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 10, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 10, 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 10, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 19, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 20, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 21, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 9, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 18, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 19, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 20, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 5, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 9, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 10, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 11, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 19, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 19, 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 19, 2, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 20, 0, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 20, 1, S("can't happen")); + test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 21, 0, S("can't happen")); +} + +template <class S> +void test37() +{ + test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 1, S("1abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 2, S("12abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 4, S("1234abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 5, S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 6, S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 1, S("2abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 2, S("23abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 3, S("234abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 4, S("2345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 5, S("2345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 1, S("3abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 2, S("34abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 3, S("345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 4, S("345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 4, 1, S("5abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 4, 2, S("5abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 1, S("1abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 5, S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 9, S("123456789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 11, S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 1, S("2abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 4, S("2345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 8, S("23456789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 9, S("234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 10, S("234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 1, S("6abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 2, S("67abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 4, S("6789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 5, S("67890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 6, S("67890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 9, 1, S("0abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 9, 2, S("0abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 1, S("1abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 1, S("2abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 1, S("1abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 5, S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 19, 1, S("0abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 19, 2, S("0abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 1, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 1, S("1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 2, S("12bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 4, S("1234bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 5, S("12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 6, S("12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 1, S("2bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 2, S("23bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 3, S("234bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 4, S("2345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 5, S("2345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 1, S("3bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 2, S("34bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 3, S("345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 4, S("345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 4, 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 4, 1, S("5bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 4, 2, S("5bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 5, 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 5, 1, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 6, 0, S("can't happen")); +} + +template <class S> +void test38() +{ + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 1, S("1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 5, S("12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 9, S("123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 10, S("1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 11, S("1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 1, S("2bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 4, S("2345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 8, S("23456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 9, S("234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 10, S("234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 1, S("6bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 2, S("67bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 4, S("6789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 5, S("67890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 6, S("67890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 9, 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 9, 1, S("0bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 9, 2, S("0bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 10, 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 10, 1, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 1, S("1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 1, S("2bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 9, S("234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 1, S("1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 5, S("12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 9, S("123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 19, 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 19, 1, S("0bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 19, 2, S("0bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 20, 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 20, 1, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 1, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 1, S("1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 2, S("12klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 4, S("1234klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 5, S("12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 6, S("12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 1, S("2klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 2, S("23klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 3, S("234klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 4, S("2345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 5, S("2345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 1, S("3klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 2, S("34klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 3, S("345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 4, S("345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 4, 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 4, 1, S("5klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 4, 2, S("5klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 5, 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 5, 1, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 1, S("1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 5, S("12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 9, S("123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 10, S("1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 11, S("1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 1, S("2klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 4, S("2345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 8, S("23456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 9, S("234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 10, S("234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 1, S("6klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 2, S("67klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 4, S("6789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 5, S("67890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 6, S("67890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 9, 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 9, 1, S("0klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 9, 2, S("0klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 10, 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 10, 1, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 1, S("1klmnopqrst")); +} + +template <class S> +void test39() +{ + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 10, S("1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 19, S("1234567890123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 20, S("12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 21, S("12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 1, S("2klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 9, S("234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 18, S("234567890123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 19, S("2345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 20, S("2345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 1, S("1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 5, S("12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 9, S("123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 10, S("1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 11, S("1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 19, 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 19, 1, S("0klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 19, 2, S("0klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 20, 0, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 20, 1, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 1, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 1, S("1t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 2, S("12t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 4, S("1234t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 5, S("12345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 6, S("12345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 1, S("2t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 2, S("23t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 3, S("234t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 4, S("2345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 5, S("2345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 1, S("3t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 2, S("34t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 3, S("345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 4, S("345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 4, 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 4, 1, S("5t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 4, 2, S("5t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 5, 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 5, 1, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 1, S("1t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 5, S("12345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 9, S("123456789t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 10, S("1234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 11, S("1234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 1, S("2t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 4, S("2345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 8, S("23456789t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 9, S("234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 10, S("234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 1, S("6t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 2, S("67t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 4, S("6789t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 5, S("67890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 6, S("67890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 9, 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 9, 1, S("0t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 9, 2, S("0t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 10, 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 10, 1, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 1, S("1t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 10, S("1234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 19, S("1234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 20, S("12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 21, S("12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 1, S("2t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 9, S("234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 18, S("234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 19, S("2345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 20, S("2345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 1, S("1t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 5, S("12345t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 9, S("123456789t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 10, S("1234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 11, S("1234567890t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 19, 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 19, 1, S("0t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 19, 2, S("0t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 20, 0, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 20, 1, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 1, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 0, S("")); +} + +template <class S> +void test40() +{ + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 2, S("12")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 4, S("1234")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 5, S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 6, S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 1, S("2")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 2, S("23")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 3, S("234")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 4, S("2345")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 5, S("2345")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 1, S("3")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 2, S("34")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 3, S("345")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 4, S("345")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 4, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 4, 1, S("5")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 4, 2, S("5")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 5, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 5, 1, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 5, S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 9, S("123456789")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 10, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 11, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 1, S("2")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 4, S("2345")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 8, S("23456789")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 9, S("234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 10, S("234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 1, S("6")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 2, S("67")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 4, S("6789")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 5, S("67890")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 6, S("67890")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 9, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 9, 1, S("0")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 9, 2, S("0")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 10, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 10, 1, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 10, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 19, S("1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 20, S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 21, S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 1, S("2")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 9, S("234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 18, S("234567890123456789")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 19, S("2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 20, S("2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 5, S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 9, S("123456789")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 10, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 11, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 19, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 19, 1, S("0")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 19, 2, S("0")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 20, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 20, 1, S("")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 1, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 2, S("12")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 4, S("1234")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 5, S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 6, S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 1, S("2")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 2, S("23")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 3, S("234")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 4, S("2345")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 5, S("2345")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 1, S("3")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 2, S("34")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 3, S("345")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 4, S("345")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 4, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 4, 1, S("5")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 4, 2, S("5")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 5, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 5, 1, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 5, S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 9, S("123456789")); +} + +template <class S> +void test41() +{ + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 10, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 11, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 1, S("2")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 4, S("2345")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 8, S("23456789")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 9, S("234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 10, S("234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 1, S("6")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 2, S("67")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 4, S("6789")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 5, S("67890")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 6, S("67890")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 9, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 9, 1, S("0")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 9, 2, S("0")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 10, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 10, 1, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 10, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 19, S("1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 20, S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 21, S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 1, S("2")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 9, S("234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 18, S("234567890123456789")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 19, S("2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 20, S("2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 1, S("1")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 5, S("12345")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 9, S("123456789")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 10, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 11, S("1234567890")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 19, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 19, 1, S("0")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 19, 2, S("0")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 20, 0, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 20, 1, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 1, S("a1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 2, S("a12bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 4, S("a1234bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 5, S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 6, S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 1, S("a2bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 2, S("a23bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 3, S("a234bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 4, S("a2345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 5, S("a2345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 1, S("a3bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 2, S("a34bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 3, S("a345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 4, S("a345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 4, 1, S("a5bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 4, 2, S("a5bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 1, S("a1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 5, S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 9, S("a123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 11, S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 1, S("a2bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 4, S("a2345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 8, S("a23456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 10, S("a234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 1, S("a6bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 2, S("a67bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 4, S("a6789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 5, S("a67890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 6, S("a67890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 9, 1, S("a0bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 9, 2, S("a0bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 1, S("a1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghijklmnopqrst")); +} + +template <class S> +void test42() +{ + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 1, S("a2bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 1, S("a1bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 5, S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 9, S("a123456789bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 19, 1, S("a0bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 19, 2, S("a0bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 1, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 1, S("a1cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 2, S("a12cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 4, S("a1234cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 5, S("a12345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 6, S("a12345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 1, S("a2cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 2, S("a23cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 3, S("a234cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 4, S("a2345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 5, S("a2345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 1, S("a3cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 2, S("a34cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 3, S("a345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 4, S("a345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 4, 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 4, 1, S("a5cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 4, 2, S("a5cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 5, 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 5, 1, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 1, S("a1cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 5, S("a12345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 9, S("a123456789cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 10, S("a1234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 11, S("a1234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 1, S("a2cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 4, S("a2345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 8, S("a23456789cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 9, S("a234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 10, S("a234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 1, S("a6cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 2, S("a67cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 4, S("a6789cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 5, S("a67890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 6, S("a67890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 9, 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 9, 1, S("a0cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 9, 2, S("a0cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 10, 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 10, 1, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 1, S("a1cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 10, S("a1234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 1, S("a2cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 9, S("a234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 18, S("a234567890123456789cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 1, S("a1cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 5, S("a12345cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 9, S("a123456789cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 10, S("a1234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 11, S("a1234567890cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 19, 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 19, 1, S("a0cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 19, 2, S("a0cdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 20, 0, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 20, 1, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 1, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 1, S("a1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 2, S("a12klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 4, S("a1234klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 5, S("a12345klmnopqrst")); +} + +template <class S> +void test43() +{ + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 6, S("a12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 1, S("a2klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 2, S("a23klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 3, S("a234klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 4, S("a2345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 5, S("a2345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 1, S("a3klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 2, S("a34klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 3, S("a345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 4, S("a345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 4, 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 4, 1, S("a5klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 4, 2, S("a5klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 5, 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 5, 1, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 1, S("a1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 5, S("a12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 9, S("a123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 10, S("a1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 11, S("a1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 1, S("a2klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 4, S("a2345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 8, S("a23456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 9, S("a234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 10, S("a234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 1, S("a6klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 2, S("a67klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 4, S("a6789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 5, S("a67890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 6, S("a67890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 9, 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 9, 1, S("a0klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 9, 2, S("a0klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 10, 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 10, 1, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 1, S("a1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 10, S("a1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 19, S("a1234567890123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 20, S("a12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 21, S("a12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 1, S("a2klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 9, S("a234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 18, S("a234567890123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 19, S("a2345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 20, S("a2345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 1, S("a1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 5, S("a12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 9, S("a123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 10, S("a1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 11, S("a1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 19, 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 19, 1, S("a0klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 19, 2, S("a0klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 20, 0, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 20, 1, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 1, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 1, S("a1t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 2, S("a12t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 4, S("a1234t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 5, S("a12345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 6, S("a12345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 1, S("a2t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 2, S("a23t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 3, S("a234t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 4, S("a2345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 5, S("a2345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 1, S("a3t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 2, S("a34t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 3, S("a345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 4, S("a345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 4, 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 4, 1, S("a5t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 4, 2, S("a5t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 5, 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 5, 1, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 1, S("a1t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 5, S("a12345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 9, S("a123456789t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 10, S("a1234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 11, S("a1234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 1, S("a2t")); +} + +template <class S> +void test44() +{ + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 4, S("a2345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 8, S("a23456789t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 9, S("a234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 10, S("a234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 1, S("a6t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 2, S("a67t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 4, S("a6789t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 5, S("a67890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 6, S("a67890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 9, 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 9, 1, S("a0t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 9, 2, S("a0t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 10, 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 10, 1, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 1, S("a1t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 10, S("a1234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 19, S("a1234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 20, S("a12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 21, S("a12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 1, S("a2t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 9, S("a234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 18, S("a234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 19, S("a2345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 20, S("a2345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 1, S("a1t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 5, S("a12345t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 9, S("a123456789t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 10, S("a1234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 11, S("a1234567890t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 19, 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 19, 1, S("a0t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 19, 2, S("a0t")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 20, 0, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 20, 1, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 1, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 2, S("a12")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 4, S("a1234")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 5, S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 6, S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 1, S("a2")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 2, S("a23")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 3, S("a234")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 4, S("a2345")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 5, S("a2345")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 1, S("a3")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 2, S("a34")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 3, S("a345")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 4, S("a345")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 4, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 4, 1, S("a5")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 4, 2, S("a5")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 5, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 5, 1, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 5, S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 9, S("a123456789")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 10, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 11, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 1, S("a2")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 4, S("a2345")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 8, S("a23456789")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 9, S("a234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 10, S("a234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 1, S("a6")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 2, S("a67")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 4, S("a6789")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 5, S("a67890")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 6, S("a67890")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 9, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 9, 1, S("a0")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 9, 2, S("a0")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 10, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 10, 1, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 10, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 19, S("a1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 20, S("a12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 21, S("a12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 1, S("a2")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 9, S("a234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 18, S("a234567890123456789")); +} + +template <class S> +void test45() +{ + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 19, S("a2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 20, S("a2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 5, S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 9, S("a123456789")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 10, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 11, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 19, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 19, 1, S("a0")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 19, 2, S("a0")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 20, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 20, 1, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 1, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 2, S("a12")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 4, S("a1234")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 5, S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 6, S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 1, S("a2")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 2, S("a23")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 3, S("a234")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 4, S("a2345")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 5, S("a2345")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 1, S("a3")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 2, S("a34")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 3, S("a345")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 4, S("a345")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 4, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 4, 1, S("a5")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 4, 2, S("a5")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 5, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 5, 1, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 5, S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 9, S("a123456789")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 10, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 11, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 1, S("a2")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 4, S("a2345")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 8, S("a23456789")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 9, S("a234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 10, S("a234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 1, S("a6")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 2, S("a67")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 4, S("a6789")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 5, S("a67890")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 6, S("a67890")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 9, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 9, 1, S("a0")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 9, 2, S("a0")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 10, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 10, 1, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 10, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 19, S("a1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 20, S("a12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 21, S("a12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 1, S("a2")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 9, S("a234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 18, S("a234567890123456789")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 19, S("a2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 20, S("a2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 1, S("a1")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 5, S("a12345")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 9, S("a123456789")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 10, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 11, S("a1234567890")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 19, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 19, 1, S("a0")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 19, 2, S("a0")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 20, 0, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 20, 1, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 1, S("abcdefghij1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 2, S("abcdefghij12klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 4, S("abcdefghij1234klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 5, S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 6, S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 1, S("abcdefghij2klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 2, S("abcdefghij23klmnopqrst")); +} + +template <class S> +void test46() +{ + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 3, S("abcdefghij234klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 4, S("abcdefghij2345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 5, S("abcdefghij2345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 1, S("abcdefghij3klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 2, S("abcdefghij34klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 3, S("abcdefghij345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 4, S("abcdefghij345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 4, 1, S("abcdefghij5klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 4, 2, S("abcdefghij5klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 1, S("abcdefghij1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 5, S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 9, S("abcdefghij123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 11, S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 1, S("abcdefghij2klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 4, S("abcdefghij2345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 8, S("abcdefghij23456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 9, S("abcdefghij234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 10, S("abcdefghij234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 1, S("abcdefghij6klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 2, S("abcdefghij67klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 4, S("abcdefghij6789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 5, S("abcdefghij67890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 6, S("abcdefghij67890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 9, 1, S("abcdefghij0klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 9, 2, S("abcdefghij0klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 1, S("abcdefghij1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 1, S("abcdefghij2klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 9, S("abcdefghij234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 1, S("abcdefghij1klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 5, S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 9, S("abcdefghij123456789klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 19, 1, S("abcdefghij0klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 19, 2, S("abcdefghij0klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 1, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 1, S("abcdefghij1lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 2, S("abcdefghij12lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 4, S("abcdefghij1234lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 5, S("abcdefghij12345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 6, S("abcdefghij12345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 1, S("abcdefghij2lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 2, S("abcdefghij23lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 3, S("abcdefghij234lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 4, S("abcdefghij2345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 5, S("abcdefghij2345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 1, S("abcdefghij3lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 2, S("abcdefghij34lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 3, S("abcdefghij345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 4, S("abcdefghij345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 4, 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 4, 1, S("abcdefghij5lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 4, 2, S("abcdefghij5lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 5, 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 5, 1, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 1, S("abcdefghij1lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 5, S("abcdefghij12345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 9, S("abcdefghij123456789lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 10, S("abcdefghij1234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 11, S("abcdefghij1234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 1, S("abcdefghij2lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 4, S("abcdefghij2345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 8, S("abcdefghij23456789lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 9, S("abcdefghij234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 10, S("abcdefghij234567890lmnopqrst")); +} + +template <class S> +void test47() +{ + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 1, S("abcdefghij6lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 2, S("abcdefghij67lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 4, S("abcdefghij6789lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 5, S("abcdefghij67890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 6, S("abcdefghij67890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 9, 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 9, 1, S("abcdefghij0lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 9, 2, S("abcdefghij0lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 10, 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 10, 1, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 1, S("abcdefghij1lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 1, S("abcdefghij2lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 9, S("abcdefghij234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 1, S("abcdefghij1lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 5, S("abcdefghij12345lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 9, S("abcdefghij123456789lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 19, 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 19, 1, S("abcdefghij0lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 19, 2, S("abcdefghij0lmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 20, 0, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 20, 1, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 1, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 1, S("abcdefghij1pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 2, S("abcdefghij12pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 4, S("abcdefghij1234pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 5, S("abcdefghij12345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 6, S("abcdefghij12345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 1, S("abcdefghij2pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 2, S("abcdefghij23pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 3, S("abcdefghij234pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 4, S("abcdefghij2345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 5, S("abcdefghij2345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 1, S("abcdefghij3pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 2, S("abcdefghij34pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 3, S("abcdefghij345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 4, S("abcdefghij345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 4, 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 4, 1, S("abcdefghij5pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 4, 2, S("abcdefghij5pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 5, 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 5, 1, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 1, S("abcdefghij1pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 5, S("abcdefghij12345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 9, S("abcdefghij123456789pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 10, S("abcdefghij1234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 11, S("abcdefghij1234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 1, S("abcdefghij2pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 4, S("abcdefghij2345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 8, S("abcdefghij23456789pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 9, S("abcdefghij234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 10, S("abcdefghij234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 1, S("abcdefghij6pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 2, S("abcdefghij67pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 4, S("abcdefghij6789pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 5, S("abcdefghij67890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 6, S("abcdefghij67890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 9, 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 9, 1, S("abcdefghij0pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 9, 2, S("abcdefghij0pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 10, 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 10, 1, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 1, S("abcdefghij1pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 1, S("abcdefghij2pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 9, S("abcdefghij234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 1, S("abcdefghij1pqrst")); +} + +template <class S> +void test48() +{ + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 5, S("abcdefghij12345pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 9, S("abcdefghij123456789pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 19, 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 19, 1, S("abcdefghij0pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 19, 2, S("abcdefghij0pqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 20, 0, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 20, 1, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 1, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 1, S("abcdefghij1t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 2, S("abcdefghij12t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 4, S("abcdefghij1234t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 5, S("abcdefghij12345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 6, S("abcdefghij12345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 1, S("abcdefghij2t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 2, S("abcdefghij23t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 3, S("abcdefghij234t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 4, S("abcdefghij2345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 5, S("abcdefghij2345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 1, S("abcdefghij3t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 2, S("abcdefghij34t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 3, S("abcdefghij345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 4, S("abcdefghij345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 4, 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 4, 1, S("abcdefghij5t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 4, 2, S("abcdefghij5t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 5, 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 5, 1, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 1, S("abcdefghij1t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 5, S("abcdefghij12345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 9, S("abcdefghij123456789t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 10, S("abcdefghij1234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 11, S("abcdefghij1234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 1, S("abcdefghij2t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 4, S("abcdefghij2345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 8, S("abcdefghij23456789t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 9, S("abcdefghij234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 10, S("abcdefghij234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 1, S("abcdefghij6t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 2, S("abcdefghij67t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 4, S("abcdefghij6789t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 5, S("abcdefghij67890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 6, S("abcdefghij67890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 9, 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 9, 1, S("abcdefghij0t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 9, 2, S("abcdefghij0t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 10, 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 10, 1, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 1, S("abcdefghij1t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 1, S("abcdefghij2t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 9, S("abcdefghij234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 1, S("abcdefghij1t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 5, S("abcdefghij12345t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 9, S("abcdefghij123456789t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 19, 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 19, 1, S("abcdefghij0t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 19, 2, S("abcdefghij0t")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 20, 0, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 20, 1, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 1, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 2, S("abcdefghij12")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 4, S("abcdefghij1234")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 5, S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 6, S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 1, S("abcdefghij2")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 2, S("abcdefghij23")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 3, S("abcdefghij234")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 4, S("abcdefghij2345")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 5, S("abcdefghij2345")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 0, S("abcdefghij")); +} + +template <class S> +void test49() +{ + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 1, S("abcdefghij3")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 2, S("abcdefghij34")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 3, S("abcdefghij345")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 4, S("abcdefghij345")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 4, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 4, 1, S("abcdefghij5")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 4, 2, S("abcdefghij5")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 5, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 5, 1, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 5, S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 9, S("abcdefghij123456789")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 10, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 11, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 1, S("abcdefghij2")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 4, S("abcdefghij2345")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 8, S("abcdefghij23456789")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 9, S("abcdefghij234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 10, S("abcdefghij234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 1, S("abcdefghij6")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 2, S("abcdefghij67")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 4, S("abcdefghij6789")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 5, S("abcdefghij67890")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 6, S("abcdefghij67890")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 9, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 9, 1, S("abcdefghij0")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 9, 2, S("abcdefghij0")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 10, 1, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 1, S("abcdefghij2")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 9, S("abcdefghij234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 5, S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 9, S("abcdefghij123456789")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 19, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 19, 1, S("abcdefghij0")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 19, 2, S("abcdefghij0")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 20, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 20, 1, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 1, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 2, S("abcdefghij12")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 4, S("abcdefghij1234")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 5, S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 6, S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 1, S("abcdefghij2")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 2, S("abcdefghij23")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 3, S("abcdefghij234")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 4, S("abcdefghij2345")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 5, S("abcdefghij2345")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 1, S("abcdefghij3")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 2, S("abcdefghij34")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 3, S("abcdefghij345")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 4, S("abcdefghij345")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 4, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 4, 1, S("abcdefghij5")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 4, 2, S("abcdefghij5")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 5, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 5, 1, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 5, S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 9, S("abcdefghij123456789")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 10, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 11, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 1, S("abcdefghij2")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 4, S("abcdefghij2345")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 8, S("abcdefghij23456789")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 9, S("abcdefghij234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 10, S("abcdefghij234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 1, S("abcdefghij6")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 2, S("abcdefghij67")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 4, S("abcdefghij6789")); +} + +template <class S> +void test50() +{ + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 5, S("abcdefghij67890")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 6, S("abcdefghij67890")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 9, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 9, 1, S("abcdefghij0")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 9, 2, S("abcdefghij0")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 10, 1, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 1, S("abcdefghij2")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 9, S("abcdefghij234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 1, S("abcdefghij1")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 5, S("abcdefghij12345")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 9, S("abcdefghij123456789")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 19, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 19, 1, S("abcdefghij0")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 19, 2, S("abcdefghij0")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 20, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 20, 1, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 1, S("abcdefghijklmnopqrs1t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 2, S("abcdefghijklmnopqrs12t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 1, S("abcdefghijklmnopqrs2t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 2, S("abcdefghijklmnopqrs23t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 3, S("abcdefghijklmnopqrs234t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 1, S("abcdefghijklmnopqrs3t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 2, S("abcdefghijklmnopqrs34t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 3, S("abcdefghijklmnopqrs345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 4, S("abcdefghijklmnopqrs345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 4, 1, S("abcdefghijklmnopqrs5t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 4, 2, S("abcdefghijklmnopqrs5t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890t")); +} + +template <class S> +void test51() +{ + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0t")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 1, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 2, S("abcdefghijklmnopqrs12")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 1, S("abcdefghijklmnopqrs2")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 2, S("abcdefghijklmnopqrs23")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 3, S("abcdefghijklmnopqrs234")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 1, S("abcdefghijklmnopqrs3")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 2, S("abcdefghijklmnopqrs34")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 3, S("abcdefghijklmnopqrs345")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 4, S("abcdefghijklmnopqrs345")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 4, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 4, 1, S("abcdefghijklmnopqrs5")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 4, 2, S("abcdefghijklmnopqrs5")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 5, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 5, 1, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 9, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 10, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 10, 1, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 1, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 2, S("abcdefghijklmnopqrs12")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 1, S("abcdefghijklmnopqrs2")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 2, S("abcdefghijklmnopqrs23")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 3, S("abcdefghijklmnopqrs234")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 1, S("abcdefghijklmnopqrs3")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 2, S("abcdefghijklmnopqrs34")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 3, S("abcdefghijklmnopqrs345")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 4, S("abcdefghijklmnopqrs345")); +} + +template <class S> +void test52() +{ + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 4, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 4, 1, S("abcdefghijklmnopqrs5")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 4, 2, S("abcdefghijklmnopqrs5")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 5, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 5, 1, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 9, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 10, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 10, 1, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 2, S("abcdefghijklmnopqrst12")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 4, S("abcdefghijklmnopqrst1234")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 5, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 6, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 1, S("abcdefghijklmnopqrst2")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 2, S("abcdefghijklmnopqrst23")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 3, S("abcdefghijklmnopqrst234")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 4, S("abcdefghijklmnopqrst2345")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 5, S("abcdefghijklmnopqrst2345")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 1, S("abcdefghijklmnopqrst3")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 2, S("abcdefghijklmnopqrst34")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 3, S("abcdefghijklmnopqrst345")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 4, S("abcdefghijklmnopqrst345")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 4, 1, S("abcdefghijklmnopqrst5")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 4, 2, S("abcdefghijklmnopqrst5")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 5, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 9, S("abcdefghijklmnopqrst123456789")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 11, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 1, S("abcdefghijklmnopqrst2")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 4, S("abcdefghijklmnopqrst2345")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 8, S("abcdefghijklmnopqrst23456789")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 9, S("abcdefghijklmnopqrst234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 10, S("abcdefghijklmnopqrst234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 1, S("abcdefghijklmnopqrst6")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 2, S("abcdefghijklmnopqrst67")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 4, S("abcdefghijklmnopqrst6789")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 5, S("abcdefghijklmnopqrst67890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 6, S("abcdefghijklmnopqrst67890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 9, 1, S("abcdefghijklmnopqrst0")); +} + +template <class S> +void test53() +{ + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 9, 2, S("abcdefghijklmnopqrst0")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrst1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrst12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrst12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrst2")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrst234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrst234567890123456789")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrst2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrst2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrst123456789")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrst0")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrst0")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 2, S("abcdefghijklmnopqrst12")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 4, S("abcdefghijklmnopqrst1234")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 5, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 6, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 1, S("abcdefghijklmnopqrst2")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 2, S("abcdefghijklmnopqrst23")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 3, S("abcdefghijklmnopqrst234")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 4, S("abcdefghijklmnopqrst2345")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 5, S("abcdefghijklmnopqrst2345")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 1, S("abcdefghijklmnopqrst3")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 2, S("abcdefghijklmnopqrst34")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 3, S("abcdefghijklmnopqrst345")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 4, S("abcdefghijklmnopqrst345")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 4, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 4, 1, S("abcdefghijklmnopqrst5")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 4, 2, S("abcdefghijklmnopqrst5")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 5, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 5, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 9, S("abcdefghijklmnopqrst123456789")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 11, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 1, S("abcdefghijklmnopqrst2")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 4, S("abcdefghijklmnopqrst2345")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 8, S("abcdefghijklmnopqrst23456789")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 9, S("abcdefghijklmnopqrst234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 10, S("abcdefghijklmnopqrst234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 1, S("abcdefghijklmnopqrst6")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 2, S("abcdefghijklmnopqrst67")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 4, S("abcdefghijklmnopqrst6789")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 5, S("abcdefghijklmnopqrst67890")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 6, S("abcdefghijklmnopqrst67890")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 9, 1, S("abcdefghijklmnopqrst0")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 9, 2, S("abcdefghijklmnopqrst0")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrst1234567890123456789")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrst12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrst12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrst2")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrst234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrst234567890123456789")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrst2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrst2345678901234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrst1")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrst123456789")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrst0")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrst0")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst")); +} + +template <class S> +void test54() +{ + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 21, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 2, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 4, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 5, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 6, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 2, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 3, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 4, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 5, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 2, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 3, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 4, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 4, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 4, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 4, 2, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 5, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 5, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 6, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 5, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 9, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 10, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 11, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 4, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 8, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 9, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 10, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 2, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 4, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 5, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 6, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 9, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 9, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 9, 2, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 10, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 10, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 10, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 19, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 20, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 21, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 9, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 18, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 19, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 20, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 5, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 9, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 10, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 11, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 19, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 19, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 19, 2, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 20, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 20, 1, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 21, 0, S("can't happen")); +} + +template <class S> +void test55() +{ + test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, S("abcdefghi1234567890")); + test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, S("abcdefghi0")); + test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, S("abcdefghi")); + test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, S("abcdefghi")); + test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 21, S("can't happen")); + test_npos(S("abcdefghij"), 9, 2, S(""), 0, S("abcdefghi")); + test_npos(S("abcdefghij"), 9, 2, S(""), 1, S("can't happen")); + test_npos(S("abcdefghij"), 9, 2, S("12345"), 0, S("abcdefghi12345")); + test_npos(S("abcdefghij"), 9, 2, S("12345"), 1, S("abcdefghi2345")); + test_npos(S("abcdefghij"), 9, 2, S("12345"), 2, S("abcdefghi345")); + test_npos(S("abcdefghij"), 9, 2, S("12345"), 4, S("abcdefghi5")); + test_npos(S("abcdefghij"), 9, 2, S("12345"), 5, S("abcdefghi")); + test_npos(S("abcdefghij"), 9, 2, S("12345"), 6, S("can't happen")); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + test4<S>(); + test5<S>(); + test6<S>(); + test7<S>(); + test8<S>(); + test9<S>(); + test10<S>(); + test11<S>(); + test12<S>(); + test13<S>(); + test14<S>(); + test15<S>(); + test16<S>(); + test17<S>(); + test18<S>(); + test19<S>(); + test20<S>(); + test21<S>(); + test22<S>(); + test23<S>(); + test24<S>(); + test25<S>(); + test26<S>(); + test27<S>(); + test28<S>(); + test29<S>(); + test30<S>(); + test31<S>(); + test32<S>(); + test33<S>(); + test34<S>(); + test35<S>(); + test36<S>(); + test37<S>(); + test38<S>(); + test39<S>(); + test40<S>(); + test41<S>(); + test42<S>(); + test43<S>(); + test44<S>(); + test45<S>(); + test46<S>(); + test47<S>(); + test48<S>(); + test49<S>(); + test50<S>(); + test51<S>(); + test52<S>(); + test53<S>(); + test54<S>(); + test55<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + test4<S>(); + test5<S>(); + test6<S>(); + test7<S>(); + test8<S>(); + test9<S>(); + test10<S>(); + test11<S>(); + test12<S>(); + test13<S>(); + test14<S>(); + test15<S>(); + test16<S>(); + test17<S>(); + test18<S>(); + test19<S>(); + test20<S>(); + test21<S>(); + test22<S>(); + test23<S>(); + test24<S>(); + test25<S>(); + test26<S>(); + test27<S>(); + test28<S>(); + test29<S>(); + test30<S>(); + test31<S>(); + test32<S>(); + test33<S>(); + test34<S>(); + test35<S>(); + test36<S>(); + test37<S>(); + test38<S>(); + test39<S>(); + test40<S>(); + test41<S>(); + test42<S>(); + test43<S>(); + test44<S>(); + test45<S>(); + test46<S>(); + test47<S>(); + test48<S>(); + test49<S>(); + test50<S>(); + test51<S>(); + test52<S>(); + test53<S>(); + test54<S>(); + test55<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.modifiers/string_swap/swap.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_swap/swap.pass.cpp new file mode 100644 index 000000000000..4973bda4ddf0 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_swap/swap.pass.cpp @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// 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 swap(basic_string& s); + +#include <string> +#include <stdexcept> +#include <algorithm> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s1, S s2) +{ + S s1_ = s1; + S s2_ = s2; + s1.swap(s2); + assert(s1.__invariants()); + assert(s2.__invariants()); + assert(s1 == s2_); + assert(s2 == s1_); +} + +int main() +{ + { + typedef std::string S; + test(S(""), S("")); + test(S(""), S("12345")); + test(S(""), S("1234567890")); + test(S(""), S("12345678901234567890")); + test(S("abcde"), S("")); + test(S("abcde"), S("12345")); + test(S("abcde"), S("1234567890")); + test(S("abcde"), S("12345678901234567890")); + test(S("abcdefghij"), S("")); + test(S("abcdefghij"), S("12345")); + test(S("abcdefghij"), S("1234567890")); + test(S("abcdefghij"), S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), S("")); + test(S("abcdefghijklmnopqrst"), S("12345")); + test(S("abcdefghijklmnopqrst"), S("1234567890")); + test(S("abcdefghijklmnopqrst"), S("12345678901234567890")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), S("")); + test(S(""), S("12345")); + test(S(""), S("1234567890")); + test(S(""), S("12345678901234567890")); + test(S("abcde"), S("")); + test(S("abcde"), S("12345")); + test(S("abcde"), S("1234567890")); + test(S("abcde"), S("12345678901234567890")); + test(S("abcdefghij"), S("")); + test(S("abcdefghij"), S("12345")); + test(S("abcdefghij"), S("1234567890")); + test(S("abcdefghij"), S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), S("")); + test(S("abcdefghijklmnopqrst"), S("12345")); + test(S("abcdefghijklmnopqrst"), S("1234567890")); + test(S("abcdefghijklmnopqrst"), S("12345678901234567890")); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp b/test/std/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..b58f5c55b643 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp @@ -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() +{ +} diff --git a/test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp new file mode 100644 index 000000000000..4a912eaec6fa --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// basic_istream<charT,traits>& +// getline(basic_istream<charT,traits>& is, +// basic_string<charT,traits,Allocator>& str); + +#include <string> +#include <sstream> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ + { + std::istringstream in(" abc\n def\n ghij"); + std::string s("initial text"); + getline(in, s); + assert(in.good()); + assert(s == " abc"); + getline(in, s); + assert(in.good()); + assert(s == " def"); + getline(in, s); + assert(in.eof()); + assert(s == " ghij"); + } + { + std::wistringstream in(L" abc\n def\n ghij"); + std::wstring s(L"initial text"); + getline(in, s); + assert(in.good()); + assert(s == L" abc"); + getline(in, s); + assert(in.good()); + assert(s == L" def"); + getline(in, s); + assert(in.eof()); + assert(s == L" ghij"); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + std::istringstream in(" abc\n def\n ghij"); + S s("initial text"); + getline(in, s); + assert(in.good()); + assert(s == " abc"); + getline(in, s); + assert(in.good()); + assert(s == " def"); + getline(in, s); + assert(in.eof()); + assert(s == " ghij"); + } + { + typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; + std::wistringstream in(L" abc\n def\n ghij"); + S s(L"initial text"); + getline(in, s); + assert(in.good()); + assert(s == L" abc"); + getline(in, s); + assert(in.good()); + assert(s == L" def"); + getline(in, s); + assert(in.eof()); + assert(s == L" ghij"); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp new file mode 100644 index 000000000000..6596f2fffa79 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp @@ -0,0 +1,93 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// basic_istream<charT,traits>& +// getline(basic_istream<charT,traits>& is, +// basic_string<charT,traits,Allocator>& str, charT delim); + +#include <string> +#include <sstream> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ + { + std::istringstream in(" abc* def** ghij"); + std::string s("initial text"); + getline(in, s, '*'); + assert(in.good()); + assert(s == " abc"); + getline(in, s, '*'); + assert(in.good()); + assert(s == " def"); + getline(in, s, '*'); + assert(in.good()); + assert(s == ""); + getline(in, s, '*'); + assert(in.eof()); + assert(s == " ghij"); + } + { + std::wistringstream in(L" abc* def** ghij"); + std::wstring s(L"initial text"); + getline(in, s, L'*'); + assert(in.good()); + assert(s == L" abc"); + getline(in, s, L'*'); + assert(in.good()); + assert(s == L" def"); + getline(in, s, L'*'); + assert(in.good()); + assert(s == L""); + getline(in, s, L'*'); + assert(in.eof()); + assert(s == L" ghij"); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + std::istringstream in(" abc* def** ghij"); + S s("initial text"); + getline(in, s, '*'); + assert(in.good()); + assert(s == " abc"); + getline(in, s, '*'); + assert(in.good()); + assert(s == " def"); + getline(in, s, '*'); + assert(in.good()); + assert(s == ""); + getline(in, s, '*'); + assert(in.eof()); + assert(s == " ghij"); + } + { + typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; + std::wistringstream in(L" abc* def** ghij"); + S s(L"initial text"); + getline(in, s, L'*'); + assert(in.good()); + assert(s == L" abc"); + getline(in, s, L'*'); + assert(in.good()); + assert(s == L" def"); + getline(in, s, L'*'); + assert(in.good()); + assert(s == L""); + getline(in, s, L'*'); + assert(in.eof()); + assert(s == L" ghij"); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp new file mode 100644 index 000000000000..84f52bb2e50f --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// basic_istream<charT,traits>& +// getline(basic_istream<charT,traits>&& is, +// basic_string<charT,traits,Allocator>& str, charT delim); + +#include <string> +#include <sstream> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::string s("initial text"); + getline(std::istringstream(" abc* def* ghij"), s, '*'); + assert(s == " abc"); + } + { + std::wstring s(L"initial text"); + getline(std::wistringstream(L" abc* def* ghij"), s, L'*'); + assert(s == L" abc"); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S s("initial text"); + getline(std::istringstream(" abc* def* ghij"), s, '*'); + assert(s == " abc"); + } + { + typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; + S s(L"initial text"); + getline(std::wistringstream(L" abc* def* ghij"), s, L'*'); + assert(s == L" abc"); + } +#endif +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp new file mode 100644 index 000000000000..a3c9911abe9b --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// basic_istream<charT,traits>& +// getline(basic_istream<charT,traits>&& is, +// basic_string<charT,traits,Allocator>& str); + +#include <string> +#include <sstream> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::string s("initial text"); + getline(std::istringstream(" abc\n def\n ghij"), s); + assert(s == " abc"); + } + { + std::wstring s(L"initial text"); + getline(std::wistringstream(L" abc\n def\n ghij"), s); + assert(s == L" abc"); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S s("initial text"); + getline(std::istringstream(" abc\n def\n ghij"), s); + assert(s == " abc"); + } + { + typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; + S s(L"initial text"); + getline(std::wistringstream(L" abc\n def\n ghij"), s); + assert(s == L" abc"); + } +#endif +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp new file mode 100644 index 000000000000..af806bc04570 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp @@ -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> + +// template<class charT, class traits, class Allocator> +// basic_istream<charT,traits>& +// operator>>(basic_istream<charT,traits>& is, +// basic_string<charT,traits,Allocator>& str); + +#include <string> +#include <sstream> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ + { + std::istringstream in("a bc defghij"); + std::string s("initial text"); + in >> s; + assert(in.good()); + assert(s == "a"); + assert(in.peek() == ' '); + in >> s; + assert(in.good()); + assert(s == "bc"); + assert(in.peek() == ' '); + in.width(3); + in >> s; + assert(in.good()); + assert(s == "def"); + assert(in.peek() == 'g'); + in >> s; + assert(in.eof()); + assert(s == "ghij"); + in >> s; + assert(in.fail()); + } + { + std::wistringstream in(L"a bc defghij"); + std::wstring s(L"initial text"); + in >> s; + assert(in.good()); + assert(s == L"a"); + assert(in.peek() == L' '); + in >> s; + assert(in.good()); + assert(s == L"bc"); + assert(in.peek() == L' '); + in.width(3); + in >> s; + assert(in.good()); + assert(s == L"def"); + assert(in.peek() == L'g'); + in >> s; + assert(in.eof()); + assert(s == L"ghij"); + in >> s; + assert(in.fail()); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + std::istringstream in("a bc defghij"); + S s("initial text"); + in >> s; + assert(in.good()); + assert(s == "a"); + assert(in.peek() == ' '); + in >> s; + assert(in.good()); + assert(s == "bc"); + assert(in.peek() == ' '); + in.width(3); + in >> s; + assert(in.good()); + assert(s == "def"); + assert(in.peek() == 'g'); + in >> s; + assert(in.eof()); + assert(s == "ghij"); + in >> s; + assert(in.fail()); + } + { + typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; + std::wistringstream in(L"a bc defghij"); + S s(L"initial text"); + in >> s; + assert(in.good()); + assert(s == L"a"); + assert(in.peek() == L' '); + in >> s; + assert(in.good()); + assert(s == L"bc"); + assert(in.peek() == L' '); + in.width(3); + in >> s; + assert(in.good()); + assert(s == L"def"); + assert(in.peek() == L'g'); + in >> s; + assert(in.eof()); + assert(s == L"ghij"); + in >> s; + assert(in.fail()); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp new file mode 100644 index 000000000000..102e8ea08159 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp @@ -0,0 +1,91 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// basic_ostream<charT, traits>& +// operator<<(basic_ostream<charT, traits>& os, +// const basic_string<charT,traits,Allocator>& str); + +#include <string> +#include <sstream> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ + { + std::ostringstream out; + std::string s("some text"); + out << s; + assert(out.good()); + assert(s == out.str()); + } + { + std::ostringstream out; + std::string s("some text"); + out.width(12); + out << s; + assert(out.good()); + assert(" " + s == out.str()); + } + { + std::wostringstream out; + std::wstring s(L"some text"); + out << s; + assert(out.good()); + assert(s == out.str()); + } + { + std::wostringstream out; + std::wstring s(L"some text"); + out.width(12); + out << s; + assert(out.good()); + assert(L" " + s == out.str()); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out; + S s("some text"); + out << s; + assert(out.good()); + assert(s == out.str()); + } + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out; + S s("some text"); + out.width(12); + out << s; + assert(out.good()); + assert(" " + s == out.str()); + } + { + typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; + std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out; + S s(L"some text"); + out << s; + assert(out.good()); + assert(s == out.str()); + } + { + typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; + std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out; + S s(L"some text"); + out.width(12); + out << s; + assert(out.good()); + assert(L" " + s == out.str()); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp new file mode 100644 index 000000000000..cee538800dd0 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp @@ -0,0 +1,78 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// void swap(basic_string<charT,traits,Allocator>& lhs, +// basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <stdexcept> +#include <algorithm> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s1, S s2) +{ + S s1_ = s1; + S s2_ = s2; + swap(s1, s2); + assert(s1.__invariants()); + assert(s2.__invariants()); + assert(s1 == s2_); + assert(s2 == s1_); +} + +int main() +{ + { + typedef std::string S; + test(S(""), S("")); + test(S(""), S("12345")); + test(S(""), S("1234567890")); + test(S(""), S("12345678901234567890")); + test(S("abcde"), S("")); + test(S("abcde"), S("12345")); + test(S("abcde"), S("1234567890")); + test(S("abcde"), S("12345678901234567890")); + test(S("abcdefghij"), S("")); + test(S("abcdefghij"), S("12345")); + test(S("abcdefghij"), S("1234567890")); + test(S("abcdefghij"), S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), S("")); + test(S("abcdefghijklmnopqrst"), S("12345")); + test(S("abcdefghijklmnopqrst"), S("1234567890")); + test(S("abcdefghijklmnopqrst"), S("12345678901234567890")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), S("")); + test(S(""), S("12345")); + test(S(""), S("1234567890")); + test(S(""), S("12345678901234567890")); + test(S("abcde"), S("")); + test(S("abcde"), S("12345")); + test(S("abcde"), S("1234567890")); + test(S("abcde"), S("12345678901234567890")); + test(S("abcdefghij"), S("")); + test(S("abcdefghij"), S("12345")); + test(S("abcdefghij"), S("1234567890")); + test(S("abcdefghij"), S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), S("")); + test(S("abcdefghijklmnopqrst"), S("12345")); + test(S("abcdefghijklmnopqrst"), S("1234567890")); + test(S("abcdefghijklmnopqrst"), S("12345678901234567890")); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp new file mode 100644 index 000000000000..cfe03655a8a1 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp @@ -0,0 +1,85 @@ +//===----------------------------------------------------------------------===// +// +// 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 swap(basic_string& c) +// noexcept(!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable<allocator_type>::value); +// +// In C++17, the standard says that swap shall have: +// noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value || +// allocator_traits<Allocator>::is_always_equal::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() {} + some_alloc(const some_alloc&); + void deallocate(void*, unsigned) {} + + typedef std::true_type propagate_on_container_swap; +}; + +template <class T> +struct some_alloc2 +{ + typedef T value_type; + + some_alloc2() {} + some_alloc2(const some_alloc2&); + void deallocate(void*, unsigned) {} + + typedef std::false_type propagate_on_container_swap; + typedef std::true_type is_always_equal; +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::string C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C; + C c1, c2; +#if TEST_STD_VER >= 14 + // In c++14, if POCS is set, swapping the allocator is required not to throw + static_assert( noexcept(swap(c1, c2)), ""); +#else + static_assert(!noexcept(swap(c1, c2)), ""); +#endif + } +#if TEST_STD_VER >= 14 + { + typedef std::basic_string<char, std::char_traits<char>, some_alloc2<char>> C; + C c1, c2; + // if the allocators are always equal, then the swap can be noexcept + static_assert( noexcept(swap(c1, c2)), ""); + } +#endif + +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_op!=/pointer_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_op!=/pointer_string.pass.cpp new file mode 100644 index 000000000000..cc08982a5ca3 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_op!=/pointer_string.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// bool operator!=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const typename S::value_type* lhs, const S& rhs, bool x) +{ + assert((lhs != rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test("", S(""), false); + test("", S("abcde"), true); + test("", S("abcdefghij"), true); + test("", S("abcdefghijklmnopqrst"), true); + test("abcde", S(""), true); + test("abcde", S("abcde"), false); + test("abcde", S("abcdefghij"), true); + test("abcde", S("abcdefghijklmnopqrst"), true); + test("abcdefghij", S(""), true); + test("abcdefghij", S("abcde"), true); + test("abcdefghij", S("abcdefghij"), false); + test("abcdefghij", S("abcdefghijklmnopqrst"), true); + test("abcdefghijklmnopqrst", S(""), true); + test("abcdefghijklmnopqrst", S("abcde"), true); + test("abcdefghijklmnopqrst", S("abcdefghij"), true); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test("", S(""), false); + test("", S("abcde"), true); + test("", S("abcdefghij"), true); + test("", S("abcdefghijklmnopqrst"), true); + test("abcde", S(""), true); + test("abcde", S("abcde"), false); + test("abcde", S("abcdefghij"), true); + test("abcde", S("abcdefghijklmnopqrst"), true); + test("abcdefghij", S(""), true); + test("abcdefghij", S("abcde"), true); + test("abcdefghij", S("abcdefghij"), false); + test("abcdefghij", S("abcdefghijklmnopqrst"), true); + test("abcdefghijklmnopqrst", S(""), true); + test("abcdefghijklmnopqrst", S("abcde"), true); + test("abcdefghijklmnopqrst", S("abcdefghij"), true); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_op!=/string_pointer.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_op!=/string_pointer.pass.cpp new file mode 100644 index 000000000000..b496d70dc2f0 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_op!=/string_pointer.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// bool operator!=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const typename S::value_type* rhs, bool x) +{ + assert((lhs != rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), "", false); + test(S(""), "abcde", true); + test(S(""), "abcdefghij", true); + test(S(""), "abcdefghijklmnopqrst", true); + test(S("abcde"), "", true); + test(S("abcde"), "abcde", false); + test(S("abcde"), "abcdefghij", true); + test(S("abcde"), "abcdefghijklmnopqrst", true); + test(S("abcdefghij"), "", true); + test(S("abcdefghij"), "abcde", true); + test(S("abcdefghij"), "abcdefghij", false); + test(S("abcdefghij"), "abcdefghijklmnopqrst", true); + test(S("abcdefghijklmnopqrst"), "", true); + test(S("abcdefghijklmnopqrst"), "abcde", true); + test(S("abcdefghijklmnopqrst"), "abcdefghij", true); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), "", false); + test(S(""), "abcde", true); + test(S(""), "abcdefghij", true); + test(S(""), "abcdefghijklmnopqrst", true); + test(S("abcde"), "", true); + test(S("abcde"), "abcde", false); + test(S("abcde"), "abcdefghij", true); + test(S("abcde"), "abcdefghijklmnopqrst", true); + test(S("abcdefghij"), "", true); + test(S("abcdefghij"), "abcde", true); + test(S("abcdefghij"), "abcdefghij", false); + test(S("abcdefghij"), "abcdefghijklmnopqrst", true); + test(S("abcdefghijklmnopqrst"), "", true); + test(S("abcdefghijklmnopqrst"), "abcde", true); + test(S("abcdefghijklmnopqrst"), "abcdefghij", true); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_op!=/string_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_op!=/string_string.pass.cpp new file mode 100644 index 000000000000..069b305111d4 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_op!=/string_string.pass.cpp @@ -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> + +// template<class charT, class traits, class Allocator> +// bool operator!=(const basic_string<charT,traits,Allocator>& lhs, +// const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const S& rhs, bool x) +{ + assert((lhs != rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), S(""), false); + test(S(""), S("abcde"), true); + test(S(""), S("abcdefghij"), true); + test(S(""), S("abcdefghijklmnopqrst"), true); + test(S("abcde"), S(""), true); + test(S("abcde"), S("abcde"), false); + test(S("abcde"), S("abcdefghij"), true); + test(S("abcde"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghij"), S(""), true); + test(S("abcdefghij"), S("abcde"), true); + test(S("abcdefghij"), S("abcdefghij"), false); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghijklmnopqrst"), S(""), true); + test(S("abcdefghijklmnopqrst"), S("abcde"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), S(""), false); + test(S(""), S("abcde"), true); + test(S(""), S("abcdefghij"), true); + test(S(""), S("abcdefghijklmnopqrst"), true); + test(S("abcde"), S(""), true); + test(S("abcde"), S("abcde"), false); + test(S("abcde"), S("abcdefghij"), true); + test(S("abcde"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghij"), S(""), true); + test(S("abcdefghij"), S("abcde"), true); + test(S("abcdefghij"), S("abcdefghij"), false); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghijklmnopqrst"), S(""), true); + test(S("abcdefghijklmnopqrst"), S("abcde"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp new file mode 100644 index 000000000000..23a89c6fc8fb --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator> +// operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs); + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator>&& +// operator+(charT lhs, basic_string<charT,traits,Allocator>&& rhs); + +#include <string> +#include <utility> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test0(typename S::value_type lhs, const S& rhs, const S& x) +{ + assert(lhs + rhs == x); +} + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template <class S> +void +test1(typename S::value_type lhs, S&& rhs, const S& x) +{ + assert(lhs + move(rhs) == x); +} + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ + { + typedef std::string S; + test0('a', S(""), S("a")); + test0('a', S("12345"), S("a12345")); + test0('a', S("1234567890"), S("a1234567890")); + test0('a', S("12345678901234567890"), S("a12345678901234567890")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1('a', S(""), S("a")); + test1('a', S("12345"), S("a12345")); + test1('a', S("1234567890"), S("a1234567890")); + test1('a', S("12345678901234567890"), S("a12345678901234567890")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0('a', S(""), S("a")); + test0('a', S("12345"), S("a12345")); + test0('a', S("1234567890"), S("a1234567890")); + test0('a', S("12345678901234567890"), S("a12345678901234567890")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1('a', S(""), S("a")); + test1('a', S("12345"), S("a12345")); + test1('a', S("1234567890"), S("a1234567890")); + test1('a', S("12345678901234567890"), S("a12345678901234567890")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp new file mode 100644 index 000000000000..665e86f2c239 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp @@ -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> + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator> +// operator+(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator>&& +// operator+(const charT* lhs, basic_string<charT,traits,Allocator>&& rhs); + +#include <string> +#include <utility> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test0(const typename S::value_type* lhs, const S& rhs, const S& x) +{ + assert(lhs + rhs == x); +} + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template <class S> +void +test1(const typename S::value_type* lhs, S&& rhs, const S& x) +{ + assert(lhs + move(rhs) == x); +} + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ + { + typedef std::string S; + test0("", S(""), S("")); + test0("", S("12345"), S("12345")); + test0("", S("1234567890"), S("1234567890")); + test0("", S("12345678901234567890"), S("12345678901234567890")); + test0("abcde", S(""), S("abcde")); + test0("abcde", S("12345"), S("abcde12345")); + test0("abcde", S("1234567890"), S("abcde1234567890")); + test0("abcde", S("12345678901234567890"), S("abcde12345678901234567890")); + test0("abcdefghij", S(""), S("abcdefghij")); + test0("abcdefghij", S("12345"), S("abcdefghij12345")); + test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890")); + test0("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst")); + test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345")); + test0("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test0("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1("", S(""), S("")); + test1("", S("12345"), S("12345")); + test1("", S("1234567890"), S("1234567890")); + test1("", S("12345678901234567890"), S("12345678901234567890")); + test1("abcde", S(""), S("abcde")); + test1("abcde", S("12345"), S("abcde12345")); + test1("abcde", S("1234567890"), S("abcde1234567890")); + test1("abcde", S("12345678901234567890"), S("abcde12345678901234567890")); + test1("abcdefghij", S(""), S("abcdefghij")); + test1("abcdefghij", S("12345"), S("abcdefghij12345")); + test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890")); + test1("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst")); + test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345")); + test1("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test1("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0("", S(""), S("")); + test0("", S("12345"), S("12345")); + test0("", S("1234567890"), S("1234567890")); + test0("", S("12345678901234567890"), S("12345678901234567890")); + test0("abcde", S(""), S("abcde")); + test0("abcde", S("12345"), S("abcde12345")); + test0("abcde", S("1234567890"), S("abcde1234567890")); + test0("abcde", S("12345678901234567890"), S("abcde12345678901234567890")); + test0("abcdefghij", S(""), S("abcdefghij")); + test0("abcdefghij", S("12345"), S("abcdefghij12345")); + test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890")); + test0("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst")); + test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345")); + test0("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test0("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1("", S(""), S("")); + test1("", S("12345"), S("12345")); + test1("", S("1234567890"), S("1234567890")); + test1("", S("12345678901234567890"), S("12345678901234567890")); + test1("abcde", S(""), S("abcde")); + test1("abcde", S("12345"), S("abcde12345")); + test1("abcde", S("1234567890"), S("abcde1234567890")); + test1("abcde", S("12345678901234567890"), S("abcde12345678901234567890")); + test1("abcdefghij", S(""), S("abcdefghij")); + test1("abcdefghij", S("12345"), S("abcdefghij12345")); + test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890")); + test1("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst")); + test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345")); + test1("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test1("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp new file mode 100644 index 000000000000..12903fe8118e --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator> +// operator+(const basic_string<charT,traits,Allocator>& lhs, charT rhs); + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator>&& +// operator+(basic_string<charT,traits,Allocator>&& lhs, charT rhs); + +#include <string> +#include <utility> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test0(const S& lhs, typename S::value_type rhs, const S& x) +{ + assert(lhs + rhs == x); +} + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template <class S> +void +test1(S&& lhs, typename S::value_type rhs, const S& x) +{ + assert(move(lhs) + rhs == x); +} + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ + { + typedef std::string S; + test0(S(""), '1', S("1")); + test0(S("abcde"), '1', S("abcde1")); + test0(S("abcdefghij"), '1', S("abcdefghij1")); + test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1(S(""), '1', S("1")); + test1(S("abcde"), '1', S("abcde1")); + test1(S("abcdefghij"), '1', S("abcdefghij1")); + test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0(S(""), '1', S("1")); + test0(S("abcde"), '1', S("abcde1")); + test0(S("abcdefghij"), '1', S("abcdefghij1")); + test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1(S(""), '1', S("1")); + test1(S("abcde"), '1', S("abcde1")); + test1(S("abcdefghij"), '1', S("abcdefghij1")); + test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp new file mode 100644 index 000000000000..63a7b769b787 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp @@ -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> + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator> +// operator+(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator>&& +// operator+(basic_string<charT,traits,Allocator>&& lhs, const charT* rhs); + +#include <string> +#include <utility> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test0(const S& lhs, const typename S::value_type* rhs, const S& x) +{ + assert(lhs + rhs == x); +} + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template <class S> +void +test1(S&& lhs, const typename S::value_type* rhs, const S& x) +{ + assert(move(lhs) + rhs == x); +} + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ + { + typedef std::string S; + test0(S(""), "", S("")); + test0(S(""), "12345", S("12345")); + test0(S(""), "1234567890", S("1234567890")); + test0(S(""), "12345678901234567890", S("12345678901234567890")); + test0(S("abcde"), "", S("abcde")); + test0(S("abcde"), "12345", S("abcde12345")); + test0(S("abcde"), "1234567890", S("abcde1234567890")); + test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890")); + test0(S("abcdefghij"), "", S("abcdefghij")); + test0(S("abcdefghij"), "12345", S("abcdefghij12345")); + test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890")); + test0(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890")); + test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst")); + test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345")); + test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890")); + test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1(S(""), "", S("")); + test1(S(""), "12345", S("12345")); + test1(S(""), "1234567890", S("1234567890")); + test1(S(""), "12345678901234567890", S("12345678901234567890")); + test1(S("abcde"), "", S("abcde")); + test1(S("abcde"), "12345", S("abcde12345")); + test1(S("abcde"), "1234567890", S("abcde1234567890")); + test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890")); + test1(S("abcdefghij"), "", S("abcdefghij")); + test1(S("abcdefghij"), "12345", S("abcdefghij12345")); + test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890")); + test1(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890")); + test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst")); + test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345")); + test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890")); + test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0(S(""), "", S("")); + test0(S(""), "12345", S("12345")); + test0(S(""), "1234567890", S("1234567890")); + test0(S(""), "12345678901234567890", S("12345678901234567890")); + test0(S("abcde"), "", S("abcde")); + test0(S("abcde"), "12345", S("abcde12345")); + test0(S("abcde"), "1234567890", S("abcde1234567890")); + test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890")); + test0(S("abcdefghij"), "", S("abcdefghij")); + test0(S("abcdefghij"), "12345", S("abcdefghij12345")); + test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890")); + test0(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890")); + test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst")); + test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345")); + test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890")); + test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1(S(""), "", S("")); + test1(S(""), "12345", S("12345")); + test1(S(""), "1234567890", S("1234567890")); + test1(S(""), "12345678901234567890", S("12345678901234567890")); + test1(S("abcde"), "", S("abcde")); + test1(S("abcde"), "12345", S("abcde12345")); + test1(S("abcde"), "1234567890", S("abcde1234567890")); + test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890")); + test1(S("abcdefghij"), "", S("abcdefghij")); + test1(S("abcdefghij"), "12345", S("abcdefghij12345")); + test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890")); + test1(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890")); + test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst")); + test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345")); + test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890")); + test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp new file mode 100644 index 000000000000..318b648d6eb0 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp @@ -0,0 +1,222 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator> +// operator+(const basic_string<charT,traits,Allocator>& lhs, +// const basic_string<charT,traits,Allocator>& rhs); + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator>&& +// operator+(const basic_string<charT,traits,Allocator>&& lhs, +// const basic_string<charT,traits,Allocator>& rhs); + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator>&& +// operator+(const basic_string<charT,traits,Allocator>& lhs, +// const basic_string<charT,traits,Allocator>&& rhs); + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator>&& +// operator+(const basic_string<charT,traits,Allocator>&& lhs, +// const basic_string<charT,traits,Allocator>&& rhs); + +#include <string> +#include <utility> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test0(const S& lhs, const S& rhs, const S& x) +{ + assert(lhs + rhs == x); +} + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template <class S> +void +test1(S&& lhs, const S& rhs, const S& x) +{ + assert(move(lhs) + rhs == x); +} + +template <class S> +void +test2(const S& lhs, S&& rhs, const S& x) +{ + assert(lhs + move(rhs) == x); +} + +template <class S> +void +test3(S&& lhs, S&& rhs, const S& x) +{ + assert(move(lhs) + move(rhs) == x); +} + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ + { + typedef std::string S; + test0(S(""), S(""), S("")); + test0(S(""), S("12345"), S("12345")); + test0(S(""), S("1234567890"), S("1234567890")); + test0(S(""), S("12345678901234567890"), S("12345678901234567890")); + test0(S("abcde"), S(""), S("abcde")); + test0(S("abcde"), S("12345"), S("abcde12345")); + test0(S("abcde"), S("1234567890"), S("abcde1234567890")); + test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); + test0(S("abcdefghij"), S(""), S("abcdefghij")); + test0(S("abcdefghij"), S("12345"), S("abcdefghij12345")); + test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); + test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); + test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); + test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1(S(""), S(""), S("")); + test1(S(""), S("12345"), S("12345")); + test1(S(""), S("1234567890"), S("1234567890")); + test1(S(""), S("12345678901234567890"), S("12345678901234567890")); + test1(S("abcde"), S(""), S("abcde")); + test1(S("abcde"), S("12345"), S("abcde12345")); + test1(S("abcde"), S("1234567890"), S("abcde1234567890")); + test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); + test1(S("abcdefghij"), S(""), S("abcdefghij")); + test1(S("abcdefghij"), S("12345"), S("abcdefghij12345")); + test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); + test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); + test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); + test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + + test2(S(""), S(""), S("")); + test2(S(""), S("12345"), S("12345")); + test2(S(""), S("1234567890"), S("1234567890")); + test2(S(""), S("12345678901234567890"), S("12345678901234567890")); + test2(S("abcde"), S(""), S("abcde")); + test2(S("abcde"), S("12345"), S("abcde12345")); + test2(S("abcde"), S("1234567890"), S("abcde1234567890")); + test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); + test2(S("abcdefghij"), S(""), S("abcdefghij")); + test2(S("abcdefghij"), S("12345"), S("abcdefghij12345")); + test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); + test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); + test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); + test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + + test3(S(""), S(""), S("")); + test3(S(""), S("12345"), S("12345")); + test3(S(""), S("1234567890"), S("1234567890")); + test3(S(""), S("12345678901234567890"), S("12345678901234567890")); + test3(S("abcde"), S(""), S("abcde")); + test3(S("abcde"), S("12345"), S("abcde12345")); + test3(S("abcde"), S("1234567890"), S("abcde1234567890")); + test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); + test3(S("abcdefghij"), S(""), S("abcdefghij")); + test3(S("abcdefghij"), S("12345"), S("abcdefghij12345")); + test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); + test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); + test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); + test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0(S(""), S(""), S("")); + test0(S(""), S("12345"), S("12345")); + test0(S(""), S("1234567890"), S("1234567890")); + test0(S(""), S("12345678901234567890"), S("12345678901234567890")); + test0(S("abcde"), S(""), S("abcde")); + test0(S("abcde"), S("12345"), S("abcde12345")); + test0(S("abcde"), S("1234567890"), S("abcde1234567890")); + test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); + test0(S("abcdefghij"), S(""), S("abcdefghij")); + test0(S("abcdefghij"), S("12345"), S("abcdefghij12345")); + test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); + test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); + test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); + test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1(S(""), S(""), S("")); + test1(S(""), S("12345"), S("12345")); + test1(S(""), S("1234567890"), S("1234567890")); + test1(S(""), S("12345678901234567890"), S("12345678901234567890")); + test1(S("abcde"), S(""), S("abcde")); + test1(S("abcde"), S("12345"), S("abcde12345")); + test1(S("abcde"), S("1234567890"), S("abcde1234567890")); + test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); + test1(S("abcdefghij"), S(""), S("abcdefghij")); + test1(S("abcdefghij"), S("12345"), S("abcdefghij12345")); + test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); + test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); + test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); + test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + + test2(S(""), S(""), S("")); + test2(S(""), S("12345"), S("12345")); + test2(S(""), S("1234567890"), S("1234567890")); + test2(S(""), S("12345678901234567890"), S("12345678901234567890")); + test2(S("abcde"), S(""), S("abcde")); + test2(S("abcde"), S("12345"), S("abcde12345")); + test2(S("abcde"), S("1234567890"), S("abcde1234567890")); + test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); + test2(S("abcdefghij"), S(""), S("abcdefghij")); + test2(S("abcdefghij"), S("12345"), S("abcdefghij12345")); + test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); + test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); + test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); + test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + + test3(S(""), S(""), S("")); + test3(S(""), S("12345"), S("12345")); + test3(S(""), S("1234567890"), S("1234567890")); + test3(S(""), S("12345678901234567890"), S("12345678901234567890")); + test3(S("abcde"), S(""), S("abcde")); + test3(S("abcde"), S("12345"), S("abcde12345")); + test3(S("abcde"), S("1234567890"), S("abcde1234567890")); + test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); + test3(S("abcdefghij"), S(""), S("abcdefghij")); + test3(S("abcdefghij"), S("12345"), S("abcdefghij12345")); + test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); + test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); + test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); + test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp new file mode 100644 index 000000000000..19a5bdd977e4 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// bool operator==(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const typename S::value_type* lhs, const S& rhs, bool x) +{ + assert((lhs == rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test("", S(""), true); + test("", S("abcde"), false); + test("", S("abcdefghij"), false); + test("", S("abcdefghijklmnopqrst"), false); + test("abcde", S(""), false); + test("abcde", S("abcde"), true); + test("abcde", S("abcdefghij"), false); + test("abcde", S("abcdefghijklmnopqrst"), false); + test("abcdefghij", S(""), false); + test("abcdefghij", S("abcde"), false); + test("abcdefghij", S("abcdefghij"), true); + test("abcdefghij", S("abcdefghijklmnopqrst"), false); + test("abcdefghijklmnopqrst", S(""), false); + test("abcdefghijklmnopqrst", S("abcde"), false); + test("abcdefghijklmnopqrst", S("abcdefghij"), false); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test("", S(""), true); + test("", S("abcde"), false); + test("", S("abcdefghij"), false); + test("", S("abcdefghijklmnopqrst"), false); + test("abcde", S(""), false); + test("abcde", S("abcde"), true); + test("abcde", S("abcdefghij"), false); + test("abcde", S("abcdefghijklmnopqrst"), false); + test("abcdefghij", S(""), false); + test("abcdefghij", S("abcde"), false); + test("abcdefghij", S("abcdefghij"), true); + test("abcdefghij", S("abcdefghijklmnopqrst"), false); + test("abcdefghijklmnopqrst", S(""), false); + test("abcdefghijklmnopqrst", S("abcde"), false); + test("abcdefghijklmnopqrst", S("abcdefghij"), false); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp new file mode 100644 index 000000000000..22006bb1be68 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const typename S::value_type* rhs, bool x) +{ + assert((lhs == rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), "", true); + test(S(""), "abcde", false); + test(S(""), "abcdefghij", false); + test(S(""), "abcdefghijklmnopqrst", false); + test(S("abcde"), "", false); + test(S("abcde"), "abcde", true); + test(S("abcde"), "abcdefghij", false); + test(S("abcde"), "abcdefghijklmnopqrst", false); + test(S("abcdefghij"), "", false); + test(S("abcdefghij"), "abcde", false); + test(S("abcdefghij"), "abcdefghij", true); + test(S("abcdefghij"), "abcdefghijklmnopqrst", false); + test(S("abcdefghijklmnopqrst"), "", false); + test(S("abcdefghijklmnopqrst"), "abcde", false); + test(S("abcdefghijklmnopqrst"), "abcdefghij", false); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), "", true); + test(S(""), "abcde", false); + test(S(""), "abcdefghij", false); + test(S(""), "abcdefghijklmnopqrst", false); + test(S("abcde"), "", false); + test(S("abcde"), "abcde", true); + test(S("abcde"), "abcdefghij", false); + test(S("abcde"), "abcdefghijklmnopqrst", false); + test(S("abcdefghij"), "", false); + test(S("abcdefghij"), "abcde", false); + test(S("abcdefghij"), "abcdefghij", true); + test(S("abcdefghij"), "abcdefghijklmnopqrst", false); + test(S("abcdefghijklmnopqrst"), "", false); + test(S("abcdefghijklmnopqrst"), "abcde", false); + test(S("abcdefghijklmnopqrst"), "abcdefghij", false); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp new file mode 100644 index 000000000000..0bff70a977a6 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp @@ -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> + +// template<class charT, class traits, class Allocator> +// bool operator==(const basic_string<charT,traits,Allocator>& lhs, +// const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const S& rhs, bool x) +{ + assert((lhs == rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), S(""), true); + test(S(""), S("abcde"), false); + test(S(""), S("abcdefghij"), false); + test(S(""), S("abcdefghijklmnopqrst"), false); + test(S("abcde"), S(""), false); + test(S("abcde"), S("abcde"), true); + test(S("abcde"), S("abcdefghij"), false); + test(S("abcde"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghij"), S(""), false); + test(S("abcdefghij"), S("abcde"), false); + test(S("abcdefghij"), S("abcdefghij"), true); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghijklmnopqrst"), S(""), false); + test(S("abcdefghijklmnopqrst"), S("abcde"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), S(""), true); + test(S(""), S("abcde"), false); + test(S(""), S("abcdefghij"), false); + test(S(""), S("abcdefghijklmnopqrst"), false); + test(S("abcde"), S(""), false); + test(S("abcde"), S("abcde"), true); + test(S("abcde"), S("abcdefghij"), false); + test(S("abcde"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghij"), S(""), false); + test(S("abcdefghij"), S("abcde"), false); + test(S("abcdefghij"), S("abcdefghij"), true); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghijklmnopqrst"), S(""), false); + test(S("abcdefghijklmnopqrst"), S("abcde"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp new file mode 100644 index 000000000000..f9fa204b9eea --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// bool operator>(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const typename S::value_type* lhs, const S& rhs, bool x) +{ + assert((lhs > rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test("", S(""), false); + test("", S("abcde"), false); + test("", S("abcdefghij"), false); + test("", S("abcdefghijklmnopqrst"), false); + test("abcde", S(""), true); + test("abcde", S("abcde"), false); + test("abcde", S("abcdefghij"), false); + test("abcde", S("abcdefghijklmnopqrst"), false); + test("abcdefghij", S(""), true); + test("abcdefghij", S("abcde"), true); + test("abcdefghij", S("abcdefghij"), false); + test("abcdefghij", S("abcdefghijklmnopqrst"), false); + test("abcdefghijklmnopqrst", S(""), true); + test("abcdefghijklmnopqrst", S("abcde"), true); + test("abcdefghijklmnopqrst", S("abcdefghij"), true); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test("", S(""), false); + test("", S("abcde"), false); + test("", S("abcdefghij"), false); + test("", S("abcdefghijklmnopqrst"), false); + test("abcde", S(""), true); + test("abcde", S("abcde"), false); + test("abcde", S("abcdefghij"), false); + test("abcde", S("abcdefghijklmnopqrst"), false); + test("abcdefghij", S(""), true); + test("abcdefghij", S("abcde"), true); + test("abcdefghij", S("abcdefghij"), false); + test("abcdefghij", S("abcdefghijklmnopqrst"), false); + test("abcdefghijklmnopqrst", S(""), true); + test("abcdefghijklmnopqrst", S("abcde"), true); + test("abcdefghijklmnopqrst", S("abcdefghij"), true); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp new file mode 100644 index 000000000000..daa6f40ae3c0 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// bool operator>(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const typename S::value_type* rhs, bool x) +{ + assert((lhs > rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), "", false); + test(S(""), "abcde", false); + test(S(""), "abcdefghij", false); + test(S(""), "abcdefghijklmnopqrst", false); + test(S("abcde"), "", true); + test(S("abcde"), "abcde", false); + test(S("abcde"), "abcdefghij", false); + test(S("abcde"), "abcdefghijklmnopqrst", false); + test(S("abcdefghij"), "", true); + test(S("abcdefghij"), "abcde", true); + test(S("abcdefghij"), "abcdefghij", false); + test(S("abcdefghij"), "abcdefghijklmnopqrst", false); + test(S("abcdefghijklmnopqrst"), "", true); + test(S("abcdefghijklmnopqrst"), "abcde", true); + test(S("abcdefghijklmnopqrst"), "abcdefghij", true); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), "", false); + test(S(""), "abcde", false); + test(S(""), "abcdefghij", false); + test(S(""), "abcdefghijklmnopqrst", false); + test(S("abcde"), "", true); + test(S("abcde"), "abcde", false); + test(S("abcde"), "abcdefghij", false); + test(S("abcde"), "abcdefghijklmnopqrst", false); + test(S("abcdefghij"), "", true); + test(S("abcdefghij"), "abcde", true); + test(S("abcdefghij"), "abcdefghij", false); + test(S("abcdefghij"), "abcdefghijklmnopqrst", false); + test(S("abcdefghijklmnopqrst"), "", true); + test(S("abcdefghijklmnopqrst"), "abcde", true); + test(S("abcdefghijklmnopqrst"), "abcdefghij", true); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp new file mode 100644 index 000000000000..95073bf7644c --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp @@ -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> + +// template<class charT, class traits, class Allocator> +// bool operator>(const basic_string<charT,traits,Allocator>& lhs, +// const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const S& rhs, bool x) +{ + assert((lhs > rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), S(""), false); + test(S(""), S("abcde"), false); + test(S(""), S("abcdefghij"), false); + test(S(""), S("abcdefghijklmnopqrst"), false); + test(S("abcde"), S(""), true); + test(S("abcde"), S("abcde"), false); + test(S("abcde"), S("abcdefghij"), false); + test(S("abcde"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghij"), S(""), true); + test(S("abcdefghij"), S("abcde"), true); + test(S("abcdefghij"), S("abcdefghij"), false); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghijklmnopqrst"), S(""), true); + test(S("abcdefghijklmnopqrst"), S("abcde"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), S(""), false); + test(S(""), S("abcde"), false); + test(S(""), S("abcdefghij"), false); + test(S(""), S("abcdefghijklmnopqrst"), false); + test(S("abcde"), S(""), true); + test(S("abcde"), S("abcde"), false); + test(S("abcde"), S("abcdefghij"), false); + test(S("abcde"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghij"), S(""), true); + test(S("abcdefghij"), S("abcde"), true); + test(S("abcdefghij"), S("abcdefghij"), false); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghijklmnopqrst"), S(""), true); + test(S("abcdefghijklmnopqrst"), S("abcde"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp new file mode 100644 index 000000000000..eab117a843fa --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// bool operator>=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const typename S::value_type* lhs, const S& rhs, bool x) +{ + assert((lhs >= rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test("", S(""), true); + test("", S("abcde"), false); + test("", S("abcdefghij"), false); + test("", S("abcdefghijklmnopqrst"), false); + test("abcde", S(""), true); + test("abcde", S("abcde"), true); + test("abcde", S("abcdefghij"), false); + test("abcde", S("abcdefghijklmnopqrst"), false); + test("abcdefghij", S(""), true); + test("abcdefghij", S("abcde"), true); + test("abcdefghij", S("abcdefghij"), true); + test("abcdefghij", S("abcdefghijklmnopqrst"), false); + test("abcdefghijklmnopqrst", S(""), true); + test("abcdefghijklmnopqrst", S("abcde"), true); + test("abcdefghijklmnopqrst", S("abcdefghij"), true); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test("", S(""), true); + test("", S("abcde"), false); + test("", S("abcdefghij"), false); + test("", S("abcdefghijklmnopqrst"), false); + test("abcde", S(""), true); + test("abcde", S("abcde"), true); + test("abcde", S("abcdefghij"), false); + test("abcde", S("abcdefghijklmnopqrst"), false); + test("abcdefghij", S(""), true); + test("abcdefghij", S("abcde"), true); + test("abcdefghij", S("abcdefghij"), true); + test("abcdefghij", S("abcdefghijklmnopqrst"), false); + test("abcdefghijklmnopqrst", S(""), true); + test("abcdefghijklmnopqrst", S("abcde"), true); + test("abcdefghijklmnopqrst", S("abcdefghij"), true); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp new file mode 100644 index 000000000000..56b3b35b3d94 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// bool operator>=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const typename S::value_type* rhs, bool x) +{ + assert((lhs >= rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), "", true); + test(S(""), "abcde", false); + test(S(""), "abcdefghij", false); + test(S(""), "abcdefghijklmnopqrst", false); + test(S("abcde"), "", true); + test(S("abcde"), "abcde", true); + test(S("abcde"), "abcdefghij", false); + test(S("abcde"), "abcdefghijklmnopqrst", false); + test(S("abcdefghij"), "", true); + test(S("abcdefghij"), "abcde", true); + test(S("abcdefghij"), "abcdefghij", true); + test(S("abcdefghij"), "abcdefghijklmnopqrst", false); + test(S("abcdefghijklmnopqrst"), "", true); + test(S("abcdefghijklmnopqrst"), "abcde", true); + test(S("abcdefghijklmnopqrst"), "abcdefghij", true); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), "", true); + test(S(""), "abcde", false); + test(S(""), "abcdefghij", false); + test(S(""), "abcdefghijklmnopqrst", false); + test(S("abcde"), "", true); + test(S("abcde"), "abcde", true); + test(S("abcde"), "abcdefghij", false); + test(S("abcde"), "abcdefghijklmnopqrst", false); + test(S("abcdefghij"), "", true); + test(S("abcdefghij"), "abcde", true); + test(S("abcdefghij"), "abcdefghij", true); + test(S("abcdefghij"), "abcdefghijklmnopqrst", false); + test(S("abcdefghijklmnopqrst"), "", true); + test(S("abcdefghijklmnopqrst"), "abcde", true); + test(S("abcdefghijklmnopqrst"), "abcdefghij", true); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp new file mode 100644 index 000000000000..c02b202c49e6 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp @@ -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> + +// template<class charT, class traits, class Allocator> +// bool operator>=(const basic_string<charT,traits,Allocator>& lhs, +// const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const S& rhs, bool x) +{ + assert((lhs >= rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), S(""), true); + test(S(""), S("abcde"), false); + test(S(""), S("abcdefghij"), false); + test(S(""), S("abcdefghijklmnopqrst"), false); + test(S("abcde"), S(""), true); + test(S("abcde"), S("abcde"), true); + test(S("abcde"), S("abcdefghij"), false); + test(S("abcde"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghij"), S(""), true); + test(S("abcdefghij"), S("abcde"), true); + test(S("abcdefghij"), S("abcdefghij"), true); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghijklmnopqrst"), S(""), true); + test(S("abcdefghijklmnopqrst"), S("abcde"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), S(""), true); + test(S(""), S("abcde"), false); + test(S(""), S("abcdefghij"), false); + test(S(""), S("abcdefghijklmnopqrst"), false); + test(S("abcde"), S(""), true); + test(S("abcde"), S("abcde"), true); + test(S("abcde"), S("abcdefghij"), false); + test(S("abcde"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghij"), S(""), true); + test(S("abcdefghij"), S("abcde"), true); + test(S("abcdefghij"), S("abcdefghij"), true); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghijklmnopqrst"), S(""), true); + test(S("abcdefghijklmnopqrst"), S("abcde"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp new file mode 100644 index 000000000000..86f6a2db119a --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// bool operator<(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const typename S::value_type* lhs, const S& rhs, bool x) +{ + assert((lhs < rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test("", S(""), false); + test("", S("abcde"), true); + test("", S("abcdefghij"), true); + test("", S("abcdefghijklmnopqrst"), true); + test("abcde", S(""), false); + test("abcde", S("abcde"), false); + test("abcde", S("abcdefghij"), true); + test("abcde", S("abcdefghijklmnopqrst"), true); + test("abcdefghij", S(""), false); + test("abcdefghij", S("abcde"), false); + test("abcdefghij", S("abcdefghij"), false); + test("abcdefghij", S("abcdefghijklmnopqrst"), true); + test("abcdefghijklmnopqrst", S(""), false); + test("abcdefghijklmnopqrst", S("abcde"), false); + test("abcdefghijklmnopqrst", S("abcdefghij"), false); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test("", S(""), false); + test("", S("abcde"), true); + test("", S("abcdefghij"), true); + test("", S("abcdefghijklmnopqrst"), true); + test("abcde", S(""), false); + test("abcde", S("abcde"), false); + test("abcde", S("abcdefghij"), true); + test("abcde", S("abcdefghijklmnopqrst"), true); + test("abcdefghij", S(""), false); + test("abcdefghij", S("abcde"), false); + test("abcdefghij", S("abcdefghij"), false); + test("abcdefghij", S("abcdefghijklmnopqrst"), true); + test("abcdefghijklmnopqrst", S(""), false); + test("abcdefghijklmnopqrst", S("abcde"), false); + test("abcdefghijklmnopqrst", S("abcdefghij"), false); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp new file mode 100644 index 000000000000..b935da5426fd --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// bool operator<(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const typename S::value_type* rhs, bool x) +{ + assert((lhs < rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), "", false); + test(S(""), "abcde", true); + test(S(""), "abcdefghij", true); + test(S(""), "abcdefghijklmnopqrst", true); + test(S("abcde"), "", false); + test(S("abcde"), "abcde", false); + test(S("abcde"), "abcdefghij", true); + test(S("abcde"), "abcdefghijklmnopqrst", true); + test(S("abcdefghij"), "", false); + test(S("abcdefghij"), "abcde", false); + test(S("abcdefghij"), "abcdefghij", false); + test(S("abcdefghij"), "abcdefghijklmnopqrst", true); + test(S("abcdefghijklmnopqrst"), "", false); + test(S("abcdefghijklmnopqrst"), "abcde", false); + test(S("abcdefghijklmnopqrst"), "abcdefghij", false); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), "", false); + test(S(""), "abcde", true); + test(S(""), "abcdefghij", true); + test(S(""), "abcdefghijklmnopqrst", true); + test(S("abcde"), "", false); + test(S("abcde"), "abcde", false); + test(S("abcde"), "abcdefghij", true); + test(S("abcde"), "abcdefghijklmnopqrst", true); + test(S("abcdefghij"), "", false); + test(S("abcdefghij"), "abcde", false); + test(S("abcdefghij"), "abcdefghij", false); + test(S("abcdefghij"), "abcdefghijklmnopqrst", true); + test(S("abcdefghijklmnopqrst"), "", false); + test(S("abcdefghijklmnopqrst"), "abcde", false); + test(S("abcdefghijklmnopqrst"), "abcdefghij", false); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp new file mode 100644 index 000000000000..487e2056f2ca --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp @@ -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> + +// template<class charT, class traits, class Allocator> +// bool operator<(const basic_string<charT,traits,Allocator>& lhs, +// const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const S& rhs, bool x) +{ + assert((lhs < rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), S(""), false); + test(S(""), S("abcde"), true); + test(S(""), S("abcdefghij"), true); + test(S(""), S("abcdefghijklmnopqrst"), true); + test(S("abcde"), S(""), false); + test(S("abcde"), S("abcde"), false); + test(S("abcde"), S("abcdefghij"), true); + test(S("abcde"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghij"), S(""), false); + test(S("abcdefghij"), S("abcde"), false); + test(S("abcdefghij"), S("abcdefghij"), false); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghijklmnopqrst"), S(""), false); + test(S("abcdefghijklmnopqrst"), S("abcde"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), S(""), false); + test(S(""), S("abcde"), true); + test(S(""), S("abcdefghij"), true); + test(S(""), S("abcdefghijklmnopqrst"), true); + test(S("abcde"), S(""), false); + test(S("abcde"), S("abcde"), false); + test(S("abcde"), S("abcdefghij"), true); + test(S("abcde"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghij"), S(""), false); + test(S("abcdefghij"), S("abcde"), false); + test(S("abcdefghij"), S("abcdefghij"), false); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghijklmnopqrst"), S(""), false); + test(S("abcdefghijklmnopqrst"), S("abcde"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp new file mode 100644 index 000000000000..21959405194d --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// bool operator<=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const typename S::value_type* lhs, const S& rhs, bool x) +{ + assert((lhs <= rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test("", S(""), true); + test("", S("abcde"), true); + test("", S("abcdefghij"), true); + test("", S("abcdefghijklmnopqrst"), true); + test("abcde", S(""), false); + test("abcde", S("abcde"), true); + test("abcde", S("abcdefghij"), true); + test("abcde", S("abcdefghijklmnopqrst"), true); + test("abcdefghij", S(""), false); + test("abcdefghij", S("abcde"), false); + test("abcdefghij", S("abcdefghij"), true); + test("abcdefghij", S("abcdefghijklmnopqrst"), true); + test("abcdefghijklmnopqrst", S(""), false); + test("abcdefghijklmnopqrst", S("abcde"), false); + test("abcdefghijklmnopqrst", S("abcdefghij"), false); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test("", S(""), true); + test("", S("abcde"), true); + test("", S("abcdefghij"), true); + test("", S("abcdefghijklmnopqrst"), true); + test("abcde", S(""), false); + test("abcde", S("abcde"), true); + test("abcde", S("abcdefghij"), true); + test("abcde", S("abcdefghijklmnopqrst"), true); + test("abcdefghij", S(""), false); + test("abcdefghij", S("abcde"), false); + test("abcdefghij", S("abcdefghij"), true); + test("abcdefghij", S("abcdefghijklmnopqrst"), true); + test("abcdefghijklmnopqrst", S(""), false); + test("abcdefghijklmnopqrst", S("abcde"), false); + test("abcdefghijklmnopqrst", S("abcdefghij"), false); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp new file mode 100644 index 000000000000..bb1bce8d4043 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// 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 charT, class traits, class Allocator> +// bool operator<=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const typename S::value_type* rhs, bool x) +{ + assert((lhs <= rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), "", true); + test(S(""), "abcde", true); + test(S(""), "abcdefghij", true); + test(S(""), "abcdefghijklmnopqrst", true); + test(S("abcde"), "", false); + test(S("abcde"), "abcde", true); + test(S("abcde"), "abcdefghij", true); + test(S("abcde"), "abcdefghijklmnopqrst", true); + test(S("abcdefghij"), "", false); + test(S("abcdefghij"), "abcde", false); + test(S("abcdefghij"), "abcdefghij", true); + test(S("abcdefghij"), "abcdefghijklmnopqrst", true); + test(S("abcdefghijklmnopqrst"), "", false); + test(S("abcdefghijklmnopqrst"), "abcde", false); + test(S("abcdefghijklmnopqrst"), "abcdefghij", false); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), "", true); + test(S(""), "abcde", true); + test(S(""), "abcdefghij", true); + test(S(""), "abcdefghijklmnopqrst", true); + test(S("abcde"), "", false); + test(S("abcde"), "abcde", true); + test(S("abcde"), "abcdefghij", true); + test(S("abcde"), "abcdefghijklmnopqrst", true); + test(S("abcdefghij"), "", false); + test(S("abcdefghij"), "abcde", false); + test(S("abcdefghij"), "abcdefghij", true); + test(S("abcdefghij"), "abcdefghijklmnopqrst", true); + test(S("abcdefghijklmnopqrst"), "", false); + test(S("abcdefghijklmnopqrst"), "abcde", false); + test(S("abcdefghijklmnopqrst"), "abcdefghij", false); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true); + } +#endif +} diff --git a/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp new file mode 100644 index 000000000000..2b975f160d5d --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp @@ -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> + +// template<class charT, class traits, class Allocator> +// bool operator<=(const basic_string<charT,traits,Allocator>& lhs, +// const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const S& rhs, bool x) +{ + assert((lhs <= rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), S(""), true); + test(S(""), S("abcde"), true); + test(S(""), S("abcdefghij"), true); + test(S(""), S("abcdefghijklmnopqrst"), true); + test(S("abcde"), S(""), false); + test(S("abcde"), S("abcde"), true); + test(S("abcde"), S("abcdefghij"), true); + test(S("abcde"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghij"), S(""), false); + test(S("abcdefghij"), S("abcde"), false); + test(S("abcdefghij"), S("abcdefghij"), true); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghijklmnopqrst"), S(""), false); + test(S("abcdefghijklmnopqrst"), S("abcde"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), S(""), true); + test(S(""), S("abcde"), true); + test(S(""), S("abcdefghij"), true); + test(S(""), S("abcdefghijklmnopqrst"), true); + test(S("abcde"), S(""), false); + test(S("abcde"), S("abcde"), true); + test(S("abcde"), S("abcdefghij"), true); + test(S("abcde"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghij"), S(""), false); + test(S("abcdefghij"), S("abcde"), false); + test(S("abcdefghij"), S("abcdefghij"), true); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghijklmnopqrst"), S(""), false); + test(S("abcdefghijklmnopqrst"), S("abcde"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/nothing_to_do.pass.cpp b/test/std/strings/basic.string/string.ops/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..b58f5c55b643 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/nothing_to_do.pass.cpp @@ -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() +{ +} diff --git a/test/std/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp b/test/std/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp new file mode 100644 index 000000000000..3bdb800bf736 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp @@ -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> + +// const charT* c_str() const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s) +{ + typedef typename S::traits_type T; + const typename S::value_type* str = s.c_str(); + if (s.size() > 0) + { + assert(T::compare(str, &s[0], s.size()) == 0); + assert(T::eq(str[s.size()], typename S::value_type())); + } + else + assert(T::eq(str[0], typename S::value_type())); +} + +int main() +{ + { + typedef std::string S; + test(S("")); + test(S("abcde")); + test(S("abcdefghij")); + test(S("abcdefghijklmnopqrst")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S("")); + test(S("abcde")); + test(S("abcdefghij")); + test(S("abcdefghijklmnopqrst")); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp b/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp new file mode 100644 index 000000000000..917248fa6916 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp @@ -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> + +// const charT* data() const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s) +{ + typedef typename S::traits_type T; + const typename S::value_type* str = s.data(); + if (s.size() > 0) + { + assert(T::compare(str, &s[0], s.size()) == 0); + assert(T::eq(str[s.size()], typename S::value_type())); + } + else + assert(T::eq(str[0], typename S::value_type())); +} + +int main() +{ + { + typedef std::string S; + test(S("")); + test(S("abcde")); + test(S("abcdefghij")); + test(S("abcdefghijklmnopqrst")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S("")); + test(S("abcde")); + test(S("abcdefghij")); + test(S("abcdefghijklmnopqrst")); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp b/test/std/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp new file mode 100644 index 000000000000..6ba040d2635d --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp @@ -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> + +// allocator_type get_allocator() const; + +#include <string> +#include <cassert> + +#include "test_allocator.h" +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const typename S::allocator_type& a) +{ + assert(s.get_allocator() == a); +} + +int main() +{ + { + typedef test_allocator<char> A; + typedef std::basic_string<char, std::char_traits<char>, A> S; + test(S(""), A()); + test(S("abcde", A(1)), A(1)); + test(S("abcdefghij", A(2)), A(2)); + test(S("abcdefghijklmnopqrst", A(3)), A(3)); + } +#if __cplusplus >= 201103L + { + typedef min_allocator<char> A; + typedef std::basic_string<char, std::char_traits<char>, A> S; + test(S(""), A()); + test(S("abcde", A()), A()); + test(S("abcdefghij", A()), A()); + test(S("abcdefghijklmnopqrst", A()), A()); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_compare/pointer.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/pointer.pass.cpp new file mode 100644 index 000000000000..dda7428992a1 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_compare/pointer.pass.cpp @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// int compare(const charT *s) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +int sign(int x) +{ + if (x == 0) + return 0; + if (x < 0) + return -1; + return 1; +} + +template <class S> +void +test(const S& s, const typename S::value_type* str, int x) +{ + assert(sign(s.compare(str)) == sign(x)); +} + +int main() +{ + { + typedef std::string S; + test(S(""), "", 0); + test(S(""), "abcde", -5); + test(S(""), "abcdefghij", -10); + test(S(""), "abcdefghijklmnopqrst", -20); + test(S("abcde"), "", 5); + test(S("abcde"), "abcde", 0); + test(S("abcde"), "abcdefghij", -5); + test(S("abcde"), "abcdefghijklmnopqrst", -15); + test(S("abcdefghij"), "", 10); + test(S("abcdefghij"), "abcde", 5); + test(S("abcdefghij"), "abcdefghij", 0); + test(S("abcdefghij"), "abcdefghijklmnopqrst", -10); + test(S("abcdefghijklmnopqrst"), "", 20); + test(S("abcdefghijklmnopqrst"), "abcde", 15); + test(S("abcdefghijklmnopqrst"), "abcdefghij", 10); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", 0); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), "", 0); + test(S(""), "abcde", -5); + test(S(""), "abcdefghij", -10); + test(S(""), "abcdefghijklmnopqrst", -20); + test(S("abcde"), "", 5); + test(S("abcde"), "abcde", 0); + test(S("abcde"), "abcdefghij", -5); + test(S("abcde"), "abcdefghijklmnopqrst", -15); + test(S("abcdefghij"), "", 10); + test(S("abcdefghij"), "abcde", 5); + test(S("abcdefghij"), "abcdefghij", 0); + test(S("abcdefghij"), "abcdefghijklmnopqrst", -10); + test(S("abcdefghijklmnopqrst"), "", 20); + test(S("abcdefghijklmnopqrst"), "abcde", 15); + test(S("abcdefghijklmnopqrst"), "abcdefghij", 10); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", 0); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp new file mode 100644 index 000000000000..9ed58a3e9bbc --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp @@ -0,0 +1,372 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// int compare(size_type pos, size_type n1, const charT *s) const; + +#include <string> +#include <stdexcept> +#include <cassert> + +#include "min_allocator.h" + +int sign(int x) +{ + if (x == 0) + return 0; + if (x < 0) + return -1; + return 1; +} + +template <class S> +void +test(const S& s, typename S::size_type pos1, typename S::size_type n1, + const typename S::value_type* str, int x) +{ + try + { + assert(sign(s.compare(pos1, n1, str)) == sign(x)); + assert(pos1 <= s.size()); + } + catch (std::out_of_range&) + { + assert(pos1 > s.size()); + } +} + +template <class S> +void test0() +{ + test(S(""), 0, 0, "", 0); + test(S(""), 0, 0, "abcde", -5); + test(S(""), 0, 0, "abcdefghij", -10); + test(S(""), 0, 0, "abcdefghijklmnopqrst", -20); + test(S(""), 0, 1, "", 0); + test(S(""), 0, 1, "abcde", -5); + test(S(""), 0, 1, "abcdefghij", -10); + test(S(""), 0, 1, "abcdefghijklmnopqrst", -20); + test(S(""), 1, 0, "", 0); + test(S(""), 1, 0, "abcde", 0); + test(S(""), 1, 0, "abcdefghij", 0); + test(S(""), 1, 0, "abcdefghijklmnopqrst", 0); + test(S("abcde"), 0, 0, "", 0); + test(S("abcde"), 0, 0, "abcde", -5); + test(S("abcde"), 0, 0, "abcdefghij", -10); + test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", -20); + test(S("abcde"), 0, 1, "", 1); + test(S("abcde"), 0, 1, "abcde", -4); + test(S("abcde"), 0, 1, "abcdefghij", -9); + test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", -19); + test(S("abcde"), 0, 2, "", 2); + test(S("abcde"), 0, 2, "abcde", -3); + test(S("abcde"), 0, 2, "abcdefghij", -8); + test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", -18); + test(S("abcde"), 0, 4, "", 4); + test(S("abcde"), 0, 4, "abcde", -1); + test(S("abcde"), 0, 4, "abcdefghij", -6); + test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", -16); + test(S("abcde"), 0, 5, "", 5); + test(S("abcde"), 0, 5, "abcde", 0); + test(S("abcde"), 0, 5, "abcdefghij", -5); + test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", -15); + test(S("abcde"), 0, 6, "", 5); + test(S("abcde"), 0, 6, "abcde", 0); + test(S("abcde"), 0, 6, "abcdefghij", -5); + test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", -15); + test(S("abcde"), 1, 0, "", 0); + test(S("abcde"), 1, 0, "abcde", -5); + test(S("abcde"), 1, 0, "abcdefghij", -10); + test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", -20); + test(S("abcde"), 1, 1, "", 1); + test(S("abcde"), 1, 1, "abcde", 1); + test(S("abcde"), 1, 1, "abcdefghij", 1); + test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 1); + test(S("abcde"), 1, 2, "", 2); + test(S("abcde"), 1, 2, "abcde", 1); + test(S("abcde"), 1, 2, "abcdefghij", 1); + test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 1); + test(S("abcde"), 1, 3, "", 3); + test(S("abcde"), 1, 3, "abcde", 1); + test(S("abcde"), 1, 3, "abcdefghij", 1); + test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 1); + test(S("abcde"), 1, 4, "", 4); + test(S("abcde"), 1, 4, "abcde", 1); + test(S("abcde"), 1, 4, "abcdefghij", 1); + test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 1); + test(S("abcde"), 1, 5, "", 4); + test(S("abcde"), 1, 5, "abcde", 1); + test(S("abcde"), 1, 5, "abcdefghij", 1); + test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 1); + test(S("abcde"), 2, 0, "", 0); + test(S("abcde"), 2, 0, "abcde", -5); + test(S("abcde"), 2, 0, "abcdefghij", -10); + test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", -20); + test(S("abcde"), 2, 1, "", 1); + test(S("abcde"), 2, 1, "abcde", 2); + test(S("abcde"), 2, 1, "abcdefghij", 2); + test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 2); + test(S("abcde"), 2, 2, "", 2); + test(S("abcde"), 2, 2, "abcde", 2); + test(S("abcde"), 2, 2, "abcdefghij", 2); + test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 2); + test(S("abcde"), 2, 3, "", 3); + test(S("abcde"), 2, 3, "abcde", 2); + test(S("abcde"), 2, 3, "abcdefghij", 2); + test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 2); + test(S("abcde"), 2, 4, "", 3); + test(S("abcde"), 2, 4, "abcde", 2); + test(S("abcde"), 2, 4, "abcdefghij", 2); + test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 2); + test(S("abcde"), 4, 0, "", 0); + test(S("abcde"), 4, 0, "abcde", -5); + test(S("abcde"), 4, 0, "abcdefghij", -10); + test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", -20); + test(S("abcde"), 4, 1, "", 1); + test(S("abcde"), 4, 1, "abcde", 4); + test(S("abcde"), 4, 1, "abcdefghij", 4); + test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 4); + test(S("abcde"), 4, 2, "", 1); + test(S("abcde"), 4, 2, "abcde", 4); + test(S("abcde"), 4, 2, "abcdefghij", 4); + test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 4); + test(S("abcde"), 5, 0, "", 0); + test(S("abcde"), 5, 0, "abcde", -5); + test(S("abcde"), 5, 0, "abcdefghij", -10); + test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", -20); + test(S("abcde"), 5, 1, "", 0); + test(S("abcde"), 5, 1, "abcde", -5); + test(S("abcde"), 5, 1, "abcdefghij", -10); + test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", -20); +} + +template <class S> +void test1() +{ + test(S("abcde"), 6, 0, "", 0); + test(S("abcde"), 6, 0, "abcde", 0); + test(S("abcde"), 6, 0, "abcdefghij", 0); + test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 0); + test(S("abcdefghij"), 0, 0, "", 0); + test(S("abcdefghij"), 0, 0, "abcde", -5); + test(S("abcdefghij"), 0, 0, "abcdefghij", -10); + test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", -20); + test(S("abcdefghij"), 0, 1, "", 1); + test(S("abcdefghij"), 0, 1, "abcde", -4); + test(S("abcdefghij"), 0, 1, "abcdefghij", -9); + test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", -19); + test(S("abcdefghij"), 0, 5, "", 5); + test(S("abcdefghij"), 0, 5, "abcde", 0); + test(S("abcdefghij"), 0, 5, "abcdefghij", -5); + test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", -15); + test(S("abcdefghij"), 0, 9, "", 9); + test(S("abcdefghij"), 0, 9, "abcde", 4); + test(S("abcdefghij"), 0, 9, "abcdefghij", -1); + test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", -11); + test(S("abcdefghij"), 0, 10, "", 10); + test(S("abcdefghij"), 0, 10, "abcde", 5); + test(S("abcdefghij"), 0, 10, "abcdefghij", 0); + test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", -10); + test(S("abcdefghij"), 0, 11, "", 10); + test(S("abcdefghij"), 0, 11, "abcde", 5); + test(S("abcdefghij"), 0, 11, "abcdefghij", 0); + test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", -10); + test(S("abcdefghij"), 1, 0, "", 0); + test(S("abcdefghij"), 1, 0, "abcde", -5); + test(S("abcdefghij"), 1, 0, "abcdefghij", -10); + test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", -20); + test(S("abcdefghij"), 1, 1, "", 1); + test(S("abcdefghij"), 1, 1, "abcde", 1); + test(S("abcdefghij"), 1, 1, "abcdefghij", 1); + test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 1); + test(S("abcdefghij"), 1, 4, "", 4); + test(S("abcdefghij"), 1, 4, "abcde", 1); + test(S("abcdefghij"), 1, 4, "abcdefghij", 1); + test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 1); + test(S("abcdefghij"), 1, 8, "", 8); + test(S("abcdefghij"), 1, 8, "abcde", 1); + test(S("abcdefghij"), 1, 8, "abcdefghij", 1); + test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 1); + test(S("abcdefghij"), 1, 9, "", 9); + test(S("abcdefghij"), 1, 9, "abcde", 1); + test(S("abcdefghij"), 1, 9, "abcdefghij", 1); + test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 1); + test(S("abcdefghij"), 1, 10, "", 9); + test(S("abcdefghij"), 1, 10, "abcde", 1); + test(S("abcdefghij"), 1, 10, "abcdefghij", 1); + test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 1); + test(S("abcdefghij"), 5, 0, "", 0); + test(S("abcdefghij"), 5, 0, "abcde", -5); + test(S("abcdefghij"), 5, 0, "abcdefghij", -10); + test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", -20); + test(S("abcdefghij"), 5, 1, "", 1); + test(S("abcdefghij"), 5, 1, "abcde", 5); + test(S("abcdefghij"), 5, 1, "abcdefghij", 5); + test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 5); + test(S("abcdefghij"), 5, 2, "", 2); + test(S("abcdefghij"), 5, 2, "abcde", 5); + test(S("abcdefghij"), 5, 2, "abcdefghij", 5); + test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 5); + test(S("abcdefghij"), 5, 4, "", 4); + test(S("abcdefghij"), 5, 4, "abcde", 5); + test(S("abcdefghij"), 5, 4, "abcdefghij", 5); + test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 5); + test(S("abcdefghij"), 5, 5, "", 5); + test(S("abcdefghij"), 5, 5, "abcde", 5); + test(S("abcdefghij"), 5, 5, "abcdefghij", 5); + test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 5); + test(S("abcdefghij"), 5, 6, "", 5); + test(S("abcdefghij"), 5, 6, "abcde", 5); + test(S("abcdefghij"), 5, 6, "abcdefghij", 5); + test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 5); + test(S("abcdefghij"), 9, 0, "", 0); + test(S("abcdefghij"), 9, 0, "abcde", -5); + test(S("abcdefghij"), 9, 0, "abcdefghij", -10); + test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", -20); + test(S("abcdefghij"), 9, 1, "", 1); + test(S("abcdefghij"), 9, 1, "abcde", 9); + test(S("abcdefghij"), 9, 1, "abcdefghij", 9); + test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 9); + test(S("abcdefghij"), 9, 2, "", 1); + test(S("abcdefghij"), 9, 2, "abcde", 9); + test(S("abcdefghij"), 9, 2, "abcdefghij", 9); + test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 9); + test(S("abcdefghij"), 10, 0, "", 0); + test(S("abcdefghij"), 10, 0, "abcde", -5); + test(S("abcdefghij"), 10, 0, "abcdefghij", -10); + test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", -20); + test(S("abcdefghij"), 10, 1, "", 0); + test(S("abcdefghij"), 10, 1, "abcde", -5); + test(S("abcdefghij"), 10, 1, "abcdefghij", -10); + test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", -20); + test(S("abcdefghij"), 11, 0, "", 0); + test(S("abcdefghij"), 11, 0, "abcde", 0); + test(S("abcdefghij"), 11, 0, "abcdefghij", 0); + test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 0); +} + +template <class S> +void test2() +{ + test(S("abcdefghijklmnopqrst"), 0, 0, "", 0); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", -5); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", -10); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", -20); + test(S("abcdefghijklmnopqrst"), 0, 1, "", 1); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", -4); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", -9); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", -19); + test(S("abcdefghijklmnopqrst"), 0, 10, "", 10); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 5); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 0); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", -10); + test(S("abcdefghijklmnopqrst"), 0, 19, "", 19); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 14); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 9); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", -1); + test(S("abcdefghijklmnopqrst"), 0, 20, "", 20); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 15); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 10); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 0); + test(S("abcdefghijklmnopqrst"), 0, 21, "", 20); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 15); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 10); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 0); + test(S("abcdefghijklmnopqrst"), 1, 0, "", 0); + test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", -5); + test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", -10); + test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", -20); + test(S("abcdefghijklmnopqrst"), 1, 1, "", 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 1); + test(S("abcdefghijklmnopqrst"), 1, 9, "", 9); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 1); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 1); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 1); + test(S("abcdefghijklmnopqrst"), 1, 18, "", 18); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 1); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 1); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 1); + test(S("abcdefghijklmnopqrst"), 1, 19, "", 19); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 1); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 1); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 1); + test(S("abcdefghijklmnopqrst"), 1, 20, "", 19); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 1); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 1); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 1); + test(S("abcdefghijklmnopqrst"), 10, 0, "", 0); + test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", -5); + test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", -10); + test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", -20); + test(S("abcdefghijklmnopqrst"), 10, 1, "", 1); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 10); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 10); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 10); + test(S("abcdefghijklmnopqrst"), 10, 5, "", 5); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 10); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 10); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 10); + test(S("abcdefghijklmnopqrst"), 10, 9, "", 9); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 10); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 10); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "", 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "", 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 10); + test(S("abcdefghijklmnopqrst"), 19, 0, "", 0); + test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", -5); + test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", -10); + test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", -20); + test(S("abcdefghijklmnopqrst"), 19, 1, "", 1); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 19); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 19); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 19); + test(S("abcdefghijklmnopqrst"), 19, 2, "", 1); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 19); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 19); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 19); + test(S("abcdefghijklmnopqrst"), 20, 0, "", 0); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", -5); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", -10); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", -20); + test(S("abcdefghijklmnopqrst"), 20, 1, "", 0); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", -5); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", -10); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", -20); + test(S("abcdefghijklmnopqrst"), 21, 0, "", 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 0); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp new file mode 100644 index 000000000000..ee804d9cc6e5 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp @@ -0,0 +1,1323 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// int compare(size_type pos, size_type n1, const charT *s, size_type n2) const; + +#include <string> +#include <stdexcept> +#include <cassert> + +#include "min_allocator.h" + +int sign(int x) +{ + if (x == 0) + return 0; + if (x < 0) + return -1; + return 1; +} + +template <class S> +void +test(const S& s, typename S::size_type pos, typename S::size_type n1, + const typename S::value_type* str, typename S::size_type n2, int x) +{ + try + { + assert(sign(s.compare(pos, n1, str, n2)) == sign(x)); + assert(pos <= s.size()); + } + catch (std::out_of_range&) + { + assert(pos > s.size()); + } +} + +template <class S> +void test0() +{ + test(S(""), 0, 0, "", 0, 0); + test(S(""), 0, 0, "abcde", 0, 0); + test(S(""), 0, 0, "abcde", 1, -1); + test(S(""), 0, 0, "abcde", 2, -2); + test(S(""), 0, 0, "abcde", 4, -4); + test(S(""), 0, 0, "abcde", 5, -5); + test(S(""), 0, 0, "abcdefghij", 0, 0); + test(S(""), 0, 0, "abcdefghij", 1, -1); + test(S(""), 0, 0, "abcdefghij", 5, -5); + test(S(""), 0, 0, "abcdefghij", 9, -9); + test(S(""), 0, 0, "abcdefghij", 10, -10); + test(S(""), 0, 0, "abcdefghijklmnopqrst", 0, 0); + test(S(""), 0, 0, "abcdefghijklmnopqrst", 1, -1); + test(S(""), 0, 0, "abcdefghijklmnopqrst", 10, -10); + test(S(""), 0, 0, "abcdefghijklmnopqrst", 19, -19); + test(S(""), 0, 0, "abcdefghijklmnopqrst", 20, -20); + test(S(""), 0, 1, "", 0, 0); + test(S(""), 0, 1, "abcde", 0, 0); + test(S(""), 0, 1, "abcde", 1, -1); + test(S(""), 0, 1, "abcde", 2, -2); + test(S(""), 0, 1, "abcde", 4, -4); + test(S(""), 0, 1, "abcde", 5, -5); + test(S(""), 0, 1, "abcdefghij", 0, 0); + test(S(""), 0, 1, "abcdefghij", 1, -1); + test(S(""), 0, 1, "abcdefghij", 5, -5); + test(S(""), 0, 1, "abcdefghij", 9, -9); + test(S(""), 0, 1, "abcdefghij", 10, -10); + test(S(""), 0, 1, "abcdefghijklmnopqrst", 0, 0); + test(S(""), 0, 1, "abcdefghijklmnopqrst", 1, -1); + test(S(""), 0, 1, "abcdefghijklmnopqrst", 10, -10); + test(S(""), 0, 1, "abcdefghijklmnopqrst", 19, -19); + test(S(""), 0, 1, "abcdefghijklmnopqrst", 20, -20); + test(S(""), 1, 0, "", 0, 0); + test(S(""), 1, 0, "abcde", 0, 0); + test(S(""), 1, 0, "abcde", 1, 0); + test(S(""), 1, 0, "abcde", 2, 0); + test(S(""), 1, 0, "abcde", 4, 0); + test(S(""), 1, 0, "abcde", 5, 0); + test(S(""), 1, 0, "abcdefghij", 0, 0); + test(S(""), 1, 0, "abcdefghij", 1, 0); + test(S(""), 1, 0, "abcdefghij", 5, 0); + test(S(""), 1, 0, "abcdefghij", 9, 0); + test(S(""), 1, 0, "abcdefghij", 10, 0); + test(S(""), 1, 0, "abcdefghijklmnopqrst", 0, 0); + test(S(""), 1, 0, "abcdefghijklmnopqrst", 1, 0); + test(S(""), 1, 0, "abcdefghijklmnopqrst", 10, 0); + test(S(""), 1, 0, "abcdefghijklmnopqrst", 19, 0); + test(S(""), 1, 0, "abcdefghijklmnopqrst", 20, 0); + test(S("abcde"), 0, 0, "", 0, 0); + test(S("abcde"), 0, 0, "abcde", 0, 0); + test(S("abcde"), 0, 0, "abcde", 1, -1); + test(S("abcde"), 0, 0, "abcde", 2, -2); + test(S("abcde"), 0, 0, "abcde", 4, -4); + test(S("abcde"), 0, 0, "abcde", 5, -5); + test(S("abcde"), 0, 0, "abcdefghij", 0, 0); + test(S("abcde"), 0, 0, "abcdefghij", 1, -1); + test(S("abcde"), 0, 0, "abcdefghij", 5, -5); + test(S("abcde"), 0, 0, "abcdefghij", 9, -9); + test(S("abcde"), 0, 0, "abcdefghij", 10, -10); + test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 0, 0); + test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 1, -1); + test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 10, -10); + test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 19, -19); + test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 20, -20); + test(S("abcde"), 0, 1, "", 0, 1); + test(S("abcde"), 0, 1, "abcde", 0, 1); + test(S("abcde"), 0, 1, "abcde", 1, 0); + test(S("abcde"), 0, 1, "abcde", 2, -1); + test(S("abcde"), 0, 1, "abcde", 4, -3); + test(S("abcde"), 0, 1, "abcde", 5, -4); + test(S("abcde"), 0, 1, "abcdefghij", 0, 1); + test(S("abcde"), 0, 1, "abcdefghij", 1, 0); + test(S("abcde"), 0, 1, "abcdefghij", 5, -4); + test(S("abcde"), 0, 1, "abcdefghij", 9, -8); + test(S("abcde"), 0, 1, "abcdefghij", 10, -9); + test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 0, 1); + test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 1, 0); + test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 10, -9); + test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 19, -18); + test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 20, -19); + test(S("abcde"), 0, 2, "", 0, 2); + test(S("abcde"), 0, 2, "abcde", 0, 2); + test(S("abcde"), 0, 2, "abcde", 1, 1); + test(S("abcde"), 0, 2, "abcde", 2, 0); + test(S("abcde"), 0, 2, "abcde", 4, -2); + test(S("abcde"), 0, 2, "abcde", 5, -3); + test(S("abcde"), 0, 2, "abcdefghij", 0, 2); + test(S("abcde"), 0, 2, "abcdefghij", 1, 1); + test(S("abcde"), 0, 2, "abcdefghij", 5, -3); + test(S("abcde"), 0, 2, "abcdefghij", 9, -7); + test(S("abcde"), 0, 2, "abcdefghij", 10, -8); + test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 0, 2); + test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 1, 1); + test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 10, -8); + test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 19, -17); + test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 20, -18); + test(S("abcde"), 0, 4, "", 0, 4); + test(S("abcde"), 0, 4, "abcde", 0, 4); + test(S("abcde"), 0, 4, "abcde", 1, 3); + test(S("abcde"), 0, 4, "abcde", 2, 2); +} + +template <class S> +void test1() +{ + test(S("abcde"), 0, 4, "abcde", 4, 0); + test(S("abcde"), 0, 4, "abcde", 5, -1); + test(S("abcde"), 0, 4, "abcdefghij", 0, 4); + test(S("abcde"), 0, 4, "abcdefghij", 1, 3); + test(S("abcde"), 0, 4, "abcdefghij", 5, -1); + test(S("abcde"), 0, 4, "abcdefghij", 9, -5); + test(S("abcde"), 0, 4, "abcdefghij", 10, -6); + test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 0, 4); + test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 1, 3); + test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 10, -6); + test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 19, -15); + test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 20, -16); + test(S("abcde"), 0, 5, "", 0, 5); + test(S("abcde"), 0, 5, "abcde", 0, 5); + test(S("abcde"), 0, 5, "abcde", 1, 4); + test(S("abcde"), 0, 5, "abcde", 2, 3); + test(S("abcde"), 0, 5, "abcde", 4, 1); + test(S("abcde"), 0, 5, "abcde", 5, 0); + test(S("abcde"), 0, 5, "abcdefghij", 0, 5); + test(S("abcde"), 0, 5, "abcdefghij", 1, 4); + test(S("abcde"), 0, 5, "abcdefghij", 5, 0); + test(S("abcde"), 0, 5, "abcdefghij", 9, -4); + test(S("abcde"), 0, 5, "abcdefghij", 10, -5); + test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 0, 5); + test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 1, 4); + test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 10, -5); + test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 19, -14); + test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 20, -15); + test(S("abcde"), 0, 6, "", 0, 5); + test(S("abcde"), 0, 6, "abcde", 0, 5); + test(S("abcde"), 0, 6, "abcde", 1, 4); + test(S("abcde"), 0, 6, "abcde", 2, 3); + test(S("abcde"), 0, 6, "abcde", 4, 1); + test(S("abcde"), 0, 6, "abcde", 5, 0); + test(S("abcde"), 0, 6, "abcdefghij", 0, 5); + test(S("abcde"), 0, 6, "abcdefghij", 1, 4); + test(S("abcde"), 0, 6, "abcdefghij", 5, 0); + test(S("abcde"), 0, 6, "abcdefghij", 9, -4); + test(S("abcde"), 0, 6, "abcdefghij", 10, -5); + test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 0, 5); + test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 1, 4); + test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 10, -5); + test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 19, -14); + test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 20, -15); + test(S("abcde"), 1, 0, "", 0, 0); + test(S("abcde"), 1, 0, "abcde", 0, 0); + test(S("abcde"), 1, 0, "abcde", 1, -1); + test(S("abcde"), 1, 0, "abcde", 2, -2); + test(S("abcde"), 1, 0, "abcde", 4, -4); + test(S("abcde"), 1, 0, "abcde", 5, -5); + test(S("abcde"), 1, 0, "abcdefghij", 0, 0); + test(S("abcde"), 1, 0, "abcdefghij", 1, -1); + test(S("abcde"), 1, 0, "abcdefghij", 5, -5); + test(S("abcde"), 1, 0, "abcdefghij", 9, -9); + test(S("abcde"), 1, 0, "abcdefghij", 10, -10); + test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 0, 0); + test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 1, -1); + test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 10, -10); + test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 19, -19); + test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 20, -20); + test(S("abcde"), 1, 1, "", 0, 1); + test(S("abcde"), 1, 1, "abcde", 0, 1); + test(S("abcde"), 1, 1, "abcde", 1, 1); + test(S("abcde"), 1, 1, "abcde", 2, 1); + test(S("abcde"), 1, 1, "abcde", 4, 1); + test(S("abcde"), 1, 1, "abcde", 5, 1); + test(S("abcde"), 1, 1, "abcdefghij", 0, 1); + test(S("abcde"), 1, 1, "abcdefghij", 1, 1); + test(S("abcde"), 1, 1, "abcdefghij", 5, 1); + test(S("abcde"), 1, 1, "abcdefghij", 9, 1); + test(S("abcde"), 1, 1, "abcdefghij", 10, 1); + test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 0, 1); + test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 1, 1); + test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 10, 1); + test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 19, 1); + test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 20, 1); + test(S("abcde"), 1, 2, "", 0, 2); + test(S("abcde"), 1, 2, "abcde", 0, 2); + test(S("abcde"), 1, 2, "abcde", 1, 1); + test(S("abcde"), 1, 2, "abcde", 2, 1); + test(S("abcde"), 1, 2, "abcde", 4, 1); + test(S("abcde"), 1, 2, "abcde", 5, 1); + test(S("abcde"), 1, 2, "abcdefghij", 0, 2); + test(S("abcde"), 1, 2, "abcdefghij", 1, 1); + test(S("abcde"), 1, 2, "abcdefghij", 5, 1); + test(S("abcde"), 1, 2, "abcdefghij", 9, 1); + test(S("abcde"), 1, 2, "abcdefghij", 10, 1); + test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 0, 2); + test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 1, 1); + test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 10, 1); + test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 19, 1); + test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 20, 1); + test(S("abcde"), 1, 3, "", 0, 3); + test(S("abcde"), 1, 3, "abcde", 0, 3); + test(S("abcde"), 1, 3, "abcde", 1, 1); + test(S("abcde"), 1, 3, "abcde", 2, 1); + test(S("abcde"), 1, 3, "abcde", 4, 1); + test(S("abcde"), 1, 3, "abcde", 5, 1); + test(S("abcde"), 1, 3, "abcdefghij", 0, 3); + test(S("abcde"), 1, 3, "abcdefghij", 1, 1); +} + +template <class S> +void test2() +{ + test(S("abcde"), 1, 3, "abcdefghij", 5, 1); + test(S("abcde"), 1, 3, "abcdefghij", 9, 1); + test(S("abcde"), 1, 3, "abcdefghij", 10, 1); + test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 0, 3); + test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 1, 1); + test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 10, 1); + test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 19, 1); + test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 20, 1); + test(S("abcde"), 1, 4, "", 0, 4); + test(S("abcde"), 1, 4, "abcde", 0, 4); + test(S("abcde"), 1, 4, "abcde", 1, 1); + test(S("abcde"), 1, 4, "abcde", 2, 1); + test(S("abcde"), 1, 4, "abcde", 4, 1); + test(S("abcde"), 1, 4, "abcde", 5, 1); + test(S("abcde"), 1, 4, "abcdefghij", 0, 4); + test(S("abcde"), 1, 4, "abcdefghij", 1, 1); + test(S("abcde"), 1, 4, "abcdefghij", 5, 1); + test(S("abcde"), 1, 4, "abcdefghij", 9, 1); + test(S("abcde"), 1, 4, "abcdefghij", 10, 1); + test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 0, 4); + test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 1, 1); + test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 10, 1); + test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 19, 1); + test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 20, 1); + test(S("abcde"), 1, 5, "", 0, 4); + test(S("abcde"), 1, 5, "abcde", 0, 4); + test(S("abcde"), 1, 5, "abcde", 1, 1); + test(S("abcde"), 1, 5, "abcde", 2, 1); + test(S("abcde"), 1, 5, "abcde", 4, 1); + test(S("abcde"), 1, 5, "abcde", 5, 1); + test(S("abcde"), 1, 5, "abcdefghij", 0, 4); + test(S("abcde"), 1, 5, "abcdefghij", 1, 1); + test(S("abcde"), 1, 5, "abcdefghij", 5, 1); + test(S("abcde"), 1, 5, "abcdefghij", 9, 1); + test(S("abcde"), 1, 5, "abcdefghij", 10, 1); + test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 0, 4); + test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 1, 1); + test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 10, 1); + test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 19, 1); + test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 20, 1); + test(S("abcde"), 2, 0, "", 0, 0); + test(S("abcde"), 2, 0, "abcde", 0, 0); + test(S("abcde"), 2, 0, "abcde", 1, -1); + test(S("abcde"), 2, 0, "abcde", 2, -2); + test(S("abcde"), 2, 0, "abcde", 4, -4); + test(S("abcde"), 2, 0, "abcde", 5, -5); + test(S("abcde"), 2, 0, "abcdefghij", 0, 0); + test(S("abcde"), 2, 0, "abcdefghij", 1, -1); + test(S("abcde"), 2, 0, "abcdefghij", 5, -5); + test(S("abcde"), 2, 0, "abcdefghij", 9, -9); + test(S("abcde"), 2, 0, "abcdefghij", 10, -10); + test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 0, 0); + test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 1, -1); + test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 10, -10); + test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 19, -19); + test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 20, -20); + test(S("abcde"), 2, 1, "", 0, 1); + test(S("abcde"), 2, 1, "abcde", 0, 1); + test(S("abcde"), 2, 1, "abcde", 1, 2); + test(S("abcde"), 2, 1, "abcde", 2, 2); + test(S("abcde"), 2, 1, "abcde", 4, 2); + test(S("abcde"), 2, 1, "abcde", 5, 2); + test(S("abcde"), 2, 1, "abcdefghij", 0, 1); + test(S("abcde"), 2, 1, "abcdefghij", 1, 2); + test(S("abcde"), 2, 1, "abcdefghij", 5, 2); + test(S("abcde"), 2, 1, "abcdefghij", 9, 2); + test(S("abcde"), 2, 1, "abcdefghij", 10, 2); + test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 0, 1); + test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 1, 2); + test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 10, 2); + test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 19, 2); + test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 20, 2); + test(S("abcde"), 2, 2, "", 0, 2); + test(S("abcde"), 2, 2, "abcde", 0, 2); + test(S("abcde"), 2, 2, "abcde", 1, 2); + test(S("abcde"), 2, 2, "abcde", 2, 2); + test(S("abcde"), 2, 2, "abcde", 4, 2); + test(S("abcde"), 2, 2, "abcde", 5, 2); + test(S("abcde"), 2, 2, "abcdefghij", 0, 2); + test(S("abcde"), 2, 2, "abcdefghij", 1, 2); + test(S("abcde"), 2, 2, "abcdefghij", 5, 2); + test(S("abcde"), 2, 2, "abcdefghij", 9, 2); + test(S("abcde"), 2, 2, "abcdefghij", 10, 2); + test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 0, 2); + test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 1, 2); + test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 10, 2); + test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 19, 2); + test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 20, 2); + test(S("abcde"), 2, 3, "", 0, 3); + test(S("abcde"), 2, 3, "abcde", 0, 3); + test(S("abcde"), 2, 3, "abcde", 1, 2); + test(S("abcde"), 2, 3, "abcde", 2, 2); + test(S("abcde"), 2, 3, "abcde", 4, 2); + test(S("abcde"), 2, 3, "abcde", 5, 2); + test(S("abcde"), 2, 3, "abcdefghij", 0, 3); + test(S("abcde"), 2, 3, "abcdefghij", 1, 2); + test(S("abcde"), 2, 3, "abcdefghij", 5, 2); + test(S("abcde"), 2, 3, "abcdefghij", 9, 2); + test(S("abcde"), 2, 3, "abcdefghij", 10, 2); + test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 0, 3); +} + +template <class S> +void test3() +{ + test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 1, 2); + test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 10, 2); + test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 19, 2); + test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 20, 2); + test(S("abcde"), 2, 4, "", 0, 3); + test(S("abcde"), 2, 4, "abcde", 0, 3); + test(S("abcde"), 2, 4, "abcde", 1, 2); + test(S("abcde"), 2, 4, "abcde", 2, 2); + test(S("abcde"), 2, 4, "abcde", 4, 2); + test(S("abcde"), 2, 4, "abcde", 5, 2); + test(S("abcde"), 2, 4, "abcdefghij", 0, 3); + test(S("abcde"), 2, 4, "abcdefghij", 1, 2); + test(S("abcde"), 2, 4, "abcdefghij", 5, 2); + test(S("abcde"), 2, 4, "abcdefghij", 9, 2); + test(S("abcde"), 2, 4, "abcdefghij", 10, 2); + test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 0, 3); + test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 1, 2); + test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 10, 2); + test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 19, 2); + test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 20, 2); + test(S("abcde"), 4, 0, "", 0, 0); + test(S("abcde"), 4, 0, "abcde", 0, 0); + test(S("abcde"), 4, 0, "abcde", 1, -1); + test(S("abcde"), 4, 0, "abcde", 2, -2); + test(S("abcde"), 4, 0, "abcde", 4, -4); + test(S("abcde"), 4, 0, "abcde", 5, -5); + test(S("abcde"), 4, 0, "abcdefghij", 0, 0); + test(S("abcde"), 4, 0, "abcdefghij", 1, -1); + test(S("abcde"), 4, 0, "abcdefghij", 5, -5); + test(S("abcde"), 4, 0, "abcdefghij", 9, -9); + test(S("abcde"), 4, 0, "abcdefghij", 10, -10); + test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 0, 0); + test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 1, -1); + test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 10, -10); + test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 19, -19); + test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 20, -20); + test(S("abcde"), 4, 1, "", 0, 1); + test(S("abcde"), 4, 1, "abcde", 0, 1); + test(S("abcde"), 4, 1, "abcde", 1, 4); + test(S("abcde"), 4, 1, "abcde", 2, 4); + test(S("abcde"), 4, 1, "abcde", 4, 4); + test(S("abcde"), 4, 1, "abcde", 5, 4); + test(S("abcde"), 4, 1, "abcdefghij", 0, 1); + test(S("abcde"), 4, 1, "abcdefghij", 1, 4); + test(S("abcde"), 4, 1, "abcdefghij", 5, 4); + test(S("abcde"), 4, 1, "abcdefghij", 9, 4); + test(S("abcde"), 4, 1, "abcdefghij", 10, 4); + test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 0, 1); + test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 1, 4); + test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 10, 4); + test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 19, 4); + test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 20, 4); + test(S("abcde"), 4, 2, "", 0, 1); + test(S("abcde"), 4, 2, "abcde", 0, 1); + test(S("abcde"), 4, 2, "abcde", 1, 4); + test(S("abcde"), 4, 2, "abcde", 2, 4); + test(S("abcde"), 4, 2, "abcde", 4, 4); + test(S("abcde"), 4, 2, "abcde", 5, 4); + test(S("abcde"), 4, 2, "abcdefghij", 0, 1); + test(S("abcde"), 4, 2, "abcdefghij", 1, 4); + test(S("abcde"), 4, 2, "abcdefghij", 5, 4); + test(S("abcde"), 4, 2, "abcdefghij", 9, 4); + test(S("abcde"), 4, 2, "abcdefghij", 10, 4); + test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 0, 1); + test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 1, 4); + test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 10, 4); + test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 19, 4); + test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 20, 4); + test(S("abcde"), 5, 0, "", 0, 0); + test(S("abcde"), 5, 0, "abcde", 0, 0); + test(S("abcde"), 5, 0, "abcde", 1, -1); + test(S("abcde"), 5, 0, "abcde", 2, -2); + test(S("abcde"), 5, 0, "abcde", 4, -4); + test(S("abcde"), 5, 0, "abcde", 5, -5); + test(S("abcde"), 5, 0, "abcdefghij", 0, 0); + test(S("abcde"), 5, 0, "abcdefghij", 1, -1); + test(S("abcde"), 5, 0, "abcdefghij", 5, -5); + test(S("abcde"), 5, 0, "abcdefghij", 9, -9); + test(S("abcde"), 5, 0, "abcdefghij", 10, -10); + test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 0, 0); + test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 1, -1); + test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 10, -10); + test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 19, -19); + test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 20, -20); + test(S("abcde"), 5, 1, "", 0, 0); + test(S("abcde"), 5, 1, "abcde", 0, 0); + test(S("abcde"), 5, 1, "abcde", 1, -1); + test(S("abcde"), 5, 1, "abcde", 2, -2); + test(S("abcde"), 5, 1, "abcde", 4, -4); + test(S("abcde"), 5, 1, "abcde", 5, -5); + test(S("abcde"), 5, 1, "abcdefghij", 0, 0); + test(S("abcde"), 5, 1, "abcdefghij", 1, -1); + test(S("abcde"), 5, 1, "abcdefghij", 5, -5); + test(S("abcde"), 5, 1, "abcdefghij", 9, -9); + test(S("abcde"), 5, 1, "abcdefghij", 10, -10); + test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 0, 0); + test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 1, -1); + test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 10, -10); + test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 19, -19); + test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 20, -20); +} + +template <class S> +void test4() +{ + test(S("abcde"), 6, 0, "", 0, 0); + test(S("abcde"), 6, 0, "abcde", 0, 0); + test(S("abcde"), 6, 0, "abcde", 1, 0); + test(S("abcde"), 6, 0, "abcde", 2, 0); + test(S("abcde"), 6, 0, "abcde", 4, 0); + test(S("abcde"), 6, 0, "abcde", 5, 0); + test(S("abcde"), 6, 0, "abcdefghij", 0, 0); + test(S("abcde"), 6, 0, "abcdefghij", 1, 0); + test(S("abcde"), 6, 0, "abcdefghij", 5, 0); + test(S("abcde"), 6, 0, "abcdefghij", 9, 0); + test(S("abcde"), 6, 0, "abcdefghij", 10, 0); + test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 0, 0); + test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 1, 0); + test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 10, 0); + test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 19, 0); + test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 20, 0); + test(S("abcdefghij"), 0, 0, "", 0, 0); + test(S("abcdefghij"), 0, 0, "abcde", 0, 0); + test(S("abcdefghij"), 0, 0, "abcde", 1, -1); + test(S("abcdefghij"), 0, 0, "abcde", 2, -2); + test(S("abcdefghij"), 0, 0, "abcde", 4, -4); + test(S("abcdefghij"), 0, 0, "abcde", 5, -5); + test(S("abcdefghij"), 0, 0, "abcdefghij", 0, 0); + test(S("abcdefghij"), 0, 0, "abcdefghij", 1, -1); + test(S("abcdefghij"), 0, 0, "abcdefghij", 5, -5); + test(S("abcdefghij"), 0, 0, "abcdefghij", 9, -9); + test(S("abcdefghij"), 0, 0, "abcdefghij", 10, -10); + test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 0, 0); + test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 1, -1); + test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 10, -10); + test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 19, -19); + test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 20, -20); + test(S("abcdefghij"), 0, 1, "", 0, 1); + test(S("abcdefghij"), 0, 1, "abcde", 0, 1); + test(S("abcdefghij"), 0, 1, "abcde", 1, 0); + test(S("abcdefghij"), 0, 1, "abcde", 2, -1); + test(S("abcdefghij"), 0, 1, "abcde", 4, -3); + test(S("abcdefghij"), 0, 1, "abcde", 5, -4); + test(S("abcdefghij"), 0, 1, "abcdefghij", 0, 1); + test(S("abcdefghij"), 0, 1, "abcdefghij", 1, 0); + test(S("abcdefghij"), 0, 1, "abcdefghij", 5, -4); + test(S("abcdefghij"), 0, 1, "abcdefghij", 9, -8); + test(S("abcdefghij"), 0, 1, "abcdefghij", 10, -9); + test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 0, 1); + test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 1, 0); + test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 10, -9); + test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 19, -18); + test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 20, -19); + test(S("abcdefghij"), 0, 5, "", 0, 5); + test(S("abcdefghij"), 0, 5, "abcde", 0, 5); + test(S("abcdefghij"), 0, 5, "abcde", 1, 4); + test(S("abcdefghij"), 0, 5, "abcde", 2, 3); + test(S("abcdefghij"), 0, 5, "abcde", 4, 1); + test(S("abcdefghij"), 0, 5, "abcde", 5, 0); + test(S("abcdefghij"), 0, 5, "abcdefghij", 0, 5); + test(S("abcdefghij"), 0, 5, "abcdefghij", 1, 4); + test(S("abcdefghij"), 0, 5, "abcdefghij", 5, 0); + test(S("abcdefghij"), 0, 5, "abcdefghij", 9, -4); + test(S("abcdefghij"), 0, 5, "abcdefghij", 10, -5); + test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 0, 5); + test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 1, 4); + test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 10, -5); + test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 19, -14); + test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 20, -15); + test(S("abcdefghij"), 0, 9, "", 0, 9); + test(S("abcdefghij"), 0, 9, "abcde", 0, 9); + test(S("abcdefghij"), 0, 9, "abcde", 1, 8); + test(S("abcdefghij"), 0, 9, "abcde", 2, 7); + test(S("abcdefghij"), 0, 9, "abcde", 4, 5); + test(S("abcdefghij"), 0, 9, "abcde", 5, 4); + test(S("abcdefghij"), 0, 9, "abcdefghij", 0, 9); + test(S("abcdefghij"), 0, 9, "abcdefghij", 1, 8); + test(S("abcdefghij"), 0, 9, "abcdefghij", 5, 4); + test(S("abcdefghij"), 0, 9, "abcdefghij", 9, 0); + test(S("abcdefghij"), 0, 9, "abcdefghij", 10, -1); + test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 0, 9); + test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 1, 8); + test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 10, -1); + test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 19, -10); + test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 20, -11); + test(S("abcdefghij"), 0, 10, "", 0, 10); + test(S("abcdefghij"), 0, 10, "abcde", 0, 10); + test(S("abcdefghij"), 0, 10, "abcde", 1, 9); + test(S("abcdefghij"), 0, 10, "abcde", 2, 8); + test(S("abcdefghij"), 0, 10, "abcde", 4, 6); + test(S("abcdefghij"), 0, 10, "abcde", 5, 5); + test(S("abcdefghij"), 0, 10, "abcdefghij", 0, 10); + test(S("abcdefghij"), 0, 10, "abcdefghij", 1, 9); + test(S("abcdefghij"), 0, 10, "abcdefghij", 5, 5); + test(S("abcdefghij"), 0, 10, "abcdefghij", 9, 1); + test(S("abcdefghij"), 0, 10, "abcdefghij", 10, 0); + test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 0, 10); + test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 1, 9); + test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 10, 0); + test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 19, -9); + test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 20, -10); + test(S("abcdefghij"), 0, 11, "", 0, 10); + test(S("abcdefghij"), 0, 11, "abcde", 0, 10); + test(S("abcdefghij"), 0, 11, "abcde", 1, 9); + test(S("abcdefghij"), 0, 11, "abcde", 2, 8); +} + +template <class S> +void test5() +{ + test(S("abcdefghij"), 0, 11, "abcde", 4, 6); + test(S("abcdefghij"), 0, 11, "abcde", 5, 5); + test(S("abcdefghij"), 0, 11, "abcdefghij", 0, 10); + test(S("abcdefghij"), 0, 11, "abcdefghij", 1, 9); + test(S("abcdefghij"), 0, 11, "abcdefghij", 5, 5); + test(S("abcdefghij"), 0, 11, "abcdefghij", 9, 1); + test(S("abcdefghij"), 0, 11, "abcdefghij", 10, 0); + test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 0, 10); + test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 1, 9); + test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 10, 0); + test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 19, -9); + test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 20, -10); + test(S("abcdefghij"), 1, 0, "", 0, 0); + test(S("abcdefghij"), 1, 0, "abcde", 0, 0); + test(S("abcdefghij"), 1, 0, "abcde", 1, -1); + test(S("abcdefghij"), 1, 0, "abcde", 2, -2); + test(S("abcdefghij"), 1, 0, "abcde", 4, -4); + test(S("abcdefghij"), 1, 0, "abcde", 5, -5); + test(S("abcdefghij"), 1, 0, "abcdefghij", 0, 0); + test(S("abcdefghij"), 1, 0, "abcdefghij", 1, -1); + test(S("abcdefghij"), 1, 0, "abcdefghij", 5, -5); + test(S("abcdefghij"), 1, 0, "abcdefghij", 9, -9); + test(S("abcdefghij"), 1, 0, "abcdefghij", 10, -10); + test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 0, 0); + test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 1, -1); + test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 10, -10); + test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 19, -19); + test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 20, -20); + test(S("abcdefghij"), 1, 1, "", 0, 1); + test(S("abcdefghij"), 1, 1, "abcde", 0, 1); + test(S("abcdefghij"), 1, 1, "abcde", 1, 1); + test(S("abcdefghij"), 1, 1, "abcde", 2, 1); + test(S("abcdefghij"), 1, 1, "abcde", 4, 1); + test(S("abcdefghij"), 1, 1, "abcde", 5, 1); + test(S("abcdefghij"), 1, 1, "abcdefghij", 0, 1); + test(S("abcdefghij"), 1, 1, "abcdefghij", 1, 1); + test(S("abcdefghij"), 1, 1, "abcdefghij", 5, 1); + test(S("abcdefghij"), 1, 1, "abcdefghij", 9, 1); + test(S("abcdefghij"), 1, 1, "abcdefghij", 10, 1); + test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 0, 1); + test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 1, 1); + test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 10, 1); + test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 19, 1); + test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 20, 1); + test(S("abcdefghij"), 1, 4, "", 0, 4); + test(S("abcdefghij"), 1, 4, "abcde", 0, 4); + test(S("abcdefghij"), 1, 4, "abcde", 1, 1); + test(S("abcdefghij"), 1, 4, "abcde", 2, 1); + test(S("abcdefghij"), 1, 4, "abcde", 4, 1); + test(S("abcdefghij"), 1, 4, "abcde", 5, 1); + test(S("abcdefghij"), 1, 4, "abcdefghij", 0, 4); + test(S("abcdefghij"), 1, 4, "abcdefghij", 1, 1); + test(S("abcdefghij"), 1, 4, "abcdefghij", 5, 1); + test(S("abcdefghij"), 1, 4, "abcdefghij", 9, 1); + test(S("abcdefghij"), 1, 4, "abcdefghij", 10, 1); + test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 0, 4); + test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 1, 1); + test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 10, 1); + test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 19, 1); + test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 20, 1); + test(S("abcdefghij"), 1, 8, "", 0, 8); + test(S("abcdefghij"), 1, 8, "abcde", 0, 8); + test(S("abcdefghij"), 1, 8, "abcde", 1, 1); + test(S("abcdefghij"), 1, 8, "abcde", 2, 1); + test(S("abcdefghij"), 1, 8, "abcde", 4, 1); + test(S("abcdefghij"), 1, 8, "abcde", 5, 1); + test(S("abcdefghij"), 1, 8, "abcdefghij", 0, 8); + test(S("abcdefghij"), 1, 8, "abcdefghij", 1, 1); + test(S("abcdefghij"), 1, 8, "abcdefghij", 5, 1); + test(S("abcdefghij"), 1, 8, "abcdefghij", 9, 1); + test(S("abcdefghij"), 1, 8, "abcdefghij", 10, 1); + test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 0, 8); + test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 1, 1); + test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 10, 1); + test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 19, 1); + test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 20, 1); + test(S("abcdefghij"), 1, 9, "", 0, 9); + test(S("abcdefghij"), 1, 9, "abcde", 0, 9); + test(S("abcdefghij"), 1, 9, "abcde", 1, 1); + test(S("abcdefghij"), 1, 9, "abcde", 2, 1); + test(S("abcdefghij"), 1, 9, "abcde", 4, 1); + test(S("abcdefghij"), 1, 9, "abcde", 5, 1); + test(S("abcdefghij"), 1, 9, "abcdefghij", 0, 9); + test(S("abcdefghij"), 1, 9, "abcdefghij", 1, 1); + test(S("abcdefghij"), 1, 9, "abcdefghij", 5, 1); + test(S("abcdefghij"), 1, 9, "abcdefghij", 9, 1); + test(S("abcdefghij"), 1, 9, "abcdefghij", 10, 1); + test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 0, 9); + test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 1, 1); + test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 10, 1); + test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 19, 1); + test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 20, 1); + test(S("abcdefghij"), 1, 10, "", 0, 9); + test(S("abcdefghij"), 1, 10, "abcde", 0, 9); + test(S("abcdefghij"), 1, 10, "abcde", 1, 1); + test(S("abcdefghij"), 1, 10, "abcde", 2, 1); + test(S("abcdefghij"), 1, 10, "abcde", 4, 1); + test(S("abcdefghij"), 1, 10, "abcde", 5, 1); + test(S("abcdefghij"), 1, 10, "abcdefghij", 0, 9); + test(S("abcdefghij"), 1, 10, "abcdefghij", 1, 1); +} + +template <class S> +void test6() +{ + test(S("abcdefghij"), 1, 10, "abcdefghij", 5, 1); + test(S("abcdefghij"), 1, 10, "abcdefghij", 9, 1); + test(S("abcdefghij"), 1, 10, "abcdefghij", 10, 1); + test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 0, 9); + test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 1, 1); + test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 10, 1); + test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 19, 1); + test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 20, 1); + test(S("abcdefghij"), 5, 0, "", 0, 0); + test(S("abcdefghij"), 5, 0, "abcde", 0, 0); + test(S("abcdefghij"), 5, 0, "abcde", 1, -1); + test(S("abcdefghij"), 5, 0, "abcde", 2, -2); + test(S("abcdefghij"), 5, 0, "abcde", 4, -4); + test(S("abcdefghij"), 5, 0, "abcde", 5, -5); + test(S("abcdefghij"), 5, 0, "abcdefghij", 0, 0); + test(S("abcdefghij"), 5, 0, "abcdefghij", 1, -1); + test(S("abcdefghij"), 5, 0, "abcdefghij", 5, -5); + test(S("abcdefghij"), 5, 0, "abcdefghij", 9, -9); + test(S("abcdefghij"), 5, 0, "abcdefghij", 10, -10); + test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 0, 0); + test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 1, -1); + test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 10, -10); + test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 19, -19); + test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 20, -20); + test(S("abcdefghij"), 5, 1, "", 0, 1); + test(S("abcdefghij"), 5, 1, "abcde", 0, 1); + test(S("abcdefghij"), 5, 1, "abcde", 1, 5); + test(S("abcdefghij"), 5, 1, "abcde", 2, 5); + test(S("abcdefghij"), 5, 1, "abcde", 4, 5); + test(S("abcdefghij"), 5, 1, "abcde", 5, 5); + test(S("abcdefghij"), 5, 1, "abcdefghij", 0, 1); + test(S("abcdefghij"), 5, 1, "abcdefghij", 1, 5); + test(S("abcdefghij"), 5, 1, "abcdefghij", 5, 5); + test(S("abcdefghij"), 5, 1, "abcdefghij", 9, 5); + test(S("abcdefghij"), 5, 1, "abcdefghij", 10, 5); + test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 0, 1); + test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 1, 5); + test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 10, 5); + test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 19, 5); + test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 20, 5); + test(S("abcdefghij"), 5, 2, "", 0, 2); + test(S("abcdefghij"), 5, 2, "abcde", 0, 2); + test(S("abcdefghij"), 5, 2, "abcde", 1, 5); + test(S("abcdefghij"), 5, 2, "abcde", 2, 5); + test(S("abcdefghij"), 5, 2, "abcde", 4, 5); + test(S("abcdefghij"), 5, 2, "abcde", 5, 5); + test(S("abcdefghij"), 5, 2, "abcdefghij", 0, 2); + test(S("abcdefghij"), 5, 2, "abcdefghij", 1, 5); + test(S("abcdefghij"), 5, 2, "abcdefghij", 5, 5); + test(S("abcdefghij"), 5, 2, "abcdefghij", 9, 5); + test(S("abcdefghij"), 5, 2, "abcdefghij", 10, 5); + test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 0, 2); + test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 1, 5); + test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 10, 5); + test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 19, 5); + test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 20, 5); + test(S("abcdefghij"), 5, 4, "", 0, 4); + test(S("abcdefghij"), 5, 4, "abcde", 0, 4); + test(S("abcdefghij"), 5, 4, "abcde", 1, 5); + test(S("abcdefghij"), 5, 4, "abcde", 2, 5); + test(S("abcdefghij"), 5, 4, "abcde", 4, 5); + test(S("abcdefghij"), 5, 4, "abcde", 5, 5); + test(S("abcdefghij"), 5, 4, "abcdefghij", 0, 4); + test(S("abcdefghij"), 5, 4, "abcdefghij", 1, 5); + test(S("abcdefghij"), 5, 4, "abcdefghij", 5, 5); + test(S("abcdefghij"), 5, 4, "abcdefghij", 9, 5); + test(S("abcdefghij"), 5, 4, "abcdefghij", 10, 5); + test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 0, 4); + test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 1, 5); + test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 10, 5); + test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 19, 5); + test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 20, 5); + test(S("abcdefghij"), 5, 5, "", 0, 5); + test(S("abcdefghij"), 5, 5, "abcde", 0, 5); + test(S("abcdefghij"), 5, 5, "abcde", 1, 5); + test(S("abcdefghij"), 5, 5, "abcde", 2, 5); + test(S("abcdefghij"), 5, 5, "abcde", 4, 5); + test(S("abcdefghij"), 5, 5, "abcde", 5, 5); + test(S("abcdefghij"), 5, 5, "abcdefghij", 0, 5); + test(S("abcdefghij"), 5, 5, "abcdefghij", 1, 5); + test(S("abcdefghij"), 5, 5, "abcdefghij", 5, 5); + test(S("abcdefghij"), 5, 5, "abcdefghij", 9, 5); + test(S("abcdefghij"), 5, 5, "abcdefghij", 10, 5); + test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 0, 5); + test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 1, 5); + test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 10, 5); + test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 19, 5); + test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 20, 5); + test(S("abcdefghij"), 5, 6, "", 0, 5); + test(S("abcdefghij"), 5, 6, "abcde", 0, 5); + test(S("abcdefghij"), 5, 6, "abcde", 1, 5); + test(S("abcdefghij"), 5, 6, "abcde", 2, 5); + test(S("abcdefghij"), 5, 6, "abcde", 4, 5); + test(S("abcdefghij"), 5, 6, "abcde", 5, 5); + test(S("abcdefghij"), 5, 6, "abcdefghij", 0, 5); + test(S("abcdefghij"), 5, 6, "abcdefghij", 1, 5); + test(S("abcdefghij"), 5, 6, "abcdefghij", 5, 5); + test(S("abcdefghij"), 5, 6, "abcdefghij", 9, 5); + test(S("abcdefghij"), 5, 6, "abcdefghij", 10, 5); + test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 0, 5); +} + +template <class S> +void test7() +{ + test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 1, 5); + test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 10, 5); + test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 19, 5); + test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 20, 5); + test(S("abcdefghij"), 9, 0, "", 0, 0); + test(S("abcdefghij"), 9, 0, "abcde", 0, 0); + test(S("abcdefghij"), 9, 0, "abcde", 1, -1); + test(S("abcdefghij"), 9, 0, "abcde", 2, -2); + test(S("abcdefghij"), 9, 0, "abcde", 4, -4); + test(S("abcdefghij"), 9, 0, "abcde", 5, -5); + test(S("abcdefghij"), 9, 0, "abcdefghij", 0, 0); + test(S("abcdefghij"), 9, 0, "abcdefghij", 1, -1); + test(S("abcdefghij"), 9, 0, "abcdefghij", 5, -5); + test(S("abcdefghij"), 9, 0, "abcdefghij", 9, -9); + test(S("abcdefghij"), 9, 0, "abcdefghij", 10, -10); + test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 0, 0); + test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 1, -1); + test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 10, -10); + test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 19, -19); + test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 20, -20); + test(S("abcdefghij"), 9, 1, "", 0, 1); + test(S("abcdefghij"), 9, 1, "abcde", 0, 1); + test(S("abcdefghij"), 9, 1, "abcde", 1, 9); + test(S("abcdefghij"), 9, 1, "abcde", 2, 9); + test(S("abcdefghij"), 9, 1, "abcde", 4, 9); + test(S("abcdefghij"), 9, 1, "abcde", 5, 9); + test(S("abcdefghij"), 9, 1, "abcdefghij", 0, 1); + test(S("abcdefghij"), 9, 1, "abcdefghij", 1, 9); + test(S("abcdefghij"), 9, 1, "abcdefghij", 5, 9); + test(S("abcdefghij"), 9, 1, "abcdefghij", 9, 9); + test(S("abcdefghij"), 9, 1, "abcdefghij", 10, 9); + test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 0, 1); + test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 1, 9); + test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 10, 9); + test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 19, 9); + test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 20, 9); + test(S("abcdefghij"), 9, 2, "", 0, 1); + test(S("abcdefghij"), 9, 2, "abcde", 0, 1); + test(S("abcdefghij"), 9, 2, "abcde", 1, 9); + test(S("abcdefghij"), 9, 2, "abcde", 2, 9); + test(S("abcdefghij"), 9, 2, "abcde", 4, 9); + test(S("abcdefghij"), 9, 2, "abcde", 5, 9); + test(S("abcdefghij"), 9, 2, "abcdefghij", 0, 1); + test(S("abcdefghij"), 9, 2, "abcdefghij", 1, 9); + test(S("abcdefghij"), 9, 2, "abcdefghij", 5, 9); + test(S("abcdefghij"), 9, 2, "abcdefghij", 9, 9); + test(S("abcdefghij"), 9, 2, "abcdefghij", 10, 9); + test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 0, 1); + test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 1, 9); + test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 10, 9); + test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 19, 9); + test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 20, 9); + test(S("abcdefghij"), 10, 0, "", 0, 0); + test(S("abcdefghij"), 10, 0, "abcde", 0, 0); + test(S("abcdefghij"), 10, 0, "abcde", 1, -1); + test(S("abcdefghij"), 10, 0, "abcde", 2, -2); + test(S("abcdefghij"), 10, 0, "abcde", 4, -4); + test(S("abcdefghij"), 10, 0, "abcde", 5, -5); + test(S("abcdefghij"), 10, 0, "abcdefghij", 0, 0); + test(S("abcdefghij"), 10, 0, "abcdefghij", 1, -1); + test(S("abcdefghij"), 10, 0, "abcdefghij", 5, -5); + test(S("abcdefghij"), 10, 0, "abcdefghij", 9, -9); + test(S("abcdefghij"), 10, 0, "abcdefghij", 10, -10); + test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 0, 0); + test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 1, -1); + test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 10, -10); + test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 19, -19); + test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 20, -20); + test(S("abcdefghij"), 10, 1, "", 0, 0); + test(S("abcdefghij"), 10, 1, "abcde", 0, 0); + test(S("abcdefghij"), 10, 1, "abcde", 1, -1); + test(S("abcdefghij"), 10, 1, "abcde", 2, -2); + test(S("abcdefghij"), 10, 1, "abcde", 4, -4); + test(S("abcdefghij"), 10, 1, "abcde", 5, -5); + test(S("abcdefghij"), 10, 1, "abcdefghij", 0, 0); + test(S("abcdefghij"), 10, 1, "abcdefghij", 1, -1); + test(S("abcdefghij"), 10, 1, "abcdefghij", 5, -5); + test(S("abcdefghij"), 10, 1, "abcdefghij", 9, -9); + test(S("abcdefghij"), 10, 1, "abcdefghij", 10, -10); + test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 0, 0); + test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 1, -1); + test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 10, -10); + test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 19, -19); + test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 20, -20); + test(S("abcdefghij"), 11, 0, "", 0, 0); + test(S("abcdefghij"), 11, 0, "abcde", 0, 0); + test(S("abcdefghij"), 11, 0, "abcde", 1, 0); + test(S("abcdefghij"), 11, 0, "abcde", 2, 0); + test(S("abcdefghij"), 11, 0, "abcde", 4, 0); + test(S("abcdefghij"), 11, 0, "abcde", 5, 0); + test(S("abcdefghij"), 11, 0, "abcdefghij", 0, 0); + test(S("abcdefghij"), 11, 0, "abcdefghij", 1, 0); + test(S("abcdefghij"), 11, 0, "abcdefghij", 5, 0); + test(S("abcdefghij"), 11, 0, "abcdefghij", 9, 0); + test(S("abcdefghij"), 11, 0, "abcdefghij", 10, 0); + test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 0, 0); + test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 1, 0); + test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 10, 0); + test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 19, 0); + test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 20, 0); +} + +template <class S> +void test8() +{ + test(S("abcdefghijklmnopqrst"), 0, 0, "", 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 2, -2); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 4, -4); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 5, -5); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 5, -5); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 9, -9); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 10, -10); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 10, -10); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 19, -19); + test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 20, -20); + test(S("abcdefghijklmnopqrst"), 0, 1, "", 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 1, 0); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 2, -1); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 4, -3); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 5, -4); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 1, 0); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 5, -4); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 9, -8); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 10, -9); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 1, 0); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 10, -9); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 19, -18); + test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 20, -19); + test(S("abcdefghijklmnopqrst"), 0, 10, "", 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 1, 9); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 2, 8); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 4, 6); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 5, 5); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 1, 9); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 5, 5); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 9, 1); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 10, 0); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 1, 9); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 10, 0); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 19, -9); + test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 20, -10); + test(S("abcdefghijklmnopqrst"), 0, 19, "", 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 1, 18); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 2, 17); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 4, 15); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 5, 14); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 1, 18); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 5, 14); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 9, 10); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 10, 9); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 1, 18); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 10, 9); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 19, 0); + test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 20, -1); + test(S("abcdefghijklmnopqrst"), 0, 20, "", 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 1, 19); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 2, 18); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 4, 16); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 5, 15); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 1, 19); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 5, 15); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 9, 11); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 10, 10); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 1, 19); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 10, 10); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 19, 1); + test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 20, 0); + test(S("abcdefghijklmnopqrst"), 0, 21, "", 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 1, 19); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 2, 18); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 4, 16); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 5, 15); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 1, 19); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 5, 15); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 9, 11); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 10, 10); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 1, 19); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 10, 10); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 19, 1); + test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 20, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, "", 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 2, -2); +} + +template <class S> +void test9() +{ + test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 4, -4); + test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 5, -5); + test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 5, -5); + test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 9, -9); + test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 10, -10); + test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 10, -10); + test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 19, -19); + test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 20, -20); + test(S("abcdefghijklmnopqrst"), 1, 1, "", 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 2, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 4, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 9, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 19, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 20, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, "", 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 2, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 4, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 9, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 19, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 20, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, "", 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 2, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 4, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 9, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 19, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 20, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, "", 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 2, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 4, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 9, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 19, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 20, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, "", 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 2, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 4, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 9, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 19, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 20, 1); + test(S("abcdefghijklmnopqrst"), 10, 0, "", 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 1, -1); + test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 2, -2); + test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 4, -4); + test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 5, -5); + test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 1, -1); +} + +template <class S> +void test10() +{ + test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 5, -5); + test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 9, -9); + test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 10, -10); + test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 1, -1); + test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 10, -10); + test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 19, -19); + test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 20, -20); + test(S("abcdefghijklmnopqrst"), 10, 1, "", 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 2, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 4, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 9, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 19, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 20, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, "", 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 2, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 4, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 9, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 19, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 20, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, "", 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 2, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 4, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 9, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 19, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 20, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "", 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 2, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 4, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 9, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 19, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 20, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "", 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 2, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 4, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 9, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 19, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 20, 10); + test(S("abcdefghijklmnopqrst"), 19, 0, "", 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 1, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 2, -2); + test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 4, -4); + test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 5, -5); + test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 1, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 5, -5); + test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 9, -9); + test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 10, -10); + test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 0, 0); +} + +template <class S> +void test11() +{ + test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 1, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 10, -10); + test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 19, -19); + test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 20, -20); + test(S("abcdefghijklmnopqrst"), 19, 1, "", 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 1, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 2, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 4, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 5, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 1, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 5, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 9, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 10, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 1, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 10, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 19, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 20, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, "", 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 1, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 2, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 4, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 5, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 1, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 5, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 9, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 10, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 1, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 10, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 19, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 20, 19); + test(S("abcdefghijklmnopqrst"), 20, 0, "", 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 2, -2); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 4, -4); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 5, -5); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 5, -5); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 9, -9); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 10, -10); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 10, -10); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 19, -19); + test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 20, -20); + test(S("abcdefghijklmnopqrst"), 20, 1, "", 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 2, -2); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 4, -4); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 5, -5); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 5, -5); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 9, -9); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 10, -10); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 10, -10); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 19, -19); + test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 20, -20); + test(S("abcdefghijklmnopqrst"), 21, 0, "", 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 2, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 4, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 5, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 5, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 9, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 10, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 10, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 19, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 20, 0); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + test4<S>(); + test5<S>(); + test6<S>(); + test7<S>(); + test8<S>(); + test9<S>(); + test10<S>(); + test11<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + test4<S>(); + test5<S>(); + test6<S>(); + test7<S>(); + test8<S>(); + test9<S>(); + test10<S>(); + test11<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp new file mode 100644 index 000000000000..3deb617e8d84 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp @@ -0,0 +1,372 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// int compare(size_type pos1, size_type n1, const basic_string& str) const; + +#include <string> +#include <stdexcept> +#include <cassert> + +#include "min_allocator.h" + +int sign(int x) +{ + if (x == 0) + return 0; + if (x < 0) + return -1; + return 1; +} + +template <class S> +void +test(const S& s, typename S::size_type pos1, typename S::size_type n1, + const S& str, int x) +{ + try + { + assert(sign(s.compare(pos1, n1, str)) == sign(x)); + assert(pos1 <= s.size()); + } + catch (std::out_of_range&) + { + assert(pos1 > s.size()); + } +} + +template <class S> +void test0() +{ + test(S(""), 0, 0, S(""), 0); + test(S(""), 0, 0, S("abcde"), -5); + test(S(""), 0, 0, S("abcdefghij"), -10); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), -20); + test(S(""), 0, 1, S(""), 0); + test(S(""), 0, 1, S("abcde"), -5); + test(S(""), 0, 1, S("abcdefghij"), -10); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), -20); + test(S(""), 1, 0, S(""), 0); + test(S(""), 1, 0, S("abcde"), 0); + test(S(""), 1, 0, S("abcdefghij"), 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0); + test(S("abcde"), 0, 0, S(""), 0); + test(S("abcde"), 0, 0, S("abcde"), -5); + test(S("abcde"), 0, 0, S("abcdefghij"), -10); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), -20); + test(S("abcde"), 0, 1, S(""), 1); + test(S("abcde"), 0, 1, S("abcde"), -4); + test(S("abcde"), 0, 1, S("abcdefghij"), -9); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), -19); + test(S("abcde"), 0, 2, S(""), 2); + test(S("abcde"), 0, 2, S("abcde"), -3); + test(S("abcde"), 0, 2, S("abcdefghij"), -8); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), -18); + test(S("abcde"), 0, 4, S(""), 4); + test(S("abcde"), 0, 4, S("abcde"), -1); + test(S("abcde"), 0, 4, S("abcdefghij"), -6); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), -16); + test(S("abcde"), 0, 5, S(""), 5); + test(S("abcde"), 0, 5, S("abcde"), 0); + test(S("abcde"), 0, 5, S("abcdefghij"), -5); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), -15); + test(S("abcde"), 0, 6, S(""), 5); + test(S("abcde"), 0, 6, S("abcde"), 0); + test(S("abcde"), 0, 6, S("abcdefghij"), -5); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), -15); + test(S("abcde"), 1, 0, S(""), 0); + test(S("abcde"), 1, 0, S("abcde"), -5); + test(S("abcde"), 1, 0, S("abcdefghij"), -10); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), -20); + test(S("abcde"), 1, 1, S(""), 1); + test(S("abcde"), 1, 1, S("abcde"), 1); + test(S("abcde"), 1, 1, S("abcdefghij"), 1); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1); + test(S("abcde"), 1, 2, S(""), 2); + test(S("abcde"), 1, 2, S("abcde"), 1); + test(S("abcde"), 1, 2, S("abcdefghij"), 1); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1); + test(S("abcde"), 1, 3, S(""), 3); + test(S("abcde"), 1, 3, S("abcde"), 1); + test(S("abcde"), 1, 3, S("abcdefghij"), 1); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1); + test(S("abcde"), 1, 4, S(""), 4); + test(S("abcde"), 1, 4, S("abcde"), 1); + test(S("abcde"), 1, 4, S("abcdefghij"), 1); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1); + test(S("abcde"), 1, 5, S(""), 4); + test(S("abcde"), 1, 5, S("abcde"), 1); + test(S("abcde"), 1, 5, S("abcdefghij"), 1); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1); + test(S("abcde"), 2, 0, S(""), 0); + test(S("abcde"), 2, 0, S("abcde"), -5); + test(S("abcde"), 2, 0, S("abcdefghij"), -10); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), -20); + test(S("abcde"), 2, 1, S(""), 1); + test(S("abcde"), 2, 1, S("abcde"), 2); + test(S("abcde"), 2, 1, S("abcdefghij"), 2); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 2); + test(S("abcde"), 2, 2, S(""), 2); + test(S("abcde"), 2, 2, S("abcde"), 2); + test(S("abcde"), 2, 2, S("abcdefghij"), 2); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 2); + test(S("abcde"), 2, 3, S(""), 3); + test(S("abcde"), 2, 3, S("abcde"), 2); + test(S("abcde"), 2, 3, S("abcdefghij"), 2); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 2); + test(S("abcde"), 2, 4, S(""), 3); + test(S("abcde"), 2, 4, S("abcde"), 2); + test(S("abcde"), 2, 4, S("abcdefghij"), 2); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 2); + test(S("abcde"), 4, 0, S(""), 0); + test(S("abcde"), 4, 0, S("abcde"), -5); + test(S("abcde"), 4, 0, S("abcdefghij"), -10); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), -20); + test(S("abcde"), 4, 1, S(""), 1); + test(S("abcde"), 4, 1, S("abcde"), 4); + test(S("abcde"), 4, 1, S("abcdefghij"), 4); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 4); + test(S("abcde"), 4, 2, S(""), 1); + test(S("abcde"), 4, 2, S("abcde"), 4); + test(S("abcde"), 4, 2, S("abcdefghij"), 4); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 4); + test(S("abcde"), 5, 0, S(""), 0); + test(S("abcde"), 5, 0, S("abcde"), -5); + test(S("abcde"), 5, 0, S("abcdefghij"), -10); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), -20); + test(S("abcde"), 5, 1, S(""), 0); + test(S("abcde"), 5, 1, S("abcde"), -5); + test(S("abcde"), 5, 1, S("abcdefghij"), -10); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), -20); +} + +template <class S> +void test1() +{ + test(S("abcde"), 6, 0, S(""), 0); + test(S("abcde"), 6, 0, S("abcde"), 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0); + test(S("abcdefghij"), 0, 0, S(""), 0); + test(S("abcdefghij"), 0, 0, S("abcde"), -5); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), -10); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), -20); + test(S("abcdefghij"), 0, 1, S(""), 1); + test(S("abcdefghij"), 0, 1, S("abcde"), -4); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), -9); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), -19); + test(S("abcdefghij"), 0, 5, S(""), 5); + test(S("abcdefghij"), 0, 5, S("abcde"), 0); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), -5); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), -15); + test(S("abcdefghij"), 0, 9, S(""), 9); + test(S("abcdefghij"), 0, 9, S("abcde"), 4); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), -1); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), -11); + test(S("abcdefghij"), 0, 10, S(""), 10); + test(S("abcdefghij"), 0, 10, S("abcde"), 5); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), -10); + test(S("abcdefghij"), 0, 11, S(""), 10); + test(S("abcdefghij"), 0, 11, S("abcde"), 5); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), -10); + test(S("abcdefghij"), 1, 0, S(""), 0); + test(S("abcdefghij"), 1, 0, S("abcde"), -5); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), -10); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), -20); + test(S("abcdefghij"), 1, 1, S(""), 1); + test(S("abcdefghij"), 1, 1, S("abcde"), 1); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1); + test(S("abcdefghij"), 1, 4, S(""), 4); + test(S("abcdefghij"), 1, 4, S("abcde"), 1); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1); + test(S("abcdefghij"), 1, 8, S(""), 8); + test(S("abcdefghij"), 1, 8, S("abcde"), 1); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1); + test(S("abcdefghij"), 1, 9, S(""), 9); + test(S("abcdefghij"), 1, 9, S("abcde"), 1); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1); + test(S("abcdefghij"), 1, 10, S(""), 9); + test(S("abcdefghij"), 1, 10, S("abcde"), 1); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1); + test(S("abcdefghij"), 5, 0, S(""), 0); + test(S("abcdefghij"), 5, 0, S("abcde"), -5); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), -10); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), -20); + test(S("abcdefghij"), 5, 1, S(""), 1); + test(S("abcdefghij"), 5, 1, S("abcde"), 5); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 5); + test(S("abcdefghij"), 5, 2, S(""), 2); + test(S("abcdefghij"), 5, 2, S("abcde"), 5); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 5); + test(S("abcdefghij"), 5, 4, S(""), 4); + test(S("abcdefghij"), 5, 4, S("abcde"), 5); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 5); + test(S("abcdefghij"), 5, 5, S(""), 5); + test(S("abcdefghij"), 5, 5, S("abcde"), 5); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 5); + test(S("abcdefghij"), 5, 6, S(""), 5); + test(S("abcdefghij"), 5, 6, S("abcde"), 5); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 5); + test(S("abcdefghij"), 9, 0, S(""), 0); + test(S("abcdefghij"), 9, 0, S("abcde"), -5); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), -10); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), -20); + test(S("abcdefghij"), 9, 1, S(""), 1); + test(S("abcdefghij"), 9, 1, S("abcde"), 9); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 9); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 9); + test(S("abcdefghij"), 9, 2, S(""), 1); + test(S("abcdefghij"), 9, 2, S("abcde"), 9); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 9); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 9); + test(S("abcdefghij"), 10, 0, S(""), 0); + test(S("abcdefghij"), 10, 0, S("abcde"), -5); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), -10); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), -20); + test(S("abcdefghij"), 10, 1, S(""), 0); + test(S("abcdefghij"), 10, 1, S("abcde"), -5); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), -10); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), -20); + test(S("abcdefghij"), 11, 0, S(""), 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0); +} + +template <class S> +void test2() +{ + test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), -5); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), -10); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), -20); + test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), -4); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), -9); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), -19); + test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 5); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), -10); + test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 14); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 9); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), -1); + test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 15); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0); + test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 15); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), -5); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), -10); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), -20); + test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1); + test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), -5); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), -10); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), -20); + test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 10); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10); + test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), -5); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), -10); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), -20); + test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 19); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 19); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 19); + test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), -5); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), -10); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), -20); + test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), -5); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), -10); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), -20); + test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp new file mode 100644 index 000000000000..122e6e9c487a --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp @@ -0,0 +1,5948 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// int compare(size_type pos1, size_type n1, const basic_string& str, +// size_type pos2, size_type n2=npos) const; +// the "=npos" was added in C++14 + +#include <string> +#include <stdexcept> +#include <cassert> + +#include "min_allocator.h" + +int sign(int x) +{ + if (x == 0) + return 0; + if (x < 0) + return -1; + return 1; +} + +template <class S> +void +test(const S& s, typename S::size_type pos1, typename S::size_type n1, + const S& str, typename S::size_type pos2, typename S::size_type n2, int x) +{ + try + { + assert(sign(s.compare(pos1, n1, str, pos2, n2)) == sign(x)); + assert(pos1 <= s.size()); + assert(pos2 <= str.size()); + } + catch (std::out_of_range&) + { + assert(pos1 > s.size() || pos2 > str.size()); + } +} + +template <class S> +void +test_npos(const S& s, typename S::size_type pos1, typename S::size_type n1, + const S& str, typename S::size_type pos2, int x) +{ + try + { + assert(sign(s.compare(pos1, n1, str, pos2)) == sign(x)); + assert(pos1 <= s.size()); + assert(pos2 <= str.size()); + } + catch (std::out_of_range&) + { + assert(pos1 > s.size() || pos2 > str.size()); + } +} + +template <class S> +void test0() +{ + test(S(""), 0, 0, S(""), 0, 0, 0); + test(S(""), 0, 0, S(""), 0, 1, 0); + test(S(""), 0, 0, S(""), 1, 0, 0); + test(S(""), 0, 0, S("abcde"), 0, 0, 0); + test(S(""), 0, 0, S("abcde"), 0, 1, -1); + test(S(""), 0, 0, S("abcde"), 0, 2, -2); + test(S(""), 0, 0, S("abcde"), 0, 4, -4); + test(S(""), 0, 0, S("abcde"), 0, 5, -5); + test(S(""), 0, 0, S("abcde"), 0, 6, -5); + test(S(""), 0, 0, S("abcde"), 1, 0, 0); + test(S(""), 0, 0, S("abcde"), 1, 1, -1); + test(S(""), 0, 0, S("abcde"), 1, 2, -2); + test(S(""), 0, 0, S("abcde"), 1, 3, -3); + test(S(""), 0, 0, S("abcde"), 1, 4, -4); + test(S(""), 0, 0, S("abcde"), 1, 5, -4); + test(S(""), 0, 0, S("abcde"), 2, 0, 0); + test(S(""), 0, 0, S("abcde"), 2, 1, -1); + test(S(""), 0, 0, S("abcde"), 2, 2, -2); + test(S(""), 0, 0, S("abcde"), 2, 3, -3); + test(S(""), 0, 0, S("abcde"), 2, 4, -3); + test(S(""), 0, 0, S("abcde"), 4, 0, 0); + test(S(""), 0, 0, S("abcde"), 4, 1, -1); + test(S(""), 0, 0, S("abcde"), 4, 2, -1); + test(S(""), 0, 0, S("abcde"), 5, 0, 0); + test(S(""), 0, 0, S("abcde"), 5, 1, 0); + test(S(""), 0, 0, S("abcde"), 6, 0, 0); + test(S(""), 0, 0, S("abcdefghij"), 0, 0, 0); + test(S(""), 0, 0, S("abcdefghij"), 0, 1, -1); + test(S(""), 0, 0, S("abcdefghij"), 0, 5, -5); + test(S(""), 0, 0, S("abcdefghij"), 0, 9, -9); + test(S(""), 0, 0, S("abcdefghij"), 0, 10, -10); + test(S(""), 0, 0, S("abcdefghij"), 0, 11, -10); + test(S(""), 0, 0, S("abcdefghij"), 1, 0, 0); + test(S(""), 0, 0, S("abcdefghij"), 1, 1, -1); + test(S(""), 0, 0, S("abcdefghij"), 1, 4, -4); + test(S(""), 0, 0, S("abcdefghij"), 1, 8, -8); + test(S(""), 0, 0, S("abcdefghij"), 1, 9, -9); + test(S(""), 0, 0, S("abcdefghij"), 1, 10, -9); + test(S(""), 0, 0, S("abcdefghij"), 5, 0, 0); + test(S(""), 0, 0, S("abcdefghij"), 5, 1, -1); + test(S(""), 0, 0, S("abcdefghij"), 5, 2, -2); + test(S(""), 0, 0, S("abcdefghij"), 5, 4, -4); + test(S(""), 0, 0, S("abcdefghij"), 5, 5, -5); + test(S(""), 0, 0, S("abcdefghij"), 5, 6, -5); + test(S(""), 0, 0, S("abcdefghij"), 9, 0, 0); + test(S(""), 0, 0, S("abcdefghij"), 9, 1, -1); + test(S(""), 0, 0, S("abcdefghij"), 9, 2, -1); + test(S(""), 0, 0, S("abcdefghij"), 10, 0, 0); + test(S(""), 0, 0, S("abcdefghij"), 10, 1, 0); + test(S(""), 0, 0, S("abcdefghij"), 11, 0, 0); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S(""), 0, 1, S(""), 0, 0, 0); + test(S(""), 0, 1, S(""), 0, 1, 0); + test(S(""), 0, 1, S(""), 1, 0, 0); + test(S(""), 0, 1, S("abcde"), 0, 0, 0); + test(S(""), 0, 1, S("abcde"), 0, 1, -1); + test(S(""), 0, 1, S("abcde"), 0, 2, -2); + test(S(""), 0, 1, S("abcde"), 0, 4, -4); + test(S(""), 0, 1, S("abcde"), 0, 5, -5); + test(S(""), 0, 1, S("abcde"), 0, 6, -5); + test(S(""), 0, 1, S("abcde"), 1, 0, 0); + test(S(""), 0, 1, S("abcde"), 1, 1, -1); + test(S(""), 0, 1, S("abcde"), 1, 2, -2); + test(S(""), 0, 1, S("abcde"), 1, 3, -3); + test(S(""), 0, 1, S("abcde"), 1, 4, -4); + test(S(""), 0, 1, S("abcde"), 1, 5, -4); + test(S(""), 0, 1, S("abcde"), 2, 0, 0); + test(S(""), 0, 1, S("abcde"), 2, 1, -1); + test(S(""), 0, 1, S("abcde"), 2, 2, -2); + test(S(""), 0, 1, S("abcde"), 2, 3, -3); + test(S(""), 0, 1, S("abcde"), 2, 4, -3); + test(S(""), 0, 1, S("abcde"), 4, 0, 0); + test(S(""), 0, 1, S("abcde"), 4, 1, -1); + test(S(""), 0, 1, S("abcde"), 4, 2, -1); + test(S(""), 0, 1, S("abcde"), 5, 0, 0); + test(S(""), 0, 1, S("abcde"), 5, 1, 0); + test(S(""), 0, 1, S("abcde"), 6, 0, 0); +} + +template <class S> +void test1() +{ + test(S(""), 0, 1, S("abcdefghij"), 0, 0, 0); + test(S(""), 0, 1, S("abcdefghij"), 0, 1, -1); + test(S(""), 0, 1, S("abcdefghij"), 0, 5, -5); + test(S(""), 0, 1, S("abcdefghij"), 0, 9, -9); + test(S(""), 0, 1, S("abcdefghij"), 0, 10, -10); + test(S(""), 0, 1, S("abcdefghij"), 0, 11, -10); + test(S(""), 0, 1, S("abcdefghij"), 1, 0, 0); + test(S(""), 0, 1, S("abcdefghij"), 1, 1, -1); + test(S(""), 0, 1, S("abcdefghij"), 1, 4, -4); + test(S(""), 0, 1, S("abcdefghij"), 1, 8, -8); + test(S(""), 0, 1, S("abcdefghij"), 1, 9, -9); + test(S(""), 0, 1, S("abcdefghij"), 1, 10, -9); + test(S(""), 0, 1, S("abcdefghij"), 5, 0, 0); + test(S(""), 0, 1, S("abcdefghij"), 5, 1, -1); + test(S(""), 0, 1, S("abcdefghij"), 5, 2, -2); + test(S(""), 0, 1, S("abcdefghij"), 5, 4, -4); + test(S(""), 0, 1, S("abcdefghij"), 5, 5, -5); + test(S(""), 0, 1, S("abcdefghij"), 5, 6, -5); + test(S(""), 0, 1, S("abcdefghij"), 9, 0, 0); + test(S(""), 0, 1, S("abcdefghij"), 9, 1, -1); + test(S(""), 0, 1, S("abcdefghij"), 9, 2, -1); + test(S(""), 0, 1, S("abcdefghij"), 10, 0, 0); + test(S(""), 0, 1, S("abcdefghij"), 10, 1, 0); + test(S(""), 0, 1, S("abcdefghij"), 11, 0, 0); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S(""), 1, 0, S(""), 0, 0, 0); + test(S(""), 1, 0, S(""), 0, 1, 0); + test(S(""), 1, 0, S(""), 1, 0, 0); + test(S(""), 1, 0, S("abcde"), 0, 0, 0); + test(S(""), 1, 0, S("abcde"), 0, 1, 0); + test(S(""), 1, 0, S("abcde"), 0, 2, 0); + test(S(""), 1, 0, S("abcde"), 0, 4, 0); + test(S(""), 1, 0, S("abcde"), 0, 5, 0); + test(S(""), 1, 0, S("abcde"), 0, 6, 0); + test(S(""), 1, 0, S("abcde"), 1, 0, 0); + test(S(""), 1, 0, S("abcde"), 1, 1, 0); + test(S(""), 1, 0, S("abcde"), 1, 2, 0); + test(S(""), 1, 0, S("abcde"), 1, 3, 0); + test(S(""), 1, 0, S("abcde"), 1, 4, 0); + test(S(""), 1, 0, S("abcde"), 1, 5, 0); + test(S(""), 1, 0, S("abcde"), 2, 0, 0); + test(S(""), 1, 0, S("abcde"), 2, 1, 0); + test(S(""), 1, 0, S("abcde"), 2, 2, 0); + test(S(""), 1, 0, S("abcde"), 2, 3, 0); + test(S(""), 1, 0, S("abcde"), 2, 4, 0); + test(S(""), 1, 0, S("abcde"), 4, 0, 0); + test(S(""), 1, 0, S("abcde"), 4, 1, 0); + test(S(""), 1, 0, S("abcde"), 4, 2, 0); + test(S(""), 1, 0, S("abcde"), 5, 0, 0); + test(S(""), 1, 0, S("abcde"), 5, 1, 0); + test(S(""), 1, 0, S("abcde"), 6, 0, 0); + test(S(""), 1, 0, S("abcdefghij"), 0, 0, 0); + test(S(""), 1, 0, S("abcdefghij"), 0, 1, 0); + test(S(""), 1, 0, S("abcdefghij"), 0, 5, 0); + test(S(""), 1, 0, S("abcdefghij"), 0, 9, 0); + test(S(""), 1, 0, S("abcdefghij"), 0, 10, 0); + test(S(""), 1, 0, S("abcdefghij"), 0, 11, 0); + test(S(""), 1, 0, S("abcdefghij"), 1, 0, 0); + test(S(""), 1, 0, S("abcdefghij"), 1, 1, 0); + test(S(""), 1, 0, S("abcdefghij"), 1, 4, 0); + test(S(""), 1, 0, S("abcdefghij"), 1, 8, 0); + test(S(""), 1, 0, S("abcdefghij"), 1, 9, 0); + test(S(""), 1, 0, S("abcdefghij"), 1, 10, 0); + test(S(""), 1, 0, S("abcdefghij"), 5, 0, 0); + test(S(""), 1, 0, S("abcdefghij"), 5, 1, 0); + test(S(""), 1, 0, S("abcdefghij"), 5, 2, 0); + test(S(""), 1, 0, S("abcdefghij"), 5, 4, 0); + test(S(""), 1, 0, S("abcdefghij"), 5, 5, 0); + test(S(""), 1, 0, S("abcdefghij"), 5, 6, 0); + test(S(""), 1, 0, S("abcdefghij"), 9, 0, 0); + test(S(""), 1, 0, S("abcdefghij"), 9, 1, 0); + test(S(""), 1, 0, S("abcdefghij"), 9, 2, 0); + test(S(""), 1, 0, S("abcdefghij"), 10, 0, 0); + test(S(""), 1, 0, S("abcdefghij"), 10, 1, 0); + test(S(""), 1, 0, S("abcdefghij"), 11, 0, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 1, 0); +} + +template <class S> +void test2() +{ + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 10, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 19, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 20, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 21, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 1, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 9, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 18, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 19, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 20, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 1, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 5, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 9, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 10, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 11, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 19, 1, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 19, 2, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 0, 0, S(""), 0, 0, 0); + test(S("abcde"), 0, 0, S(""), 0, 1, 0); + test(S("abcde"), 0, 0, S(""), 1, 0, 0); + test(S("abcde"), 0, 0, S("abcde"), 0, 0, 0); + test(S("abcde"), 0, 0, S("abcde"), 0, 1, -1); + test(S("abcde"), 0, 0, S("abcde"), 0, 2, -2); + test(S("abcde"), 0, 0, S("abcde"), 0, 4, -4); + test(S("abcde"), 0, 0, S("abcde"), 0, 5, -5); + test(S("abcde"), 0, 0, S("abcde"), 0, 6, -5); + test(S("abcde"), 0, 0, S("abcde"), 1, 0, 0); + test(S("abcde"), 0, 0, S("abcde"), 1, 1, -1); + test(S("abcde"), 0, 0, S("abcde"), 1, 2, -2); + test(S("abcde"), 0, 0, S("abcde"), 1, 3, -3); + test(S("abcde"), 0, 0, S("abcde"), 1, 4, -4); + test(S("abcde"), 0, 0, S("abcde"), 1, 5, -4); + test(S("abcde"), 0, 0, S("abcde"), 2, 0, 0); + test(S("abcde"), 0, 0, S("abcde"), 2, 1, -1); + test(S("abcde"), 0, 0, S("abcde"), 2, 2, -2); + test(S("abcde"), 0, 0, S("abcde"), 2, 3, -3); + test(S("abcde"), 0, 0, S("abcde"), 2, 4, -3); + test(S("abcde"), 0, 0, S("abcde"), 4, 0, 0); + test(S("abcde"), 0, 0, S("abcde"), 4, 1, -1); + test(S("abcde"), 0, 0, S("abcde"), 4, 2, -1); + test(S("abcde"), 0, 0, S("abcde"), 5, 0, 0); + test(S("abcde"), 0, 0, S("abcde"), 5, 1, 0); + test(S("abcde"), 0, 0, S("abcde"), 6, 0, 0); + test(S("abcde"), 0, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcde"), 0, 0, S("abcdefghij"), 0, 1, -1); + test(S("abcde"), 0, 0, S("abcdefghij"), 0, 5, -5); + test(S("abcde"), 0, 0, S("abcdefghij"), 0, 9, -9); + test(S("abcde"), 0, 0, S("abcdefghij"), 0, 10, -10); + test(S("abcde"), 0, 0, S("abcdefghij"), 0, 11, -10); + test(S("abcde"), 0, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcde"), 0, 0, S("abcdefghij"), 1, 1, -1); + test(S("abcde"), 0, 0, S("abcdefghij"), 1, 4, -4); + test(S("abcde"), 0, 0, S("abcdefghij"), 1, 8, -8); + test(S("abcde"), 0, 0, S("abcdefghij"), 1, 9, -9); + test(S("abcde"), 0, 0, S("abcdefghij"), 1, 10, -9); + test(S("abcde"), 0, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcde"), 0, 0, S("abcdefghij"), 5, 1, -1); + test(S("abcde"), 0, 0, S("abcdefghij"), 5, 2, -2); + test(S("abcde"), 0, 0, S("abcdefghij"), 5, 4, -4); + test(S("abcde"), 0, 0, S("abcdefghij"), 5, 5, -5); + test(S("abcde"), 0, 0, S("abcdefghij"), 5, 6, -5); + test(S("abcde"), 0, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcde"), 0, 0, S("abcdefghij"), 9, 1, -1); + test(S("abcde"), 0, 0, S("abcdefghij"), 9, 2, -1); + test(S("abcde"), 0, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcde"), 0, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcde"), 0, 0, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 0, 1, S(""), 0, 0, 1); + test(S("abcde"), 0, 1, S(""), 0, 1, 1); + test(S("abcde"), 0, 1, S(""), 1, 0, 0); + test(S("abcde"), 0, 1, S("abcde"), 0, 0, 1); +} + +template <class S> +void test3() +{ + test(S("abcde"), 0, 1, S("abcde"), 0, 1, 0); + test(S("abcde"), 0, 1, S("abcde"), 0, 2, -1); + test(S("abcde"), 0, 1, S("abcde"), 0, 4, -3); + test(S("abcde"), 0, 1, S("abcde"), 0, 5, -4); + test(S("abcde"), 0, 1, S("abcde"), 0, 6, -4); + test(S("abcde"), 0, 1, S("abcde"), 1, 0, 1); + test(S("abcde"), 0, 1, S("abcde"), 1, 1, -1); + test(S("abcde"), 0, 1, S("abcde"), 1, 2, -1); + test(S("abcde"), 0, 1, S("abcde"), 1, 3, -1); + test(S("abcde"), 0, 1, S("abcde"), 1, 4, -1); + test(S("abcde"), 0, 1, S("abcde"), 1, 5, -1); + test(S("abcde"), 0, 1, S("abcde"), 2, 0, 1); + test(S("abcde"), 0, 1, S("abcde"), 2, 1, -2); + test(S("abcde"), 0, 1, S("abcde"), 2, 2, -2); + test(S("abcde"), 0, 1, S("abcde"), 2, 3, -2); + test(S("abcde"), 0, 1, S("abcde"), 2, 4, -2); + test(S("abcde"), 0, 1, S("abcde"), 4, 0, 1); + test(S("abcde"), 0, 1, S("abcde"), 4, 1, -4); + test(S("abcde"), 0, 1, S("abcde"), 4, 2, -4); + test(S("abcde"), 0, 1, S("abcde"), 5, 0, 1); + test(S("abcde"), 0, 1, S("abcde"), 5, 1, 1); + test(S("abcde"), 0, 1, S("abcde"), 6, 0, 0); + test(S("abcde"), 0, 1, S("abcdefghij"), 0, 0, 1); + test(S("abcde"), 0, 1, S("abcdefghij"), 0, 1, 0); + test(S("abcde"), 0, 1, S("abcdefghij"), 0, 5, -4); + test(S("abcde"), 0, 1, S("abcdefghij"), 0, 9, -8); + test(S("abcde"), 0, 1, S("abcdefghij"), 0, 10, -9); + test(S("abcde"), 0, 1, S("abcdefghij"), 0, 11, -9); + test(S("abcde"), 0, 1, S("abcdefghij"), 1, 0, 1); + test(S("abcde"), 0, 1, S("abcdefghij"), 1, 1, -1); + test(S("abcde"), 0, 1, S("abcdefghij"), 1, 4, -1); + test(S("abcde"), 0, 1, S("abcdefghij"), 1, 8, -1); + test(S("abcde"), 0, 1, S("abcdefghij"), 1, 9, -1); + test(S("abcde"), 0, 1, S("abcdefghij"), 1, 10, -1); + test(S("abcde"), 0, 1, S("abcdefghij"), 5, 0, 1); + test(S("abcde"), 0, 1, S("abcdefghij"), 5, 1, -5); + test(S("abcde"), 0, 1, S("abcdefghij"), 5, 2, -5); + test(S("abcde"), 0, 1, S("abcdefghij"), 5, 4, -5); + test(S("abcde"), 0, 1, S("abcdefghij"), 5, 5, -5); + test(S("abcde"), 0, 1, S("abcdefghij"), 5, 6, -5); + test(S("abcde"), 0, 1, S("abcdefghij"), 9, 0, 1); + test(S("abcde"), 0, 1, S("abcdefghij"), 9, 1, -9); + test(S("abcde"), 0, 1, S("abcdefghij"), 9, 2, -9); + test(S("abcde"), 0, 1, S("abcdefghij"), 10, 0, 1); + test(S("abcde"), 0, 1, S("abcdefghij"), 10, 1, 1); + test(S("abcde"), 0, 1, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 0, 1); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 1, 0); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 10, -9); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 19, -18); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 20, -19); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 21, -19); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 0, 1); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 9, -1); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 18, -1); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 19, -1); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 20, -1); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 0, 1); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 1, -10); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 5, -10); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 9, -10); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 19, 0, 1); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 19, 1, -19); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 19, 2, -19); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 20, 0, 1); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 20, 1, 1); + test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 0, 2, S(""), 0, 0, 2); + test(S("abcde"), 0, 2, S(""), 0, 1, 2); + test(S("abcde"), 0, 2, S(""), 1, 0, 0); + test(S("abcde"), 0, 2, S("abcde"), 0, 0, 2); + test(S("abcde"), 0, 2, S("abcde"), 0, 1, 1); + test(S("abcde"), 0, 2, S("abcde"), 0, 2, 0); + test(S("abcde"), 0, 2, S("abcde"), 0, 4, -2); + test(S("abcde"), 0, 2, S("abcde"), 0, 5, -3); + test(S("abcde"), 0, 2, S("abcde"), 0, 6, -3); + test(S("abcde"), 0, 2, S("abcde"), 1, 0, 2); + test(S("abcde"), 0, 2, S("abcde"), 1, 1, -1); + test(S("abcde"), 0, 2, S("abcde"), 1, 2, -1); + test(S("abcde"), 0, 2, S("abcde"), 1, 3, -1); + test(S("abcde"), 0, 2, S("abcde"), 1, 4, -1); + test(S("abcde"), 0, 2, S("abcde"), 1, 5, -1); + test(S("abcde"), 0, 2, S("abcde"), 2, 0, 2); + test(S("abcde"), 0, 2, S("abcde"), 2, 1, -2); + test(S("abcde"), 0, 2, S("abcde"), 2, 2, -2); + test(S("abcde"), 0, 2, S("abcde"), 2, 3, -2); + test(S("abcde"), 0, 2, S("abcde"), 2, 4, -2); + test(S("abcde"), 0, 2, S("abcde"), 4, 0, 2); + test(S("abcde"), 0, 2, S("abcde"), 4, 1, -4); + test(S("abcde"), 0, 2, S("abcde"), 4, 2, -4); + test(S("abcde"), 0, 2, S("abcde"), 5, 0, 2); + test(S("abcde"), 0, 2, S("abcde"), 5, 1, 2); + test(S("abcde"), 0, 2, S("abcde"), 6, 0, 0); + test(S("abcde"), 0, 2, S("abcdefghij"), 0, 0, 2); + test(S("abcde"), 0, 2, S("abcdefghij"), 0, 1, 1); + test(S("abcde"), 0, 2, S("abcdefghij"), 0, 5, -3); + test(S("abcde"), 0, 2, S("abcdefghij"), 0, 9, -7); +} + +template <class S> +void test4() +{ + test(S("abcde"), 0, 2, S("abcdefghij"), 0, 10, -8); + test(S("abcde"), 0, 2, S("abcdefghij"), 0, 11, -8); + test(S("abcde"), 0, 2, S("abcdefghij"), 1, 0, 2); + test(S("abcde"), 0, 2, S("abcdefghij"), 1, 1, -1); + test(S("abcde"), 0, 2, S("abcdefghij"), 1, 4, -1); + test(S("abcde"), 0, 2, S("abcdefghij"), 1, 8, -1); + test(S("abcde"), 0, 2, S("abcdefghij"), 1, 9, -1); + test(S("abcde"), 0, 2, S("abcdefghij"), 1, 10, -1); + test(S("abcde"), 0, 2, S("abcdefghij"), 5, 0, 2); + test(S("abcde"), 0, 2, S("abcdefghij"), 5, 1, -5); + test(S("abcde"), 0, 2, S("abcdefghij"), 5, 2, -5); + test(S("abcde"), 0, 2, S("abcdefghij"), 5, 4, -5); + test(S("abcde"), 0, 2, S("abcdefghij"), 5, 5, -5); + test(S("abcde"), 0, 2, S("abcdefghij"), 5, 6, -5); + test(S("abcde"), 0, 2, S("abcdefghij"), 9, 0, 2); + test(S("abcde"), 0, 2, S("abcdefghij"), 9, 1, -9); + test(S("abcde"), 0, 2, S("abcdefghij"), 9, 2, -9); + test(S("abcde"), 0, 2, S("abcdefghij"), 10, 0, 2); + test(S("abcde"), 0, 2, S("abcdefghij"), 10, 1, 2); + test(S("abcde"), 0, 2, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 0, 2); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 1, 1); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 10, -8); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 19, -17); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 20, -18); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 21, -18); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 0, 2); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 9, -1); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 18, -1); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 19, -1); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 20, -1); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 0, 2); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 1, -10); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 5, -10); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 9, -10); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 19, 0, 2); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 19, 1, -19); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 19, 2, -19); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 20, 0, 2); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 20, 1, 2); + test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 0, 4, S(""), 0, 0, 4); + test(S("abcde"), 0, 4, S(""), 0, 1, 4); + test(S("abcde"), 0, 4, S(""), 1, 0, 0); + test(S("abcde"), 0, 4, S("abcde"), 0, 0, 4); + test(S("abcde"), 0, 4, S("abcde"), 0, 1, 3); + test(S("abcde"), 0, 4, S("abcde"), 0, 2, 2); + test(S("abcde"), 0, 4, S("abcde"), 0, 4, 0); + test(S("abcde"), 0, 4, S("abcde"), 0, 5, -1); + test(S("abcde"), 0, 4, S("abcde"), 0, 6, -1); + test(S("abcde"), 0, 4, S("abcde"), 1, 0, 4); + test(S("abcde"), 0, 4, S("abcde"), 1, 1, -1); + test(S("abcde"), 0, 4, S("abcde"), 1, 2, -1); + test(S("abcde"), 0, 4, S("abcde"), 1, 3, -1); + test(S("abcde"), 0, 4, S("abcde"), 1, 4, -1); + test(S("abcde"), 0, 4, S("abcde"), 1, 5, -1); + test(S("abcde"), 0, 4, S("abcde"), 2, 0, 4); + test(S("abcde"), 0, 4, S("abcde"), 2, 1, -2); + test(S("abcde"), 0, 4, S("abcde"), 2, 2, -2); + test(S("abcde"), 0, 4, S("abcde"), 2, 3, -2); + test(S("abcde"), 0, 4, S("abcde"), 2, 4, -2); + test(S("abcde"), 0, 4, S("abcde"), 4, 0, 4); + test(S("abcde"), 0, 4, S("abcde"), 4, 1, -4); + test(S("abcde"), 0, 4, S("abcde"), 4, 2, -4); + test(S("abcde"), 0, 4, S("abcde"), 5, 0, 4); + test(S("abcde"), 0, 4, S("abcde"), 5, 1, 4); + test(S("abcde"), 0, 4, S("abcde"), 6, 0, 0); + test(S("abcde"), 0, 4, S("abcdefghij"), 0, 0, 4); + test(S("abcde"), 0, 4, S("abcdefghij"), 0, 1, 3); + test(S("abcde"), 0, 4, S("abcdefghij"), 0, 5, -1); + test(S("abcde"), 0, 4, S("abcdefghij"), 0, 9, -5); + test(S("abcde"), 0, 4, S("abcdefghij"), 0, 10, -6); + test(S("abcde"), 0, 4, S("abcdefghij"), 0, 11, -6); + test(S("abcde"), 0, 4, S("abcdefghij"), 1, 0, 4); + test(S("abcde"), 0, 4, S("abcdefghij"), 1, 1, -1); + test(S("abcde"), 0, 4, S("abcdefghij"), 1, 4, -1); + test(S("abcde"), 0, 4, S("abcdefghij"), 1, 8, -1); + test(S("abcde"), 0, 4, S("abcdefghij"), 1, 9, -1); + test(S("abcde"), 0, 4, S("abcdefghij"), 1, 10, -1); + test(S("abcde"), 0, 4, S("abcdefghij"), 5, 0, 4); + test(S("abcde"), 0, 4, S("abcdefghij"), 5, 1, -5); + test(S("abcde"), 0, 4, S("abcdefghij"), 5, 2, -5); + test(S("abcde"), 0, 4, S("abcdefghij"), 5, 4, -5); + test(S("abcde"), 0, 4, S("abcdefghij"), 5, 5, -5); + test(S("abcde"), 0, 4, S("abcdefghij"), 5, 6, -5); + test(S("abcde"), 0, 4, S("abcdefghij"), 9, 0, 4); + test(S("abcde"), 0, 4, S("abcdefghij"), 9, 1, -9); + test(S("abcde"), 0, 4, S("abcdefghij"), 9, 2, -9); + test(S("abcde"), 0, 4, S("abcdefghij"), 10, 0, 4); + test(S("abcde"), 0, 4, S("abcdefghij"), 10, 1, 4); + test(S("abcde"), 0, 4, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 0, 4); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 1, 3); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 10, -6); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 19, -15); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 20, -16); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 21, -16); +} + +template <class S> +void test5() +{ + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 0, 4); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 9, -1); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 18, -1); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 19, -1); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 20, -1); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 0, 4); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 1, -10); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 5, -10); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 9, -10); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 19, 0, 4); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 19, 1, -19); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 19, 2, -19); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 20, 0, 4); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 20, 1, 4); + test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 0, 5, S(""), 0, 0, 5); + test(S("abcde"), 0, 5, S(""), 0, 1, 5); + test(S("abcde"), 0, 5, S(""), 1, 0, 0); + test(S("abcde"), 0, 5, S("abcde"), 0, 0, 5); + test(S("abcde"), 0, 5, S("abcde"), 0, 1, 4); + test(S("abcde"), 0, 5, S("abcde"), 0, 2, 3); + test(S("abcde"), 0, 5, S("abcde"), 0, 4, 1); + test(S("abcde"), 0, 5, S("abcde"), 0, 5, 0); + test(S("abcde"), 0, 5, S("abcde"), 0, 6, 0); + test(S("abcde"), 0, 5, S("abcde"), 1, 0, 5); + test(S("abcde"), 0, 5, S("abcde"), 1, 1, -1); + test(S("abcde"), 0, 5, S("abcde"), 1, 2, -1); + test(S("abcde"), 0, 5, S("abcde"), 1, 3, -1); + test(S("abcde"), 0, 5, S("abcde"), 1, 4, -1); + test(S("abcde"), 0, 5, S("abcde"), 1, 5, -1); + test(S("abcde"), 0, 5, S("abcde"), 2, 0, 5); + test(S("abcde"), 0, 5, S("abcde"), 2, 1, -2); + test(S("abcde"), 0, 5, S("abcde"), 2, 2, -2); + test(S("abcde"), 0, 5, S("abcde"), 2, 3, -2); + test(S("abcde"), 0, 5, S("abcde"), 2, 4, -2); + test(S("abcde"), 0, 5, S("abcde"), 4, 0, 5); + test(S("abcde"), 0, 5, S("abcde"), 4, 1, -4); + test(S("abcde"), 0, 5, S("abcde"), 4, 2, -4); + test(S("abcde"), 0, 5, S("abcde"), 5, 0, 5); + test(S("abcde"), 0, 5, S("abcde"), 5, 1, 5); + test(S("abcde"), 0, 5, S("abcde"), 6, 0, 0); + test(S("abcde"), 0, 5, S("abcdefghij"), 0, 0, 5); + test(S("abcde"), 0, 5, S("abcdefghij"), 0, 1, 4); + test(S("abcde"), 0, 5, S("abcdefghij"), 0, 5, 0); + test(S("abcde"), 0, 5, S("abcdefghij"), 0, 9, -4); + test(S("abcde"), 0, 5, S("abcdefghij"), 0, 10, -5); + test(S("abcde"), 0, 5, S("abcdefghij"), 0, 11, -5); + test(S("abcde"), 0, 5, S("abcdefghij"), 1, 0, 5); + test(S("abcde"), 0, 5, S("abcdefghij"), 1, 1, -1); + test(S("abcde"), 0, 5, S("abcdefghij"), 1, 4, -1); + test(S("abcde"), 0, 5, S("abcdefghij"), 1, 8, -1); + test(S("abcde"), 0, 5, S("abcdefghij"), 1, 9, -1); + test(S("abcde"), 0, 5, S("abcdefghij"), 1, 10, -1); + test(S("abcde"), 0, 5, S("abcdefghij"), 5, 0, 5); + test(S("abcde"), 0, 5, S("abcdefghij"), 5, 1, -5); + test(S("abcde"), 0, 5, S("abcdefghij"), 5, 2, -5); + test(S("abcde"), 0, 5, S("abcdefghij"), 5, 4, -5); + test(S("abcde"), 0, 5, S("abcdefghij"), 5, 5, -5); + test(S("abcde"), 0, 5, S("abcdefghij"), 5, 6, -5); + test(S("abcde"), 0, 5, S("abcdefghij"), 9, 0, 5); + test(S("abcde"), 0, 5, S("abcdefghij"), 9, 1, -9); + test(S("abcde"), 0, 5, S("abcdefghij"), 9, 2, -9); + test(S("abcde"), 0, 5, S("abcdefghij"), 10, 0, 5); + test(S("abcde"), 0, 5, S("abcdefghij"), 10, 1, 5); + test(S("abcde"), 0, 5, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 0, 5); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 1, 4); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 10, -5); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 19, -14); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 20, -15); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 21, -15); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 0, 5); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 9, -1); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 18, -1); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 19, -1); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 20, -1); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 0, 5); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 1, -10); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 5, -10); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 9, -10); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 19, 0, 5); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 19, 1, -19); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 19, 2, -19); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 20, 0, 5); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 20, 1, 5); + test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 0, 6, S(""), 0, 0, 5); + test(S("abcde"), 0, 6, S(""), 0, 1, 5); + test(S("abcde"), 0, 6, S(""), 1, 0, 0); + test(S("abcde"), 0, 6, S("abcde"), 0, 0, 5); + test(S("abcde"), 0, 6, S("abcde"), 0, 1, 4); + test(S("abcde"), 0, 6, S("abcde"), 0, 2, 3); + test(S("abcde"), 0, 6, S("abcde"), 0, 4, 1); + test(S("abcde"), 0, 6, S("abcde"), 0, 5, 0); +} + +template <class S> +void test6() +{ + test(S("abcde"), 0, 6, S("abcde"), 0, 6, 0); + test(S("abcde"), 0, 6, S("abcde"), 1, 0, 5); + test(S("abcde"), 0, 6, S("abcde"), 1, 1, -1); + test(S("abcde"), 0, 6, S("abcde"), 1, 2, -1); + test(S("abcde"), 0, 6, S("abcde"), 1, 3, -1); + test(S("abcde"), 0, 6, S("abcde"), 1, 4, -1); + test(S("abcde"), 0, 6, S("abcde"), 1, 5, -1); + test(S("abcde"), 0, 6, S("abcde"), 2, 0, 5); + test(S("abcde"), 0, 6, S("abcde"), 2, 1, -2); + test(S("abcde"), 0, 6, S("abcde"), 2, 2, -2); + test(S("abcde"), 0, 6, S("abcde"), 2, 3, -2); + test(S("abcde"), 0, 6, S("abcde"), 2, 4, -2); + test(S("abcde"), 0, 6, S("abcde"), 4, 0, 5); + test(S("abcde"), 0, 6, S("abcde"), 4, 1, -4); + test(S("abcde"), 0, 6, S("abcde"), 4, 2, -4); + test(S("abcde"), 0, 6, S("abcde"), 5, 0, 5); + test(S("abcde"), 0, 6, S("abcde"), 5, 1, 5); + test(S("abcde"), 0, 6, S("abcde"), 6, 0, 0); + test(S("abcde"), 0, 6, S("abcdefghij"), 0, 0, 5); + test(S("abcde"), 0, 6, S("abcdefghij"), 0, 1, 4); + test(S("abcde"), 0, 6, S("abcdefghij"), 0, 5, 0); + test(S("abcde"), 0, 6, S("abcdefghij"), 0, 9, -4); + test(S("abcde"), 0, 6, S("abcdefghij"), 0, 10, -5); + test(S("abcde"), 0, 6, S("abcdefghij"), 0, 11, -5); + test(S("abcde"), 0, 6, S("abcdefghij"), 1, 0, 5); + test(S("abcde"), 0, 6, S("abcdefghij"), 1, 1, -1); + test(S("abcde"), 0, 6, S("abcdefghij"), 1, 4, -1); + test(S("abcde"), 0, 6, S("abcdefghij"), 1, 8, -1); + test(S("abcde"), 0, 6, S("abcdefghij"), 1, 9, -1); + test(S("abcde"), 0, 6, S("abcdefghij"), 1, 10, -1); + test(S("abcde"), 0, 6, S("abcdefghij"), 5, 0, 5); + test(S("abcde"), 0, 6, S("abcdefghij"), 5, 1, -5); + test(S("abcde"), 0, 6, S("abcdefghij"), 5, 2, -5); + test(S("abcde"), 0, 6, S("abcdefghij"), 5, 4, -5); + test(S("abcde"), 0, 6, S("abcdefghij"), 5, 5, -5); + test(S("abcde"), 0, 6, S("abcdefghij"), 5, 6, -5); + test(S("abcde"), 0, 6, S("abcdefghij"), 9, 0, 5); + test(S("abcde"), 0, 6, S("abcdefghij"), 9, 1, -9); + test(S("abcde"), 0, 6, S("abcdefghij"), 9, 2, -9); + test(S("abcde"), 0, 6, S("abcdefghij"), 10, 0, 5); + test(S("abcde"), 0, 6, S("abcdefghij"), 10, 1, 5); + test(S("abcde"), 0, 6, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 0, 5); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 1, 4); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 10, -5); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 19, -14); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 20, -15); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 21, -15); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 0, 5); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 9, -1); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 18, -1); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 19, -1); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 20, -1); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 0, 5); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 1, -10); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 5, -10); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 9, -10); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 19, 0, 5); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 19, 1, -19); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 19, 2, -19); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 20, 0, 5); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 20, 1, 5); + test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 1, 0, S(""), 0, 0, 0); + test(S("abcde"), 1, 0, S(""), 0, 1, 0); + test(S("abcde"), 1, 0, S(""), 1, 0, 0); + test(S("abcde"), 1, 0, S("abcde"), 0, 0, 0); + test(S("abcde"), 1, 0, S("abcde"), 0, 1, -1); + test(S("abcde"), 1, 0, S("abcde"), 0, 2, -2); + test(S("abcde"), 1, 0, S("abcde"), 0, 4, -4); + test(S("abcde"), 1, 0, S("abcde"), 0, 5, -5); + test(S("abcde"), 1, 0, S("abcde"), 0, 6, -5); + test(S("abcde"), 1, 0, S("abcde"), 1, 0, 0); + test(S("abcde"), 1, 0, S("abcde"), 1, 1, -1); + test(S("abcde"), 1, 0, S("abcde"), 1, 2, -2); + test(S("abcde"), 1, 0, S("abcde"), 1, 3, -3); + test(S("abcde"), 1, 0, S("abcde"), 1, 4, -4); + test(S("abcde"), 1, 0, S("abcde"), 1, 5, -4); + test(S("abcde"), 1, 0, S("abcde"), 2, 0, 0); + test(S("abcde"), 1, 0, S("abcde"), 2, 1, -1); + test(S("abcde"), 1, 0, S("abcde"), 2, 2, -2); + test(S("abcde"), 1, 0, S("abcde"), 2, 3, -3); + test(S("abcde"), 1, 0, S("abcde"), 2, 4, -3); + test(S("abcde"), 1, 0, S("abcde"), 4, 0, 0); + test(S("abcde"), 1, 0, S("abcde"), 4, 1, -1); + test(S("abcde"), 1, 0, S("abcde"), 4, 2, -1); + test(S("abcde"), 1, 0, S("abcde"), 5, 0, 0); + test(S("abcde"), 1, 0, S("abcde"), 5, 1, 0); + test(S("abcde"), 1, 0, S("abcde"), 6, 0, 0); + test(S("abcde"), 1, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcde"), 1, 0, S("abcdefghij"), 0, 1, -1); + test(S("abcde"), 1, 0, S("abcdefghij"), 0, 5, -5); + test(S("abcde"), 1, 0, S("abcdefghij"), 0, 9, -9); + test(S("abcde"), 1, 0, S("abcdefghij"), 0, 10, -10); + test(S("abcde"), 1, 0, S("abcdefghij"), 0, 11, -10); + test(S("abcde"), 1, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcde"), 1, 0, S("abcdefghij"), 1, 1, -1); +} + +template <class S> +void test7() +{ + test(S("abcde"), 1, 0, S("abcdefghij"), 1, 4, -4); + test(S("abcde"), 1, 0, S("abcdefghij"), 1, 8, -8); + test(S("abcde"), 1, 0, S("abcdefghij"), 1, 9, -9); + test(S("abcde"), 1, 0, S("abcdefghij"), 1, 10, -9); + test(S("abcde"), 1, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcde"), 1, 0, S("abcdefghij"), 5, 1, -1); + test(S("abcde"), 1, 0, S("abcdefghij"), 5, 2, -2); + test(S("abcde"), 1, 0, S("abcdefghij"), 5, 4, -4); + test(S("abcde"), 1, 0, S("abcdefghij"), 5, 5, -5); + test(S("abcde"), 1, 0, S("abcdefghij"), 5, 6, -5); + test(S("abcde"), 1, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcde"), 1, 0, S("abcdefghij"), 9, 1, -1); + test(S("abcde"), 1, 0, S("abcdefghij"), 9, 2, -1); + test(S("abcde"), 1, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcde"), 1, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcde"), 1, 0, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 1, 1, S(""), 0, 0, 1); + test(S("abcde"), 1, 1, S(""), 0, 1, 1); + test(S("abcde"), 1, 1, S(""), 1, 0, 0); + test(S("abcde"), 1, 1, S("abcde"), 0, 0, 1); + test(S("abcde"), 1, 1, S("abcde"), 0, 1, 1); + test(S("abcde"), 1, 1, S("abcde"), 0, 2, 1); + test(S("abcde"), 1, 1, S("abcde"), 0, 4, 1); + test(S("abcde"), 1, 1, S("abcde"), 0, 5, 1); + test(S("abcde"), 1, 1, S("abcde"), 0, 6, 1); + test(S("abcde"), 1, 1, S("abcde"), 1, 0, 1); + test(S("abcde"), 1, 1, S("abcde"), 1, 1, 0); + test(S("abcde"), 1, 1, S("abcde"), 1, 2, -1); + test(S("abcde"), 1, 1, S("abcde"), 1, 3, -2); + test(S("abcde"), 1, 1, S("abcde"), 1, 4, -3); + test(S("abcde"), 1, 1, S("abcde"), 1, 5, -3); + test(S("abcde"), 1, 1, S("abcde"), 2, 0, 1); + test(S("abcde"), 1, 1, S("abcde"), 2, 1, -1); + test(S("abcde"), 1, 1, S("abcde"), 2, 2, -1); + test(S("abcde"), 1, 1, S("abcde"), 2, 3, -1); + test(S("abcde"), 1, 1, S("abcde"), 2, 4, -1); + test(S("abcde"), 1, 1, S("abcde"), 4, 0, 1); + test(S("abcde"), 1, 1, S("abcde"), 4, 1, -3); + test(S("abcde"), 1, 1, S("abcde"), 4, 2, -3); + test(S("abcde"), 1, 1, S("abcde"), 5, 0, 1); + test(S("abcde"), 1, 1, S("abcde"), 5, 1, 1); + test(S("abcde"), 1, 1, S("abcde"), 6, 0, 0); + test(S("abcde"), 1, 1, S("abcdefghij"), 0, 0, 1); + test(S("abcde"), 1, 1, S("abcdefghij"), 0, 1, 1); + test(S("abcde"), 1, 1, S("abcdefghij"), 0, 5, 1); + test(S("abcde"), 1, 1, S("abcdefghij"), 0, 9, 1); + test(S("abcde"), 1, 1, S("abcdefghij"), 0, 10, 1); + test(S("abcde"), 1, 1, S("abcdefghij"), 0, 11, 1); + test(S("abcde"), 1, 1, S("abcdefghij"), 1, 0, 1); + test(S("abcde"), 1, 1, S("abcdefghij"), 1, 1, 0); + test(S("abcde"), 1, 1, S("abcdefghij"), 1, 4, -3); + test(S("abcde"), 1, 1, S("abcdefghij"), 1, 8, -7); + test(S("abcde"), 1, 1, S("abcdefghij"), 1, 9, -8); + test(S("abcde"), 1, 1, S("abcdefghij"), 1, 10, -8); + test(S("abcde"), 1, 1, S("abcdefghij"), 5, 0, 1); + test(S("abcde"), 1, 1, S("abcdefghij"), 5, 1, -4); + test(S("abcde"), 1, 1, S("abcdefghij"), 5, 2, -4); + test(S("abcde"), 1, 1, S("abcdefghij"), 5, 4, -4); + test(S("abcde"), 1, 1, S("abcdefghij"), 5, 5, -4); + test(S("abcde"), 1, 1, S("abcdefghij"), 5, 6, -4); + test(S("abcde"), 1, 1, S("abcdefghij"), 9, 0, 1); + test(S("abcde"), 1, 1, S("abcdefghij"), 9, 1, -8); + test(S("abcde"), 1, 1, S("abcdefghij"), 9, 2, -8); + test(S("abcde"), 1, 1, S("abcdefghij"), 10, 0, 1); + test(S("abcde"), 1, 1, S("abcdefghij"), 10, 1, 1); + test(S("abcde"), 1, 1, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 0, 1); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 1, 1); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 10, 1); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 19, 1); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 20, 1); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 21, 1); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 0, 1); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 1, 0); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 9, -8); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 18, -17); +} + +template <class S> +void test8() +{ + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 19, -18); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 20, -18); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 0, 1); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 1, -9); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 5, -9); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 10, -9); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 11, -9); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 19, 0, 1); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 19, 1, -18); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 19, 2, -18); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 20, 0, 1); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 20, 1, 1); + test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 1, 2, S(""), 0, 0, 2); + test(S("abcde"), 1, 2, S(""), 0, 1, 2); + test(S("abcde"), 1, 2, S(""), 1, 0, 0); + test(S("abcde"), 1, 2, S("abcde"), 0, 0, 2); + test(S("abcde"), 1, 2, S("abcde"), 0, 1, 1); + test(S("abcde"), 1, 2, S("abcde"), 0, 2, 1); + test(S("abcde"), 1, 2, S("abcde"), 0, 4, 1); + test(S("abcde"), 1, 2, S("abcde"), 0, 5, 1); + test(S("abcde"), 1, 2, S("abcde"), 0, 6, 1); + test(S("abcde"), 1, 2, S("abcde"), 1, 0, 2); + test(S("abcde"), 1, 2, S("abcde"), 1, 1, 1); + test(S("abcde"), 1, 2, S("abcde"), 1, 2, 0); + test(S("abcde"), 1, 2, S("abcde"), 1, 3, -1); + test(S("abcde"), 1, 2, S("abcde"), 1, 4, -2); + test(S("abcde"), 1, 2, S("abcde"), 1, 5, -2); + test(S("abcde"), 1, 2, S("abcde"), 2, 0, 2); + test(S("abcde"), 1, 2, S("abcde"), 2, 1, -1); + test(S("abcde"), 1, 2, S("abcde"), 2, 2, -1); + test(S("abcde"), 1, 2, S("abcde"), 2, 3, -1); + test(S("abcde"), 1, 2, S("abcde"), 2, 4, -1); + test(S("abcde"), 1, 2, S("abcde"), 4, 0, 2); + test(S("abcde"), 1, 2, S("abcde"), 4, 1, -3); + test(S("abcde"), 1, 2, S("abcde"), 4, 2, -3); + test(S("abcde"), 1, 2, S("abcde"), 5, 0, 2); + test(S("abcde"), 1, 2, S("abcde"), 5, 1, 2); + test(S("abcde"), 1, 2, S("abcde"), 6, 0, 0); + test(S("abcde"), 1, 2, S("abcdefghij"), 0, 0, 2); + test(S("abcde"), 1, 2, S("abcdefghij"), 0, 1, 1); + test(S("abcde"), 1, 2, S("abcdefghij"), 0, 5, 1); + test(S("abcde"), 1, 2, S("abcdefghij"), 0, 9, 1); + test(S("abcde"), 1, 2, S("abcdefghij"), 0, 10, 1); + test(S("abcde"), 1, 2, S("abcdefghij"), 0, 11, 1); + test(S("abcde"), 1, 2, S("abcdefghij"), 1, 0, 2); + test(S("abcde"), 1, 2, S("abcdefghij"), 1, 1, 1); + test(S("abcde"), 1, 2, S("abcdefghij"), 1, 4, -2); + test(S("abcde"), 1, 2, S("abcdefghij"), 1, 8, -6); + test(S("abcde"), 1, 2, S("abcdefghij"), 1, 9, -7); + test(S("abcde"), 1, 2, S("abcdefghij"), 1, 10, -7); + test(S("abcde"), 1, 2, S("abcdefghij"), 5, 0, 2); + test(S("abcde"), 1, 2, S("abcdefghij"), 5, 1, -4); + test(S("abcde"), 1, 2, S("abcdefghij"), 5, 2, -4); + test(S("abcde"), 1, 2, S("abcdefghij"), 5, 4, -4); + test(S("abcde"), 1, 2, S("abcdefghij"), 5, 5, -4); + test(S("abcde"), 1, 2, S("abcdefghij"), 5, 6, -4); + test(S("abcde"), 1, 2, S("abcdefghij"), 9, 0, 2); + test(S("abcde"), 1, 2, S("abcdefghij"), 9, 1, -8); + test(S("abcde"), 1, 2, S("abcdefghij"), 9, 2, -8); + test(S("abcde"), 1, 2, S("abcdefghij"), 10, 0, 2); + test(S("abcde"), 1, 2, S("abcdefghij"), 10, 1, 2); + test(S("abcde"), 1, 2, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 0, 2); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 1, 1); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 10, 1); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 19, 1); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 20, 1); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 21, 1); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 0, 2); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 1, 1); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 9, -7); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 18, -16); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 19, -17); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 20, -17); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 0, 2); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 1, -9); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 5, -9); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 10, -9); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 11, -9); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 19, 0, 2); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 19, 1, -18); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 19, 2, -18); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 20, 0, 2); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 20, 1, 2); + test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 1, 3, S(""), 0, 0, 3); + test(S("abcde"), 1, 3, S(""), 0, 1, 3); + test(S("abcde"), 1, 3, S(""), 1, 0, 0); + test(S("abcde"), 1, 3, S("abcde"), 0, 0, 3); + test(S("abcde"), 1, 3, S("abcde"), 0, 1, 1); + test(S("abcde"), 1, 3, S("abcde"), 0, 2, 1); + test(S("abcde"), 1, 3, S("abcde"), 0, 4, 1); + test(S("abcde"), 1, 3, S("abcde"), 0, 5, 1); + test(S("abcde"), 1, 3, S("abcde"), 0, 6, 1); + test(S("abcde"), 1, 3, S("abcde"), 1, 0, 3); + test(S("abcde"), 1, 3, S("abcde"), 1, 1, 2); + test(S("abcde"), 1, 3, S("abcde"), 1, 2, 1); +} + +template <class S> +void test9() +{ + test(S("abcde"), 1, 3, S("abcde"), 1, 3, 0); + test(S("abcde"), 1, 3, S("abcde"), 1, 4, -1); + test(S("abcde"), 1, 3, S("abcde"), 1, 5, -1); + test(S("abcde"), 1, 3, S("abcde"), 2, 0, 3); + test(S("abcde"), 1, 3, S("abcde"), 2, 1, -1); + test(S("abcde"), 1, 3, S("abcde"), 2, 2, -1); + test(S("abcde"), 1, 3, S("abcde"), 2, 3, -1); + test(S("abcde"), 1, 3, S("abcde"), 2, 4, -1); + test(S("abcde"), 1, 3, S("abcde"), 4, 0, 3); + test(S("abcde"), 1, 3, S("abcde"), 4, 1, -3); + test(S("abcde"), 1, 3, S("abcde"), 4, 2, -3); + test(S("abcde"), 1, 3, S("abcde"), 5, 0, 3); + test(S("abcde"), 1, 3, S("abcde"), 5, 1, 3); + test(S("abcde"), 1, 3, S("abcde"), 6, 0, 0); + test(S("abcde"), 1, 3, S("abcdefghij"), 0, 0, 3); + test(S("abcde"), 1, 3, S("abcdefghij"), 0, 1, 1); + test(S("abcde"), 1, 3, S("abcdefghij"), 0, 5, 1); + test(S("abcde"), 1, 3, S("abcdefghij"), 0, 9, 1); + test(S("abcde"), 1, 3, S("abcdefghij"), 0, 10, 1); + test(S("abcde"), 1, 3, S("abcdefghij"), 0, 11, 1); + test(S("abcde"), 1, 3, S("abcdefghij"), 1, 0, 3); + test(S("abcde"), 1, 3, S("abcdefghij"), 1, 1, 2); + test(S("abcde"), 1, 3, S("abcdefghij"), 1, 4, -1); + test(S("abcde"), 1, 3, S("abcdefghij"), 1, 8, -5); + test(S("abcde"), 1, 3, S("abcdefghij"), 1, 9, -6); + test(S("abcde"), 1, 3, S("abcdefghij"), 1, 10, -6); + test(S("abcde"), 1, 3, S("abcdefghij"), 5, 0, 3); + test(S("abcde"), 1, 3, S("abcdefghij"), 5, 1, -4); + test(S("abcde"), 1, 3, S("abcdefghij"), 5, 2, -4); + test(S("abcde"), 1, 3, S("abcdefghij"), 5, 4, -4); + test(S("abcde"), 1, 3, S("abcdefghij"), 5, 5, -4); + test(S("abcde"), 1, 3, S("abcdefghij"), 5, 6, -4); + test(S("abcde"), 1, 3, S("abcdefghij"), 9, 0, 3); + test(S("abcde"), 1, 3, S("abcdefghij"), 9, 1, -8); + test(S("abcde"), 1, 3, S("abcdefghij"), 9, 2, -8); + test(S("abcde"), 1, 3, S("abcdefghij"), 10, 0, 3); + test(S("abcde"), 1, 3, S("abcdefghij"), 10, 1, 3); + test(S("abcde"), 1, 3, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 0, 3); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 1, 1); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 10, 1); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 19, 1); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 20, 1); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 21, 1); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 0, 3); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 1, 2); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 9, -6); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 18, -15); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 19, -16); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 20, -16); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 0, 3); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 1, -9); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 5, -9); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 10, -9); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 11, -9); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 19, 0, 3); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 19, 1, -18); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 19, 2, -18); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 20, 0, 3); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 20, 1, 3); + test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 1, 4, S(""), 0, 0, 4); + test(S("abcde"), 1, 4, S(""), 0, 1, 4); + test(S("abcde"), 1, 4, S(""), 1, 0, 0); + test(S("abcde"), 1, 4, S("abcde"), 0, 0, 4); + test(S("abcde"), 1, 4, S("abcde"), 0, 1, 1); + test(S("abcde"), 1, 4, S("abcde"), 0, 2, 1); + test(S("abcde"), 1, 4, S("abcde"), 0, 4, 1); + test(S("abcde"), 1, 4, S("abcde"), 0, 5, 1); + test(S("abcde"), 1, 4, S("abcde"), 0, 6, 1); + test(S("abcde"), 1, 4, S("abcde"), 1, 0, 4); + test(S("abcde"), 1, 4, S("abcde"), 1, 1, 3); + test(S("abcde"), 1, 4, S("abcde"), 1, 2, 2); + test(S("abcde"), 1, 4, S("abcde"), 1, 3, 1); + test(S("abcde"), 1, 4, S("abcde"), 1, 4, 0); + test(S("abcde"), 1, 4, S("abcde"), 1, 5, 0); + test(S("abcde"), 1, 4, S("abcde"), 2, 0, 4); + test(S("abcde"), 1, 4, S("abcde"), 2, 1, -1); + test(S("abcde"), 1, 4, S("abcde"), 2, 2, -1); + test(S("abcde"), 1, 4, S("abcde"), 2, 3, -1); + test(S("abcde"), 1, 4, S("abcde"), 2, 4, -1); + test(S("abcde"), 1, 4, S("abcde"), 4, 0, 4); + test(S("abcde"), 1, 4, S("abcde"), 4, 1, -3); + test(S("abcde"), 1, 4, S("abcde"), 4, 2, -3); + test(S("abcde"), 1, 4, S("abcde"), 5, 0, 4); + test(S("abcde"), 1, 4, S("abcde"), 5, 1, 4); + test(S("abcde"), 1, 4, S("abcde"), 6, 0, 0); + test(S("abcde"), 1, 4, S("abcdefghij"), 0, 0, 4); + test(S("abcde"), 1, 4, S("abcdefghij"), 0, 1, 1); + test(S("abcde"), 1, 4, S("abcdefghij"), 0, 5, 1); + test(S("abcde"), 1, 4, S("abcdefghij"), 0, 9, 1); + test(S("abcde"), 1, 4, S("abcdefghij"), 0, 10, 1); + test(S("abcde"), 1, 4, S("abcdefghij"), 0, 11, 1); + test(S("abcde"), 1, 4, S("abcdefghij"), 1, 0, 4); + test(S("abcde"), 1, 4, S("abcdefghij"), 1, 1, 3); + test(S("abcde"), 1, 4, S("abcdefghij"), 1, 4, 0); + test(S("abcde"), 1, 4, S("abcdefghij"), 1, 8, -4); + test(S("abcde"), 1, 4, S("abcdefghij"), 1, 9, -5); + test(S("abcde"), 1, 4, S("abcdefghij"), 1, 10, -5); +} + +template <class S> +void test10() +{ + test(S("abcde"), 1, 4, S("abcdefghij"), 5, 0, 4); + test(S("abcde"), 1, 4, S("abcdefghij"), 5, 1, -4); + test(S("abcde"), 1, 4, S("abcdefghij"), 5, 2, -4); + test(S("abcde"), 1, 4, S("abcdefghij"), 5, 4, -4); + test(S("abcde"), 1, 4, S("abcdefghij"), 5, 5, -4); + test(S("abcde"), 1, 4, S("abcdefghij"), 5, 6, -4); + test(S("abcde"), 1, 4, S("abcdefghij"), 9, 0, 4); + test(S("abcde"), 1, 4, S("abcdefghij"), 9, 1, -8); + test(S("abcde"), 1, 4, S("abcdefghij"), 9, 2, -8); + test(S("abcde"), 1, 4, S("abcdefghij"), 10, 0, 4); + test(S("abcde"), 1, 4, S("abcdefghij"), 10, 1, 4); + test(S("abcde"), 1, 4, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 0, 4); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 1, 1); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 10, 1); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 19, 1); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 20, 1); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 21, 1); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 0, 4); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 1, 3); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 9, -5); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 18, -14); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 19, -15); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 20, -15); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 0, 4); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 1, -9); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 5, -9); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 10, -9); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 11, -9); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 19, 0, 4); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 19, 1, -18); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 19, 2, -18); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 20, 0, 4); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 20, 1, 4); + test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 1, 5, S(""), 0, 0, 4); + test(S("abcde"), 1, 5, S(""), 0, 1, 4); + test(S("abcde"), 1, 5, S(""), 1, 0, 0); + test(S("abcde"), 1, 5, S("abcde"), 0, 0, 4); + test(S("abcde"), 1, 5, S("abcde"), 0, 1, 1); + test(S("abcde"), 1, 5, S("abcde"), 0, 2, 1); + test(S("abcde"), 1, 5, S("abcde"), 0, 4, 1); + test(S("abcde"), 1, 5, S("abcde"), 0, 5, 1); + test(S("abcde"), 1, 5, S("abcde"), 0, 6, 1); + test(S("abcde"), 1, 5, S("abcde"), 1, 0, 4); + test(S("abcde"), 1, 5, S("abcde"), 1, 1, 3); + test(S("abcde"), 1, 5, S("abcde"), 1, 2, 2); + test(S("abcde"), 1, 5, S("abcde"), 1, 3, 1); + test(S("abcde"), 1, 5, S("abcde"), 1, 4, 0); + test(S("abcde"), 1, 5, S("abcde"), 1, 5, 0); + test(S("abcde"), 1, 5, S("abcde"), 2, 0, 4); + test(S("abcde"), 1, 5, S("abcde"), 2, 1, -1); + test(S("abcde"), 1, 5, S("abcde"), 2, 2, -1); + test(S("abcde"), 1, 5, S("abcde"), 2, 3, -1); + test(S("abcde"), 1, 5, S("abcde"), 2, 4, -1); + test(S("abcde"), 1, 5, S("abcde"), 4, 0, 4); + test(S("abcde"), 1, 5, S("abcde"), 4, 1, -3); + test(S("abcde"), 1, 5, S("abcde"), 4, 2, -3); + test(S("abcde"), 1, 5, S("abcde"), 5, 0, 4); + test(S("abcde"), 1, 5, S("abcde"), 5, 1, 4); + test(S("abcde"), 1, 5, S("abcde"), 6, 0, 0); + test(S("abcde"), 1, 5, S("abcdefghij"), 0, 0, 4); + test(S("abcde"), 1, 5, S("abcdefghij"), 0, 1, 1); + test(S("abcde"), 1, 5, S("abcdefghij"), 0, 5, 1); + test(S("abcde"), 1, 5, S("abcdefghij"), 0, 9, 1); + test(S("abcde"), 1, 5, S("abcdefghij"), 0, 10, 1); + test(S("abcde"), 1, 5, S("abcdefghij"), 0, 11, 1); + test(S("abcde"), 1, 5, S("abcdefghij"), 1, 0, 4); + test(S("abcde"), 1, 5, S("abcdefghij"), 1, 1, 3); + test(S("abcde"), 1, 5, S("abcdefghij"), 1, 4, 0); + test(S("abcde"), 1, 5, S("abcdefghij"), 1, 8, -4); + test(S("abcde"), 1, 5, S("abcdefghij"), 1, 9, -5); + test(S("abcde"), 1, 5, S("abcdefghij"), 1, 10, -5); + test(S("abcde"), 1, 5, S("abcdefghij"), 5, 0, 4); + test(S("abcde"), 1, 5, S("abcdefghij"), 5, 1, -4); + test(S("abcde"), 1, 5, S("abcdefghij"), 5, 2, -4); + test(S("abcde"), 1, 5, S("abcdefghij"), 5, 4, -4); + test(S("abcde"), 1, 5, S("abcdefghij"), 5, 5, -4); + test(S("abcde"), 1, 5, S("abcdefghij"), 5, 6, -4); + test(S("abcde"), 1, 5, S("abcdefghij"), 9, 0, 4); + test(S("abcde"), 1, 5, S("abcdefghij"), 9, 1, -8); + test(S("abcde"), 1, 5, S("abcdefghij"), 9, 2, -8); + test(S("abcde"), 1, 5, S("abcdefghij"), 10, 0, 4); + test(S("abcde"), 1, 5, S("abcdefghij"), 10, 1, 4); + test(S("abcde"), 1, 5, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 0, 4); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 1, 1); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 10, 1); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 19, 1); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 20, 1); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 21, 1); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 0, 4); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 1, 3); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 9, -5); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 18, -14); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 19, -15); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 20, -15); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 0, 4); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 1, -9); +} + +template <class S> +void test11() +{ + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 5, -9); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 10, -9); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 11, -9); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 19, 0, 4); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 19, 1, -18); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 19, 2, -18); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 20, 0, 4); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 20, 1, 4); + test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 2, 0, S(""), 0, 0, 0); + test(S("abcde"), 2, 0, S(""), 0, 1, 0); + test(S("abcde"), 2, 0, S(""), 1, 0, 0); + test(S("abcde"), 2, 0, S("abcde"), 0, 0, 0); + test(S("abcde"), 2, 0, S("abcde"), 0, 1, -1); + test(S("abcde"), 2, 0, S("abcde"), 0, 2, -2); + test(S("abcde"), 2, 0, S("abcde"), 0, 4, -4); + test(S("abcde"), 2, 0, S("abcde"), 0, 5, -5); + test(S("abcde"), 2, 0, S("abcde"), 0, 6, -5); + test(S("abcde"), 2, 0, S("abcde"), 1, 0, 0); + test(S("abcde"), 2, 0, S("abcde"), 1, 1, -1); + test(S("abcde"), 2, 0, S("abcde"), 1, 2, -2); + test(S("abcde"), 2, 0, S("abcde"), 1, 3, -3); + test(S("abcde"), 2, 0, S("abcde"), 1, 4, -4); + test(S("abcde"), 2, 0, S("abcde"), 1, 5, -4); + test(S("abcde"), 2, 0, S("abcde"), 2, 0, 0); + test(S("abcde"), 2, 0, S("abcde"), 2, 1, -1); + test(S("abcde"), 2, 0, S("abcde"), 2, 2, -2); + test(S("abcde"), 2, 0, S("abcde"), 2, 3, -3); + test(S("abcde"), 2, 0, S("abcde"), 2, 4, -3); + test(S("abcde"), 2, 0, S("abcde"), 4, 0, 0); + test(S("abcde"), 2, 0, S("abcde"), 4, 1, -1); + test(S("abcde"), 2, 0, S("abcde"), 4, 2, -1); + test(S("abcde"), 2, 0, S("abcde"), 5, 0, 0); + test(S("abcde"), 2, 0, S("abcde"), 5, 1, 0); + test(S("abcde"), 2, 0, S("abcde"), 6, 0, 0); + test(S("abcde"), 2, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcde"), 2, 0, S("abcdefghij"), 0, 1, -1); + test(S("abcde"), 2, 0, S("abcdefghij"), 0, 5, -5); + test(S("abcde"), 2, 0, S("abcdefghij"), 0, 9, -9); + test(S("abcde"), 2, 0, S("abcdefghij"), 0, 10, -10); + test(S("abcde"), 2, 0, S("abcdefghij"), 0, 11, -10); + test(S("abcde"), 2, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcde"), 2, 0, S("abcdefghij"), 1, 1, -1); + test(S("abcde"), 2, 0, S("abcdefghij"), 1, 4, -4); + test(S("abcde"), 2, 0, S("abcdefghij"), 1, 8, -8); + test(S("abcde"), 2, 0, S("abcdefghij"), 1, 9, -9); + test(S("abcde"), 2, 0, S("abcdefghij"), 1, 10, -9); + test(S("abcde"), 2, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcde"), 2, 0, S("abcdefghij"), 5, 1, -1); + test(S("abcde"), 2, 0, S("abcdefghij"), 5, 2, -2); + test(S("abcde"), 2, 0, S("abcdefghij"), 5, 4, -4); + test(S("abcde"), 2, 0, S("abcdefghij"), 5, 5, -5); + test(S("abcde"), 2, 0, S("abcdefghij"), 5, 6, -5); + test(S("abcde"), 2, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcde"), 2, 0, S("abcdefghij"), 9, 1, -1); + test(S("abcde"), 2, 0, S("abcdefghij"), 9, 2, -1); + test(S("abcde"), 2, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcde"), 2, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcde"), 2, 0, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 2, 1, S(""), 0, 0, 1); + test(S("abcde"), 2, 1, S(""), 0, 1, 1); + test(S("abcde"), 2, 1, S(""), 1, 0, 0); + test(S("abcde"), 2, 1, S("abcde"), 0, 0, 1); + test(S("abcde"), 2, 1, S("abcde"), 0, 1, 2); + test(S("abcde"), 2, 1, S("abcde"), 0, 2, 2); + test(S("abcde"), 2, 1, S("abcde"), 0, 4, 2); + test(S("abcde"), 2, 1, S("abcde"), 0, 5, 2); + test(S("abcde"), 2, 1, S("abcde"), 0, 6, 2); + test(S("abcde"), 2, 1, S("abcde"), 1, 0, 1); + test(S("abcde"), 2, 1, S("abcde"), 1, 1, 1); + test(S("abcde"), 2, 1, S("abcde"), 1, 2, 1); + test(S("abcde"), 2, 1, S("abcde"), 1, 3, 1); + test(S("abcde"), 2, 1, S("abcde"), 1, 4, 1); + test(S("abcde"), 2, 1, S("abcde"), 1, 5, 1); + test(S("abcde"), 2, 1, S("abcde"), 2, 0, 1); +} + +template <class S> +void test12() +{ + test(S("abcde"), 2, 1, S("abcde"), 2, 1, 0); + test(S("abcde"), 2, 1, S("abcde"), 2, 2, -1); + test(S("abcde"), 2, 1, S("abcde"), 2, 3, -2); + test(S("abcde"), 2, 1, S("abcde"), 2, 4, -2); + test(S("abcde"), 2, 1, S("abcde"), 4, 0, 1); + test(S("abcde"), 2, 1, S("abcde"), 4, 1, -2); + test(S("abcde"), 2, 1, S("abcde"), 4, 2, -2); + test(S("abcde"), 2, 1, S("abcde"), 5, 0, 1); + test(S("abcde"), 2, 1, S("abcde"), 5, 1, 1); + test(S("abcde"), 2, 1, S("abcde"), 6, 0, 0); + test(S("abcde"), 2, 1, S("abcdefghij"), 0, 0, 1); + test(S("abcde"), 2, 1, S("abcdefghij"), 0, 1, 2); + test(S("abcde"), 2, 1, S("abcdefghij"), 0, 5, 2); + test(S("abcde"), 2, 1, S("abcdefghij"), 0, 9, 2); + test(S("abcde"), 2, 1, S("abcdefghij"), 0, 10, 2); + test(S("abcde"), 2, 1, S("abcdefghij"), 0, 11, 2); + test(S("abcde"), 2, 1, S("abcdefghij"), 1, 0, 1); + test(S("abcde"), 2, 1, S("abcdefghij"), 1, 1, 1); + test(S("abcde"), 2, 1, S("abcdefghij"), 1, 4, 1); + test(S("abcde"), 2, 1, S("abcdefghij"), 1, 8, 1); + test(S("abcde"), 2, 1, S("abcdefghij"), 1, 9, 1); + test(S("abcde"), 2, 1, S("abcdefghij"), 1, 10, 1); + test(S("abcde"), 2, 1, S("abcdefghij"), 5, 0, 1); + test(S("abcde"), 2, 1, S("abcdefghij"), 5, 1, -3); + test(S("abcde"), 2, 1, S("abcdefghij"), 5, 2, -3); + test(S("abcde"), 2, 1, S("abcdefghij"), 5, 4, -3); + test(S("abcde"), 2, 1, S("abcdefghij"), 5, 5, -3); + test(S("abcde"), 2, 1, S("abcdefghij"), 5, 6, -3); + test(S("abcde"), 2, 1, S("abcdefghij"), 9, 0, 1); + test(S("abcde"), 2, 1, S("abcdefghij"), 9, 1, -7); + test(S("abcde"), 2, 1, S("abcdefghij"), 9, 2, -7); + test(S("abcde"), 2, 1, S("abcdefghij"), 10, 0, 1); + test(S("abcde"), 2, 1, S("abcdefghij"), 10, 1, 1); + test(S("abcde"), 2, 1, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 0, 1); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 1, 2); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 10, 2); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 19, 2); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 20, 2); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 21, 2); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 0, 1); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 1, 1); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 9, 1); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 18, 1); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 19, 1); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 20, 1); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 0, 1); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 1, -8); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 5, -8); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 9, -8); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 10, -8); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 11, -8); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 19, 0, 1); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 19, 1, -17); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 19, 2, -17); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 20, 0, 1); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 20, 1, 1); + test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 2, 2, S(""), 0, 0, 2); + test(S("abcde"), 2, 2, S(""), 0, 1, 2); + test(S("abcde"), 2, 2, S(""), 1, 0, 0); + test(S("abcde"), 2, 2, S("abcde"), 0, 0, 2); + test(S("abcde"), 2, 2, S("abcde"), 0, 1, 2); + test(S("abcde"), 2, 2, S("abcde"), 0, 2, 2); + test(S("abcde"), 2, 2, S("abcde"), 0, 4, 2); + test(S("abcde"), 2, 2, S("abcde"), 0, 5, 2); + test(S("abcde"), 2, 2, S("abcde"), 0, 6, 2); + test(S("abcde"), 2, 2, S("abcde"), 1, 0, 2); + test(S("abcde"), 2, 2, S("abcde"), 1, 1, 1); + test(S("abcde"), 2, 2, S("abcde"), 1, 2, 1); + test(S("abcde"), 2, 2, S("abcde"), 1, 3, 1); + test(S("abcde"), 2, 2, S("abcde"), 1, 4, 1); + test(S("abcde"), 2, 2, S("abcde"), 1, 5, 1); + test(S("abcde"), 2, 2, S("abcde"), 2, 0, 2); + test(S("abcde"), 2, 2, S("abcde"), 2, 1, 1); + test(S("abcde"), 2, 2, S("abcde"), 2, 2, 0); + test(S("abcde"), 2, 2, S("abcde"), 2, 3, -1); + test(S("abcde"), 2, 2, S("abcde"), 2, 4, -1); + test(S("abcde"), 2, 2, S("abcde"), 4, 0, 2); + test(S("abcde"), 2, 2, S("abcde"), 4, 1, -2); + test(S("abcde"), 2, 2, S("abcde"), 4, 2, -2); + test(S("abcde"), 2, 2, S("abcde"), 5, 0, 2); + test(S("abcde"), 2, 2, S("abcde"), 5, 1, 2); + test(S("abcde"), 2, 2, S("abcde"), 6, 0, 0); + test(S("abcde"), 2, 2, S("abcdefghij"), 0, 0, 2); + test(S("abcde"), 2, 2, S("abcdefghij"), 0, 1, 2); + test(S("abcde"), 2, 2, S("abcdefghij"), 0, 5, 2); + test(S("abcde"), 2, 2, S("abcdefghij"), 0, 9, 2); + test(S("abcde"), 2, 2, S("abcdefghij"), 0, 10, 2); + test(S("abcde"), 2, 2, S("abcdefghij"), 0, 11, 2); + test(S("abcde"), 2, 2, S("abcdefghij"), 1, 0, 2); + test(S("abcde"), 2, 2, S("abcdefghij"), 1, 1, 1); + test(S("abcde"), 2, 2, S("abcdefghij"), 1, 4, 1); + test(S("abcde"), 2, 2, S("abcdefghij"), 1, 8, 1); + test(S("abcde"), 2, 2, S("abcdefghij"), 1, 9, 1); + test(S("abcde"), 2, 2, S("abcdefghij"), 1, 10, 1); + test(S("abcde"), 2, 2, S("abcdefghij"), 5, 0, 2); + test(S("abcde"), 2, 2, S("abcdefghij"), 5, 1, -3); + test(S("abcde"), 2, 2, S("abcdefghij"), 5, 2, -3); + test(S("abcde"), 2, 2, S("abcdefghij"), 5, 4, -3); +} + +template <class S> +void test13() +{ + test(S("abcde"), 2, 2, S("abcdefghij"), 5, 5, -3); + test(S("abcde"), 2, 2, S("abcdefghij"), 5, 6, -3); + test(S("abcde"), 2, 2, S("abcdefghij"), 9, 0, 2); + test(S("abcde"), 2, 2, S("abcdefghij"), 9, 1, -7); + test(S("abcde"), 2, 2, S("abcdefghij"), 9, 2, -7); + test(S("abcde"), 2, 2, S("abcdefghij"), 10, 0, 2); + test(S("abcde"), 2, 2, S("abcdefghij"), 10, 1, 2); + test(S("abcde"), 2, 2, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 0, 2); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 1, 2); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 10, 2); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 19, 2); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 20, 2); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 21, 2); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 0, 2); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 1, 1); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 9, 1); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 18, 1); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 19, 1); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 20, 1); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 0, 2); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 1, -8); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 5, -8); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 9, -8); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 10, -8); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 11, -8); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 19, 0, 2); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 19, 1, -17); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 19, 2, -17); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 20, 0, 2); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 20, 1, 2); + test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 2, 3, S(""), 0, 0, 3); + test(S("abcde"), 2, 3, S(""), 0, 1, 3); + test(S("abcde"), 2, 3, S(""), 1, 0, 0); + test(S("abcde"), 2, 3, S("abcde"), 0, 0, 3); + test(S("abcde"), 2, 3, S("abcde"), 0, 1, 2); + test(S("abcde"), 2, 3, S("abcde"), 0, 2, 2); + test(S("abcde"), 2, 3, S("abcde"), 0, 4, 2); + test(S("abcde"), 2, 3, S("abcde"), 0, 5, 2); + test(S("abcde"), 2, 3, S("abcde"), 0, 6, 2); + test(S("abcde"), 2, 3, S("abcde"), 1, 0, 3); + test(S("abcde"), 2, 3, S("abcde"), 1, 1, 1); + test(S("abcde"), 2, 3, S("abcde"), 1, 2, 1); + test(S("abcde"), 2, 3, S("abcde"), 1, 3, 1); + test(S("abcde"), 2, 3, S("abcde"), 1, 4, 1); + test(S("abcde"), 2, 3, S("abcde"), 1, 5, 1); + test(S("abcde"), 2, 3, S("abcde"), 2, 0, 3); + test(S("abcde"), 2, 3, S("abcde"), 2, 1, 2); + test(S("abcde"), 2, 3, S("abcde"), 2, 2, 1); + test(S("abcde"), 2, 3, S("abcde"), 2, 3, 0); + test(S("abcde"), 2, 3, S("abcde"), 2, 4, 0); + test(S("abcde"), 2, 3, S("abcde"), 4, 0, 3); + test(S("abcde"), 2, 3, S("abcde"), 4, 1, -2); + test(S("abcde"), 2, 3, S("abcde"), 4, 2, -2); + test(S("abcde"), 2, 3, S("abcde"), 5, 0, 3); + test(S("abcde"), 2, 3, S("abcde"), 5, 1, 3); + test(S("abcde"), 2, 3, S("abcde"), 6, 0, 0); + test(S("abcde"), 2, 3, S("abcdefghij"), 0, 0, 3); + test(S("abcde"), 2, 3, S("abcdefghij"), 0, 1, 2); + test(S("abcde"), 2, 3, S("abcdefghij"), 0, 5, 2); + test(S("abcde"), 2, 3, S("abcdefghij"), 0, 9, 2); + test(S("abcde"), 2, 3, S("abcdefghij"), 0, 10, 2); + test(S("abcde"), 2, 3, S("abcdefghij"), 0, 11, 2); + test(S("abcde"), 2, 3, S("abcdefghij"), 1, 0, 3); + test(S("abcde"), 2, 3, S("abcdefghij"), 1, 1, 1); + test(S("abcde"), 2, 3, S("abcdefghij"), 1, 4, 1); + test(S("abcde"), 2, 3, S("abcdefghij"), 1, 8, 1); + test(S("abcde"), 2, 3, S("abcdefghij"), 1, 9, 1); + test(S("abcde"), 2, 3, S("abcdefghij"), 1, 10, 1); + test(S("abcde"), 2, 3, S("abcdefghij"), 5, 0, 3); + test(S("abcde"), 2, 3, S("abcdefghij"), 5, 1, -3); + test(S("abcde"), 2, 3, S("abcdefghij"), 5, 2, -3); + test(S("abcde"), 2, 3, S("abcdefghij"), 5, 4, -3); + test(S("abcde"), 2, 3, S("abcdefghij"), 5, 5, -3); + test(S("abcde"), 2, 3, S("abcdefghij"), 5, 6, -3); + test(S("abcde"), 2, 3, S("abcdefghij"), 9, 0, 3); + test(S("abcde"), 2, 3, S("abcdefghij"), 9, 1, -7); + test(S("abcde"), 2, 3, S("abcdefghij"), 9, 2, -7); + test(S("abcde"), 2, 3, S("abcdefghij"), 10, 0, 3); + test(S("abcde"), 2, 3, S("abcdefghij"), 10, 1, 3); + test(S("abcde"), 2, 3, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 0, 3); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 1, 2); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 10, 2); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 19, 2); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 20, 2); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 21, 2); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 0, 3); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 1, 1); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 9, 1); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 18, 1); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 19, 1); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 20, 1); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 0, 3); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 1, -8); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 5, -8); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 9, -8); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 10, -8); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 11, -8); +} + +template <class S> +void test14() +{ + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 19, 0, 3); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 19, 1, -17); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 19, 2, -17); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 20, 0, 3); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 20, 1, 3); + test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 2, 4, S(""), 0, 0, 3); + test(S("abcde"), 2, 4, S(""), 0, 1, 3); + test(S("abcde"), 2, 4, S(""), 1, 0, 0); + test(S("abcde"), 2, 4, S("abcde"), 0, 0, 3); + test(S("abcde"), 2, 4, S("abcde"), 0, 1, 2); + test(S("abcde"), 2, 4, S("abcde"), 0, 2, 2); + test(S("abcde"), 2, 4, S("abcde"), 0, 4, 2); + test(S("abcde"), 2, 4, S("abcde"), 0, 5, 2); + test(S("abcde"), 2, 4, S("abcde"), 0, 6, 2); + test(S("abcde"), 2, 4, S("abcde"), 1, 0, 3); + test(S("abcde"), 2, 4, S("abcde"), 1, 1, 1); + test(S("abcde"), 2, 4, S("abcde"), 1, 2, 1); + test(S("abcde"), 2, 4, S("abcde"), 1, 3, 1); + test(S("abcde"), 2, 4, S("abcde"), 1, 4, 1); + test(S("abcde"), 2, 4, S("abcde"), 1, 5, 1); + test(S("abcde"), 2, 4, S("abcde"), 2, 0, 3); + test(S("abcde"), 2, 4, S("abcde"), 2, 1, 2); + test(S("abcde"), 2, 4, S("abcde"), 2, 2, 1); + test(S("abcde"), 2, 4, S("abcde"), 2, 3, 0); + test(S("abcde"), 2, 4, S("abcde"), 2, 4, 0); + test(S("abcde"), 2, 4, S("abcde"), 4, 0, 3); + test(S("abcde"), 2, 4, S("abcde"), 4, 1, -2); + test(S("abcde"), 2, 4, S("abcde"), 4, 2, -2); + test(S("abcde"), 2, 4, S("abcde"), 5, 0, 3); + test(S("abcde"), 2, 4, S("abcde"), 5, 1, 3); + test(S("abcde"), 2, 4, S("abcde"), 6, 0, 0); + test(S("abcde"), 2, 4, S("abcdefghij"), 0, 0, 3); + test(S("abcde"), 2, 4, S("abcdefghij"), 0, 1, 2); + test(S("abcde"), 2, 4, S("abcdefghij"), 0, 5, 2); + test(S("abcde"), 2, 4, S("abcdefghij"), 0, 9, 2); + test(S("abcde"), 2, 4, S("abcdefghij"), 0, 10, 2); + test(S("abcde"), 2, 4, S("abcdefghij"), 0, 11, 2); + test(S("abcde"), 2, 4, S("abcdefghij"), 1, 0, 3); + test(S("abcde"), 2, 4, S("abcdefghij"), 1, 1, 1); + test(S("abcde"), 2, 4, S("abcdefghij"), 1, 4, 1); + test(S("abcde"), 2, 4, S("abcdefghij"), 1, 8, 1); + test(S("abcde"), 2, 4, S("abcdefghij"), 1, 9, 1); + test(S("abcde"), 2, 4, S("abcdefghij"), 1, 10, 1); + test(S("abcde"), 2, 4, S("abcdefghij"), 5, 0, 3); + test(S("abcde"), 2, 4, S("abcdefghij"), 5, 1, -3); + test(S("abcde"), 2, 4, S("abcdefghij"), 5, 2, -3); + test(S("abcde"), 2, 4, S("abcdefghij"), 5, 4, -3); + test(S("abcde"), 2, 4, S("abcdefghij"), 5, 5, -3); + test(S("abcde"), 2, 4, S("abcdefghij"), 5, 6, -3); + test(S("abcde"), 2, 4, S("abcdefghij"), 9, 0, 3); + test(S("abcde"), 2, 4, S("abcdefghij"), 9, 1, -7); + test(S("abcde"), 2, 4, S("abcdefghij"), 9, 2, -7); + test(S("abcde"), 2, 4, S("abcdefghij"), 10, 0, 3); + test(S("abcde"), 2, 4, S("abcdefghij"), 10, 1, 3); + test(S("abcde"), 2, 4, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 0, 3); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 1, 2); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 10, 2); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 19, 2); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 20, 2); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 21, 2); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 0, 3); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 1, 1); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 9, 1); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 18, 1); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 19, 1); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 20, 1); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 0, 3); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 1, -8); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 5, -8); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 9, -8); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 10, -8); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 11, -8); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 19, 0, 3); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 19, 1, -17); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 19, 2, -17); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 20, 0, 3); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 20, 1, 3); + test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 4, 0, S(""), 0, 0, 0); + test(S("abcde"), 4, 0, S(""), 0, 1, 0); + test(S("abcde"), 4, 0, S(""), 1, 0, 0); + test(S("abcde"), 4, 0, S("abcde"), 0, 0, 0); + test(S("abcde"), 4, 0, S("abcde"), 0, 1, -1); + test(S("abcde"), 4, 0, S("abcde"), 0, 2, -2); + test(S("abcde"), 4, 0, S("abcde"), 0, 4, -4); + test(S("abcde"), 4, 0, S("abcde"), 0, 5, -5); + test(S("abcde"), 4, 0, S("abcde"), 0, 6, -5); + test(S("abcde"), 4, 0, S("abcde"), 1, 0, 0); + test(S("abcde"), 4, 0, S("abcde"), 1, 1, -1); + test(S("abcde"), 4, 0, S("abcde"), 1, 2, -2); + test(S("abcde"), 4, 0, S("abcde"), 1, 3, -3); + test(S("abcde"), 4, 0, S("abcde"), 1, 4, -4); + test(S("abcde"), 4, 0, S("abcde"), 1, 5, -4); + test(S("abcde"), 4, 0, S("abcde"), 2, 0, 0); + test(S("abcde"), 4, 0, S("abcde"), 2, 1, -1); + test(S("abcde"), 4, 0, S("abcde"), 2, 2, -2); + test(S("abcde"), 4, 0, S("abcde"), 2, 3, -3); + test(S("abcde"), 4, 0, S("abcde"), 2, 4, -3); +} + +template <class S> +void test15() +{ + test(S("abcde"), 4, 0, S("abcde"), 4, 0, 0); + test(S("abcde"), 4, 0, S("abcde"), 4, 1, -1); + test(S("abcde"), 4, 0, S("abcde"), 4, 2, -1); + test(S("abcde"), 4, 0, S("abcde"), 5, 0, 0); + test(S("abcde"), 4, 0, S("abcde"), 5, 1, 0); + test(S("abcde"), 4, 0, S("abcde"), 6, 0, 0); + test(S("abcde"), 4, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcde"), 4, 0, S("abcdefghij"), 0, 1, -1); + test(S("abcde"), 4, 0, S("abcdefghij"), 0, 5, -5); + test(S("abcde"), 4, 0, S("abcdefghij"), 0, 9, -9); + test(S("abcde"), 4, 0, S("abcdefghij"), 0, 10, -10); + test(S("abcde"), 4, 0, S("abcdefghij"), 0, 11, -10); + test(S("abcde"), 4, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcde"), 4, 0, S("abcdefghij"), 1, 1, -1); + test(S("abcde"), 4, 0, S("abcdefghij"), 1, 4, -4); + test(S("abcde"), 4, 0, S("abcdefghij"), 1, 8, -8); + test(S("abcde"), 4, 0, S("abcdefghij"), 1, 9, -9); + test(S("abcde"), 4, 0, S("abcdefghij"), 1, 10, -9); + test(S("abcde"), 4, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcde"), 4, 0, S("abcdefghij"), 5, 1, -1); + test(S("abcde"), 4, 0, S("abcdefghij"), 5, 2, -2); + test(S("abcde"), 4, 0, S("abcdefghij"), 5, 4, -4); + test(S("abcde"), 4, 0, S("abcdefghij"), 5, 5, -5); + test(S("abcde"), 4, 0, S("abcdefghij"), 5, 6, -5); + test(S("abcde"), 4, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcde"), 4, 0, S("abcdefghij"), 9, 1, -1); + test(S("abcde"), 4, 0, S("abcdefghij"), 9, 2, -1); + test(S("abcde"), 4, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcde"), 4, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcde"), 4, 0, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 4, 1, S(""), 0, 0, 1); + test(S("abcde"), 4, 1, S(""), 0, 1, 1); + test(S("abcde"), 4, 1, S(""), 1, 0, 0); + test(S("abcde"), 4, 1, S("abcde"), 0, 0, 1); + test(S("abcde"), 4, 1, S("abcde"), 0, 1, 4); + test(S("abcde"), 4, 1, S("abcde"), 0, 2, 4); + test(S("abcde"), 4, 1, S("abcde"), 0, 4, 4); + test(S("abcde"), 4, 1, S("abcde"), 0, 5, 4); + test(S("abcde"), 4, 1, S("abcde"), 0, 6, 4); + test(S("abcde"), 4, 1, S("abcde"), 1, 0, 1); + test(S("abcde"), 4, 1, S("abcde"), 1, 1, 3); + test(S("abcde"), 4, 1, S("abcde"), 1, 2, 3); + test(S("abcde"), 4, 1, S("abcde"), 1, 3, 3); + test(S("abcde"), 4, 1, S("abcde"), 1, 4, 3); + test(S("abcde"), 4, 1, S("abcde"), 1, 5, 3); + test(S("abcde"), 4, 1, S("abcde"), 2, 0, 1); + test(S("abcde"), 4, 1, S("abcde"), 2, 1, 2); + test(S("abcde"), 4, 1, S("abcde"), 2, 2, 2); + test(S("abcde"), 4, 1, S("abcde"), 2, 3, 2); + test(S("abcde"), 4, 1, S("abcde"), 2, 4, 2); + test(S("abcde"), 4, 1, S("abcde"), 4, 0, 1); + test(S("abcde"), 4, 1, S("abcde"), 4, 1, 0); + test(S("abcde"), 4, 1, S("abcde"), 4, 2, 0); + test(S("abcde"), 4, 1, S("abcde"), 5, 0, 1); + test(S("abcde"), 4, 1, S("abcde"), 5, 1, 1); + test(S("abcde"), 4, 1, S("abcde"), 6, 0, 0); + test(S("abcde"), 4, 1, S("abcdefghij"), 0, 0, 1); + test(S("abcde"), 4, 1, S("abcdefghij"), 0, 1, 4); + test(S("abcde"), 4, 1, S("abcdefghij"), 0, 5, 4); + test(S("abcde"), 4, 1, S("abcdefghij"), 0, 9, 4); + test(S("abcde"), 4, 1, S("abcdefghij"), 0, 10, 4); + test(S("abcde"), 4, 1, S("abcdefghij"), 0, 11, 4); + test(S("abcde"), 4, 1, S("abcdefghij"), 1, 0, 1); + test(S("abcde"), 4, 1, S("abcdefghij"), 1, 1, 3); + test(S("abcde"), 4, 1, S("abcdefghij"), 1, 4, 3); + test(S("abcde"), 4, 1, S("abcdefghij"), 1, 8, 3); + test(S("abcde"), 4, 1, S("abcdefghij"), 1, 9, 3); + test(S("abcde"), 4, 1, S("abcdefghij"), 1, 10, 3); + test(S("abcde"), 4, 1, S("abcdefghij"), 5, 0, 1); + test(S("abcde"), 4, 1, S("abcdefghij"), 5, 1, -1); + test(S("abcde"), 4, 1, S("abcdefghij"), 5, 2, -1); + test(S("abcde"), 4, 1, S("abcdefghij"), 5, 4, -1); + test(S("abcde"), 4, 1, S("abcdefghij"), 5, 5, -1); + test(S("abcde"), 4, 1, S("abcdefghij"), 5, 6, -1); + test(S("abcde"), 4, 1, S("abcdefghij"), 9, 0, 1); + test(S("abcde"), 4, 1, S("abcdefghij"), 9, 1, -5); +} + +template <class S> +void test16() +{ + test(S("abcde"), 4, 1, S("abcdefghij"), 9, 2, -5); + test(S("abcde"), 4, 1, S("abcdefghij"), 10, 0, 1); + test(S("abcde"), 4, 1, S("abcdefghij"), 10, 1, 1); + test(S("abcde"), 4, 1, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 0, 1); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 1, 4); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 10, 4); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 19, 4); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 20, 4); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 21, 4); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 0, 1); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 1, 3); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 9, 3); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 18, 3); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 19, 3); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 20, 3); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 0, 1); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 1, -6); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 5, -6); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 9, -6); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 10, -6); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 11, -6); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 19, 0, 1); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 19, 1, -15); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 19, 2, -15); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 20, 0, 1); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 20, 1, 1); + test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 4, 2, S(""), 0, 0, 1); + test(S("abcde"), 4, 2, S(""), 0, 1, 1); + test(S("abcde"), 4, 2, S(""), 1, 0, 0); + test(S("abcde"), 4, 2, S("abcde"), 0, 0, 1); + test(S("abcde"), 4, 2, S("abcde"), 0, 1, 4); + test(S("abcde"), 4, 2, S("abcde"), 0, 2, 4); + test(S("abcde"), 4, 2, S("abcde"), 0, 4, 4); + test(S("abcde"), 4, 2, S("abcde"), 0, 5, 4); + test(S("abcde"), 4, 2, S("abcde"), 0, 6, 4); + test(S("abcde"), 4, 2, S("abcde"), 1, 0, 1); + test(S("abcde"), 4, 2, S("abcde"), 1, 1, 3); + test(S("abcde"), 4, 2, S("abcde"), 1, 2, 3); + test(S("abcde"), 4, 2, S("abcde"), 1, 3, 3); + test(S("abcde"), 4, 2, S("abcde"), 1, 4, 3); + test(S("abcde"), 4, 2, S("abcde"), 1, 5, 3); + test(S("abcde"), 4, 2, S("abcde"), 2, 0, 1); + test(S("abcde"), 4, 2, S("abcde"), 2, 1, 2); + test(S("abcde"), 4, 2, S("abcde"), 2, 2, 2); + test(S("abcde"), 4, 2, S("abcde"), 2, 3, 2); + test(S("abcde"), 4, 2, S("abcde"), 2, 4, 2); + test(S("abcde"), 4, 2, S("abcde"), 4, 0, 1); + test(S("abcde"), 4, 2, S("abcde"), 4, 1, 0); + test(S("abcde"), 4, 2, S("abcde"), 4, 2, 0); + test(S("abcde"), 4, 2, S("abcde"), 5, 0, 1); + test(S("abcde"), 4, 2, S("abcde"), 5, 1, 1); + test(S("abcde"), 4, 2, S("abcde"), 6, 0, 0); + test(S("abcde"), 4, 2, S("abcdefghij"), 0, 0, 1); + test(S("abcde"), 4, 2, S("abcdefghij"), 0, 1, 4); + test(S("abcde"), 4, 2, S("abcdefghij"), 0, 5, 4); + test(S("abcde"), 4, 2, S("abcdefghij"), 0, 9, 4); + test(S("abcde"), 4, 2, S("abcdefghij"), 0, 10, 4); + test(S("abcde"), 4, 2, S("abcdefghij"), 0, 11, 4); + test(S("abcde"), 4, 2, S("abcdefghij"), 1, 0, 1); + test(S("abcde"), 4, 2, S("abcdefghij"), 1, 1, 3); + test(S("abcde"), 4, 2, S("abcdefghij"), 1, 4, 3); + test(S("abcde"), 4, 2, S("abcdefghij"), 1, 8, 3); + test(S("abcde"), 4, 2, S("abcdefghij"), 1, 9, 3); + test(S("abcde"), 4, 2, S("abcdefghij"), 1, 10, 3); + test(S("abcde"), 4, 2, S("abcdefghij"), 5, 0, 1); + test(S("abcde"), 4, 2, S("abcdefghij"), 5, 1, -1); + test(S("abcde"), 4, 2, S("abcdefghij"), 5, 2, -1); + test(S("abcde"), 4, 2, S("abcdefghij"), 5, 4, -1); + test(S("abcde"), 4, 2, S("abcdefghij"), 5, 5, -1); + test(S("abcde"), 4, 2, S("abcdefghij"), 5, 6, -1); + test(S("abcde"), 4, 2, S("abcdefghij"), 9, 0, 1); + test(S("abcde"), 4, 2, S("abcdefghij"), 9, 1, -5); + test(S("abcde"), 4, 2, S("abcdefghij"), 9, 2, -5); + test(S("abcde"), 4, 2, S("abcdefghij"), 10, 0, 1); + test(S("abcde"), 4, 2, S("abcdefghij"), 10, 1, 1); + test(S("abcde"), 4, 2, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 0, 1); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 1, 4); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 10, 4); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 19, 4); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 20, 4); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 21, 4); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 0, 1); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 1, 3); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 9, 3); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 18, 3); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 19, 3); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 20, 3); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 0, 1); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 1, -6); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 5, -6); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 9, -6); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 10, -6); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 11, -6); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 19, 0, 1); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 19, 1, -15); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 19, 2, -15); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 20, 0, 1); +} + +template <class S> +void test17() +{ + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 20, 1, 1); + test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 5, 0, S(""), 0, 0, 0); + test(S("abcde"), 5, 0, S(""), 0, 1, 0); + test(S("abcde"), 5, 0, S(""), 1, 0, 0); + test(S("abcde"), 5, 0, S("abcde"), 0, 0, 0); + test(S("abcde"), 5, 0, S("abcde"), 0, 1, -1); + test(S("abcde"), 5, 0, S("abcde"), 0, 2, -2); + test(S("abcde"), 5, 0, S("abcde"), 0, 4, -4); + test(S("abcde"), 5, 0, S("abcde"), 0, 5, -5); + test(S("abcde"), 5, 0, S("abcde"), 0, 6, -5); + test(S("abcde"), 5, 0, S("abcde"), 1, 0, 0); + test(S("abcde"), 5, 0, S("abcde"), 1, 1, -1); + test(S("abcde"), 5, 0, S("abcde"), 1, 2, -2); + test(S("abcde"), 5, 0, S("abcde"), 1, 3, -3); + test(S("abcde"), 5, 0, S("abcde"), 1, 4, -4); + test(S("abcde"), 5, 0, S("abcde"), 1, 5, -4); + test(S("abcde"), 5, 0, S("abcde"), 2, 0, 0); + test(S("abcde"), 5, 0, S("abcde"), 2, 1, -1); + test(S("abcde"), 5, 0, S("abcde"), 2, 2, -2); + test(S("abcde"), 5, 0, S("abcde"), 2, 3, -3); + test(S("abcde"), 5, 0, S("abcde"), 2, 4, -3); + test(S("abcde"), 5, 0, S("abcde"), 4, 0, 0); + test(S("abcde"), 5, 0, S("abcde"), 4, 1, -1); + test(S("abcde"), 5, 0, S("abcde"), 4, 2, -1); + test(S("abcde"), 5, 0, S("abcde"), 5, 0, 0); + test(S("abcde"), 5, 0, S("abcde"), 5, 1, 0); + test(S("abcde"), 5, 0, S("abcde"), 6, 0, 0); + test(S("abcde"), 5, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcde"), 5, 0, S("abcdefghij"), 0, 1, -1); + test(S("abcde"), 5, 0, S("abcdefghij"), 0, 5, -5); + test(S("abcde"), 5, 0, S("abcdefghij"), 0, 9, -9); + test(S("abcde"), 5, 0, S("abcdefghij"), 0, 10, -10); + test(S("abcde"), 5, 0, S("abcdefghij"), 0, 11, -10); + test(S("abcde"), 5, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcde"), 5, 0, S("abcdefghij"), 1, 1, -1); + test(S("abcde"), 5, 0, S("abcdefghij"), 1, 4, -4); + test(S("abcde"), 5, 0, S("abcdefghij"), 1, 8, -8); + test(S("abcde"), 5, 0, S("abcdefghij"), 1, 9, -9); + test(S("abcde"), 5, 0, S("abcdefghij"), 1, 10, -9); + test(S("abcde"), 5, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcde"), 5, 0, S("abcdefghij"), 5, 1, -1); + test(S("abcde"), 5, 0, S("abcdefghij"), 5, 2, -2); + test(S("abcde"), 5, 0, S("abcdefghij"), 5, 4, -4); + test(S("abcde"), 5, 0, S("abcdefghij"), 5, 5, -5); + test(S("abcde"), 5, 0, S("abcdefghij"), 5, 6, -5); + test(S("abcde"), 5, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcde"), 5, 0, S("abcdefghij"), 9, 1, -1); + test(S("abcde"), 5, 0, S("abcdefghij"), 9, 2, -1); + test(S("abcde"), 5, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcde"), 5, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcde"), 5, 0, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 5, 1, S(""), 0, 0, 0); + test(S("abcde"), 5, 1, S(""), 0, 1, 0); + test(S("abcde"), 5, 1, S(""), 1, 0, 0); + test(S("abcde"), 5, 1, S("abcde"), 0, 0, 0); + test(S("abcde"), 5, 1, S("abcde"), 0, 1, -1); + test(S("abcde"), 5, 1, S("abcde"), 0, 2, -2); + test(S("abcde"), 5, 1, S("abcde"), 0, 4, -4); + test(S("abcde"), 5, 1, S("abcde"), 0, 5, -5); + test(S("abcde"), 5, 1, S("abcde"), 0, 6, -5); + test(S("abcde"), 5, 1, S("abcde"), 1, 0, 0); + test(S("abcde"), 5, 1, S("abcde"), 1, 1, -1); + test(S("abcde"), 5, 1, S("abcde"), 1, 2, -2); + test(S("abcde"), 5, 1, S("abcde"), 1, 3, -3); + test(S("abcde"), 5, 1, S("abcde"), 1, 4, -4); + test(S("abcde"), 5, 1, S("abcde"), 1, 5, -4); + test(S("abcde"), 5, 1, S("abcde"), 2, 0, 0); + test(S("abcde"), 5, 1, S("abcde"), 2, 1, -1); + test(S("abcde"), 5, 1, S("abcde"), 2, 2, -2); + test(S("abcde"), 5, 1, S("abcde"), 2, 3, -3); + test(S("abcde"), 5, 1, S("abcde"), 2, 4, -3); + test(S("abcde"), 5, 1, S("abcde"), 4, 0, 0); + test(S("abcde"), 5, 1, S("abcde"), 4, 1, -1); + test(S("abcde"), 5, 1, S("abcde"), 4, 2, -1); + test(S("abcde"), 5, 1, S("abcde"), 5, 0, 0); +} + +template <class S> +void test18() +{ + test(S("abcde"), 5, 1, S("abcde"), 5, 1, 0); + test(S("abcde"), 5, 1, S("abcde"), 6, 0, 0); + test(S("abcde"), 5, 1, S("abcdefghij"), 0, 0, 0); + test(S("abcde"), 5, 1, S("abcdefghij"), 0, 1, -1); + test(S("abcde"), 5, 1, S("abcdefghij"), 0, 5, -5); + test(S("abcde"), 5, 1, S("abcdefghij"), 0, 9, -9); + test(S("abcde"), 5, 1, S("abcdefghij"), 0, 10, -10); + test(S("abcde"), 5, 1, S("abcdefghij"), 0, 11, -10); + test(S("abcde"), 5, 1, S("abcdefghij"), 1, 0, 0); + test(S("abcde"), 5, 1, S("abcdefghij"), 1, 1, -1); + test(S("abcde"), 5, 1, S("abcdefghij"), 1, 4, -4); + test(S("abcde"), 5, 1, S("abcdefghij"), 1, 8, -8); + test(S("abcde"), 5, 1, S("abcdefghij"), 1, 9, -9); + test(S("abcde"), 5, 1, S("abcdefghij"), 1, 10, -9); + test(S("abcde"), 5, 1, S("abcdefghij"), 5, 0, 0); + test(S("abcde"), 5, 1, S("abcdefghij"), 5, 1, -1); + test(S("abcde"), 5, 1, S("abcdefghij"), 5, 2, -2); + test(S("abcde"), 5, 1, S("abcdefghij"), 5, 4, -4); + test(S("abcde"), 5, 1, S("abcdefghij"), 5, 5, -5); + test(S("abcde"), 5, 1, S("abcdefghij"), 5, 6, -5); + test(S("abcde"), 5, 1, S("abcdefghij"), 9, 0, 0); + test(S("abcde"), 5, 1, S("abcdefghij"), 9, 1, -1); + test(S("abcde"), 5, 1, S("abcdefghij"), 9, 2, -1); + test(S("abcde"), 5, 1, S("abcdefghij"), 10, 0, 0); + test(S("abcde"), 5, 1, S("abcdefghij"), 10, 1, 0); + test(S("abcde"), 5, 1, S("abcdefghij"), 11, 0, 0); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcde"), 6, 0, S(""), 0, 0, 0); + test(S("abcde"), 6, 0, S(""), 0, 1, 0); + test(S("abcde"), 6, 0, S(""), 1, 0, 0); + test(S("abcde"), 6, 0, S("abcde"), 0, 0, 0); + test(S("abcde"), 6, 0, S("abcde"), 0, 1, 0); + test(S("abcde"), 6, 0, S("abcde"), 0, 2, 0); + test(S("abcde"), 6, 0, S("abcde"), 0, 4, 0); + test(S("abcde"), 6, 0, S("abcde"), 0, 5, 0); + test(S("abcde"), 6, 0, S("abcde"), 0, 6, 0); + test(S("abcde"), 6, 0, S("abcde"), 1, 0, 0); + test(S("abcde"), 6, 0, S("abcde"), 1, 1, 0); + test(S("abcde"), 6, 0, S("abcde"), 1, 2, 0); + test(S("abcde"), 6, 0, S("abcde"), 1, 3, 0); + test(S("abcde"), 6, 0, S("abcde"), 1, 4, 0); + test(S("abcde"), 6, 0, S("abcde"), 1, 5, 0); + test(S("abcde"), 6, 0, S("abcde"), 2, 0, 0); + test(S("abcde"), 6, 0, S("abcde"), 2, 1, 0); + test(S("abcde"), 6, 0, S("abcde"), 2, 2, 0); + test(S("abcde"), 6, 0, S("abcde"), 2, 3, 0); + test(S("abcde"), 6, 0, S("abcde"), 2, 4, 0); + test(S("abcde"), 6, 0, S("abcde"), 4, 0, 0); + test(S("abcde"), 6, 0, S("abcde"), 4, 1, 0); + test(S("abcde"), 6, 0, S("abcde"), 4, 2, 0); + test(S("abcde"), 6, 0, S("abcde"), 5, 0, 0); + test(S("abcde"), 6, 0, S("abcde"), 5, 1, 0); + test(S("abcde"), 6, 0, S("abcde"), 6, 0, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 0, 1, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 0, 5, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 0, 9, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 0, 10, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 0, 11, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 1, 1, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 1, 4, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 1, 8, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 1, 9, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 1, 10, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 5, 1, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 5, 2, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 5, 4, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 5, 5, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 5, 6, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 9, 1, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 9, 2, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcde"), 6, 0, S("abcdefghij"), 11, 0, 0); +} + +template <class S> +void test19() +{ + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 1, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 10, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 19, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 20, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 21, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 1, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 9, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 18, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 19, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 20, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 1, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 5, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 9, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 10, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 11, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 19, 1, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 19, 2, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 0, 0, S(""), 0, 0, 0); + test(S("abcdefghij"), 0, 0, S(""), 0, 1, 0); + test(S("abcdefghij"), 0, 0, S(""), 1, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcde"), 0, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcde"), 0, 1, -1); + test(S("abcdefghij"), 0, 0, S("abcde"), 0, 2, -2); + test(S("abcdefghij"), 0, 0, S("abcde"), 0, 4, -4); + test(S("abcdefghij"), 0, 0, S("abcde"), 0, 5, -5); + test(S("abcdefghij"), 0, 0, S("abcde"), 0, 6, -5); + test(S("abcdefghij"), 0, 0, S("abcde"), 1, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcde"), 1, 1, -1); + test(S("abcdefghij"), 0, 0, S("abcde"), 1, 2, -2); + test(S("abcdefghij"), 0, 0, S("abcde"), 1, 3, -3); + test(S("abcdefghij"), 0, 0, S("abcde"), 1, 4, -4); + test(S("abcdefghij"), 0, 0, S("abcde"), 1, 5, -4); + test(S("abcdefghij"), 0, 0, S("abcde"), 2, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcde"), 2, 1, -1); + test(S("abcdefghij"), 0, 0, S("abcde"), 2, 2, -2); + test(S("abcdefghij"), 0, 0, S("abcde"), 2, 3, -3); + test(S("abcdefghij"), 0, 0, S("abcde"), 2, 4, -3); + test(S("abcdefghij"), 0, 0, S("abcde"), 4, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcde"), 4, 1, -1); + test(S("abcdefghij"), 0, 0, S("abcde"), 4, 2, -1); + test(S("abcdefghij"), 0, 0, S("abcde"), 5, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcde"), 5, 1, 0); + test(S("abcdefghij"), 0, 0, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 1, -1); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 5, -5); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 9, -9); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 10, -10); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 11, -10); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 4, -4); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 8, -8); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 9, -9); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 10, -9); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 1, -1); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 2, -2); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 9, 1, -1); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 9, 2, -1); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcdefghij"), 0, 0, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 0, 1, S(""), 0, 0, 1); + test(S("abcdefghij"), 0, 1, S(""), 0, 1, 1); +} + +template <class S> +void test20() +{ + test(S("abcdefghij"), 0, 1, S(""), 1, 0, 0); + test(S("abcdefghij"), 0, 1, S("abcde"), 0, 0, 1); + test(S("abcdefghij"), 0, 1, S("abcde"), 0, 1, 0); + test(S("abcdefghij"), 0, 1, S("abcde"), 0, 2, -1); + test(S("abcdefghij"), 0, 1, S("abcde"), 0, 4, -3); + test(S("abcdefghij"), 0, 1, S("abcde"), 0, 5, -4); + test(S("abcdefghij"), 0, 1, S("abcde"), 0, 6, -4); + test(S("abcdefghij"), 0, 1, S("abcde"), 1, 0, 1); + test(S("abcdefghij"), 0, 1, S("abcde"), 1, 1, -1); + test(S("abcdefghij"), 0, 1, S("abcde"), 1, 2, -1); + test(S("abcdefghij"), 0, 1, S("abcde"), 1, 3, -1); + test(S("abcdefghij"), 0, 1, S("abcde"), 1, 4, -1); + test(S("abcdefghij"), 0, 1, S("abcde"), 1, 5, -1); + test(S("abcdefghij"), 0, 1, S("abcde"), 2, 0, 1); + test(S("abcdefghij"), 0, 1, S("abcde"), 2, 1, -2); + test(S("abcdefghij"), 0, 1, S("abcde"), 2, 2, -2); + test(S("abcdefghij"), 0, 1, S("abcde"), 2, 3, -2); + test(S("abcdefghij"), 0, 1, S("abcde"), 2, 4, -2); + test(S("abcdefghij"), 0, 1, S("abcde"), 4, 0, 1); + test(S("abcdefghij"), 0, 1, S("abcde"), 4, 1, -4); + test(S("abcdefghij"), 0, 1, S("abcde"), 4, 2, -4); + test(S("abcdefghij"), 0, 1, S("abcde"), 5, 0, 1); + test(S("abcdefghij"), 0, 1, S("abcde"), 5, 1, 1); + test(S("abcdefghij"), 0, 1, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 0, 1); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 1, 0); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 5, -4); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 9, -8); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 10, -9); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 11, -9); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 0, 1); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 4, -1); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 8, -1); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 9, -1); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 10, -1); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 0, 1); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 1, -5); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 2, -5); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 4, -5); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 9, 0, 1); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 9, 1, -9); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 9, 2, -9); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 10, 0, 1); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 10, 1, 1); + test(S("abcdefghij"), 0, 1, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 0, 1); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 1, 0); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 10, -9); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 19, -18); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 20, -19); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 21, -19); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 0, 1); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 9, -1); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 18, -1); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 19, -1); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 20, -1); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 0, 1); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 1, -10); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 5, -10); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 9, -10); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 19, 0, 1); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 19, 1, -19); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 19, 2, -19); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 20, 0, 1); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 20, 1, 1); + test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 0, 5, S(""), 0, 0, 5); + test(S("abcdefghij"), 0, 5, S(""), 0, 1, 5); + test(S("abcdefghij"), 0, 5, S(""), 1, 0, 0); + test(S("abcdefghij"), 0, 5, S("abcde"), 0, 0, 5); + test(S("abcdefghij"), 0, 5, S("abcde"), 0, 1, 4); + test(S("abcdefghij"), 0, 5, S("abcde"), 0, 2, 3); + test(S("abcdefghij"), 0, 5, S("abcde"), 0, 4, 1); + test(S("abcdefghij"), 0, 5, S("abcde"), 0, 5, 0); + test(S("abcdefghij"), 0, 5, S("abcde"), 0, 6, 0); + test(S("abcdefghij"), 0, 5, S("abcde"), 1, 0, 5); + test(S("abcdefghij"), 0, 5, S("abcde"), 1, 1, -1); + test(S("abcdefghij"), 0, 5, S("abcde"), 1, 2, -1); + test(S("abcdefghij"), 0, 5, S("abcde"), 1, 3, -1); + test(S("abcdefghij"), 0, 5, S("abcde"), 1, 4, -1); + test(S("abcdefghij"), 0, 5, S("abcde"), 1, 5, -1); + test(S("abcdefghij"), 0, 5, S("abcde"), 2, 0, 5); + test(S("abcdefghij"), 0, 5, S("abcde"), 2, 1, -2); + test(S("abcdefghij"), 0, 5, S("abcde"), 2, 2, -2); + test(S("abcdefghij"), 0, 5, S("abcde"), 2, 3, -2); + test(S("abcdefghij"), 0, 5, S("abcde"), 2, 4, -2); + test(S("abcdefghij"), 0, 5, S("abcde"), 4, 0, 5); + test(S("abcdefghij"), 0, 5, S("abcde"), 4, 1, -4); + test(S("abcdefghij"), 0, 5, S("abcde"), 4, 2, -4); + test(S("abcdefghij"), 0, 5, S("abcde"), 5, 0, 5); + test(S("abcdefghij"), 0, 5, S("abcde"), 5, 1, 5); + test(S("abcdefghij"), 0, 5, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 0, 5); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 1, 4); +} + +template <class S> +void test21() +{ + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 5, 0); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 9, -4); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 10, -5); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 11, -5); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 0, 5); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 4, -1); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 8, -1); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 9, -1); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 10, -1); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 0, 5); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 1, -5); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 2, -5); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 4, -5); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 9, 0, 5); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 9, 1, -9); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 9, 2, -9); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 10, 0, 5); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 10, 1, 5); + test(S("abcdefghij"), 0, 5, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 0, 5); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 1, 4); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 10, -5); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 19, -14); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 20, -15); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 21, -15); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 0, 5); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 9, -1); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 18, -1); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 19, -1); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 20, -1); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 0, 5); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 1, -10); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 5, -10); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 9, -10); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 19, 0, 5); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 19, 1, -19); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 19, 2, -19); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 20, 0, 5); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 20, 1, 5); + test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 0, 9, S(""), 0, 0, 9); + test(S("abcdefghij"), 0, 9, S(""), 0, 1, 9); + test(S("abcdefghij"), 0, 9, S(""), 1, 0, 0); + test(S("abcdefghij"), 0, 9, S("abcde"), 0, 0, 9); + test(S("abcdefghij"), 0, 9, S("abcde"), 0, 1, 8); + test(S("abcdefghij"), 0, 9, S("abcde"), 0, 2, 7); + test(S("abcdefghij"), 0, 9, S("abcde"), 0, 4, 5); + test(S("abcdefghij"), 0, 9, S("abcde"), 0, 5, 4); + test(S("abcdefghij"), 0, 9, S("abcde"), 0, 6, 4); + test(S("abcdefghij"), 0, 9, S("abcde"), 1, 0, 9); + test(S("abcdefghij"), 0, 9, S("abcde"), 1, 1, -1); + test(S("abcdefghij"), 0, 9, S("abcde"), 1, 2, -1); + test(S("abcdefghij"), 0, 9, S("abcde"), 1, 3, -1); + test(S("abcdefghij"), 0, 9, S("abcde"), 1, 4, -1); + test(S("abcdefghij"), 0, 9, S("abcde"), 1, 5, -1); + test(S("abcdefghij"), 0, 9, S("abcde"), 2, 0, 9); + test(S("abcdefghij"), 0, 9, S("abcde"), 2, 1, -2); + test(S("abcdefghij"), 0, 9, S("abcde"), 2, 2, -2); + test(S("abcdefghij"), 0, 9, S("abcde"), 2, 3, -2); + test(S("abcdefghij"), 0, 9, S("abcde"), 2, 4, -2); + test(S("abcdefghij"), 0, 9, S("abcde"), 4, 0, 9); + test(S("abcdefghij"), 0, 9, S("abcde"), 4, 1, -4); + test(S("abcdefghij"), 0, 9, S("abcde"), 4, 2, -4); + test(S("abcdefghij"), 0, 9, S("abcde"), 5, 0, 9); + test(S("abcdefghij"), 0, 9, S("abcde"), 5, 1, 9); + test(S("abcdefghij"), 0, 9, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 0, 9); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 1, 8); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 5, 4); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 9, 0); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 10, -1); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 11, -1); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 0, 9); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 4, -1); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 8, -1); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 9, -1); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 10, -1); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 0, 9); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 1, -5); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 2, -5); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 4, -5); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 9, 0, 9); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 9, 1, -9); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 9, 2, -9); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 10, 0, 9); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 10, 1, 9); + test(S("abcdefghij"), 0, 9, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 0, 9); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 1, 8); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 10, -1); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 19, -10); +} + +template <class S> +void test22() +{ + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 20, -11); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 21, -11); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 0, 9); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 9, -1); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 18, -1); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 19, -1); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 20, -1); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 0, 9); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 1, -10); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 5, -10); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 9, -10); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 19, 0, 9); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 19, 1, -19); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 19, 2, -19); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 20, 0, 9); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 20, 1, 9); + test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 0, 10, S(""), 0, 0, 10); + test(S("abcdefghij"), 0, 10, S(""), 0, 1, 10); + test(S("abcdefghij"), 0, 10, S(""), 1, 0, 0); + test(S("abcdefghij"), 0, 10, S("abcde"), 0, 0, 10); + test(S("abcdefghij"), 0, 10, S("abcde"), 0, 1, 9); + test(S("abcdefghij"), 0, 10, S("abcde"), 0, 2, 8); + test(S("abcdefghij"), 0, 10, S("abcde"), 0, 4, 6); + test(S("abcdefghij"), 0, 10, S("abcde"), 0, 5, 5); + test(S("abcdefghij"), 0, 10, S("abcde"), 0, 6, 5); + test(S("abcdefghij"), 0, 10, S("abcde"), 1, 0, 10); + test(S("abcdefghij"), 0, 10, S("abcde"), 1, 1, -1); + test(S("abcdefghij"), 0, 10, S("abcde"), 1, 2, -1); + test(S("abcdefghij"), 0, 10, S("abcde"), 1, 3, -1); + test(S("abcdefghij"), 0, 10, S("abcde"), 1, 4, -1); + test(S("abcdefghij"), 0, 10, S("abcde"), 1, 5, -1); + test(S("abcdefghij"), 0, 10, S("abcde"), 2, 0, 10); + test(S("abcdefghij"), 0, 10, S("abcde"), 2, 1, -2); + test(S("abcdefghij"), 0, 10, S("abcde"), 2, 2, -2); + test(S("abcdefghij"), 0, 10, S("abcde"), 2, 3, -2); + test(S("abcdefghij"), 0, 10, S("abcde"), 2, 4, -2); + test(S("abcdefghij"), 0, 10, S("abcde"), 4, 0, 10); + test(S("abcdefghij"), 0, 10, S("abcde"), 4, 1, -4); + test(S("abcdefghij"), 0, 10, S("abcde"), 4, 2, -4); + test(S("abcdefghij"), 0, 10, S("abcde"), 5, 0, 10); + test(S("abcdefghij"), 0, 10, S("abcde"), 5, 1, 10); + test(S("abcdefghij"), 0, 10, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 0, 10); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 1, 9); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 5, 5); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 9, 1); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 10, 0); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 11, 0); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 0, 10); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 4, -1); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 8, -1); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 9, -1); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 10, -1); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 0, 10); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 1, -5); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 2, -5); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 4, -5); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 9, 0, 10); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 9, 1, -9); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 9, 2, -9); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 10, 0, 10); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 10, 1, 10); + test(S("abcdefghij"), 0, 10, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 0, 10); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 1, 9); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 10, 0); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 19, -9); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 20, -10); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 21, -10); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 0, 10); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 9, -1); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 18, -1); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 19, -1); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 20, -1); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 0, 10); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 1, -10); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 5, -10); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 9, -10); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 19, 0, 10); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 19, 1, -19); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 19, 2, -19); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 20, 0, 10); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 20, 1, 10); + test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 0, 11, S(""), 0, 0, 10); + test(S("abcdefghij"), 0, 11, S(""), 0, 1, 10); + test(S("abcdefghij"), 0, 11, S(""), 1, 0, 0); + test(S("abcdefghij"), 0, 11, S("abcde"), 0, 0, 10); + test(S("abcdefghij"), 0, 11, S("abcde"), 0, 1, 9); + test(S("abcdefghij"), 0, 11, S("abcde"), 0, 2, 8); +} + +template <class S> +void test23() +{ + test(S("abcdefghij"), 0, 11, S("abcde"), 0, 4, 6); + test(S("abcdefghij"), 0, 11, S("abcde"), 0, 5, 5); + test(S("abcdefghij"), 0, 11, S("abcde"), 0, 6, 5); + test(S("abcdefghij"), 0, 11, S("abcde"), 1, 0, 10); + test(S("abcdefghij"), 0, 11, S("abcde"), 1, 1, -1); + test(S("abcdefghij"), 0, 11, S("abcde"), 1, 2, -1); + test(S("abcdefghij"), 0, 11, S("abcde"), 1, 3, -1); + test(S("abcdefghij"), 0, 11, S("abcde"), 1, 4, -1); + test(S("abcdefghij"), 0, 11, S("abcde"), 1, 5, -1); + test(S("abcdefghij"), 0, 11, S("abcde"), 2, 0, 10); + test(S("abcdefghij"), 0, 11, S("abcde"), 2, 1, -2); + test(S("abcdefghij"), 0, 11, S("abcde"), 2, 2, -2); + test(S("abcdefghij"), 0, 11, S("abcde"), 2, 3, -2); + test(S("abcdefghij"), 0, 11, S("abcde"), 2, 4, -2); + test(S("abcdefghij"), 0, 11, S("abcde"), 4, 0, 10); + test(S("abcdefghij"), 0, 11, S("abcde"), 4, 1, -4); + test(S("abcdefghij"), 0, 11, S("abcde"), 4, 2, -4); + test(S("abcdefghij"), 0, 11, S("abcde"), 5, 0, 10); + test(S("abcdefghij"), 0, 11, S("abcde"), 5, 1, 10); + test(S("abcdefghij"), 0, 11, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 0, 10); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 1, 9); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 5, 5); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 9, 1); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 10, 0); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 11, 0); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 0, 10); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 4, -1); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 8, -1); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 9, -1); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 10, -1); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 0, 10); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 1, -5); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 2, -5); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 4, -5); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 9, 0, 10); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 9, 1, -9); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 9, 2, -9); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 10, 0, 10); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 10, 1, 10); + test(S("abcdefghij"), 0, 11, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 0, 10); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 1, 9); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 10, 0); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 19, -9); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 20, -10); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 21, -10); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 0, 10); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 9, -1); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 18, -1); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 19, -1); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 20, -1); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 0, 10); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 1, -10); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 5, -10); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 9, -10); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 19, 0, 10); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 19, 1, -19); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 19, 2, -19); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 20, 0, 10); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 20, 1, 10); + test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 1, 0, S(""), 0, 0, 0); + test(S("abcdefghij"), 1, 0, S(""), 0, 1, 0); + test(S("abcdefghij"), 1, 0, S(""), 1, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcde"), 0, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcde"), 0, 1, -1); + test(S("abcdefghij"), 1, 0, S("abcde"), 0, 2, -2); + test(S("abcdefghij"), 1, 0, S("abcde"), 0, 4, -4); + test(S("abcdefghij"), 1, 0, S("abcde"), 0, 5, -5); + test(S("abcdefghij"), 1, 0, S("abcde"), 0, 6, -5); + test(S("abcdefghij"), 1, 0, S("abcde"), 1, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcde"), 1, 1, -1); + test(S("abcdefghij"), 1, 0, S("abcde"), 1, 2, -2); + test(S("abcdefghij"), 1, 0, S("abcde"), 1, 3, -3); + test(S("abcdefghij"), 1, 0, S("abcde"), 1, 4, -4); + test(S("abcdefghij"), 1, 0, S("abcde"), 1, 5, -4); + test(S("abcdefghij"), 1, 0, S("abcde"), 2, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcde"), 2, 1, -1); + test(S("abcdefghij"), 1, 0, S("abcde"), 2, 2, -2); + test(S("abcdefghij"), 1, 0, S("abcde"), 2, 3, -3); + test(S("abcdefghij"), 1, 0, S("abcde"), 2, 4, -3); + test(S("abcdefghij"), 1, 0, S("abcde"), 4, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcde"), 4, 1, -1); + test(S("abcdefghij"), 1, 0, S("abcde"), 4, 2, -1); + test(S("abcdefghij"), 1, 0, S("abcde"), 5, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcde"), 5, 1, 0); + test(S("abcdefghij"), 1, 0, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 1, -1); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 5, -5); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 9, -9); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 10, -10); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 11, -10); +} + +template <class S> +void test24() +{ + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 4, -4); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 8, -8); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 9, -9); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 10, -9); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 1, -1); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 2, -2); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 9, 1, -1); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 9, 2, -1); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcdefghij"), 1, 0, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 1, 1, S(""), 0, 0, 1); + test(S("abcdefghij"), 1, 1, S(""), 0, 1, 1); + test(S("abcdefghij"), 1, 1, S(""), 1, 0, 0); + test(S("abcdefghij"), 1, 1, S("abcde"), 0, 0, 1); + test(S("abcdefghij"), 1, 1, S("abcde"), 0, 1, 1); + test(S("abcdefghij"), 1, 1, S("abcde"), 0, 2, 1); + test(S("abcdefghij"), 1, 1, S("abcde"), 0, 4, 1); + test(S("abcdefghij"), 1, 1, S("abcde"), 0, 5, 1); + test(S("abcdefghij"), 1, 1, S("abcde"), 0, 6, 1); + test(S("abcdefghij"), 1, 1, S("abcde"), 1, 0, 1); + test(S("abcdefghij"), 1, 1, S("abcde"), 1, 1, 0); + test(S("abcdefghij"), 1, 1, S("abcde"), 1, 2, -1); + test(S("abcdefghij"), 1, 1, S("abcde"), 1, 3, -2); + test(S("abcdefghij"), 1, 1, S("abcde"), 1, 4, -3); + test(S("abcdefghij"), 1, 1, S("abcde"), 1, 5, -3); + test(S("abcdefghij"), 1, 1, S("abcde"), 2, 0, 1); + test(S("abcdefghij"), 1, 1, S("abcde"), 2, 1, -1); + test(S("abcdefghij"), 1, 1, S("abcde"), 2, 2, -1); + test(S("abcdefghij"), 1, 1, S("abcde"), 2, 3, -1); + test(S("abcdefghij"), 1, 1, S("abcde"), 2, 4, -1); + test(S("abcdefghij"), 1, 1, S("abcde"), 4, 0, 1); + test(S("abcdefghij"), 1, 1, S("abcde"), 4, 1, -3); + test(S("abcdefghij"), 1, 1, S("abcde"), 4, 2, -3); + test(S("abcdefghij"), 1, 1, S("abcde"), 5, 0, 1); + test(S("abcdefghij"), 1, 1, S("abcde"), 5, 1, 1); + test(S("abcdefghij"), 1, 1, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 0, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 1, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 5, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 9, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 10, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 11, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 0, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 1, 0); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 4, -3); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 8, -7); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 9, -8); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 10, -8); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 0, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 1, -4); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 2, -4); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 5, -4); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 6, -4); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 9, 0, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 9, 1, -8); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 9, 2, -8); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 10, 0, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 10, 1, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 0, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 1, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 10, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 19, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 20, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 21, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 0, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 1, 0); +} + +template <class S> +void test25() +{ + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 9, -8); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 18, -17); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 19, -18); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 20, -18); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 0, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 1, -9); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 5, -9); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 10, -9); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 11, -9); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 19, 0, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 19, 1, -18); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 19, 2, -18); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 20, 0, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 20, 1, 1); + test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 1, 4, S(""), 0, 0, 4); + test(S("abcdefghij"), 1, 4, S(""), 0, 1, 4); + test(S("abcdefghij"), 1, 4, S(""), 1, 0, 0); + test(S("abcdefghij"), 1, 4, S("abcde"), 0, 0, 4); + test(S("abcdefghij"), 1, 4, S("abcde"), 0, 1, 1); + test(S("abcdefghij"), 1, 4, S("abcde"), 0, 2, 1); + test(S("abcdefghij"), 1, 4, S("abcde"), 0, 4, 1); + test(S("abcdefghij"), 1, 4, S("abcde"), 0, 5, 1); + test(S("abcdefghij"), 1, 4, S("abcde"), 0, 6, 1); + test(S("abcdefghij"), 1, 4, S("abcde"), 1, 0, 4); + test(S("abcdefghij"), 1, 4, S("abcde"), 1, 1, 3); + test(S("abcdefghij"), 1, 4, S("abcde"), 1, 2, 2); + test(S("abcdefghij"), 1, 4, S("abcde"), 1, 3, 1); + test(S("abcdefghij"), 1, 4, S("abcde"), 1, 4, 0); + test(S("abcdefghij"), 1, 4, S("abcde"), 1, 5, 0); + test(S("abcdefghij"), 1, 4, S("abcde"), 2, 0, 4); + test(S("abcdefghij"), 1, 4, S("abcde"), 2, 1, -1); + test(S("abcdefghij"), 1, 4, S("abcde"), 2, 2, -1); + test(S("abcdefghij"), 1, 4, S("abcde"), 2, 3, -1); + test(S("abcdefghij"), 1, 4, S("abcde"), 2, 4, -1); + test(S("abcdefghij"), 1, 4, S("abcde"), 4, 0, 4); + test(S("abcdefghij"), 1, 4, S("abcde"), 4, 1, -3); + test(S("abcdefghij"), 1, 4, S("abcde"), 4, 2, -3); + test(S("abcdefghij"), 1, 4, S("abcde"), 5, 0, 4); + test(S("abcdefghij"), 1, 4, S("abcde"), 5, 1, 4); + test(S("abcdefghij"), 1, 4, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 0, 4); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 1, 1); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 5, 1); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 9, 1); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 10, 1); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 11, 1); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 0, 4); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 1, 3); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 4, 0); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 8, -4); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 9, -5); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 10, -5); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 0, 4); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 1, -4); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 2, -4); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 5, -4); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 6, -4); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 9, 0, 4); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 9, 1, -8); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 9, 2, -8); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 10, 0, 4); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 10, 1, 4); + test(S("abcdefghij"), 1, 4, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 0, 4); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 1, 1); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 10, 1); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 19, 1); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 20, 1); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 21, 1); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 0, 4); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 1, 3); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 9, -5); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 18, -14); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 19, -15); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 20, -15); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 0, 4); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 1, -9); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 5, -9); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 10, -9); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 11, -9); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 19, 0, 4); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 19, 1, -18); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 19, 2, -18); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 20, 0, 4); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 20, 1, 4); + test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 1, 8, S(""), 0, 0, 8); + test(S("abcdefghij"), 1, 8, S(""), 0, 1, 8); + test(S("abcdefghij"), 1, 8, S(""), 1, 0, 0); + test(S("abcdefghij"), 1, 8, S("abcde"), 0, 0, 8); + test(S("abcdefghij"), 1, 8, S("abcde"), 0, 1, 1); + test(S("abcdefghij"), 1, 8, S("abcde"), 0, 2, 1); + test(S("abcdefghij"), 1, 8, S("abcde"), 0, 4, 1); + test(S("abcdefghij"), 1, 8, S("abcde"), 0, 5, 1); + test(S("abcdefghij"), 1, 8, S("abcde"), 0, 6, 1); + test(S("abcdefghij"), 1, 8, S("abcde"), 1, 0, 8); +} + +template <class S> +void test26() +{ + test(S("abcdefghij"), 1, 8, S("abcde"), 1, 1, 7); + test(S("abcdefghij"), 1, 8, S("abcde"), 1, 2, 6); + test(S("abcdefghij"), 1, 8, S("abcde"), 1, 3, 5); + test(S("abcdefghij"), 1, 8, S("abcde"), 1, 4, 4); + test(S("abcdefghij"), 1, 8, S("abcde"), 1, 5, 4); + test(S("abcdefghij"), 1, 8, S("abcde"), 2, 0, 8); + test(S("abcdefghij"), 1, 8, S("abcde"), 2, 1, -1); + test(S("abcdefghij"), 1, 8, S("abcde"), 2, 2, -1); + test(S("abcdefghij"), 1, 8, S("abcde"), 2, 3, -1); + test(S("abcdefghij"), 1, 8, S("abcde"), 2, 4, -1); + test(S("abcdefghij"), 1, 8, S("abcde"), 4, 0, 8); + test(S("abcdefghij"), 1, 8, S("abcde"), 4, 1, -3); + test(S("abcdefghij"), 1, 8, S("abcde"), 4, 2, -3); + test(S("abcdefghij"), 1, 8, S("abcde"), 5, 0, 8); + test(S("abcdefghij"), 1, 8, S("abcde"), 5, 1, 8); + test(S("abcdefghij"), 1, 8, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 0, 8); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 1, 1); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 5, 1); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 9, 1); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 10, 1); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 11, 1); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 0, 8); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 1, 7); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 4, 4); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 8, 0); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 9, -1); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 10, -1); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 0, 8); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 1, -4); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 2, -4); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 5, -4); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 6, -4); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 9, 0, 8); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 9, 1, -8); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 9, 2, -8); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 10, 0, 8); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 10, 1, 8); + test(S("abcdefghij"), 1, 8, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 0, 8); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 1, 1); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 10, 1); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 19, 1); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 20, 1); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 21, 1); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 0, 8); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 1, 7); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 9, -1); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 18, -10); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 19, -11); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 20, -11); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 0, 8); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 1, -9); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 5, -9); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 10, -9); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 11, -9); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 19, 0, 8); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 19, 1, -18); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 19, 2, -18); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 20, 0, 8); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 20, 1, 8); + test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 1, 9, S(""), 0, 0, 9); + test(S("abcdefghij"), 1, 9, S(""), 0, 1, 9); + test(S("abcdefghij"), 1, 9, S(""), 1, 0, 0); + test(S("abcdefghij"), 1, 9, S("abcde"), 0, 0, 9); + test(S("abcdefghij"), 1, 9, S("abcde"), 0, 1, 1); + test(S("abcdefghij"), 1, 9, S("abcde"), 0, 2, 1); + test(S("abcdefghij"), 1, 9, S("abcde"), 0, 4, 1); + test(S("abcdefghij"), 1, 9, S("abcde"), 0, 5, 1); + test(S("abcdefghij"), 1, 9, S("abcde"), 0, 6, 1); + test(S("abcdefghij"), 1, 9, S("abcde"), 1, 0, 9); + test(S("abcdefghij"), 1, 9, S("abcde"), 1, 1, 8); + test(S("abcdefghij"), 1, 9, S("abcde"), 1, 2, 7); + test(S("abcdefghij"), 1, 9, S("abcde"), 1, 3, 6); + test(S("abcdefghij"), 1, 9, S("abcde"), 1, 4, 5); + test(S("abcdefghij"), 1, 9, S("abcde"), 1, 5, 5); + test(S("abcdefghij"), 1, 9, S("abcde"), 2, 0, 9); + test(S("abcdefghij"), 1, 9, S("abcde"), 2, 1, -1); + test(S("abcdefghij"), 1, 9, S("abcde"), 2, 2, -1); + test(S("abcdefghij"), 1, 9, S("abcde"), 2, 3, -1); + test(S("abcdefghij"), 1, 9, S("abcde"), 2, 4, -1); + test(S("abcdefghij"), 1, 9, S("abcde"), 4, 0, 9); + test(S("abcdefghij"), 1, 9, S("abcde"), 4, 1, -3); + test(S("abcdefghij"), 1, 9, S("abcde"), 4, 2, -3); + test(S("abcdefghij"), 1, 9, S("abcde"), 5, 0, 9); + test(S("abcdefghij"), 1, 9, S("abcde"), 5, 1, 9); + test(S("abcdefghij"), 1, 9, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 0, 9); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 1, 1); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 5, 1); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 9, 1); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 10, 1); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 11, 1); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 0, 9); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 1, 8); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 4, 5); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 8, 1); +} + +template <class S> +void test27() +{ + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 9, 0); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 10, 0); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 0, 9); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 1, -4); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 2, -4); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 5, -4); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 6, -4); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 9, 0, 9); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 9, 1, -8); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 9, 2, -8); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 10, 0, 9); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 10, 1, 9); + test(S("abcdefghij"), 1, 9, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 0, 9); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 1, 1); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 10, 1); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 19, 1); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 20, 1); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 21, 1); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 0, 9); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 1, 8); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 9, 0); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 18, -9); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 19, -10); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 20, -10); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 0, 9); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 1, -9); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 5, -9); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 10, -9); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 11, -9); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 19, 0, 9); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 19, 1, -18); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 19, 2, -18); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 20, 0, 9); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 20, 1, 9); + test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 1, 10, S(""), 0, 0, 9); + test(S("abcdefghij"), 1, 10, S(""), 0, 1, 9); + test(S("abcdefghij"), 1, 10, S(""), 1, 0, 0); + test(S("abcdefghij"), 1, 10, S("abcde"), 0, 0, 9); + test(S("abcdefghij"), 1, 10, S("abcde"), 0, 1, 1); + test(S("abcdefghij"), 1, 10, S("abcde"), 0, 2, 1); + test(S("abcdefghij"), 1, 10, S("abcde"), 0, 4, 1); + test(S("abcdefghij"), 1, 10, S("abcde"), 0, 5, 1); + test(S("abcdefghij"), 1, 10, S("abcde"), 0, 6, 1); + test(S("abcdefghij"), 1, 10, S("abcde"), 1, 0, 9); + test(S("abcdefghij"), 1, 10, S("abcde"), 1, 1, 8); + test(S("abcdefghij"), 1, 10, S("abcde"), 1, 2, 7); + test(S("abcdefghij"), 1, 10, S("abcde"), 1, 3, 6); + test(S("abcdefghij"), 1, 10, S("abcde"), 1, 4, 5); + test(S("abcdefghij"), 1, 10, S("abcde"), 1, 5, 5); + test(S("abcdefghij"), 1, 10, S("abcde"), 2, 0, 9); + test(S("abcdefghij"), 1, 10, S("abcde"), 2, 1, -1); + test(S("abcdefghij"), 1, 10, S("abcde"), 2, 2, -1); + test(S("abcdefghij"), 1, 10, S("abcde"), 2, 3, -1); + test(S("abcdefghij"), 1, 10, S("abcde"), 2, 4, -1); + test(S("abcdefghij"), 1, 10, S("abcde"), 4, 0, 9); + test(S("abcdefghij"), 1, 10, S("abcde"), 4, 1, -3); + test(S("abcdefghij"), 1, 10, S("abcde"), 4, 2, -3); + test(S("abcdefghij"), 1, 10, S("abcde"), 5, 0, 9); + test(S("abcdefghij"), 1, 10, S("abcde"), 5, 1, 9); + test(S("abcdefghij"), 1, 10, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 0, 9); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 1, 1); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 5, 1); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 9, 1); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 10, 1); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 11, 1); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 0, 9); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 1, 8); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 4, 5); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 8, 1); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 9, 0); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 10, 0); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 0, 9); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 1, -4); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 2, -4); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 5, -4); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 6, -4); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 9, 0, 9); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 9, 1, -8); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 9, 2, -8); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 10, 0, 9); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 10, 1, 9); + test(S("abcdefghij"), 1, 10, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 0, 9); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 1, 1); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 10, 1); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 19, 1); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 20, 1); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 21, 1); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 0, 9); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 1, 8); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 9, 0); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 18, -9); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 19, -10); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 20, -10); +} + +template <class S> +void test28() +{ + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 0, 9); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 1, -9); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 5, -9); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 10, -9); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 11, -9); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 19, 0, 9); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 19, 1, -18); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 19, 2, -18); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 20, 0, 9); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 20, 1, 9); + test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 5, 0, S(""), 0, 0, 0); + test(S("abcdefghij"), 5, 0, S(""), 0, 1, 0); + test(S("abcdefghij"), 5, 0, S(""), 1, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcde"), 0, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcde"), 0, 1, -1); + test(S("abcdefghij"), 5, 0, S("abcde"), 0, 2, -2); + test(S("abcdefghij"), 5, 0, S("abcde"), 0, 4, -4); + test(S("abcdefghij"), 5, 0, S("abcde"), 0, 5, -5); + test(S("abcdefghij"), 5, 0, S("abcde"), 0, 6, -5); + test(S("abcdefghij"), 5, 0, S("abcde"), 1, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcde"), 1, 1, -1); + test(S("abcdefghij"), 5, 0, S("abcde"), 1, 2, -2); + test(S("abcdefghij"), 5, 0, S("abcde"), 1, 3, -3); + test(S("abcdefghij"), 5, 0, S("abcde"), 1, 4, -4); + test(S("abcdefghij"), 5, 0, S("abcde"), 1, 5, -4); + test(S("abcdefghij"), 5, 0, S("abcde"), 2, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcde"), 2, 1, -1); + test(S("abcdefghij"), 5, 0, S("abcde"), 2, 2, -2); + test(S("abcdefghij"), 5, 0, S("abcde"), 2, 3, -3); + test(S("abcdefghij"), 5, 0, S("abcde"), 2, 4, -3); + test(S("abcdefghij"), 5, 0, S("abcde"), 4, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcde"), 4, 1, -1); + test(S("abcdefghij"), 5, 0, S("abcde"), 4, 2, -1); + test(S("abcdefghij"), 5, 0, S("abcde"), 5, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcde"), 5, 1, 0); + test(S("abcdefghij"), 5, 0, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 1, -1); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 5, -5); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 9, -9); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 10, -10); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 11, -10); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 4, -4); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 8, -8); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 9, -9); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 10, -9); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 1, -1); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 2, -2); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 9, 1, -1); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 9, 2, -1); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcdefghij"), 5, 0, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 5, 1, S(""), 0, 0, 1); + test(S("abcdefghij"), 5, 1, S(""), 0, 1, 1); + test(S("abcdefghij"), 5, 1, S(""), 1, 0, 0); + test(S("abcdefghij"), 5, 1, S("abcde"), 0, 0, 1); + test(S("abcdefghij"), 5, 1, S("abcde"), 0, 1, 5); + test(S("abcdefghij"), 5, 1, S("abcde"), 0, 2, 5); + test(S("abcdefghij"), 5, 1, S("abcde"), 0, 4, 5); + test(S("abcdefghij"), 5, 1, S("abcde"), 0, 5, 5); + test(S("abcdefghij"), 5, 1, S("abcde"), 0, 6, 5); + test(S("abcdefghij"), 5, 1, S("abcde"), 1, 0, 1); + test(S("abcdefghij"), 5, 1, S("abcde"), 1, 1, 4); + test(S("abcdefghij"), 5, 1, S("abcde"), 1, 2, 4); + test(S("abcdefghij"), 5, 1, S("abcde"), 1, 3, 4); + test(S("abcdefghij"), 5, 1, S("abcde"), 1, 4, 4); +} + +template <class S> +void test29() +{ + test(S("abcdefghij"), 5, 1, S("abcde"), 1, 5, 4); + test(S("abcdefghij"), 5, 1, S("abcde"), 2, 0, 1); + test(S("abcdefghij"), 5, 1, S("abcde"), 2, 1, 3); + test(S("abcdefghij"), 5, 1, S("abcde"), 2, 2, 3); + test(S("abcdefghij"), 5, 1, S("abcde"), 2, 3, 3); + test(S("abcdefghij"), 5, 1, S("abcde"), 2, 4, 3); + test(S("abcdefghij"), 5, 1, S("abcde"), 4, 0, 1); + test(S("abcdefghij"), 5, 1, S("abcde"), 4, 1, 1); + test(S("abcdefghij"), 5, 1, S("abcde"), 4, 2, 1); + test(S("abcdefghij"), 5, 1, S("abcde"), 5, 0, 1); + test(S("abcdefghij"), 5, 1, S("abcde"), 5, 1, 1); + test(S("abcdefghij"), 5, 1, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 0, 1); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 1, 5); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 5, 5); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 9, 5); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 10, 5); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 11, 5); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 0, 1); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 1, 4); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 4, 4); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 8, 4); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 9, 4); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 10, 4); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 0, 1); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 1, 0); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 2, -1); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 4, -3); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 5, -4); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 6, -4); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 9, 0, 1); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 9, 1, -4); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 9, 2, -4); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 10, 0, 1); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 10, 1, 1); + test(S("abcdefghij"), 5, 1, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 0, 1); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 1, 5); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 10, 5); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 19, 5); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 20, 5); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 21, 5); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 0, 1); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 1, 4); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 9, 4); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 18, 4); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 19, 4); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 20, 4); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 0, 1); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 1, -5); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 9, -5); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 10, -5); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 11, -5); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 19, 0, 1); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 19, 1, -14); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 19, 2, -14); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 20, 0, 1); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 20, 1, 1); + test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 5, 2, S(""), 0, 0, 2); + test(S("abcdefghij"), 5, 2, S(""), 0, 1, 2); + test(S("abcdefghij"), 5, 2, S(""), 1, 0, 0); + test(S("abcdefghij"), 5, 2, S("abcde"), 0, 0, 2); + test(S("abcdefghij"), 5, 2, S("abcde"), 0, 1, 5); + test(S("abcdefghij"), 5, 2, S("abcde"), 0, 2, 5); + test(S("abcdefghij"), 5, 2, S("abcde"), 0, 4, 5); + test(S("abcdefghij"), 5, 2, S("abcde"), 0, 5, 5); + test(S("abcdefghij"), 5, 2, S("abcde"), 0, 6, 5); + test(S("abcdefghij"), 5, 2, S("abcde"), 1, 0, 2); + test(S("abcdefghij"), 5, 2, S("abcde"), 1, 1, 4); + test(S("abcdefghij"), 5, 2, S("abcde"), 1, 2, 4); + test(S("abcdefghij"), 5, 2, S("abcde"), 1, 3, 4); + test(S("abcdefghij"), 5, 2, S("abcde"), 1, 4, 4); + test(S("abcdefghij"), 5, 2, S("abcde"), 1, 5, 4); + test(S("abcdefghij"), 5, 2, S("abcde"), 2, 0, 2); + test(S("abcdefghij"), 5, 2, S("abcde"), 2, 1, 3); + test(S("abcdefghij"), 5, 2, S("abcde"), 2, 2, 3); + test(S("abcdefghij"), 5, 2, S("abcde"), 2, 3, 3); + test(S("abcdefghij"), 5, 2, S("abcde"), 2, 4, 3); + test(S("abcdefghij"), 5, 2, S("abcde"), 4, 0, 2); + test(S("abcdefghij"), 5, 2, S("abcde"), 4, 1, 1); + test(S("abcdefghij"), 5, 2, S("abcde"), 4, 2, 1); + test(S("abcdefghij"), 5, 2, S("abcde"), 5, 0, 2); + test(S("abcdefghij"), 5, 2, S("abcde"), 5, 1, 2); + test(S("abcdefghij"), 5, 2, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 0, 2); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 1, 5); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 5, 5); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 9, 5); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 10, 5); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 11, 5); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 0, 2); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 1, 4); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 4, 4); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 8, 4); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 9, 4); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 10, 4); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 0, 2); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 1, 1); +} + +template <class S> +void test30() +{ + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 2, 0); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 4, -2); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 5, -3); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 6, -3); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 9, 0, 2); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 9, 1, -4); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 9, 2, -4); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 10, 0, 2); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 10, 1, 2); + test(S("abcdefghij"), 5, 2, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 0, 2); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 1, 5); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 10, 5); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 19, 5); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 20, 5); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 21, 5); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 0, 2); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 1, 4); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 9, 4); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 18, 4); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 19, 4); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 20, 4); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 0, 2); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 1, -5); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 9, -5); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 10, -5); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 11, -5); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 19, 0, 2); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 19, 1, -14); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 19, 2, -14); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 20, 0, 2); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 20, 1, 2); + test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 5, 4, S(""), 0, 0, 4); + test(S("abcdefghij"), 5, 4, S(""), 0, 1, 4); + test(S("abcdefghij"), 5, 4, S(""), 1, 0, 0); + test(S("abcdefghij"), 5, 4, S("abcde"), 0, 0, 4); + test(S("abcdefghij"), 5, 4, S("abcde"), 0, 1, 5); + test(S("abcdefghij"), 5, 4, S("abcde"), 0, 2, 5); + test(S("abcdefghij"), 5, 4, S("abcde"), 0, 4, 5); + test(S("abcdefghij"), 5, 4, S("abcde"), 0, 5, 5); + test(S("abcdefghij"), 5, 4, S("abcde"), 0, 6, 5); + test(S("abcdefghij"), 5, 4, S("abcde"), 1, 0, 4); + test(S("abcdefghij"), 5, 4, S("abcde"), 1, 1, 4); + test(S("abcdefghij"), 5, 4, S("abcde"), 1, 2, 4); + test(S("abcdefghij"), 5, 4, S("abcde"), 1, 3, 4); + test(S("abcdefghij"), 5, 4, S("abcde"), 1, 4, 4); + test(S("abcdefghij"), 5, 4, S("abcde"), 1, 5, 4); + test(S("abcdefghij"), 5, 4, S("abcde"), 2, 0, 4); + test(S("abcdefghij"), 5, 4, S("abcde"), 2, 1, 3); + test(S("abcdefghij"), 5, 4, S("abcde"), 2, 2, 3); + test(S("abcdefghij"), 5, 4, S("abcde"), 2, 3, 3); + test(S("abcdefghij"), 5, 4, S("abcde"), 2, 4, 3); + test(S("abcdefghij"), 5, 4, S("abcde"), 4, 0, 4); + test(S("abcdefghij"), 5, 4, S("abcde"), 4, 1, 1); + test(S("abcdefghij"), 5, 4, S("abcde"), 4, 2, 1); + test(S("abcdefghij"), 5, 4, S("abcde"), 5, 0, 4); + test(S("abcdefghij"), 5, 4, S("abcde"), 5, 1, 4); + test(S("abcdefghij"), 5, 4, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 0, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 1, 5); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 5, 5); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 9, 5); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 10, 5); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 11, 5); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 0, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 1, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 4, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 8, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 9, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 10, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 0, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 1, 3); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 2, 2); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 4, 0); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 5, -1); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 6, -1); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 9, 0, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 9, 1, -4); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 9, 2, -4); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 10, 0, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 10, 1, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 0, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 1, 5); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 10, 5); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 19, 5); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 20, 5); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 21, 5); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 0, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 1, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 9, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 18, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 19, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 20, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 0, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 1, -5); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 9, -5); +} + +template <class S> +void test31() +{ + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 10, -5); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 11, -5); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 19, 0, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 19, 1, -14); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 19, 2, -14); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 20, 0, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 20, 1, 4); + test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 5, 5, S(""), 0, 0, 5); + test(S("abcdefghij"), 5, 5, S(""), 0, 1, 5); + test(S("abcdefghij"), 5, 5, S(""), 1, 0, 0); + test(S("abcdefghij"), 5, 5, S("abcde"), 0, 0, 5); + test(S("abcdefghij"), 5, 5, S("abcde"), 0, 1, 5); + test(S("abcdefghij"), 5, 5, S("abcde"), 0, 2, 5); + test(S("abcdefghij"), 5, 5, S("abcde"), 0, 4, 5); + test(S("abcdefghij"), 5, 5, S("abcde"), 0, 5, 5); + test(S("abcdefghij"), 5, 5, S("abcde"), 0, 6, 5); + test(S("abcdefghij"), 5, 5, S("abcde"), 1, 0, 5); + test(S("abcdefghij"), 5, 5, S("abcde"), 1, 1, 4); + test(S("abcdefghij"), 5, 5, S("abcde"), 1, 2, 4); + test(S("abcdefghij"), 5, 5, S("abcde"), 1, 3, 4); + test(S("abcdefghij"), 5, 5, S("abcde"), 1, 4, 4); + test(S("abcdefghij"), 5, 5, S("abcde"), 1, 5, 4); + test(S("abcdefghij"), 5, 5, S("abcde"), 2, 0, 5); + test(S("abcdefghij"), 5, 5, S("abcde"), 2, 1, 3); + test(S("abcdefghij"), 5, 5, S("abcde"), 2, 2, 3); + test(S("abcdefghij"), 5, 5, S("abcde"), 2, 3, 3); + test(S("abcdefghij"), 5, 5, S("abcde"), 2, 4, 3); + test(S("abcdefghij"), 5, 5, S("abcde"), 4, 0, 5); + test(S("abcdefghij"), 5, 5, S("abcde"), 4, 1, 1); + test(S("abcdefghij"), 5, 5, S("abcde"), 4, 2, 1); + test(S("abcdefghij"), 5, 5, S("abcde"), 5, 0, 5); + test(S("abcdefghij"), 5, 5, S("abcde"), 5, 1, 5); + test(S("abcdefghij"), 5, 5, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 0, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 1, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 5, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 9, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 10, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 11, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 0, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 1, 4); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 4, 4); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 8, 4); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 9, 4); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 10, 4); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 0, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 1, 4); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 2, 3); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 4, 1); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 5, 0); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 6, 0); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 9, 0, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 9, 1, -4); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 9, 2, -4); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 10, 0, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 10, 1, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 0, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 1, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 10, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 19, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 20, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 21, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 0, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 1, 4); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 9, 4); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 18, 4); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 19, 4); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 20, 4); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 0, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 1, -5); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 9, -5); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 10, -5); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 11, -5); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 19, 0, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 19, 1, -14); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 19, 2, -14); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 20, 0, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 20, 1, 5); + test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 5, 6, S(""), 0, 0, 5); + test(S("abcdefghij"), 5, 6, S(""), 0, 1, 5); + test(S("abcdefghij"), 5, 6, S(""), 1, 0, 0); + test(S("abcdefghij"), 5, 6, S("abcde"), 0, 0, 5); + test(S("abcdefghij"), 5, 6, S("abcde"), 0, 1, 5); + test(S("abcdefghij"), 5, 6, S("abcde"), 0, 2, 5); + test(S("abcdefghij"), 5, 6, S("abcde"), 0, 4, 5); + test(S("abcdefghij"), 5, 6, S("abcde"), 0, 5, 5); + test(S("abcdefghij"), 5, 6, S("abcde"), 0, 6, 5); + test(S("abcdefghij"), 5, 6, S("abcde"), 1, 0, 5); + test(S("abcdefghij"), 5, 6, S("abcde"), 1, 1, 4); + test(S("abcdefghij"), 5, 6, S("abcde"), 1, 2, 4); + test(S("abcdefghij"), 5, 6, S("abcde"), 1, 3, 4); + test(S("abcdefghij"), 5, 6, S("abcde"), 1, 4, 4); + test(S("abcdefghij"), 5, 6, S("abcde"), 1, 5, 4); + test(S("abcdefghij"), 5, 6, S("abcde"), 2, 0, 5); + test(S("abcdefghij"), 5, 6, S("abcde"), 2, 1, 3); + test(S("abcdefghij"), 5, 6, S("abcde"), 2, 2, 3); +} + +template <class S> +void test32() +{ + test(S("abcdefghij"), 5, 6, S("abcde"), 2, 3, 3); + test(S("abcdefghij"), 5, 6, S("abcde"), 2, 4, 3); + test(S("abcdefghij"), 5, 6, S("abcde"), 4, 0, 5); + test(S("abcdefghij"), 5, 6, S("abcde"), 4, 1, 1); + test(S("abcdefghij"), 5, 6, S("abcde"), 4, 2, 1); + test(S("abcdefghij"), 5, 6, S("abcde"), 5, 0, 5); + test(S("abcdefghij"), 5, 6, S("abcde"), 5, 1, 5); + test(S("abcdefghij"), 5, 6, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 0, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 1, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 5, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 9, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 10, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 11, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 0, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 1, 4); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 4, 4); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 8, 4); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 9, 4); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 10, 4); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 0, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 1, 4); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 2, 3); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 4, 1); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 5, 0); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 6, 0); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 9, 0, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 9, 1, -4); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 9, 2, -4); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 10, 0, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 10, 1, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 0, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 1, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 10, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 19, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 20, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 21, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 0, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 1, 4); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 9, 4); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 18, 4); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 19, 4); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 20, 4); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 0, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 1, -5); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 9, -5); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 10, -5); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 11, -5); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 19, 0, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 19, 1, -14); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 19, 2, -14); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 20, 0, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 20, 1, 5); + test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 9, 0, S(""), 0, 0, 0); + test(S("abcdefghij"), 9, 0, S(""), 0, 1, 0); + test(S("abcdefghij"), 9, 0, S(""), 1, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcde"), 0, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcde"), 0, 1, -1); + test(S("abcdefghij"), 9, 0, S("abcde"), 0, 2, -2); + test(S("abcdefghij"), 9, 0, S("abcde"), 0, 4, -4); + test(S("abcdefghij"), 9, 0, S("abcde"), 0, 5, -5); + test(S("abcdefghij"), 9, 0, S("abcde"), 0, 6, -5); + test(S("abcdefghij"), 9, 0, S("abcde"), 1, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcde"), 1, 1, -1); + test(S("abcdefghij"), 9, 0, S("abcde"), 1, 2, -2); + test(S("abcdefghij"), 9, 0, S("abcde"), 1, 3, -3); + test(S("abcdefghij"), 9, 0, S("abcde"), 1, 4, -4); + test(S("abcdefghij"), 9, 0, S("abcde"), 1, 5, -4); + test(S("abcdefghij"), 9, 0, S("abcde"), 2, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcde"), 2, 1, -1); + test(S("abcdefghij"), 9, 0, S("abcde"), 2, 2, -2); + test(S("abcdefghij"), 9, 0, S("abcde"), 2, 3, -3); + test(S("abcdefghij"), 9, 0, S("abcde"), 2, 4, -3); + test(S("abcdefghij"), 9, 0, S("abcde"), 4, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcde"), 4, 1, -1); + test(S("abcdefghij"), 9, 0, S("abcde"), 4, 2, -1); + test(S("abcdefghij"), 9, 0, S("abcde"), 5, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcde"), 5, 1, 0); + test(S("abcdefghij"), 9, 0, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 1, -1); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 5, -5); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 9, -9); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 10, -10); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 11, -10); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 4, -4); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 8, -8); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 9, -9); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 10, -9); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 1, -1); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 2, -2); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 6, -5); +} + +template <class S> +void test33() +{ + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 9, 1, -1); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 9, 2, -1); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcdefghij"), 9, 0, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 9, 1, S(""), 0, 0, 1); + test(S("abcdefghij"), 9, 1, S(""), 0, 1, 1); + test(S("abcdefghij"), 9, 1, S(""), 1, 0, 0); + test(S("abcdefghij"), 9, 1, S("abcde"), 0, 0, 1); + test(S("abcdefghij"), 9, 1, S("abcde"), 0, 1, 9); + test(S("abcdefghij"), 9, 1, S("abcde"), 0, 2, 9); + test(S("abcdefghij"), 9, 1, S("abcde"), 0, 4, 9); + test(S("abcdefghij"), 9, 1, S("abcde"), 0, 5, 9); + test(S("abcdefghij"), 9, 1, S("abcde"), 0, 6, 9); + test(S("abcdefghij"), 9, 1, S("abcde"), 1, 0, 1); + test(S("abcdefghij"), 9, 1, S("abcde"), 1, 1, 8); + test(S("abcdefghij"), 9, 1, S("abcde"), 1, 2, 8); + test(S("abcdefghij"), 9, 1, S("abcde"), 1, 3, 8); + test(S("abcdefghij"), 9, 1, S("abcde"), 1, 4, 8); + test(S("abcdefghij"), 9, 1, S("abcde"), 1, 5, 8); + test(S("abcdefghij"), 9, 1, S("abcde"), 2, 0, 1); + test(S("abcdefghij"), 9, 1, S("abcde"), 2, 1, 7); + test(S("abcdefghij"), 9, 1, S("abcde"), 2, 2, 7); + test(S("abcdefghij"), 9, 1, S("abcde"), 2, 3, 7); + test(S("abcdefghij"), 9, 1, S("abcde"), 2, 4, 7); + test(S("abcdefghij"), 9, 1, S("abcde"), 4, 0, 1); + test(S("abcdefghij"), 9, 1, S("abcde"), 4, 1, 5); + test(S("abcdefghij"), 9, 1, S("abcde"), 4, 2, 5); + test(S("abcdefghij"), 9, 1, S("abcde"), 5, 0, 1); + test(S("abcdefghij"), 9, 1, S("abcde"), 5, 1, 1); + test(S("abcdefghij"), 9, 1, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 0, 1); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 1, 9); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 5, 9); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 9, 9); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 10, 9); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 11, 9); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 0, 1); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 1, 8); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 4, 8); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 8, 8); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 9, 8); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 10, 8); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 0, 1); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 1, 4); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 2, 4); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 4, 4); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 5, 4); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 6, 4); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 9, 0, 1); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 9, 1, 0); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 9, 2, 0); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 10, 0, 1); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 10, 1, 1); + test(S("abcdefghij"), 9, 1, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 0, 1); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 1, 9); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 10, 9); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 19, 9); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 20, 9); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 21, 9); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 0, 1); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 1, 8); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 9, 8); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 18, 8); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 19, 8); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 20, 8); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 0, 1); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 5, -1); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 9, -1); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 10, -1); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 11, -1); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 19, 0, 1); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 19, 1, -10); +} + +template <class S> +void test34() +{ + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 19, 2, -10); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 20, 0, 1); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 20, 1, 1); + test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 9, 2, S(""), 0, 0, 1); + test(S("abcdefghij"), 9, 2, S(""), 0, 1, 1); + test(S("abcdefghij"), 9, 2, S(""), 1, 0, 0); + test(S("abcdefghij"), 9, 2, S("abcde"), 0, 0, 1); + test(S("abcdefghij"), 9, 2, S("abcde"), 0, 1, 9); + test(S("abcdefghij"), 9, 2, S("abcde"), 0, 2, 9); + test(S("abcdefghij"), 9, 2, S("abcde"), 0, 4, 9); + test(S("abcdefghij"), 9, 2, S("abcde"), 0, 5, 9); + test(S("abcdefghij"), 9, 2, S("abcde"), 0, 6, 9); + test(S("abcdefghij"), 9, 2, S("abcde"), 1, 0, 1); + test(S("abcdefghij"), 9, 2, S("abcde"), 1, 1, 8); + test(S("abcdefghij"), 9, 2, S("abcde"), 1, 2, 8); + test(S("abcdefghij"), 9, 2, S("abcde"), 1, 3, 8); + test(S("abcdefghij"), 9, 2, S("abcde"), 1, 4, 8); + test(S("abcdefghij"), 9, 2, S("abcde"), 1, 5, 8); + test(S("abcdefghij"), 9, 2, S("abcde"), 2, 0, 1); + test(S("abcdefghij"), 9, 2, S("abcde"), 2, 1, 7); + test(S("abcdefghij"), 9, 2, S("abcde"), 2, 2, 7); + test(S("abcdefghij"), 9, 2, S("abcde"), 2, 3, 7); + test(S("abcdefghij"), 9, 2, S("abcde"), 2, 4, 7); + test(S("abcdefghij"), 9, 2, S("abcde"), 4, 0, 1); + test(S("abcdefghij"), 9, 2, S("abcde"), 4, 1, 5); + test(S("abcdefghij"), 9, 2, S("abcde"), 4, 2, 5); + test(S("abcdefghij"), 9, 2, S("abcde"), 5, 0, 1); + test(S("abcdefghij"), 9, 2, S("abcde"), 5, 1, 1); + test(S("abcdefghij"), 9, 2, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 0, 1); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 1, 9); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 5, 9); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 9, 9); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 10, 9); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 11, 9); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 0, 1); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 1, 8); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 4, 8); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 8, 8); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 9, 8); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 10, 8); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 0, 1); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 1, 4); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 2, 4); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 4, 4); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 5, 4); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 6, 4); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 9, 0, 1); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 9, 1, 0); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 9, 2, 0); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 10, 0, 1); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 10, 1, 1); + test(S("abcdefghij"), 9, 2, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 0, 1); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 1, 9); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 10, 9); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 19, 9); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 20, 9); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 21, 9); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 0, 1); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 1, 8); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 9, 8); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 18, 8); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 19, 8); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 20, 8); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 0, 1); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 5, -1); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 9, -1); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 10, -1); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 11, -1); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 19, 0, 1); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 19, 1, -10); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 19, 2, -10); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 20, 0, 1); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 20, 1, 1); + test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 10, 0, S(""), 0, 0, 0); + test(S("abcdefghij"), 10, 0, S(""), 0, 1, 0); + test(S("abcdefghij"), 10, 0, S(""), 1, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcde"), 0, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcde"), 0, 1, -1); + test(S("abcdefghij"), 10, 0, S("abcde"), 0, 2, -2); + test(S("abcdefghij"), 10, 0, S("abcde"), 0, 4, -4); + test(S("abcdefghij"), 10, 0, S("abcde"), 0, 5, -5); + test(S("abcdefghij"), 10, 0, S("abcde"), 0, 6, -5); + test(S("abcdefghij"), 10, 0, S("abcde"), 1, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcde"), 1, 1, -1); + test(S("abcdefghij"), 10, 0, S("abcde"), 1, 2, -2); + test(S("abcdefghij"), 10, 0, S("abcde"), 1, 3, -3); + test(S("abcdefghij"), 10, 0, S("abcde"), 1, 4, -4); + test(S("abcdefghij"), 10, 0, S("abcde"), 1, 5, -4); + test(S("abcdefghij"), 10, 0, S("abcde"), 2, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcde"), 2, 1, -1); + test(S("abcdefghij"), 10, 0, S("abcde"), 2, 2, -2); + test(S("abcdefghij"), 10, 0, S("abcde"), 2, 3, -3); + test(S("abcdefghij"), 10, 0, S("abcde"), 2, 4, -3); + test(S("abcdefghij"), 10, 0, S("abcde"), 4, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcde"), 4, 1, -1); +} + +template <class S> +void test35() +{ + test(S("abcdefghij"), 10, 0, S("abcde"), 4, 2, -1); + test(S("abcdefghij"), 10, 0, S("abcde"), 5, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcde"), 5, 1, 0); + test(S("abcdefghij"), 10, 0, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 1, -1); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 5, -5); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 9, -9); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 10, -10); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 11, -10); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 4, -4); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 8, -8); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 9, -9); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 10, -9); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 1, -1); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 2, -2); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 9, 1, -1); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 9, 2, -1); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcdefghij"), 10, 0, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 10, 1, S(""), 0, 0, 0); + test(S("abcdefghij"), 10, 1, S(""), 0, 1, 0); + test(S("abcdefghij"), 10, 1, S(""), 1, 0, 0); + test(S("abcdefghij"), 10, 1, S("abcde"), 0, 0, 0); + test(S("abcdefghij"), 10, 1, S("abcde"), 0, 1, -1); + test(S("abcdefghij"), 10, 1, S("abcde"), 0, 2, -2); + test(S("abcdefghij"), 10, 1, S("abcde"), 0, 4, -4); + test(S("abcdefghij"), 10, 1, S("abcde"), 0, 5, -5); + test(S("abcdefghij"), 10, 1, S("abcde"), 0, 6, -5); + test(S("abcdefghij"), 10, 1, S("abcde"), 1, 0, 0); + test(S("abcdefghij"), 10, 1, S("abcde"), 1, 1, -1); + test(S("abcdefghij"), 10, 1, S("abcde"), 1, 2, -2); + test(S("abcdefghij"), 10, 1, S("abcde"), 1, 3, -3); + test(S("abcdefghij"), 10, 1, S("abcde"), 1, 4, -4); + test(S("abcdefghij"), 10, 1, S("abcde"), 1, 5, -4); + test(S("abcdefghij"), 10, 1, S("abcde"), 2, 0, 0); + test(S("abcdefghij"), 10, 1, S("abcde"), 2, 1, -1); + test(S("abcdefghij"), 10, 1, S("abcde"), 2, 2, -2); + test(S("abcdefghij"), 10, 1, S("abcde"), 2, 3, -3); + test(S("abcdefghij"), 10, 1, S("abcde"), 2, 4, -3); + test(S("abcdefghij"), 10, 1, S("abcde"), 4, 0, 0); + test(S("abcdefghij"), 10, 1, S("abcde"), 4, 1, -1); + test(S("abcdefghij"), 10, 1, S("abcde"), 4, 2, -1); + test(S("abcdefghij"), 10, 1, S("abcde"), 5, 0, 0); + test(S("abcdefghij"), 10, 1, S("abcde"), 5, 1, 0); + test(S("abcdefghij"), 10, 1, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 0, 0); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 1, -1); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 5, -5); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 9, -9); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 10, -10); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 11, -10); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 0, 0); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 4, -4); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 8, -8); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 9, -9); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 10, -9); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 0, 0); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 1, -1); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 2, -2); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 9, 0, 0); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 9, 1, -1); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 9, 2, -1); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 10, 0, 0); +} + +template <class S> +void test36() +{ + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 10, 1, 0); + test(S("abcdefghij"), 10, 1, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghij"), 11, 0, S(""), 0, 0, 0); + test(S("abcdefghij"), 11, 0, S(""), 0, 1, 0); + test(S("abcdefghij"), 11, 0, S(""), 1, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 0, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 0, 1, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 0, 2, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 0, 4, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 0, 5, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 0, 6, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 1, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 1, 1, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 1, 2, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 1, 3, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 1, 4, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 1, 5, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 2, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 2, 1, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 2, 2, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 2, 3, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 2, 4, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 4, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 4, 1, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 4, 2, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 5, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 5, 1, 0); + test(S("abcdefghij"), 11, 0, S("abcde"), 6, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 1, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 5, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 9, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 10, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 11, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 1, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 4, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 8, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 9, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 10, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 1, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 2, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 4, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 5, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 6, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 9, 1, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 9, 2, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 1, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 10, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 19, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 20, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 21, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 1, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 9, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 18, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 19, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 20, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 1, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 5, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 9, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 10, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 11, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 19, 1, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 19, 2, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); +} + +template <class S> +void test37() +{ + test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 1, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 2, -2); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 4, -4); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 5, -5); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 6, -5); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 2, -2); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 3, -3); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 4, -4); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 5, -4); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 2, -2); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 3, -3); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 4, -3); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 4, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 4, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 4, 2, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 5, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 5, 1, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 5, -5); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 9, -9); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 10, -10); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 11, -10); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 4, -4); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 8, -8); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 9, -9); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 10, -9); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 2, -2); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 9, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 9, 2, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 1, 0); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 2, -1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 4, -3); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 5, -4); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 6, -4); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 2, -1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 3, -1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 4, -1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 5, -1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 1, -2); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 2, -2); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 3, -2); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 4, -2); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 4, 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 4, 1, -4); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 4, 2, -4); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 5, 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 5, 1, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 6, 0, 0); +} + +template <class S> +void test38() +{ + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 1, 0); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 5, -4); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 9, -8); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 10, -9); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 11, -9); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 4, -1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 8, -1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 9, -1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 10, -1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 1, -5); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 2, -5); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 4, -5); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 9, 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 9, 1, -9); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 9, 2, -9); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 10, 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 10, 1, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 1, 0); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 10, -9); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 19, -18); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 20, -19); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 21, -19); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 9, -1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 18, -1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 19, -1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 20, -1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 1, -10); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 5, -10); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 9, -10); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 19, 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 19, 1, -19); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 19, 2, -19); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 20, 0, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 20, 1, 1); + test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 1, 9); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 2, 8); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 4, 6); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 5, 5); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 6, 5); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 2, -1); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 3, -1); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 4, -1); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 5, -1); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 1, -2); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 2, -2); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 3, -2); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 4, -2); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 4, 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 4, 1, -4); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 4, 2, -4); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 5, 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 5, 1, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 1, 9); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 5, 5); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 9, 1); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 10, 0); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 11, 0); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 4, -1); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 8, -1); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 9, -1); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 10, -1); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 1, -5); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 2, -5); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 4, -5); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 9, 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 9, 1, -9); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 9, 2, -9); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 10, 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 10, 1, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 1, 9); +} + +template <class S> +void test39() +{ + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 10, 0); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 19, -9); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 20, -10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 21, -10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 9, -1); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 18, -1); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 19, -1); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 20, -1); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 1, -10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 5, -10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 9, -10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 19, 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 19, 1, -19); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 19, 2, -19); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 20, 0, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 20, 1, 10); + test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 1, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 1, 18); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 2, 17); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 4, 15); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 5, 14); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 6, 14); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 2, -1); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 3, -1); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 4, -1); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 5, -1); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 1, -2); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 2, -2); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 3, -2); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 4, -2); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 4, 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 4, 1, -4); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 4, 2, -4); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 5, 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 5, 1, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 1, 18); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 5, 14); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 9, 10); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 10, 9); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 11, 9); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 4, -1); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 8, -1); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 9, -1); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 10, -1); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 1, -5); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 2, -5); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 4, -5); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 9, 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 9, 1, -9); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 9, 2, -9); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 10, 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 10, 1, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 1, 18); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 10, 9); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 19, 0); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 20, -1); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 21, -1); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 9, -1); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 18, -1); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 19, -1); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 20, -1); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 1, -10); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 5, -10); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 9, -10); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 19, 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 19, 1, -19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 19, 2, -19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 20, 0, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 20, 1, 19); + test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 1, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 0, 20); +} + +template <class S> +void test40() +{ + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 1, 19); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 2, 18); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 4, 16); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 5, 15); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 6, 15); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 2, -1); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 3, -1); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 4, -1); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 5, -1); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 1, -2); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 2, -2); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 3, -2); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 4, -2); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 4, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 4, 1, -4); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 4, 2, -4); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 5, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 5, 1, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 1, 19); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 5, 15); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 9, 11); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 10, 10); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 11, 10); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 4, -1); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 8, -1); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 9, -1); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 10, -1); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 1, -5); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 2, -5); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 4, -5); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 9, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 9, 1, -9); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 9, 2, -9); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 10, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 10, 1, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 1, 19); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 10, 10); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 19, 1); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 20, 0); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 21, 0); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 9, -1); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 18, -1); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 19, -1); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 20, -1); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 1, -10); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 5, -10); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 9, -10); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 19, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 19, 1, -19); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 19, 2, -19); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 20, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 20, 1, 20); + test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 1, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 1, 19); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 2, 18); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 4, 16); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 5, 15); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 6, 15); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 2, -1); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 3, -1); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 4, -1); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 5, -1); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 1, -2); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 2, -2); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 3, -2); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 4, -2); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 4, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 4, 1, -4); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 4, 2, -4); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 5, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 5, 1, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 1, 19); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 5, 15); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 9, 11); +} + +template <class S> +void test41() +{ + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 10, 10); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 11, 10); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 4, -1); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 8, -1); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 9, -1); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 10, -1); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 1, -5); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 2, -5); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 4, -5); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 9, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 9, 1, -9); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 9, 2, -9); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 10, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 10, 1, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 1, 19); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 10, 10); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 19, 1); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 20, 0); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 21, 0); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 9, -1); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 18, -1); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 19, -1); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 20, -1); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 1, -10); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 5, -10); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 9, -10); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 19, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 19, 1, -19); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 19, 2, -19); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 20, 0, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 20, 1, 20); + test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 1, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 2, -2); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 4, -4); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 5, -5); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 6, -5); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 2, -2); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 3, -3); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 4, -4); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 5, -4); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 2, -2); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 3, -3); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 4, -3); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 4, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 4, 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 4, 2, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 5, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 5, 1, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 5, -5); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 9, -9); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 10, -10); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 11, -10); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 4, -4); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 8, -8); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 9, -9); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 10, -9); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 2, -2); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 9, 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 9, 2, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 21, -20); +} + +template <class S> +void test42() +{ + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 2, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 4, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 6, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 1, 0); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 2, -1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 3, -2); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 4, -3); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 5, -3); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 2, -1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 3, -1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 4, -1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 4, 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 4, 1, -3); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 4, 2, -3); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 5, 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 5, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 9, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 11, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 1, 0); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 4, -3); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 8, -7); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 9, -8); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 10, -8); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 1, -4); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 2, -4); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 5, -4); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 6, -4); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 9, 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 9, 1, -8); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 9, 2, -8); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 10, 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 10, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 19, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 20, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 21, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 1, 0); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 9, -8); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 18, -17); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 19, -18); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 20, -18); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 1, -9); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 5, -9); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 10, -9); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 11, -9); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 19, 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 19, 1, -18); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 19, 2, -18); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 20, 0, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 20, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 1, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 2, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 4, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 5, 1); +} + +template <class S> +void test43() +{ + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 6, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 1, 8); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 2, 7); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 3, 6); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 4, 5); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 5, 5); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 2, -1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 3, -1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 4, -1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 4, 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 4, 1, -3); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 4, 2, -3); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 5, 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 5, 1, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 9, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 11, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 1, 8); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 4, 5); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 8, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 9, 0); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 10, 0); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 1, -4); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 2, -4); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 5, -4); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 6, -4); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 9, 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 9, 1, -8); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 9, 2, -8); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 10, 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 10, 1, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 19, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 20, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 21, 1); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 1, 8); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 9, 0); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 18, -9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 19, -10); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 20, -10); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 1, -9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 5, -9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 10, -9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 11, -9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 19, 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 19, 1, -18); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 19, 2, -18); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 20, 0, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 20, 1, 9); + test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 1, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 2, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 4, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 6, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 1, 17); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 2, 16); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 3, 15); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 4, 14); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 5, 14); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 2, -1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 3, -1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 4, -1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 4, 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 4, 1, -3); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 4, 2, -3); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 5, 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 5, 1, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 9, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 11, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 1, 17); +} + +template <class S> +void test44() +{ + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 4, 14); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 8, 10); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 9, 9); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 10, 9); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 1, -4); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 2, -4); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 5, -4); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 6, -4); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 9, 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 9, 1, -8); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 9, 2, -8); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 10, 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 10, 1, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 19, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 20, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 21, 1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 1, 17); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 9, 9); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 18, 0); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 19, -1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 20, -1); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 1, -9); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 5, -9); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 10, -9); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 11, -9); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 19, 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 19, 1, -18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 19, 2, -18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 20, 0, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 20, 1, 18); + test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 1, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 2, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 4, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 6, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 1, 18); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 2, 17); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 3, 16); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 4, 15); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 5, 15); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 2, -1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 3, -1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 4, -1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 4, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 4, 1, -3); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 4, 2, -3); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 5, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 5, 1, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 9, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 11, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 1, 18); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 4, 15); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 8, 11); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 9, 10); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 10, 10); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 1, -4); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 2, -4); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 5, -4); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 6, -4); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 9, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 9, 1, -8); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 9, 2, -8); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 10, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 10, 1, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 19, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 20, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 21, 1); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 1, 18); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 9, 10); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 18, 1); +} + +template <class S> +void test45() +{ + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 19, 0); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 20, 0); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 1, -9); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 5, -9); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 10, -9); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 11, -9); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 19, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 19, 1, -18); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 19, 2, -18); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 20, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 20, 1, 19); + test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 1, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 2, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 4, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 6, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 1, 18); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 2, 17); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 3, 16); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 4, 15); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 5, 15); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 1, -1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 2, -1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 3, -1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 4, -1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 4, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 4, 1, -3); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 4, 2, -3); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 5, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 5, 1, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 5, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 9, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 11, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 1, 18); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 4, 15); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 8, 11); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 9, 10); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 10, 10); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 1, -4); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 2, -4); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 5, -4); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 6, -4); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 9, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 9, 1, -8); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 9, 2, -8); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 10, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 10, 1, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 10, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 19, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 20, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 21, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 1, 18); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 9, 10); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 18, 1); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 19, 0); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 20, 0); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 1, -9); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 5, -9); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 10, -9); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 11, -9); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 19, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 19, 1, -18); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 19, 2, -18); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 20, 0, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 20, 1, 19); + test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 1, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 2, -2); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 4, -4); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 5, -5); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 6, -5); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 2, -2); +} + +template <class S> +void test46() +{ + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 3, -3); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 4, -4); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 5, -4); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 1, -1); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 2, -2); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 3, -3); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 4, -3); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 4, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 4, 1, -1); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 4, 2, -1); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 5, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 5, 1, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 5, -5); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 9, -9); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 10, -10); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 11, -10); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 4, -4); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 8, -8); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 9, -9); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 10, -9); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 1, -1); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 2, -2); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 9, 1, -1); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 9, 2, -1); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 2, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 4, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 6, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 2, 9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 3, 9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 4, 9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 5, 9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 1, 8); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 2, 8); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 3, 8); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 4, 8); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 4, 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 4, 1, 6); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 4, 2, 6); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 5, 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 5, 1, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 9, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 11, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 4, 9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 8, 9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 9, 9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 10, 9); +} + +template <class S> +void test47() +{ + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 1, 5); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 2, 5); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 4, 5); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 5, 5); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 6, 5); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 9, 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 9, 1, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 9, 2, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 10, 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 10, 1, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 19, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 20, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 21, 10); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 9, 9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 18, 9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 19, 9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 20, 9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 1, 0); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 5, -4); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 9, -8); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 10, -9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 11, -9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 19, 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 19, 1, -9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 19, 2, -9); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 20, 0, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 20, 1, 1); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 1, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 2, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 4, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 6, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 2, 9); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 3, 9); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 4, 9); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 5, 9); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 1, 8); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 2, 8); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 3, 8); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 4, 8); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 4, 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 4, 1, 6); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 4, 2, 6); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 5, 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 5, 1, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 9, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 11, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 4, 9); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 8, 9); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 9, 9); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 10, 9); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 1, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 2, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 4, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 5, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 6, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 9, 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 9, 1, 1); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 9, 2, 1); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 10, 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 10, 1, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 19, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 20, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 21, 10); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 9, 9); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 18, 9); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 19, 9); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 20, 9); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 1, 4); +} + +template <class S> +void test48() +{ + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 5, 0); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 9, -4); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 10, -5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 11, -5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 19, 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 19, 1, -9); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 19, 2, -9); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 20, 0, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 20, 1, 5); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 2, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 4, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 6, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 2, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 3, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 4, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 5, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 1, 8); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 2, 8); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 3, 8); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 4, 8); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 4, 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 4, 1, 6); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 4, 2, 6); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 5, 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 5, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 9, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 11, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 4, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 8, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 9, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 10, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 1, 5); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 2, 5); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 4, 5); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 5, 5); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 6, 5); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 9, 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 9, 1, 1); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 9, 2, 1); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 10, 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 10, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 19, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 20, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 21, 10); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 9, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 18, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 19, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 20, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 1, 8); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 5, 4); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 9, 0); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 10, -1); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 11, -1); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 19, 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 19, 1, -9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 19, 2, -9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 20, 0, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 20, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 2, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 4, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 6, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 2, 9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 3, 9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 4, 9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 5, 9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 0, 10); +} + +template <class S> +void test49() +{ + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 1, 8); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 2, 8); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 3, 8); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 4, 8); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 4, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 4, 1, 6); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 4, 2, 6); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 5, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 5, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 9, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 11, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 4, 9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 8, 9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 9, 9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 10, 9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 1, 5); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 2, 5); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 4, 5); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 5, 5); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 6, 5); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 9, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 9, 1, 1); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 9, 2, 1); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 10, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 10, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 19, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 20, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 21, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 9, 9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 18, 9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 19, 9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 20, 9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 5, 5); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 9, 1); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 10, 0); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 11, 0); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 19, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 19, 1, -9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 19, 2, -9); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 20, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 20, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 2, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 4, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 6, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 2, 9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 3, 9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 4, 9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 5, 9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 1, 8); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 2, 8); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 3, 8); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 4, 8); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 4, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 4, 1, 6); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 4, 2, 6); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 5, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 5, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 5, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 9, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 11, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 4, 9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 8, 9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 9, 9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 10, 9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 1, 5); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 2, 5); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 4, 5); +} + +template <class S> +void test50() +{ + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 5, 5); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 6, 5); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 9, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 9, 1, 1); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 9, 2, 1); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 10, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 10, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 10, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 19, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 20, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 21, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 9, 9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 18, 9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 19, 9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 20, 9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 1, 9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 5, 5); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 9, 1); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 10, 0); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 11, 0); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 19, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 19, 1, -9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 19, 2, -9); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 20, 0, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 20, 1, 10); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 1, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 2, -2); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 4, -4); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 5, -5); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 6, -5); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 2, -2); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 3, -3); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 4, -4); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 5, -4); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 1, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 2, -2); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 3, -3); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 4, -3); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 4, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 4, 1, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 4, 2, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 5, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 5, 1, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 5, -5); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 9, -9); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 10, -10); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 11, -10); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 4, -4); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 8, -8); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 9, -9); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 10, -9); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 1, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 2, -2); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 9, 1, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 9, 2, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 11, -10); +} + +template <class S> +void test51() +{ + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 1, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 2, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 4, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 5, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 6, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 1, 18); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 2, 18); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 3, 18); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 4, 18); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 5, 18); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 1, 17); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 2, 17); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 3, 17); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 4, 17); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 4, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 4, 1, 15); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 4, 2, 15); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 5, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 5, 1, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 1, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 5, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 9, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 10, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 11, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 1, 18); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 4, 18); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 8, 18); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 9, 18); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 10, 18); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 1, 14); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 2, 14); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 4, 14); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 5, 14); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 6, 14); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 9, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 9, 1, 10); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 9, 2, 10); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 10, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 10, 1, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 1, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 10, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 19, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 20, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 21, 19); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 1, 18); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 9, 18); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 18, 18); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 19, 18); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 20, 18); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 1, 9); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 5, 9); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 9, 9); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 10, 9); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 11, 9); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 19, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 19, 1, 0); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 19, 2, 0); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 20, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 20, 1, 1); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 1, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 1, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 2, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 4, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 5, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 6, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 1, 18); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 2, 18); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 3, 18); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 4, 18); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 5, 18); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 1, 17); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 2, 17); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 3, 17); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 4, 17); +} + +template <class S> +void test52() +{ + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 4, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 4, 1, 15); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 4, 2, 15); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 5, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 5, 1, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 1, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 5, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 9, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 10, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 11, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 1, 18); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 4, 18); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 8, 18); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 9, 18); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 10, 18); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 1, 14); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 2, 14); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 4, 14); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 5, 14); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 6, 14); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 9, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 9, 1, 10); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 9, 2, 10); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 10, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 10, 1, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 1, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 10, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 19, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 20, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 21, 19); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 1, 18); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 9, 18); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 18, 18); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 19, 18); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 20, 18); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 1, 9); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 5, 9); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 9, 9); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 10, 9); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 11, 9); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 19, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 19, 1, 0); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 19, 2, 0); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 20, 0, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 20, 1, 1); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 1, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 2, -2); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 4, -4); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 5, -5); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 6, -5); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 2, -2); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 3, -3); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 4, -4); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 5, -4); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 2, -2); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 3, -3); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 4, -3); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 4, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 4, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 4, 2, -1); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 5, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 5, 1, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 5, -5); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 9, -9); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 10, -10); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 11, -10); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 4, -4); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 8, -8); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 9, -9); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 10, -9); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 2, -2); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 9, 1, -1); +} + +template <class S> +void test53() +{ + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 9, 2, -1); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 1, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 2, -2); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 4, -4); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 5, -5); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 6, -5); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 2, -2); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 3, -3); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 4, -4); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 5, -4); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 2, -2); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 3, -3); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 4, -3); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 4, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 4, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 4, 2, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 5, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 5, 1, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 5, -5); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 9, -9); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 10, -10); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 11, -10); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 4, -4); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 8, -8); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 9, -9); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 10, -9); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 2, -2); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 4, -4); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 5, -5); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 6, -5); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 9, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 9, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 9, 2, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 10, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 10, 1, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 10, -10); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 19, -19); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 20, -20); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 21, -20); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 9, -9); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 18, -18); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 19, -19); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 20, -19); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 5, -5); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 9, -9); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 10, -10); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 11, -10); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 19, 1, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 19, 2, -1); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 20, 0, 0); +} + +template <class S> +void test54() +{ + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 21, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 2, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 4, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 5, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 6, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 2, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 3, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 4, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 5, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 2, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 3, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 4, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 4, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 4, 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 4, 2, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 5, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 5, 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 6, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 5, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 9, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 10, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 11, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 4, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 8, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 9, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 10, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 2, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 4, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 5, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 6, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 9, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 9, 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 9, 2, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 10, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 10, 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 11, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 10, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 19, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 20, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 21, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 9, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 18, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 19, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 20, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 5, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 9, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 10, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 11, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 19, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 19, 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 19, 2, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 20, 0, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 20, 1, 0); + test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 21, 0, 0); +} + +template<class S> +void test55() +{ + test_npos(S(""), 0, 0, S(""), 0, 0); + test_npos(S(""), 0, 0, S("abcde"), 0, -5); + test_npos(S("abcde"), 0, 0, S("abcdefghij"), 0, -10); + test_npos(S("abcde"), 0, 0, S("abcdefghij"), 1, -9); + test_npos(S("abcde"), 0, 0, S("abcdefghij"), 5, -5); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + test4<S>(); + test5<S>(); + test6<S>(); + test7<S>(); + test8<S>(); + test9<S>(); + test10<S>(); + test11<S>(); + test12<S>(); + test13<S>(); + test14<S>(); + test15<S>(); + test16<S>(); + test17<S>(); + test18<S>(); + test19<S>(); + test20<S>(); + test21<S>(); + test22<S>(); + test23<S>(); + test24<S>(); + test25<S>(); + test26<S>(); + test27<S>(); + test28<S>(); + test29<S>(); + test30<S>(); + test31<S>(); + test32<S>(); + test33<S>(); + test34<S>(); + test35<S>(); + test36<S>(); + test37<S>(); + test38<S>(); + test39<S>(); + test40<S>(); + test41<S>(); + test42<S>(); + test43<S>(); + test44<S>(); + test45<S>(); + test46<S>(); + test47<S>(); + test48<S>(); + test49<S>(); + test50<S>(); + test51<S>(); + test52<S>(); + test53<S>(); + test54<S>(); + test55<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + test4<S>(); + test5<S>(); + test6<S>(); + test7<S>(); + test8<S>(); + test9<S>(); + test10<S>(); + test11<S>(); + test12<S>(); + test13<S>(); + test14<S>(); + test15<S>(); + test16<S>(); + test17<S>(); + test18<S>(); + test19<S>(); + test20<S>(); + test21<S>(); + test22<S>(); + test23<S>(); + test24<S>(); + test25<S>(); + test26<S>(); + test27<S>(); + test28<S>(); + test29<S>(); + test30<S>(); + test31<S>(); + test32<S>(); + test33<S>(); + test34<S>(); + test35<S>(); + test36<S>(); + test37<S>(); + test38<S>(); + test39<S>(); + test40<S>(); + test41<S>(); + test42<S>(); + test43<S>(); + test44<S>(); + test45<S>(); + test46<S>(); + test47<S>(); + test48<S>(); + test49<S>(); + test50<S>(); + test51<S>(); + test52<S>(); + test53<S>(); + test54<S>(); + test55<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_compare/string.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/string.pass.cpp new file mode 100644 index 000000000000..7de95a8cda56 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_compare/string.pass.cpp @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// int compare(const basic_string& str) const + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +int sign(int x) +{ + if (x == 0) + return 0; + if (x < 0) + return -1; + return 1; +} + +template <class S> +void +test(const S& s, const S& str, int x) +{ + assert(sign(s.compare(str)) == sign(x)); +} + +int main() +{ + { + typedef std::string S; + test(S(""), S(""), 0); + test(S(""), S("abcde"), -5); + test(S(""), S("abcdefghij"), -10); + test(S(""), S("abcdefghijklmnopqrst"), -20); + test(S("abcde"), S(""), 5); + test(S("abcde"), S("abcde"), 0); + test(S("abcde"), S("abcdefghij"), -5); + test(S("abcde"), S("abcdefghijklmnopqrst"), -15); + test(S("abcdefghij"), S(""), 10); + test(S("abcdefghij"), S("abcde"), 5); + test(S("abcdefghij"), S("abcdefghij"), 0); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), -10); + test(S("abcdefghijklmnopqrst"), S(""), 20); + test(S("abcdefghijklmnopqrst"), S("abcde"), 15); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), 0); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), S(""), 0); + test(S(""), S("abcde"), -5); + test(S(""), S("abcdefghij"), -10); + test(S(""), S("abcdefghijklmnopqrst"), -20); + test(S("abcde"), S(""), 5); + test(S("abcde"), S("abcde"), 0); + test(S("abcde"), S("abcdefghij"), -5); + test(S("abcde"), S("abcdefghijklmnopqrst"), -15); + test(S("abcdefghij"), S(""), 10); + test(S("abcdefghij"), S("abcde"), 5); + test(S("abcdefghij"), S("abcdefghij"), 0); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), -10); + test(S("abcdefghijklmnopqrst"), S(""), 20); + test(S("abcdefghijklmnopqrst"), S("abcde"), 15); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), 0); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp new file mode 100644 index 000000000000..590173eddf41 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp @@ -0,0 +1,102 @@ +//===----------------------------------------------------------------------===// +// +// 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 find_first_not_of(charT c, size_type pos = 0) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, typename S::value_type c, typename S::size_type pos, + typename S::size_type x) +{ + assert(s.find_first_not_of(c, pos) == x); + if (x != S::npos) + assert(pos <= x && x < s.size()); +} + +template <class S> +void +test(const S& s, typename S::value_type c, typename S::size_type x) +{ + assert(s.find_first_not_of(c) == x); + if (x != S::npos) + assert(x < s.size()); +} + +int main() +{ + { + typedef std::string S; + test(S(""), 'q', 0, S::npos); + test(S(""), 'q', 1, S::npos); + test(S("kitcj"), 'q', 0, 0); + test(S("qkamf"), 'q', 1, 1); + test(S("nhmko"), 'q', 2, 2); + test(S("tpsaf"), 'q', 4, 4); + test(S("lahfb"), 'q', 5, S::npos); + test(S("irkhs"), 'q', 6, S::npos); + test(S("gmfhdaipsr"), 'q', 0, 0); + test(S("kantesmpgj"), 'q', 1, 1); + test(S("odaftiegpm"), 'q', 5, 5); + test(S("oknlrstdpi"), 'q', 9, 9); + test(S("eolhfgpjqk"), 'q', 10, S::npos); + test(S("pcdrofikas"), 'q', 11, S::npos); + test(S("nbatdlmekrgcfqsophij"), 'q', 0, 0); + test(S("bnrpehidofmqtcksjgla"), 'q', 1, 1); + test(S("jdmciepkaqgotsrfnhlb"), 'q', 10, 10); + test(S("jtdaefblsokrmhpgcnqi"), 'q', 19, 19); + test(S("hkbgspofltajcnedqmri"), 'q', 20, S::npos); + test(S("oselktgbcapndfjihrmq"), 'q', 21, S::npos); + + test(S(""), 'q', S::npos); + test(S("q"), 'q', S::npos); + test(S("qqq"), 'q', S::npos); + test(S("csope"), 'q', 0); + test(S("gfsmthlkon"), 'q', 0); + test(S("laenfsbridchgotmkqpj"), 'q', 0); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), 'q', 0, S::npos); + test(S(""), 'q', 1, S::npos); + test(S("kitcj"), 'q', 0, 0); + test(S("qkamf"), 'q', 1, 1); + test(S("nhmko"), 'q', 2, 2); + test(S("tpsaf"), 'q', 4, 4); + test(S("lahfb"), 'q', 5, S::npos); + test(S("irkhs"), 'q', 6, S::npos); + test(S("gmfhdaipsr"), 'q', 0, 0); + test(S("kantesmpgj"), 'q', 1, 1); + test(S("odaftiegpm"), 'q', 5, 5); + test(S("oknlrstdpi"), 'q', 9, 9); + test(S("eolhfgpjqk"), 'q', 10, S::npos); + test(S("pcdrofikas"), 'q', 11, S::npos); + test(S("nbatdlmekrgcfqsophij"), 'q', 0, 0); + test(S("bnrpehidofmqtcksjgla"), 'q', 1, 1); + test(S("jdmciepkaqgotsrfnhlb"), 'q', 10, 10); + test(S("jtdaefblsokrmhpgcnqi"), 'q', 19, 19); + test(S("hkbgspofltajcnedqmri"), 'q', 20, S::npos); + test(S("oselktgbcapndfjihrmq"), 'q', 21, S::npos); + + test(S(""), 'q', S::npos); + test(S("q"), 'q', S::npos); + test(S("qqq"), 'q', S::npos); + test(S("csope"), 'q', 0); + test(S("gfsmthlkon"), 'q', 0); + test(S("laenfsbridchgotmkqpj"), 'q', 0); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size.pass.cpp new file mode 100644 index 000000000000..53d3a95292c2 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size.pass.cpp @@ -0,0 +1,158 @@ +//===----------------------------------------------------------------------===// +// +// 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 find_first_not_of(const charT* s, size_type pos = 0) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type pos, + typename S::size_type x) +{ + assert(s.find_first_not_of(str, pos) == x); + if (x != S::npos) + assert(pos <= x && x < s.size()); +} + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type x) +{ + assert(s.find_first_not_of(str) == x); + if (x != S::npos) + assert(x < s.size()); +} + +template <class S> +void test0() +{ + test(S(""), "", 0, S::npos); + test(S(""), "laenf", 0, S::npos); + test(S(""), "pqlnkmbdjo", 0, S::npos); + test(S(""), "qkamfogpnljdcshbreti", 0, S::npos); + test(S(""), "", 1, S::npos); + test(S(""), "bjaht", 1, S::npos); + test(S(""), "hjlcmgpket", 1, S::npos); + test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos); + test(S("fodgq"), "", 0, 0); + test(S("qanej"), "dfkap", 0, 0); + test(S("clbao"), "ihqrfebgad", 0, 0); + test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, S::npos); + test(S("srdfq"), "", 1, 1); + test(S("oemth"), "ikcrq", 1, 1); + test(S("cdaih"), "dmajblfhsg", 1, 3); + test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, S::npos); + test(S("cshmd"), "", 2, 2); + test(S("lhcdo"), "oebqi", 2, 2); + test(S("qnsoh"), "kojhpmbsfe", 2, S::npos); + test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, S::npos); + test(S("fmtsp"), "", 4, 4); + test(S("khbpm"), "aobjd", 4, 4); + test(S("pbsji"), "pcbahntsje", 4, 4); + test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, S::npos); + test(S("eqmpa"), "", 5, S::npos); + test(S("omigs"), "kocgb", 5, S::npos); + test(S("onmje"), "fbslrjiqkm", 5, S::npos); + test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos); + test(S("schfa"), "", 6, S::npos); + test(S("igdsc"), "qngpd", 6, S::npos); + test(S("brqgo"), "rodhqklgmb", 6, S::npos); + test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos); + test(S("hcjitbfapl"), "", 0, 0); + test(S("daiprenocl"), "ashjd", 0, 2); + test(S("litpcfdghe"), "mgojkldsqh", 0, 1); + test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, S::npos); + test(S("qpghtfbaji"), "", 1, 1); + test(S("gfshlcmdjr"), "nadkh", 1, 1); + test(S("nkodajteqp"), "ofdrqmkebl", 1, 4); + test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, S::npos); + test(S("crnklpmegd"), "", 5, 5); + test(S("jsbtafedoc"), "prqgn", 5, 5); + test(S("qnmodrtkeb"), "pejafmnokr", 5, 6); + test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, S::npos); + test(S("lmofqdhpki"), "", 9, 9); + test(S("hnefkqimca"), "rtjpa", 9, S::npos); + test(S("drtasbgmfp"), "ktsrmnqagd", 9, 9); + test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, S::npos); + test(S("elgofjmbrq"), "", 10, S::npos); + test(S("mjqdgalkpc"), "dplqa", 10, S::npos); + test(S("kthqnfcerm"), "dkacjoptns", 10, S::npos); + test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos); + test(S("eqsgalomhb"), "", 11, S::npos); + test(S("akiteljmoh"), "lofbc", 11, S::npos); + test(S("hlbdfreqjo"), "astoegbfpn", 11, S::npos); + test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos); + test(S("snafbdlghrjkpqtoceim"), "", 0, 0); + test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 0); + test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 1); + test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, S::npos); + test(S("jlnkraeodhcspfgbqitm"), "", 1, 1); + test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 1); + test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 3); + test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, S::npos); + test(S("hdpkobnsalmcfijregtq"), "", 10, 10); + test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 11); + test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 13); + test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, S::npos); + test(S("niptglfbosehkamrdqcj"), "", 19, 19); + test(S("copqdhstbingamjfkler"), "djkqc", 19, 19); + test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, S::npos); + test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, S::npos); + test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos); + test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, S::npos); + test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, S::npos); + test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos); + test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos); + test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, S::npos); + test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, S::npos); + test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos); +} + +template <class S> +void test1() +{ + test(S(""), "", S::npos); + test(S(""), "laenf", S::npos); + test(S(""), "pqlnkmbdjo", S::npos); + test(S(""), "qkamfogpnljdcshbreti", S::npos); + test(S("nhmko"), "", 0); + test(S("lahfb"), "irkhs", 0); + test(S("gmfhd"), "kantesmpgj", 2); + test(S("odaft"), "oknlrstdpiqmjbaghcfe", S::npos); + test(S("eolhfgpjqk"), "", 0); + test(S("nbatdlmekr"), "bnrpe", 2); + test(S("jdmciepkaq"), "jtdaefblso", 2); + test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", S::npos); + test(S("gprdcokbnjhlsfmtieqa"), "", 0); + test(S("qjghlnftcaismkropdeb"), "bjaht", 0); + test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 1); + test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", S::npos); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size_size.pass.cpp new file mode 100644 index 000000000000..14ac4b2a153b --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size_size.pass.cpp @@ -0,0 +1,387 @@ +//===----------------------------------------------------------------------===// +// +// 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 find_first_not_of(const charT* s, size_type pos, size_type n) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type pos, + typename S::size_type n, typename S::size_type x) +{ + assert(s.find_first_not_of(str, pos, n) == x); + if (x != S::npos) + assert(pos <= x && x < s.size()); +} + +template <class S> +void test0() +{ + test(S(""), "", 0, 0, S::npos); + test(S(""), "irkhs", 0, 0, S::npos); + test(S(""), "kante", 0, 1, S::npos); + test(S(""), "oknlr", 0, 2, S::npos); + test(S(""), "pcdro", 0, 4, S::npos); + test(S(""), "bnrpe", 0, 5, S::npos); + test(S(""), "jtdaefblso", 0, 0, S::npos); + test(S(""), "oselktgbca", 0, 1, S::npos); + test(S(""), "eqgaplhckj", 0, 5, S::npos); + test(S(""), "bjahtcmnlp", 0, 9, S::npos); + test(S(""), "hjlcmgpket", 0, 10, S::npos); + test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos); + test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos); + test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos); + test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos); + test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos); + test(S(""), "", 1, 0, S::npos); + test(S(""), "lbtqd", 1, 0, S::npos); + test(S(""), "tboim", 1, 1, S::npos); + test(S(""), "slcer", 1, 2, S::npos); + test(S(""), "cbjfs", 1, 4, S::npos); + test(S(""), "aqibs", 1, 5, S::npos); + test(S(""), "gtfblmqinc", 1, 0, S::npos); + test(S(""), "mkqpbtdalg", 1, 1, S::npos); + test(S(""), "kphatlimcd", 1, 5, S::npos); + test(S(""), "pblasqogic", 1, 9, S::npos); + test(S(""), "arosdhcfme", 1, 10, S::npos); + test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos); + test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos); + test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos); + test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos); + test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos); + test(S("eaint"), "", 0, 0, 0); + test(S("binja"), "gfsrt", 0, 0, 0); + test(S("latkm"), "pfsoc", 0, 1, 0); + test(S("lecfr"), "tpflm", 0, 2, 0); + test(S("eqkst"), "sgkec", 0, 4, 1); + test(S("cdafr"), "romds", 0, 5, 0); + test(S("prbhe"), "qhjistlgmr", 0, 0, 0); + test(S("lbisk"), "pedfirsglo", 0, 1, 0); + test(S("hrlpd"), "aqcoslgrmk", 0, 5, 0); + test(S("ehmja"), "dabckmepqj", 0, 9, 1); + test(S("mhqgd"), "pqscrjthli", 0, 10, 0); + test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, 0); + test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, 0); + test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, 0); + test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, S::npos); + test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, S::npos); + test(S("clrgb"), "", 1, 0, 1); + test(S("tjmek"), "osmia", 1, 0, 1); + test(S("bgstp"), "ckonl", 1, 1, 1); + test(S("hstrk"), "ilcaj", 1, 2, 1); + test(S("kmspj"), "lasiq", 1, 4, 1); + test(S("tjboh"), "kfqmr", 1, 5, 1); + test(S("ilbcj"), "klnitfaobg", 1, 0, 1); + test(S("jkngf"), "gjhmdlqikp", 1, 1, 1); + test(S("gfcql"), "skbgtahqej", 1, 5, 1); + test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 1); + test(S("bthpg"), "bjgfmnlkio", 1, 10, 1); + test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, 1); + test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, 1); + test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 3); + test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, S::npos); + test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, S::npos); + test(S("ndrhl"), "", 2, 0, 2); + test(S("mrecp"), "otkgb", 2, 0, 2); + test(S("qlasf"), "cqsjl", 2, 1, 2); + test(S("smaqd"), "dpifl", 2, 2, 2); + test(S("hjeni"), "oapht", 2, 4, 2); + test(S("ocmfj"), "cifts", 2, 5, 2); + test(S("hmftq"), "nmsckbgalo", 2, 0, 2); + test(S("fklad"), "tpksqhamle", 2, 1, 2); + test(S("dirnm"), "tpdrchmkji", 2, 5, 3); + test(S("hrgdc"), "ijagfkblst", 2, 9, 3); + test(S("ifakg"), "kpocsignjb", 2, 10, 2); + test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, 2); + test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, 2); + test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 2); + test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, S::npos); + test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, S::npos); + test(S("cjgao"), "", 4, 0, 4); + test(S("kjplq"), "mabns", 4, 0, 4); + test(S("herni"), "bdnrp", 4, 1, 4); + test(S("tadrb"), "scidp", 4, 2, 4); + test(S("pkfeo"), "agbjl", 4, 4, 4); + test(S("hoser"), "jfmpr", 4, 5, S::npos); + test(S("kgrsp"), "rbpefghsmj", 4, 0, 4); + test(S("pgejb"), "apsfntdoqc", 4, 1, 4); + test(S("thlnq"), "ndkjeisgcl", 4, 5, 4); + test(S("nbmit"), "rnfpqatdeo", 4, 9, S::npos); + test(S("jgmib"), "bntjlqrfik", 4, 10, S::npos); + test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, 4); + test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, 4); + test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, S::npos); + test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, S::npos); + test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, S::npos); + test(S("klopi"), "", 5, 0, S::npos); + test(S("dajhn"), "psthd", 5, 0, S::npos); + test(S("jbgno"), "rpmjd", 5, 1, S::npos); + test(S("hkjae"), "dfsmk", 5, 2, S::npos); +} + +template <class S> +void test1() +{ + test(S("gbhqo"), "skqne", 5, 4, S::npos); + test(S("ktdor"), "kipnf", 5, 5, S::npos); + test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos); + test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos); + test(S("armql"), "pcdgltbrfj", 5, 5, S::npos); + test(S("cdhjo"), "aekfctpirg", 5, 9, S::npos); + test(S("jcons"), "ledihrsgpf", 5, 10, S::npos); + test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos); + test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos); + test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, S::npos); + test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, S::npos); + test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos); + test(S("gajqn"), "", 6, 0, S::npos); + test(S("stedk"), "hrnat", 6, 0, S::npos); + test(S("tjkaf"), "gsqdt", 6, 1, S::npos); + test(S("dthpe"), "bspkd", 6, 2, S::npos); + test(S("klhde"), "ohcmb", 6, 4, S::npos); + test(S("bhlki"), "heatr", 6, 5, S::npos); + test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos); + test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos); + test(S("dpqbr"), "lmbtdehjrn", 6, 5, S::npos); + test(S("kdhmo"), "teqmcrlgib", 6, 9, S::npos); + test(S("jblqp"), "njolbmspac", 6, 10, S::npos); + test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos); + test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos); + test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, S::npos); + test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos); + test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos); + test(S("jnkrfhotgl"), "", 0, 0, 0); + test(S("dltjfngbko"), "rqegt", 0, 0, 0); + test(S("bmjlpkiqde"), "dashm", 0, 1, 0); + test(S("skrflobnqm"), "jqirk", 0, 2, 0); + test(S("jkpldtshrm"), "rckeg", 0, 4, 0); + test(S("ghasdbnjqo"), "jscie", 0, 5, 0); + test(S("igrkhpbqjt"), "efsphndliq", 0, 0, 0); + test(S("ikthdgcamf"), "gdicosleja", 0, 1, 0); + test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 2); + test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 4); + test(S("itphbqsker"), "dtablcrseo", 0, 10, 0); + test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, 0); + test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, 0); + test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 0); + test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 1); + test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, S::npos); + test(S("shbcqnmoar"), "", 1, 0, 1); + test(S("bdoshlmfin"), "ontrs", 1, 0, 1); + test(S("khfrebnsgq"), "pfkna", 1, 1, 1); + test(S("getcrsaoji"), "ekosa", 1, 2, 2); + test(S("fjiknedcpq"), "anqhk", 1, 4, 1); + test(S("tkejgnafrm"), "jekca", 1, 5, 4); + test(S("jnakolqrde"), "ikemsjgacf", 1, 0, 1); + test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, 1); + test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 3); + test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 1); + test(S("cigfqkated"), "sqcflrgtim", 1, 10, 5); + test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, 1); + test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, 1); + test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 5); + test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 5); + test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, S::npos); + test(S("ectnhskflp"), "", 5, 0, 5); + test(S("fgtianblpq"), "pijag", 5, 0, 5); + test(S("mfeqklirnh"), "jrckd", 5, 1, 5); + test(S("astedncjhk"), "qcloh", 5, 2, 5); + test(S("fhlqgcajbr"), "thlmp", 5, 4, 5); + test(S("epfhocmdng"), "qidmo", 5, 5, 5); + test(S("apcnsibger"), "lnegpsjqrd", 5, 0, 5); + test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 6); + test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 5); + test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 6); + test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 5); + test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, 5); + test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, 5); + test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 6); + test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 8); + test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, S::npos); + test(S("shoiedtcjb"), "", 9, 0, 9); + test(S("ebcinjgads"), "tqbnh", 9, 0, 9); + test(S("dqmregkcfl"), "akmle", 9, 1, 9); + test(S("ngcrieqajf"), "iqfkm", 9, 2, 9); + test(S("qosmilgnjb"), "tqjsr", 9, 4, 9); + test(S("ikabsjtdfl"), "jplqg", 9, 5, S::npos); + test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, 9); + test(S("fdnplotmgh"), "morkglpesn", 9, 1, 9); + test(S("fdbicojerm"), "dmicerngat", 9, 5, S::npos); + test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 9); + test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 9); + test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, 9); + test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 9); + test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 9); + test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, S::npos); + test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, S::npos); + test(S("ncjpmaekbs"), "", 10, 0, S::npos); + test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos); + test(S("pqfhsgilen"), "qnpor", 10, 1, S::npos); + test(S("gqtjsbdckh"), "otdma", 10, 2, S::npos); + test(S("cfkqpjlegi"), "efhjg", 10, 4, S::npos); + test(S("beanrfodgj"), "odpte", 10, 5, S::npos); + test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos); + test(S("iomkfthagj"), "oaklidrbqg", 10, 1, S::npos); +} + +template <class S> +void test2() +{ + test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, S::npos); + test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, S::npos); + test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, S::npos); + test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos); + test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, S::npos); + test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, S::npos); + test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, S::npos); + test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos); + test(S("cqjohampgd"), "", 11, 0, S::npos); + test(S("hobitmpsan"), "aocjb", 11, 0, S::npos); + test(S("tjehkpsalm"), "jbrnk", 11, 1, S::npos); + test(S("ngfbojitcl"), "tqedg", 11, 2, S::npos); + test(S("rcfkdbhgjo"), "nqskp", 11, 4, S::npos); + test(S("qghptonrea"), "eaqkl", 11, 5, S::npos); + test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos); + test(S("hlmgabenti"), "lsftgajqpm", 11, 1, S::npos); + test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, S::npos); + test(S("jqedtkornm"), "shkncmiaqj", 11, 9, S::npos); + test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, S::npos); + test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos); + test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos); + test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, S::npos); + test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos); + test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos); + test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, 0); + test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, 0); + test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 0); + test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 0); + test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 0); + test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 0); + test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, 0); + test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 0); + test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 0); + test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 0); + test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 0); + test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, 0); + test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 0); + test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 0); + test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 11); + test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, S::npos); + test(S("febhmqtjanokscdirpgl"), "", 1, 0, 1); + test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, 1); + test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 1); + test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 2); + test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 2); + test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 1); + test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, 1); + test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 1); + test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 1); + test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 3); + test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 2); + test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, 1); + test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 1); + test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 2); + test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 13); + test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, S::npos); + test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, 10); + test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, 10); + test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 10); + test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 10); + test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 11); + test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 10); + test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, 10); + test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 10); + test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 10); + test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 11); + test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 10); + test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, 10); + test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 10); + test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 11); + test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 11); + test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, S::npos); + test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, 19); + test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, 19); + test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 19); + test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 19); + test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 19); + test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, S::npos); + test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, 19); + test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 19); + test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 19); + test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 19); + test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 19); + test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, 19); + test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 19); + test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, S::npos); + test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, S::npos); + test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, S::npos); + test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos); + test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos); + test(S("grkpahljcftesdmonqib"), "odife", 20, 1, S::npos); + test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, S::npos); + test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, S::npos); + test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, S::npos); + test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos); + test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, S::npos); + test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, S::npos); + test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, S::npos); + test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, S::npos); + test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos); +} + +template <class S> +void test3() +{ + test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, S::npos); + test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, S::npos); + test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, S::npos); + test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos); + test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos); + test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos); + test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, S::npos); + test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, S::npos); + test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, S::npos); + test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, S::npos); + test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos); + test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, S::npos); + test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, S::npos); + test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, S::npos); + test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, S::npos); + test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos); + test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, S::npos); + test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, S::npos); + test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, S::npos); + test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp new file mode 100644 index 000000000000..4fb072fa4744 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp @@ -0,0 +1,157 @@ +//===----------------------------------------------------------------------===// +// +// 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 find_first_not_of(const basic_string& str, size_type pos = 0) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x) +{ + assert(s.find_first_not_of(str, pos) == x); + if (x != S::npos) + assert(pos <= x && x < s.size()); +} + +template <class S> +void +test(const S& s, const S& str, typename S::size_type x) +{ + assert(s.find_first_not_of(str) == x); + if (x != S::npos) + assert(x < s.size()); +} + +template <class S> +void test0() +{ + test(S(""), S(""), 0, S::npos); + test(S(""), S("laenf"), 0, S::npos); + test(S(""), S("pqlnkmbdjo"), 0, S::npos); + test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos); + test(S(""), S(""), 1, S::npos); + test(S(""), S("bjaht"), 1, S::npos); + test(S(""), S("hjlcmgpket"), 1, S::npos); + test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos); + test(S("fodgq"), S(""), 0, 0); + test(S("qanej"), S("dfkap"), 0, 0); + test(S("clbao"), S("ihqrfebgad"), 0, 0); + test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, S::npos); + test(S("srdfq"), S(""), 1, 1); + test(S("oemth"), S("ikcrq"), 1, 1); + test(S("cdaih"), S("dmajblfhsg"), 1, 3); + test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, S::npos); + test(S("cshmd"), S(""), 2, 2); + test(S("lhcdo"), S("oebqi"), 2, 2); + test(S("qnsoh"), S("kojhpmbsfe"), 2, S::npos); + test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, S::npos); + test(S("fmtsp"), S(""), 4, 4); + test(S("khbpm"), S("aobjd"), 4, 4); + test(S("pbsji"), S("pcbahntsje"), 4, 4); + test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, S::npos); + test(S("eqmpa"), S(""), 5, S::npos); + test(S("omigs"), S("kocgb"), 5, S::npos); + test(S("onmje"), S("fbslrjiqkm"), 5, S::npos); + test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos); + test(S("schfa"), S(""), 6, S::npos); + test(S("igdsc"), S("qngpd"), 6, S::npos); + test(S("brqgo"), S("rodhqklgmb"), 6, S::npos); + test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos); + test(S("hcjitbfapl"), S(""), 0, 0); + test(S("daiprenocl"), S("ashjd"), 0, 2); + test(S("litpcfdghe"), S("mgojkldsqh"), 0, 1); + test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, S::npos); + test(S("qpghtfbaji"), S(""), 1, 1); + test(S("gfshlcmdjr"), S("nadkh"), 1, 1); + test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 4); + test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, S::npos); + test(S("crnklpmegd"), S(""), 5, 5); + test(S("jsbtafedoc"), S("prqgn"), 5, 5); + test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 6); + test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, S::npos); + test(S("lmofqdhpki"), S(""), 9, 9); + test(S("hnefkqimca"), S("rtjpa"), 9, S::npos); + test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 9); + test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, S::npos); + test(S("elgofjmbrq"), S(""), 10, S::npos); + test(S("mjqdgalkpc"), S("dplqa"), 10, S::npos); + test(S("kthqnfcerm"), S("dkacjoptns"), 10, S::npos); + test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos); + test(S("eqsgalomhb"), S(""), 11, S::npos); + test(S("akiteljmoh"), S("lofbc"), 11, S::npos); + test(S("hlbdfreqjo"), S("astoegbfpn"), 11, S::npos); + test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos); + test(S("snafbdlghrjkpqtoceim"), S(""), 0, 0); + test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 0); + test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 1); + test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, S::npos); + test(S("jlnkraeodhcspfgbqitm"), S(""), 1, 1); + test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 1); + test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 3); + test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, S::npos); + test(S("hdpkobnsalmcfijregtq"), S(""), 10, 10); + test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 11); + test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 13); + test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, S::npos); + test(S("niptglfbosehkamrdqcj"), S(""), 19, 19); + test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 19); + test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, S::npos); + test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, S::npos); + test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos); + test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, S::npos); + test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, S::npos); + test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos); + test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos); + test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, S::npos); + test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, S::npos); + test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos); +} + +template <class S> +void test1() +{ + test(S(""), S(""), S::npos); + test(S(""), S("laenf"), S::npos); + test(S(""), S("pqlnkmbdjo"), S::npos); + test(S(""), S("qkamfogpnljdcshbreti"), S::npos); + test(S("nhmko"), S(""), 0); + test(S("lahfb"), S("irkhs"), 0); + test(S("gmfhd"), S("kantesmpgj"), 2); + test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), S::npos); + test(S("eolhfgpjqk"), S(""), 0); + test(S("nbatdlmekr"), S("bnrpe"), 2); + test(S("jdmciepkaq"), S("jtdaefblso"), 2); + test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), S::npos); + test(S("gprdcokbnjhlsfmtieqa"), S(""), 0); + test(S("qjghlnftcaismkropdeb"), S("bjaht"), 0); + test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 1); + test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), S::npos); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.first.of/char_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.of/char_size.pass.cpp new file mode 100644 index 000000000000..32d0e86f3d84 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.first.of/char_size.pass.cpp @@ -0,0 +1,98 @@ +//===----------------------------------------------------------------------===// +// +// 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 find_first_of(charT c, size_type pos = 0) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, typename S::value_type c, typename S::size_type pos, + typename S::size_type x) +{ + assert(s.find_first_of(c, pos) == x); + if (x != S::npos) + assert(pos <= x && x < s.size()); +} + +template <class S> +void +test(const S& s, typename S::value_type c, typename S::size_type x) +{ + assert(s.find_first_of(c) == x); + if (x != S::npos) + assert(x < s.size()); +} + +int main() +{ + { + typedef std::string S; + test(S(""), 'e', 0, S::npos); + test(S(""), 'e', 1, S::npos); + test(S("kitcj"), 'e', 0, S::npos); + test(S("qkamf"), 'e', 1, S::npos); + test(S("nhmko"), 'e', 2, S::npos); + test(S("tpsaf"), 'e', 4, S::npos); + test(S("lahfb"), 'e', 5, S::npos); + test(S("irkhs"), 'e', 6, S::npos); + test(S("gmfhdaipsr"), 'e', 0, S::npos); + test(S("kantesmpgj"), 'e', 1, 4); + test(S("odaftiegpm"), 'e', 5, 6); + test(S("oknlrstdpi"), 'e', 9, S::npos); + test(S("eolhfgpjqk"), 'e', 10, S::npos); + test(S("pcdrofikas"), 'e', 11, S::npos); + test(S("nbatdlmekrgcfqsophij"), 'e', 0, 7); + test(S("bnrpehidofmqtcksjgla"), 'e', 1, 4); + test(S("jdmciepkaqgotsrfnhlb"), 'e', 10, S::npos); + test(S("jtdaefblsokrmhpgcnqi"), 'e', 19, S::npos); + test(S("hkbgspofltajcnedqmri"), 'e', 20, S::npos); + test(S("oselktgbcapndfjihrmq"), 'e', 21, S::npos); + + test(S(""), 'e', S::npos); + test(S("csope"), 'e', 4); + test(S("gfsmthlkon"), 'e', S::npos); + test(S("laenfsbridchgotmkqpj"), 'e', 2); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), 'e', 0, S::npos); + test(S(""), 'e', 1, S::npos); + test(S("kitcj"), 'e', 0, S::npos); + test(S("qkamf"), 'e', 1, S::npos); + test(S("nhmko"), 'e', 2, S::npos); + test(S("tpsaf"), 'e', 4, S::npos); + test(S("lahfb"), 'e', 5, S::npos); + test(S("irkhs"), 'e', 6, S::npos); + test(S("gmfhdaipsr"), 'e', 0, S::npos); + test(S("kantesmpgj"), 'e', 1, 4); + test(S("odaftiegpm"), 'e', 5, 6); + test(S("oknlrstdpi"), 'e', 9, S::npos); + test(S("eolhfgpjqk"), 'e', 10, S::npos); + test(S("pcdrofikas"), 'e', 11, S::npos); + test(S("nbatdlmekrgcfqsophij"), 'e', 0, 7); + test(S("bnrpehidofmqtcksjgla"), 'e', 1, 4); + test(S("jdmciepkaqgotsrfnhlb"), 'e', 10, S::npos); + test(S("jtdaefblsokrmhpgcnqi"), 'e', 19, S::npos); + test(S("hkbgspofltajcnedqmri"), 'e', 20, S::npos); + test(S("oselktgbcapndfjihrmq"), 'e', 21, S::npos); + + test(S(""), 'e', S::npos); + test(S("csope"), 'e', 4); + test(S("gfsmthlkon"), 'e', S::npos); + test(S("laenfsbridchgotmkqpj"), 'e', 2); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size.pass.cpp new file mode 100644 index 000000000000..6dd176df0165 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size.pass.cpp @@ -0,0 +1,158 @@ +//===----------------------------------------------------------------------===// +// +// 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 find_first_of(const charT* s, size_type pos = 0) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type pos, + typename S::size_type x) +{ + assert(s.find_first_of(str, pos) == x); + if (x != S::npos) + assert(pos <= x && x < s.size()); +} + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type x) +{ + assert(s.find_first_of(str) == x); + if (x != S::npos) + assert(x < s.size()); +} + +template <class S> +void test0() +{ + test(S(""), "", 0, S::npos); + test(S(""), "laenf", 0, S::npos); + test(S(""), "pqlnkmbdjo", 0, S::npos); + test(S(""), "qkamfogpnljdcshbreti", 0, S::npos); + test(S(""), "", 1, S::npos); + test(S(""), "bjaht", 1, S::npos); + test(S(""), "hjlcmgpket", 1, S::npos); + test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos); + test(S("fodgq"), "", 0, S::npos); + test(S("qanej"), "dfkap", 0, 1); + test(S("clbao"), "ihqrfebgad", 0, 2); + test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, 0); + test(S("srdfq"), "", 1, S::npos); + test(S("oemth"), "ikcrq", 1, S::npos); + test(S("cdaih"), "dmajblfhsg", 1, 1); + test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, 1); + test(S("cshmd"), "", 2, S::npos); + test(S("lhcdo"), "oebqi", 2, 4); + test(S("qnsoh"), "kojhpmbsfe", 2, 2); + test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, 2); + test(S("fmtsp"), "", 4, S::npos); + test(S("khbpm"), "aobjd", 4, S::npos); + test(S("pbsji"), "pcbahntsje", 4, S::npos); + test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, 4); + test(S("eqmpa"), "", 5, S::npos); + test(S("omigs"), "kocgb", 5, S::npos); + test(S("onmje"), "fbslrjiqkm", 5, S::npos); + test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos); + test(S("schfa"), "", 6, S::npos); + test(S("igdsc"), "qngpd", 6, S::npos); + test(S("brqgo"), "rodhqklgmb", 6, S::npos); + test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos); + test(S("hcjitbfapl"), "", 0, S::npos); + test(S("daiprenocl"), "ashjd", 0, 0); + test(S("litpcfdghe"), "mgojkldsqh", 0, 0); + test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, 0); + test(S("qpghtfbaji"), "", 1, S::npos); + test(S("gfshlcmdjr"), "nadkh", 1, 3); + test(S("nkodajteqp"), "ofdrqmkebl", 1, 1); + test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, 1); + test(S("crnklpmegd"), "", 5, S::npos); + test(S("jsbtafedoc"), "prqgn", 5, S::npos); + test(S("qnmodrtkeb"), "pejafmnokr", 5, 5); + test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, 5); + test(S("lmofqdhpki"), "", 9, S::npos); + test(S("hnefkqimca"), "rtjpa", 9, 9); + test(S("drtasbgmfp"), "ktsrmnqagd", 9, S::npos); + test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, 9); + test(S("elgofjmbrq"), "", 10, S::npos); + test(S("mjqdgalkpc"), "dplqa", 10, S::npos); + test(S("kthqnfcerm"), "dkacjoptns", 10, S::npos); + test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos); + test(S("eqsgalomhb"), "", 11, S::npos); + test(S("akiteljmoh"), "lofbc", 11, S::npos); + test(S("hlbdfreqjo"), "astoegbfpn", 11, S::npos); + test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos); + test(S("snafbdlghrjkpqtoceim"), "", 0, S::npos); + test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 3); + test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 0); + test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, 0); + test(S("jlnkraeodhcspfgbqitm"), "", 1, S::npos); + test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 3); + test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 1); + test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, 1); + test(S("hdpkobnsalmcfijregtq"), "", 10, S::npos); + test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 10); + test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 10); + test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, 10); + test(S("niptglfbosehkamrdqcj"), "", 19, S::npos); + test(S("copqdhstbingamjfkler"), "djkqc", 19, S::npos); + test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 19); + test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, 19); + test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos); + test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, S::npos); + test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, S::npos); + test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos); + test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos); + test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, S::npos); + test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, S::npos); + test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos); +} + +template <class S> +void test1() +{ + test(S(""), "", S::npos); + test(S(""), "laenf", S::npos); + test(S(""), "pqlnkmbdjo", S::npos); + test(S(""), "qkamfogpnljdcshbreti", S::npos); + test(S("nhmko"), "", S::npos); + test(S("lahfb"), "irkhs", 2); + test(S("gmfhd"), "kantesmpgj", 0); + test(S("odaft"), "oknlrstdpiqmjbaghcfe", 0); + test(S("eolhfgpjqk"), "", S::npos); + test(S("nbatdlmekr"), "bnrpe", 0); + test(S("jdmciepkaq"), "jtdaefblso", 0); + test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", 0); + test(S("gprdcokbnjhlsfmtieqa"), "", S::npos); + test(S("qjghlnftcaismkropdeb"), "bjaht", 1); + test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 0); + test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", 0); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size_size.pass.cpp new file mode 100644 index 000000000000..9e98a6ad20f7 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size_size.pass.cpp @@ -0,0 +1,387 @@ +//===----------------------------------------------------------------------===// +// +// 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 find_first_of(const charT* s, size_type pos, size_type n) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type pos, + typename S::size_type n, typename S::size_type x) +{ + assert(s.find_first_of(str, pos, n) == x); + if (x != S::npos) + assert(pos <= x && x < s.size()); +} + +template <class S> +void test0() +{ + test(S(""), "", 0, 0, S::npos); + test(S(""), "irkhs", 0, 0, S::npos); + test(S(""), "kante", 0, 1, S::npos); + test(S(""), "oknlr", 0, 2, S::npos); + test(S(""), "pcdro", 0, 4, S::npos); + test(S(""), "bnrpe", 0, 5, S::npos); + test(S(""), "jtdaefblso", 0, 0, S::npos); + test(S(""), "oselktgbca", 0, 1, S::npos); + test(S(""), "eqgaplhckj", 0, 5, S::npos); + test(S(""), "bjahtcmnlp", 0, 9, S::npos); + test(S(""), "hjlcmgpket", 0, 10, S::npos); + test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos); + test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos); + test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos); + test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos); + test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos); + test(S(""), "", 1, 0, S::npos); + test(S(""), "lbtqd", 1, 0, S::npos); + test(S(""), "tboim", 1, 1, S::npos); + test(S(""), "slcer", 1, 2, S::npos); + test(S(""), "cbjfs", 1, 4, S::npos); + test(S(""), "aqibs", 1, 5, S::npos); + test(S(""), "gtfblmqinc", 1, 0, S::npos); + test(S(""), "mkqpbtdalg", 1, 1, S::npos); + test(S(""), "kphatlimcd", 1, 5, S::npos); + test(S(""), "pblasqogic", 1, 9, S::npos); + test(S(""), "arosdhcfme", 1, 10, S::npos); + test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos); + test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos); + test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos); + test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos); + test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos); + test(S("eaint"), "", 0, 0, S::npos); + test(S("binja"), "gfsrt", 0, 0, S::npos); + test(S("latkm"), "pfsoc", 0, 1, S::npos); + test(S("lecfr"), "tpflm", 0, 2, S::npos); + test(S("eqkst"), "sgkec", 0, 4, 0); + test(S("cdafr"), "romds", 0, 5, 1); + test(S("prbhe"), "qhjistlgmr", 0, 0, S::npos); + test(S("lbisk"), "pedfirsglo", 0, 1, S::npos); + test(S("hrlpd"), "aqcoslgrmk", 0, 5, S::npos); + test(S("ehmja"), "dabckmepqj", 0, 9, 0); + test(S("mhqgd"), "pqscrjthli", 0, 10, 1); + test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, S::npos); + test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, S::npos); + test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, S::npos); + test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, 0); + test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, 0); + test(S("clrgb"), "", 1, 0, S::npos); + test(S("tjmek"), "osmia", 1, 0, S::npos); + test(S("bgstp"), "ckonl", 1, 1, S::npos); + test(S("hstrk"), "ilcaj", 1, 2, S::npos); + test(S("kmspj"), "lasiq", 1, 4, 2); + test(S("tjboh"), "kfqmr", 1, 5, S::npos); + test(S("ilbcj"), "klnitfaobg", 1, 0, S::npos); + test(S("jkngf"), "gjhmdlqikp", 1, 1, 3); + test(S("gfcql"), "skbgtahqej", 1, 5, S::npos); + test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 2); + test(S("bthpg"), "bjgfmnlkio", 1, 10, 4); + test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, S::npos); + test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, S::npos); + test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 1); + test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, 1); + test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, 1); + test(S("ndrhl"), "", 2, 0, S::npos); + test(S("mrecp"), "otkgb", 2, 0, S::npos); + test(S("qlasf"), "cqsjl", 2, 1, S::npos); + test(S("smaqd"), "dpifl", 2, 2, 4); + test(S("hjeni"), "oapht", 2, 4, S::npos); + test(S("ocmfj"), "cifts", 2, 5, 3); + test(S("hmftq"), "nmsckbgalo", 2, 0, S::npos); + test(S("fklad"), "tpksqhamle", 2, 1, S::npos); + test(S("dirnm"), "tpdrchmkji", 2, 5, 2); + test(S("hrgdc"), "ijagfkblst", 2, 9, 2); + test(S("ifakg"), "kpocsignjb", 2, 10, 3); + test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, S::npos); + test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, S::npos); + test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 3); + test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, 2); + test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, 2); + test(S("cjgao"), "", 4, 0, S::npos); + test(S("kjplq"), "mabns", 4, 0, S::npos); + test(S("herni"), "bdnrp", 4, 1, S::npos); + test(S("tadrb"), "scidp", 4, 2, S::npos); + test(S("pkfeo"), "agbjl", 4, 4, S::npos); + test(S("hoser"), "jfmpr", 4, 5, 4); + test(S("kgrsp"), "rbpefghsmj", 4, 0, S::npos); + test(S("pgejb"), "apsfntdoqc", 4, 1, S::npos); + test(S("thlnq"), "ndkjeisgcl", 4, 5, S::npos); + test(S("nbmit"), "rnfpqatdeo", 4, 9, 4); + test(S("jgmib"), "bntjlqrfik", 4, 10, 4); + test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, S::npos); + test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, S::npos); + test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 4); + test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 4); + test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, 4); + test(S("klopi"), "", 5, 0, S::npos); + test(S("dajhn"), "psthd", 5, 0, S::npos); + test(S("jbgno"), "rpmjd", 5, 1, S::npos); + test(S("hkjae"), "dfsmk", 5, 2, S::npos); +} + +template <class S> +void test1() +{ + test(S("gbhqo"), "skqne", 5, 4, S::npos); + test(S("ktdor"), "kipnf", 5, 5, S::npos); + test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos); + test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos); + test(S("armql"), "pcdgltbrfj", 5, 5, S::npos); + test(S("cdhjo"), "aekfctpirg", 5, 9, S::npos); + test(S("jcons"), "ledihrsgpf", 5, 10, S::npos); + test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos); + test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos); + test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, S::npos); + test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, S::npos); + test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos); + test(S("gajqn"), "", 6, 0, S::npos); + test(S("stedk"), "hrnat", 6, 0, S::npos); + test(S("tjkaf"), "gsqdt", 6, 1, S::npos); + test(S("dthpe"), "bspkd", 6, 2, S::npos); + test(S("klhde"), "ohcmb", 6, 4, S::npos); + test(S("bhlki"), "heatr", 6, 5, S::npos); + test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos); + test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos); + test(S("dpqbr"), "lmbtdehjrn", 6, 5, S::npos); + test(S("kdhmo"), "teqmcrlgib", 6, 9, S::npos); + test(S("jblqp"), "njolbmspac", 6, 10, S::npos); + test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos); + test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos); + test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, S::npos); + test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos); + test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos); + test(S("jnkrfhotgl"), "", 0, 0, S::npos); + test(S("dltjfngbko"), "rqegt", 0, 0, S::npos); + test(S("bmjlpkiqde"), "dashm", 0, 1, 8); + test(S("skrflobnqm"), "jqirk", 0, 2, 8); + test(S("jkpldtshrm"), "rckeg", 0, 4, 1); + test(S("ghasdbnjqo"), "jscie", 0, 5, 3); + test(S("igrkhpbqjt"), "efsphndliq", 0, 0, S::npos); + test(S("ikthdgcamf"), "gdicosleja", 0, 1, 5); + test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 0); + test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 0); + test(S("itphbqsker"), "dtablcrseo", 0, 10, 1); + test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, S::npos); + test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, S::npos); + test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 4); + test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 0); + test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, 0); + test(S("shbcqnmoar"), "", 1, 0, S::npos); + test(S("bdoshlmfin"), "ontrs", 1, 0, S::npos); + test(S("khfrebnsgq"), "pfkna", 1, 1, S::npos); + test(S("getcrsaoji"), "ekosa", 1, 2, 1); + test(S("fjiknedcpq"), "anqhk", 1, 4, 4); + test(S("tkejgnafrm"), "jekca", 1, 5, 1); + test(S("jnakolqrde"), "ikemsjgacf", 1, 0, S::npos); + test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, S::npos); + test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 1); + test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 4); + test(S("cigfqkated"), "sqcflrgtim", 1, 10, 1); + test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, S::npos); + test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, S::npos); + test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 1); + test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 1); + test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, 1); + test(S("ectnhskflp"), "", 5, 0, S::npos); + test(S("fgtianblpq"), "pijag", 5, 0, S::npos); + test(S("mfeqklirnh"), "jrckd", 5, 1, S::npos); + test(S("astedncjhk"), "qcloh", 5, 2, 6); + test(S("fhlqgcajbr"), "thlmp", 5, 4, S::npos); + test(S("epfhocmdng"), "qidmo", 5, 5, 6); + test(S("apcnsibger"), "lnegpsjqrd", 5, 0, S::npos); + test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 5); + test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 7); + test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 5); + test(S("jbhcfposld"), "trfqgmckbe", 5, 10, S::npos); + test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, S::npos); + test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, S::npos); + test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 5); + test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 5); + test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, 5); + test(S("shoiedtcjb"), "", 9, 0, S::npos); + test(S("ebcinjgads"), "tqbnh", 9, 0, S::npos); + test(S("dqmregkcfl"), "akmle", 9, 1, S::npos); + test(S("ngcrieqajf"), "iqfkm", 9, 2, S::npos); + test(S("qosmilgnjb"), "tqjsr", 9, 4, S::npos); + test(S("ikabsjtdfl"), "jplqg", 9, 5, 9); + test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, S::npos); + test(S("fdnplotmgh"), "morkglpesn", 9, 1, S::npos); + test(S("fdbicojerm"), "dmicerngat", 9, 5, 9); + test(S("mbtafndjcq"), "radgeskbtc", 9, 9, S::npos); + test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, S::npos); + test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, S::npos); + test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, S::npos); + test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, S::npos); + test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 9); + test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, 9); + test(S("ncjpmaekbs"), "", 10, 0, S::npos); + test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos); + test(S("pqfhsgilen"), "qnpor", 10, 1, S::npos); + test(S("gqtjsbdckh"), "otdma", 10, 2, S::npos); + test(S("cfkqpjlegi"), "efhjg", 10, 4, S::npos); + test(S("beanrfodgj"), "odpte", 10, 5, S::npos); + test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos); + test(S("iomkfthagj"), "oaklidrbqg", 10, 1, S::npos); +} + +template <class S> +void test2() +{ + test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, S::npos); + test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, S::npos); + test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, S::npos); + test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos); + test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, S::npos); + test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, S::npos); + test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, S::npos); + test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos); + test(S("cqjohampgd"), "", 11, 0, S::npos); + test(S("hobitmpsan"), "aocjb", 11, 0, S::npos); + test(S("tjehkpsalm"), "jbrnk", 11, 1, S::npos); + test(S("ngfbojitcl"), "tqedg", 11, 2, S::npos); + test(S("rcfkdbhgjo"), "nqskp", 11, 4, S::npos); + test(S("qghptonrea"), "eaqkl", 11, 5, S::npos); + test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos); + test(S("hlmgabenti"), "lsftgajqpm", 11, 1, S::npos); + test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, S::npos); + test(S("jqedtkornm"), "shkncmiaqj", 11, 9, S::npos); + test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, S::npos); + test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos); + test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos); + test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, S::npos); + test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos); + test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos); + test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, S::npos); + test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, S::npos); + test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 4); + test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 3); + test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 3); + test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 3); + test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, S::npos); + test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 19); + test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 2); + test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 2); + test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 2); + test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, S::npos); + test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 16); + test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 1); + test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 0); + test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, 0); + test(S("febhmqtjanokscdirpgl"), "", 1, 0, S::npos); + test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, S::npos); + test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 6); + test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 1); + test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 1); + test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 6); + test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, S::npos); + test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 19); + test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 4); + test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 1); + test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 1); + test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, S::npos); + test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 7); + test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 1); + test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 1); + test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, 1); + test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, S::npos); + test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, S::npos); + test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 12); + test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, S::npos); + test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 10); + test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 15); + test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, S::npos); + test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, S::npos); + test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 11); + test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 10); + test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 11); + test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, S::npos); + test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 18); + test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 10); + test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 10); + test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, 10); + test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, S::npos); + test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, S::npos); + test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, S::npos); + test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, S::npos); + test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, S::npos); + test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 19); + test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, S::npos); + test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, S::npos); + test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, S::npos); + test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, S::npos); + test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, S::npos); + test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, S::npos); + test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, S::npos); + test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 19); + test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 19); + test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, 19); + test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos); + test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos); + test(S("grkpahljcftesdmonqib"), "odife", 20, 1, S::npos); + test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, S::npos); + test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, S::npos); + test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, S::npos); + test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos); + test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, S::npos); + test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, S::npos); + test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, S::npos); + test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, S::npos); + test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos); +} + +template <class S> +void test3() +{ + test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, S::npos); + test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, S::npos); + test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, S::npos); + test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos); + test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos); + test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos); + test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, S::npos); + test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, S::npos); + test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, S::npos); + test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, S::npos); + test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos); + test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, S::npos); + test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, S::npos); + test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, S::npos); + test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, S::npos); + test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos); + test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, S::npos); + test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, S::npos); + test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, S::npos); + test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp new file mode 100644 index 000000000000..e409edc25f48 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp @@ -0,0 +1,157 @@ +//===----------------------------------------------------------------------===// +// +// 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 find_first_of(const basic_string& str, size_type pos = 0) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x) +{ + assert(s.find_first_of(str, pos) == x); + if (x != S::npos) + assert(pos <= x && x < s.size()); +} + +template <class S> +void +test(const S& s, const S& str, typename S::size_type x) +{ + assert(s.find_first_of(str) == x); + if (x != S::npos) + assert(x < s.size()); +} + +template <class S> +void test0() +{ + test(S(""), S(""), 0, S::npos); + test(S(""), S("laenf"), 0, S::npos); + test(S(""), S("pqlnkmbdjo"), 0, S::npos); + test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos); + test(S(""), S(""), 1, S::npos); + test(S(""), S("bjaht"), 1, S::npos); + test(S(""), S("hjlcmgpket"), 1, S::npos); + test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos); + test(S("fodgq"), S(""), 0, S::npos); + test(S("qanej"), S("dfkap"), 0, 1); + test(S("clbao"), S("ihqrfebgad"), 0, 2); + test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, 0); + test(S("srdfq"), S(""), 1, S::npos); + test(S("oemth"), S("ikcrq"), 1, S::npos); + test(S("cdaih"), S("dmajblfhsg"), 1, 1); + test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, 1); + test(S("cshmd"), S(""), 2, S::npos); + test(S("lhcdo"), S("oebqi"), 2, 4); + test(S("qnsoh"), S("kojhpmbsfe"), 2, 2); + test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, 2); + test(S("fmtsp"), S(""), 4, S::npos); + test(S("khbpm"), S("aobjd"), 4, S::npos); + test(S("pbsji"), S("pcbahntsje"), 4, S::npos); + test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, 4); + test(S("eqmpa"), S(""), 5, S::npos); + test(S("omigs"), S("kocgb"), 5, S::npos); + test(S("onmje"), S("fbslrjiqkm"), 5, S::npos); + test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos); + test(S("schfa"), S(""), 6, S::npos); + test(S("igdsc"), S("qngpd"), 6, S::npos); + test(S("brqgo"), S("rodhqklgmb"), 6, S::npos); + test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos); + test(S("hcjitbfapl"), S(""), 0, S::npos); + test(S("daiprenocl"), S("ashjd"), 0, 0); + test(S("litpcfdghe"), S("mgojkldsqh"), 0, 0); + test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, 0); + test(S("qpghtfbaji"), S(""), 1, S::npos); + test(S("gfshlcmdjr"), S("nadkh"), 1, 3); + test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 1); + test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, 1); + test(S("crnklpmegd"), S(""), 5, S::npos); + test(S("jsbtafedoc"), S("prqgn"), 5, S::npos); + test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 5); + test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, 5); + test(S("lmofqdhpki"), S(""), 9, S::npos); + test(S("hnefkqimca"), S("rtjpa"), 9, 9); + test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, S::npos); + test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, 9); + test(S("elgofjmbrq"), S(""), 10, S::npos); + test(S("mjqdgalkpc"), S("dplqa"), 10, S::npos); + test(S("kthqnfcerm"), S("dkacjoptns"), 10, S::npos); + test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos); + test(S("eqsgalomhb"), S(""), 11, S::npos); + test(S("akiteljmoh"), S("lofbc"), 11, S::npos); + test(S("hlbdfreqjo"), S("astoegbfpn"), 11, S::npos); + test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos); + test(S("snafbdlghrjkpqtoceim"), S(""), 0, S::npos); + test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 3); + test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 0); + test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, 0); + test(S("jlnkraeodhcspfgbqitm"), S(""), 1, S::npos); + test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 3); + test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 1); + test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, 1); + test(S("hdpkobnsalmcfijregtq"), S(""), 10, S::npos); + test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 10); + test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 10); + test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, 10); + test(S("niptglfbosehkamrdqcj"), S(""), 19, S::npos); + test(S("copqdhstbingamjfkler"), S("djkqc"), 19, S::npos); + test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 19); + test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, 19); + test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos); + test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, S::npos); + test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, S::npos); + test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos); + test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos); + test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, S::npos); + test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, S::npos); + test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos); +} + +template <class S> +void test1() +{ + test(S(""), S(""), S::npos); + test(S(""), S("laenf"), S::npos); + test(S(""), S("pqlnkmbdjo"), S::npos); + test(S(""), S("qkamfogpnljdcshbreti"), S::npos); + test(S("nhmko"), S(""), S::npos); + test(S("lahfb"), S("irkhs"), 2); + test(S("gmfhd"), S("kantesmpgj"), 0); + test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), 0); + test(S("eolhfgpjqk"), S(""), S::npos); + test(S("nbatdlmekr"), S("bnrpe"), 0); + test(S("jdmciepkaq"), S("jtdaefblso"), 0); + test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), 0); + test(S("gprdcokbnjhlsfmtieqa"), S(""), S::npos); + test(S("qjghlnftcaismkropdeb"), S("bjaht"), 1); + test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 0); + test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), 0); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.last.not.of/char_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.not.of/char_size.pass.cpp new file mode 100644 index 000000000000..b130f9287ba3 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.last.not.of/char_size.pass.cpp @@ -0,0 +1,98 @@ +//===----------------------------------------------------------------------===// +// +// 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 find_last_not_of(charT c, size_type pos = npos) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, typename S::value_type c, typename S::size_type pos, + typename S::size_type x) +{ + assert(s.find_last_not_of(c, pos) == x); + if (x != S::npos) + assert(x <= pos && x < s.size()); +} + +template <class S> +void +test(const S& s, typename S::value_type c, typename S::size_type x) +{ + assert(s.find_last_not_of(c) == x); + if (x != S::npos) + assert(x < s.size()); +} + +int main() +{ + { + typedef std::string S; + test(S(""), 'i', 0, S::npos); + test(S(""), 'i', 1, S::npos); + test(S("kitcj"), 'i', 0, 0); + test(S("qkamf"), 'i', 1, 1); + test(S("nhmko"), 'i', 2, 2); + test(S("tpsaf"), 'i', 4, 4); + test(S("lahfb"), 'i', 5, 4); + test(S("irkhs"), 'i', 6, 4); + test(S("gmfhdaipsr"), 'i', 0, 0); + test(S("kantesmpgj"), 'i', 1, 1); + test(S("odaftiegpm"), 'i', 5, 4); + test(S("oknlrstdpi"), 'i', 9, 8); + test(S("eolhfgpjqk"), 'i', 10, 9); + test(S("pcdrofikas"), 'i', 11, 9); + test(S("nbatdlmekrgcfqsophij"), 'i', 0, 0); + test(S("bnrpehidofmqtcksjgla"), 'i', 1, 1); + test(S("jdmciepkaqgotsrfnhlb"), 'i', 10, 10); + test(S("jtdaefblsokrmhpgcnqi"), 'i', 19, 18); + test(S("hkbgspofltajcnedqmri"), 'i', 20, 18); + test(S("oselktgbcapndfjihrmq"), 'i', 21, 19); + + test(S(""), 'i', S::npos); + test(S("csope"), 'i', 4); + test(S("gfsmthlkon"), 'i', 9); + test(S("laenfsbridchgotmkqpj"), 'i', 19); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), 'i', 0, S::npos); + test(S(""), 'i', 1, S::npos); + test(S("kitcj"), 'i', 0, 0); + test(S("qkamf"), 'i', 1, 1); + test(S("nhmko"), 'i', 2, 2); + test(S("tpsaf"), 'i', 4, 4); + test(S("lahfb"), 'i', 5, 4); + test(S("irkhs"), 'i', 6, 4); + test(S("gmfhdaipsr"), 'i', 0, 0); + test(S("kantesmpgj"), 'i', 1, 1); + test(S("odaftiegpm"), 'i', 5, 4); + test(S("oknlrstdpi"), 'i', 9, 8); + test(S("eolhfgpjqk"), 'i', 10, 9); + test(S("pcdrofikas"), 'i', 11, 9); + test(S("nbatdlmekrgcfqsophij"), 'i', 0, 0); + test(S("bnrpehidofmqtcksjgla"), 'i', 1, 1); + test(S("jdmciepkaqgotsrfnhlb"), 'i', 10, 10); + test(S("jtdaefblsokrmhpgcnqi"), 'i', 19, 18); + test(S("hkbgspofltajcnedqmri"), 'i', 20, 18); + test(S("oselktgbcapndfjihrmq"), 'i', 21, 19); + + test(S(""), 'i', S::npos); + test(S("csope"), 'i', 4); + test(S("gfsmthlkon"), 'i', 9); + test(S("laenfsbridchgotmkqpj"), 'i', 19); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size.pass.cpp new file mode 100644 index 000000000000..3e6bd9d093ea --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size.pass.cpp @@ -0,0 +1,158 @@ +//===----------------------------------------------------------------------===// +// +// 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 find_last_not_of(const charT* s, size_type pos = npos) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type pos, + typename S::size_type x) +{ + assert(s.find_last_not_of(str, pos) == x); + if (x != S::npos) + assert(x <= pos && x < s.size()); +} + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type x) +{ + assert(s.find_last_not_of(str) == x); + if (x != S::npos) + assert(x < s.size()); +} + +template <class S> +void test0() +{ + test(S(""), "", 0, S::npos); + test(S(""), "laenf", 0, S::npos); + test(S(""), "pqlnkmbdjo", 0, S::npos); + test(S(""), "qkamfogpnljdcshbreti", 0, S::npos); + test(S(""), "", 1, S::npos); + test(S(""), "bjaht", 1, S::npos); + test(S(""), "hjlcmgpket", 1, S::npos); + test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos); + test(S("fodgq"), "", 0, 0); + test(S("qanej"), "dfkap", 0, 0); + test(S("clbao"), "ihqrfebgad", 0, 0); + test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, S::npos); + test(S("srdfq"), "", 1, 1); + test(S("oemth"), "ikcrq", 1, 1); + test(S("cdaih"), "dmajblfhsg", 1, 0); + test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, S::npos); + test(S("cshmd"), "", 2, 2); + test(S("lhcdo"), "oebqi", 2, 2); + test(S("qnsoh"), "kojhpmbsfe", 2, 1); + test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, S::npos); + test(S("fmtsp"), "", 4, 4); + test(S("khbpm"), "aobjd", 4, 4); + test(S("pbsji"), "pcbahntsje", 4, 4); + test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, S::npos); + test(S("eqmpa"), "", 5, 4); + test(S("omigs"), "kocgb", 5, 4); + test(S("onmje"), "fbslrjiqkm", 5, 4); + test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos); + test(S("schfa"), "", 6, 4); + test(S("igdsc"), "qngpd", 6, 4); + test(S("brqgo"), "rodhqklgmb", 6, S::npos); + test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos); + test(S("hcjitbfapl"), "", 0, 0); + test(S("daiprenocl"), "ashjd", 0, S::npos); + test(S("litpcfdghe"), "mgojkldsqh", 0, S::npos); + test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, S::npos); + test(S("qpghtfbaji"), "", 1, 1); + test(S("gfshlcmdjr"), "nadkh", 1, 1); + test(S("nkodajteqp"), "ofdrqmkebl", 1, 0); + test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, S::npos); + test(S("crnklpmegd"), "", 5, 5); + test(S("jsbtafedoc"), "prqgn", 5, 5); + test(S("qnmodrtkeb"), "pejafmnokr", 5, 4); + test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, S::npos); + test(S("lmofqdhpki"), "", 9, 9); + test(S("hnefkqimca"), "rtjpa", 9, 8); + test(S("drtasbgmfp"), "ktsrmnqagd", 9, 9); + test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, S::npos); + test(S("elgofjmbrq"), "", 10, 9); + test(S("mjqdgalkpc"), "dplqa", 10, 9); + test(S("kthqnfcerm"), "dkacjoptns", 10, 9); + test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos); + test(S("eqsgalomhb"), "", 11, 9); + test(S("akiteljmoh"), "lofbc", 11, 9); + test(S("hlbdfreqjo"), "astoegbfpn", 11, 8); + test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos); + test(S("snafbdlghrjkpqtoceim"), "", 0, 0); + test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 0); + test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, S::npos); + test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, S::npos); + test(S("jlnkraeodhcspfgbqitm"), "", 1, 1); + test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 1); + test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 0); + test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, S::npos); + test(S("hdpkobnsalmcfijregtq"), "", 10, 10); + test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 9); + test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 9); + test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, S::npos); + test(S("niptglfbosehkamrdqcj"), "", 19, 19); + test(S("copqdhstbingamjfkler"), "djkqc", 19, 19); + test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 16); + test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, S::npos); + test(S("eaintpchlqsbdgrkjofm"), "", 20, 19); + test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, 18); + test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, 19); + test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos); + test(S("liatsqdoegkmfcnbhrpj"), "", 21, 19); + test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, 19); + test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, 19); + test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos); +} + +template <class S> +void test1() +{ + test(S(""), "", S::npos); + test(S(""), "laenf", S::npos); + test(S(""), "pqlnkmbdjo", S::npos); + test(S(""), "qkamfogpnljdcshbreti", S::npos); + test(S("nhmko"), "", 4); + test(S("lahfb"), "irkhs", 4); + test(S("gmfhd"), "kantesmpgj", 4); + test(S("odaft"), "oknlrstdpiqmjbaghcfe", S::npos); + test(S("eolhfgpjqk"), "", 9); + test(S("nbatdlmekr"), "bnrpe", 8); + test(S("jdmciepkaq"), "jtdaefblso", 9); + test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", S::npos); + test(S("gprdcokbnjhlsfmtieqa"), "", 19); + test(S("qjghlnftcaismkropdeb"), "bjaht", 18); + test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 17); + test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", S::npos); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size_size.pass.cpp new file mode 100644 index 000000000000..4db7762b2755 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size_size.pass.cpp @@ -0,0 +1,387 @@ +//===----------------------------------------------------------------------===// +// +// 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 find_last_not_of(const charT* s, size_type pos, size_type n) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type pos, + typename S::size_type n, typename S::size_type x) +{ + assert(s.find_last_not_of(str, pos, n) == x); + if (x != S::npos) + assert(x <= pos && x < s.size()); +} + +template <class S> +void test0() +{ + test(S(""), "", 0, 0, S::npos); + test(S(""), "irkhs", 0, 0, S::npos); + test(S(""), "kante", 0, 1, S::npos); + test(S(""), "oknlr", 0, 2, S::npos); + test(S(""), "pcdro", 0, 4, S::npos); + test(S(""), "bnrpe", 0, 5, S::npos); + test(S(""), "jtdaefblso", 0, 0, S::npos); + test(S(""), "oselktgbca", 0, 1, S::npos); + test(S(""), "eqgaplhckj", 0, 5, S::npos); + test(S(""), "bjahtcmnlp", 0, 9, S::npos); + test(S(""), "hjlcmgpket", 0, 10, S::npos); + test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos); + test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos); + test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos); + test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos); + test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos); + test(S(""), "", 1, 0, S::npos); + test(S(""), "lbtqd", 1, 0, S::npos); + test(S(""), "tboim", 1, 1, S::npos); + test(S(""), "slcer", 1, 2, S::npos); + test(S(""), "cbjfs", 1, 4, S::npos); + test(S(""), "aqibs", 1, 5, S::npos); + test(S(""), "gtfblmqinc", 1, 0, S::npos); + test(S(""), "mkqpbtdalg", 1, 1, S::npos); + test(S(""), "kphatlimcd", 1, 5, S::npos); + test(S(""), "pblasqogic", 1, 9, S::npos); + test(S(""), "arosdhcfme", 1, 10, S::npos); + test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos); + test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos); + test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos); + test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos); + test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos); + test(S("eaint"), "", 0, 0, 0); + test(S("binja"), "gfsrt", 0, 0, 0); + test(S("latkm"), "pfsoc", 0, 1, 0); + test(S("lecfr"), "tpflm", 0, 2, 0); + test(S("eqkst"), "sgkec", 0, 4, S::npos); + test(S("cdafr"), "romds", 0, 5, 0); + test(S("prbhe"), "qhjistlgmr", 0, 0, 0); + test(S("lbisk"), "pedfirsglo", 0, 1, 0); + test(S("hrlpd"), "aqcoslgrmk", 0, 5, 0); + test(S("ehmja"), "dabckmepqj", 0, 9, S::npos); + test(S("mhqgd"), "pqscrjthli", 0, 10, 0); + test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, 0); + test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, 0); + test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, 0); + test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, S::npos); + test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, S::npos); + test(S("clrgb"), "", 1, 0, 1); + test(S("tjmek"), "osmia", 1, 0, 1); + test(S("bgstp"), "ckonl", 1, 1, 1); + test(S("hstrk"), "ilcaj", 1, 2, 1); + test(S("kmspj"), "lasiq", 1, 4, 1); + test(S("tjboh"), "kfqmr", 1, 5, 1); + test(S("ilbcj"), "klnitfaobg", 1, 0, 1); + test(S("jkngf"), "gjhmdlqikp", 1, 1, 1); + test(S("gfcql"), "skbgtahqej", 1, 5, 1); + test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 1); + test(S("bthpg"), "bjgfmnlkio", 1, 10, 1); + test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, 1); + test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, 1); + test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, S::npos); + test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, S::npos); + test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, S::npos); + test(S("ndrhl"), "", 2, 0, 2); + test(S("mrecp"), "otkgb", 2, 0, 2); + test(S("qlasf"), "cqsjl", 2, 1, 2); + test(S("smaqd"), "dpifl", 2, 2, 2); + test(S("hjeni"), "oapht", 2, 4, 2); + test(S("ocmfj"), "cifts", 2, 5, 2); + test(S("hmftq"), "nmsckbgalo", 2, 0, 2); + test(S("fklad"), "tpksqhamle", 2, 1, 2); + test(S("dirnm"), "tpdrchmkji", 2, 5, 1); + test(S("hrgdc"), "ijagfkblst", 2, 9, 1); + test(S("ifakg"), "kpocsignjb", 2, 10, 2); + test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, 2); + test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, 2); + test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 2); + test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, S::npos); + test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, S::npos); + test(S("cjgao"), "", 4, 0, 4); + test(S("kjplq"), "mabns", 4, 0, 4); + test(S("herni"), "bdnrp", 4, 1, 4); + test(S("tadrb"), "scidp", 4, 2, 4); + test(S("pkfeo"), "agbjl", 4, 4, 4); + test(S("hoser"), "jfmpr", 4, 5, 3); + test(S("kgrsp"), "rbpefghsmj", 4, 0, 4); + test(S("pgejb"), "apsfntdoqc", 4, 1, 4); + test(S("thlnq"), "ndkjeisgcl", 4, 5, 4); + test(S("nbmit"), "rnfpqatdeo", 4, 9, 3); + test(S("jgmib"), "bntjlqrfik", 4, 10, 2); + test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, 4); + test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, 4); + test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 3); + test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 2); + test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, S::npos); + test(S("klopi"), "", 5, 0, 4); + test(S("dajhn"), "psthd", 5, 0, 4); + test(S("jbgno"), "rpmjd", 5, 1, 4); + test(S("hkjae"), "dfsmk", 5, 2, 4); +} + +template <class S> +void test1() +{ + test(S("gbhqo"), "skqne", 5, 4, 4); + test(S("ktdor"), "kipnf", 5, 5, 4); + test(S("ldprn"), "hmrnqdgifl", 5, 0, 4); + test(S("egmjk"), "fsmjcdairn", 5, 1, 4); + test(S("armql"), "pcdgltbrfj", 5, 5, 3); + test(S("cdhjo"), "aekfctpirg", 5, 9, 4); + test(S("jcons"), "ledihrsgpf", 5, 10, 3); + test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, 4); + test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, 4); + test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, 1); + test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, 2); + test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos); + test(S("gajqn"), "", 6, 0, 4); + test(S("stedk"), "hrnat", 6, 0, 4); + test(S("tjkaf"), "gsqdt", 6, 1, 4); + test(S("dthpe"), "bspkd", 6, 2, 4); + test(S("klhde"), "ohcmb", 6, 4, 4); + test(S("bhlki"), "heatr", 6, 5, 4); + test(S("lqmoh"), "pmblckedfn", 6, 0, 4); + test(S("mtqin"), "aceqmsrbik", 6, 1, 4); + test(S("dpqbr"), "lmbtdehjrn", 6, 5, 4); + test(S("kdhmo"), "teqmcrlgib", 6, 9, 4); + test(S("jblqp"), "njolbmspac", 6, 10, 3); + test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, 4); + test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, 4); + test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, 1); + test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos); + test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos); + test(S("jnkrfhotgl"), "", 0, 0, 0); + test(S("dltjfngbko"), "rqegt", 0, 0, 0); + test(S("bmjlpkiqde"), "dashm", 0, 1, 0); + test(S("skrflobnqm"), "jqirk", 0, 2, 0); + test(S("jkpldtshrm"), "rckeg", 0, 4, 0); + test(S("ghasdbnjqo"), "jscie", 0, 5, 0); + test(S("igrkhpbqjt"), "efsphndliq", 0, 0, 0); + test(S("ikthdgcamf"), "gdicosleja", 0, 1, 0); + test(S("pcofgeniam"), "qcpjibosfl", 0, 5, S::npos); + test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, S::npos); + test(S("itphbqsker"), "dtablcrseo", 0, 10, 0); + test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, 0); + test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, 0); + test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 0); + test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, S::npos); + test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, S::npos); + test(S("shbcqnmoar"), "", 1, 0, 1); + test(S("bdoshlmfin"), "ontrs", 1, 0, 1); + test(S("khfrebnsgq"), "pfkna", 1, 1, 1); + test(S("getcrsaoji"), "ekosa", 1, 2, 0); + test(S("fjiknedcpq"), "anqhk", 1, 4, 1); + test(S("tkejgnafrm"), "jekca", 1, 5, 0); + test(S("jnakolqrde"), "ikemsjgacf", 1, 0, 1); + test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, 1); + test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 0); + test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 1); + test(S("cigfqkated"), "sqcflrgtim", 1, 10, S::npos); + test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, 1); + test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, 1); + test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, S::npos); + test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, S::npos); + test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, S::npos); + test(S("ectnhskflp"), "", 5, 0, 5); + test(S("fgtianblpq"), "pijag", 5, 0, 5); + test(S("mfeqklirnh"), "jrckd", 5, 1, 5); + test(S("astedncjhk"), "qcloh", 5, 2, 5); + test(S("fhlqgcajbr"), "thlmp", 5, 4, 5); + test(S("epfhocmdng"), "qidmo", 5, 5, 5); + test(S("apcnsibger"), "lnegpsjqrd", 5, 0, 5); + test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 4); + test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 5); + test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 3); + test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 5); + test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, 5); + test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, 5); + test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 1); + test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, S::npos); + test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, S::npos); + test(S("shoiedtcjb"), "", 9, 0, 9); + test(S("ebcinjgads"), "tqbnh", 9, 0, 9); + test(S("dqmregkcfl"), "akmle", 9, 1, 9); + test(S("ngcrieqajf"), "iqfkm", 9, 2, 9); + test(S("qosmilgnjb"), "tqjsr", 9, 4, 9); + test(S("ikabsjtdfl"), "jplqg", 9, 5, 8); + test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, 9); + test(S("fdnplotmgh"), "morkglpesn", 9, 1, 9); + test(S("fdbicojerm"), "dmicerngat", 9, 5, 8); + test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 9); + test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 9); + test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, 9); + test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 9); + test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 9); + test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 3); + test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, S::npos); + test(S("ncjpmaekbs"), "", 10, 0, 9); + test(S("hlbosgmrak"), "hpmsd", 10, 0, 9); + test(S("pqfhsgilen"), "qnpor", 10, 1, 9); + test(S("gqtjsbdckh"), "otdma", 10, 2, 9); + test(S("cfkqpjlegi"), "efhjg", 10, 4, 9); + test(S("beanrfodgj"), "odpte", 10, 5, 9); + test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, 9); + test(S("iomkfthagj"), "oaklidrbqg", 10, 1, 9); +} + +template <class S> +void test2() +{ + test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, 8); + test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, 9); + test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, 8); + test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, 9); + test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, 9); + test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, 7); + test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, 5); + test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos); + test(S("cqjohampgd"), "", 11, 0, 9); + test(S("hobitmpsan"), "aocjb", 11, 0, 9); + test(S("tjehkpsalm"), "jbrnk", 11, 1, 9); + test(S("ngfbojitcl"), "tqedg", 11, 2, 9); + test(S("rcfkdbhgjo"), "nqskp", 11, 4, 9); + test(S("qghptonrea"), "eaqkl", 11, 5, 7); + test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, 9); + test(S("hlmgabenti"), "lsftgajqpm", 11, 1, 9); + test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, 9); + test(S("jqedtkornm"), "shkncmiaqj", 11, 9, 7); + test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, 8); + test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, 9); + test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, 9); + test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, 8); + test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos); + test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos); + test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, 0); + test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, 0); + test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 0); + test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 0); + test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 0); + test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 0); + test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, 0); + test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 0); + test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 0); + test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 0); + test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 0); + test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, 0); + test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 0); + test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 0); + test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, S::npos); + test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, S::npos); + test(S("febhmqtjanokscdirpgl"), "", 1, 0, 1); + test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, 1); + test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 1); + test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 0); + test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 0); + test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 1); + test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, 1); + test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 1); + test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 1); + test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 0); + test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 0); + test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, 1); + test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 1); + test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 0); + test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, S::npos); + test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, S::npos); + test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, 10); + test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, 10); + test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 10); + test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 10); + test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 9); + test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 10); + test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, 10); + test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 10); + test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 10); + test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 8); + test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 10); + test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, 10); + test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 10); + test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 8); + test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, S::npos); + test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, S::npos); + test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, 19); + test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, 19); + test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 19); + test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 19); + test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 19); + test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 17); + test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, 19); + test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 19); + test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 19); + test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 19); + test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 19); + test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, 19); + test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 19); + test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 18); + test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 7); + test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, S::npos); + test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, 19); + test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, 19); + test(S("grkpahljcftesdmonqib"), "odife", 20, 1, 19); + test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, 19); + test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, 18); + test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, 18); + test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, 19); + test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, 19); + test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, 18); + test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, 18); + test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, 17); + test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, 19); +} + +template <class S> +void test3() +{ + test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, 19); + test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, 19); + test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, 1); + test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos); + test(S("ecgdanriptblhjfqskom"), "", 21, 0, 19); + test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, 19); + test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, 19); + test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, 19); + test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, 19); + test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, 19); + test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, 19); + test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, 19); + test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, 18); + test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, 19); + test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, 19); + test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, 19); + test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, 19); + test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, 19); + test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, 7); + test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp new file mode 100644 index 000000000000..ba93adbe445e --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp @@ -0,0 +1,157 @@ +//===----------------------------------------------------------------------===// +// +// 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 find_last_not_of(const basic_string& str, size_type pos = npos) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x) +{ + assert(s.find_last_not_of(str, pos) == x); + if (x != S::npos) + assert(x <= pos && x < s.size()); +} + +template <class S> +void +test(const S& s, const S& str, typename S::size_type x) +{ + assert(s.find_last_not_of(str) == x); + if (x != S::npos) + assert(x < s.size()); +} + +template <class S> +void test0() +{ + test(S(""), S(""), 0, S::npos); + test(S(""), S("laenf"), 0, S::npos); + test(S(""), S("pqlnkmbdjo"), 0, S::npos); + test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos); + test(S(""), S(""), 1, S::npos); + test(S(""), S("bjaht"), 1, S::npos); + test(S(""), S("hjlcmgpket"), 1, S::npos); + test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos); + test(S("fodgq"), S(""), 0, 0); + test(S("qanej"), S("dfkap"), 0, 0); + test(S("clbao"), S("ihqrfebgad"), 0, 0); + test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, S::npos); + test(S("srdfq"), S(""), 1, 1); + test(S("oemth"), S("ikcrq"), 1, 1); + test(S("cdaih"), S("dmajblfhsg"), 1, 0); + test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, S::npos); + test(S("cshmd"), S(""), 2, 2); + test(S("lhcdo"), S("oebqi"), 2, 2); + test(S("qnsoh"), S("kojhpmbsfe"), 2, 1); + test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, S::npos); + test(S("fmtsp"), S(""), 4, 4); + test(S("khbpm"), S("aobjd"), 4, 4); + test(S("pbsji"), S("pcbahntsje"), 4, 4); + test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, S::npos); + test(S("eqmpa"), S(""), 5, 4); + test(S("omigs"), S("kocgb"), 5, 4); + test(S("onmje"), S("fbslrjiqkm"), 5, 4); + test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos); + test(S("schfa"), S(""), 6, 4); + test(S("igdsc"), S("qngpd"), 6, 4); + test(S("brqgo"), S("rodhqklgmb"), 6, S::npos); + test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos); + test(S("hcjitbfapl"), S(""), 0, 0); + test(S("daiprenocl"), S("ashjd"), 0, S::npos); + test(S("litpcfdghe"), S("mgojkldsqh"), 0, S::npos); + test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, S::npos); + test(S("qpghtfbaji"), S(""), 1, 1); + test(S("gfshlcmdjr"), S("nadkh"), 1, 1); + test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 0); + test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, S::npos); + test(S("crnklpmegd"), S(""), 5, 5); + test(S("jsbtafedoc"), S("prqgn"), 5, 5); + test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 4); + test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, S::npos); + test(S("lmofqdhpki"), S(""), 9, 9); + test(S("hnefkqimca"), S("rtjpa"), 9, 8); + test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 9); + test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, S::npos); + test(S("elgofjmbrq"), S(""), 10, 9); + test(S("mjqdgalkpc"), S("dplqa"), 10, 9); + test(S("kthqnfcerm"), S("dkacjoptns"), 10, 9); + test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos); + test(S("eqsgalomhb"), S(""), 11, 9); + test(S("akiteljmoh"), S("lofbc"), 11, 9); + test(S("hlbdfreqjo"), S("astoegbfpn"), 11, 8); + test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos); + test(S("snafbdlghrjkpqtoceim"), S(""), 0, 0); + test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 0); + test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, S::npos); + test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, S::npos); + test(S("jlnkraeodhcspfgbqitm"), S(""), 1, 1); + test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 1); + test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 0); + test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, S::npos); + test(S("hdpkobnsalmcfijregtq"), S(""), 10, 10); + test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 9); + test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 9); + test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, S::npos); + test(S("niptglfbosehkamrdqcj"), S(""), 19, 19); + test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 19); + test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 16); + test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, S::npos); + test(S("eaintpchlqsbdgrkjofm"), S(""), 20, 19); + test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, 18); + test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, 19); + test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos); + test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, 19); + test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, 19); + test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, 19); + test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos); +} + +template <class S> +void test1() +{ + test(S(""), S(""), S::npos); + test(S(""), S("laenf"), S::npos); + test(S(""), S("pqlnkmbdjo"), S::npos); + test(S(""), S("qkamfogpnljdcshbreti"), S::npos); + test(S("nhmko"), S(""), 4); + test(S("lahfb"), S("irkhs"), 4); + test(S("gmfhd"), S("kantesmpgj"), 4); + test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), S::npos); + test(S("eolhfgpjqk"), S(""), 9); + test(S("nbatdlmekr"), S("bnrpe"), 8); + test(S("jdmciepkaq"), S("jtdaefblso"), 9); + test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), S::npos); + test(S("gprdcokbnjhlsfmtieqa"), S(""), 19); + test(S("qjghlnftcaismkropdeb"), S("bjaht"), 18); + test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 17); + test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), S::npos); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.last.of/char_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.of/char_size.pass.cpp new file mode 100644 index 000000000000..12765b71f28f --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.last.of/char_size.pass.cpp @@ -0,0 +1,98 @@ +//===----------------------------------------------------------------------===// +// +// 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 find_last_of(charT c, size_type pos = npos) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, typename S::value_type c, typename S::size_type pos, + typename S::size_type x) +{ + assert(s.find_last_of(c, pos) == x); + if (x != S::npos) + assert(x <= pos && x < s.size()); +} + +template <class S> +void +test(const S& s, typename S::value_type c, typename S::size_type x) +{ + assert(s.find_last_of(c) == x); + if (x != S::npos) + assert(x < s.size()); +} + +int main() +{ + { + typedef std::string S; + test(S(""), 'm', 0, S::npos); + test(S(""), 'm', 1, S::npos); + test(S("kitcj"), 'm', 0, S::npos); + test(S("qkamf"), 'm', 1, S::npos); + test(S("nhmko"), 'm', 2, 2); + test(S("tpsaf"), 'm', 4, S::npos); + test(S("lahfb"), 'm', 5, S::npos); + test(S("irkhs"), 'm', 6, S::npos); + test(S("gmfhdaipsr"), 'm', 0, S::npos); + test(S("kantesmpgj"), 'm', 1, S::npos); + test(S("odaftiegpm"), 'm', 5, S::npos); + test(S("oknlrstdpi"), 'm', 9, S::npos); + test(S("eolhfgpjqk"), 'm', 10, S::npos); + test(S("pcdrofikas"), 'm', 11, S::npos); + test(S("nbatdlmekrgcfqsophij"), 'm', 0, S::npos); + test(S("bnrpehidofmqtcksjgla"), 'm', 1, S::npos); + test(S("jdmciepkaqgotsrfnhlb"), 'm', 10, 2); + test(S("jtdaefblsokrmhpgcnqi"), 'm', 19, 12); + test(S("hkbgspofltajcnedqmri"), 'm', 20, 17); + test(S("oselktgbcapndfjihrmq"), 'm', 21, 18); + + test(S(""), 'm', S::npos); + test(S("csope"), 'm', S::npos); + test(S("gfsmthlkon"), 'm', 3); + test(S("laenfsbridchgotmkqpj"), 'm', 15); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), 'm', 0, S::npos); + test(S(""), 'm', 1, S::npos); + test(S("kitcj"), 'm', 0, S::npos); + test(S("qkamf"), 'm', 1, S::npos); + test(S("nhmko"), 'm', 2, 2); + test(S("tpsaf"), 'm', 4, S::npos); + test(S("lahfb"), 'm', 5, S::npos); + test(S("irkhs"), 'm', 6, S::npos); + test(S("gmfhdaipsr"), 'm', 0, S::npos); + test(S("kantesmpgj"), 'm', 1, S::npos); + test(S("odaftiegpm"), 'm', 5, S::npos); + test(S("oknlrstdpi"), 'm', 9, S::npos); + test(S("eolhfgpjqk"), 'm', 10, S::npos); + test(S("pcdrofikas"), 'm', 11, S::npos); + test(S("nbatdlmekrgcfqsophij"), 'm', 0, S::npos); + test(S("bnrpehidofmqtcksjgla"), 'm', 1, S::npos); + test(S("jdmciepkaqgotsrfnhlb"), 'm', 10, 2); + test(S("jtdaefblsokrmhpgcnqi"), 'm', 19, 12); + test(S("hkbgspofltajcnedqmri"), 'm', 20, 17); + test(S("oselktgbcapndfjihrmq"), 'm', 21, 18); + + test(S(""), 'm', S::npos); + test(S("csope"), 'm', S::npos); + test(S("gfsmthlkon"), 'm', 3); + test(S("laenfsbridchgotmkqpj"), 'm', 15); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size.pass.cpp new file mode 100644 index 000000000000..f1b447c43f4b --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size.pass.cpp @@ -0,0 +1,158 @@ +//===----------------------------------------------------------------------===// +// +// 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 find_last_of(const charT* s, size_type pos = npos) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type pos, + typename S::size_type x) +{ + assert(s.find_last_of(str, pos) == x); + if (x != S::npos) + assert(x <= pos && x < s.size()); +} + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type x) +{ + assert(s.find_last_of(str) == x); + if (x != S::npos) + assert(x < s.size()); +} + +template <class S> +void test0() +{ + test(S(""), "", 0, S::npos); + test(S(""), "laenf", 0, S::npos); + test(S(""), "pqlnkmbdjo", 0, S::npos); + test(S(""), "qkamfogpnljdcshbreti", 0, S::npos); + test(S(""), "", 1, S::npos); + test(S(""), "bjaht", 1, S::npos); + test(S(""), "hjlcmgpket", 1, S::npos); + test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos); + test(S("fodgq"), "", 0, S::npos); + test(S("qanej"), "dfkap", 0, S::npos); + test(S("clbao"), "ihqrfebgad", 0, S::npos); + test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, 0); + test(S("srdfq"), "", 1, S::npos); + test(S("oemth"), "ikcrq", 1, S::npos); + test(S("cdaih"), "dmajblfhsg", 1, 1); + test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, 1); + test(S("cshmd"), "", 2, S::npos); + test(S("lhcdo"), "oebqi", 2, S::npos); + test(S("qnsoh"), "kojhpmbsfe", 2, 2); + test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, 2); + test(S("fmtsp"), "", 4, S::npos); + test(S("khbpm"), "aobjd", 4, 2); + test(S("pbsji"), "pcbahntsje", 4, 3); + test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, 4); + test(S("eqmpa"), "", 5, S::npos); + test(S("omigs"), "kocgb", 5, 3); + test(S("onmje"), "fbslrjiqkm", 5, 3); + test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, 4); + test(S("schfa"), "", 6, S::npos); + test(S("igdsc"), "qngpd", 6, 2); + test(S("brqgo"), "rodhqklgmb", 6, 4); + test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, 4); + test(S("hcjitbfapl"), "", 0, S::npos); + test(S("daiprenocl"), "ashjd", 0, 0); + test(S("litpcfdghe"), "mgojkldsqh", 0, 0); + test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, 0); + test(S("qpghtfbaji"), "", 1, S::npos); + test(S("gfshlcmdjr"), "nadkh", 1, S::npos); + test(S("nkodajteqp"), "ofdrqmkebl", 1, 1); + test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, 1); + test(S("crnklpmegd"), "", 5, S::npos); + test(S("jsbtafedoc"), "prqgn", 5, S::npos); + test(S("qnmodrtkeb"), "pejafmnokr", 5, 5); + test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, 5); + test(S("lmofqdhpki"), "", 9, S::npos); + test(S("hnefkqimca"), "rtjpa", 9, 9); + test(S("drtasbgmfp"), "ktsrmnqagd", 9, 7); + test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, 9); + test(S("elgofjmbrq"), "", 10, S::npos); + test(S("mjqdgalkpc"), "dplqa", 10, 8); + test(S("kthqnfcerm"), "dkacjoptns", 10, 6); + test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, 9); + test(S("eqsgalomhb"), "", 11, S::npos); + test(S("akiteljmoh"), "lofbc", 11, 8); + test(S("hlbdfreqjo"), "astoegbfpn", 11, 9); + test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, 9); + test(S("snafbdlghrjkpqtoceim"), "", 0, S::npos); + test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, S::npos); + test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 0); + test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, 0); + test(S("jlnkraeodhcspfgbqitm"), "", 1, S::npos); + test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, S::npos); + test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 1); + test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, 1); + test(S("hdpkobnsalmcfijregtq"), "", 10, S::npos); + test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 10); + test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 10); + test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, 10); + test(S("niptglfbosehkamrdqcj"), "", 19, S::npos); + test(S("copqdhstbingamjfkler"), "djkqc", 19, 16); + test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 19); + test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, 19); + test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos); + test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, 19); + test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, 18); + test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, 19); + test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos); + test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, 12); + test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, 17); + test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, 19); +} + +template <class S> +void test1() +{ + test(S(""), "", S::npos); + test(S(""), "laenf", S::npos); + test(S(""), "pqlnkmbdjo", S::npos); + test(S(""), "qkamfogpnljdcshbreti", S::npos); + test(S("nhmko"), "", S::npos); + test(S("lahfb"), "irkhs", 2); + test(S("gmfhd"), "kantesmpgj", 1); + test(S("odaft"), "oknlrstdpiqmjbaghcfe", 4); + test(S("eolhfgpjqk"), "", S::npos); + test(S("nbatdlmekr"), "bnrpe", 9); + test(S("jdmciepkaq"), "jtdaefblso", 8); + test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", 9); + test(S("gprdcokbnjhlsfmtieqa"), "", S::npos); + test(S("qjghlnftcaismkropdeb"), "bjaht", 19); + test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 19); + test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", 19); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size_size.pass.cpp new file mode 100644 index 000000000000..7f96e6351aa6 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size_size.pass.cpp @@ -0,0 +1,387 @@ +//===----------------------------------------------------------------------===// +// +// 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 find_last_of(const charT* s, size_type pos, size_type n) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type pos, + typename S::size_type n, typename S::size_type x) +{ + assert(s.find_last_of(str, pos, n) == x); + if (x != S::npos) + assert(x <= pos && x < s.size()); +} + +template <class S> +void test0() +{ + test(S(""), "", 0, 0, S::npos); + test(S(""), "irkhs", 0, 0, S::npos); + test(S(""), "kante", 0, 1, S::npos); + test(S(""), "oknlr", 0, 2, S::npos); + test(S(""), "pcdro", 0, 4, S::npos); + test(S(""), "bnrpe", 0, 5, S::npos); + test(S(""), "jtdaefblso", 0, 0, S::npos); + test(S(""), "oselktgbca", 0, 1, S::npos); + test(S(""), "eqgaplhckj", 0, 5, S::npos); + test(S(""), "bjahtcmnlp", 0, 9, S::npos); + test(S(""), "hjlcmgpket", 0, 10, S::npos); + test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos); + test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos); + test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos); + test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos); + test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos); + test(S(""), "", 1, 0, S::npos); + test(S(""), "lbtqd", 1, 0, S::npos); + test(S(""), "tboim", 1, 1, S::npos); + test(S(""), "slcer", 1, 2, S::npos); + test(S(""), "cbjfs", 1, 4, S::npos); + test(S(""), "aqibs", 1, 5, S::npos); + test(S(""), "gtfblmqinc", 1, 0, S::npos); + test(S(""), "mkqpbtdalg", 1, 1, S::npos); + test(S(""), "kphatlimcd", 1, 5, S::npos); + test(S(""), "pblasqogic", 1, 9, S::npos); + test(S(""), "arosdhcfme", 1, 10, S::npos); + test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos); + test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos); + test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos); + test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos); + test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos); + test(S("eaint"), "", 0, 0, S::npos); + test(S("binja"), "gfsrt", 0, 0, S::npos); + test(S("latkm"), "pfsoc", 0, 1, S::npos); + test(S("lecfr"), "tpflm", 0, 2, S::npos); + test(S("eqkst"), "sgkec", 0, 4, 0); + test(S("cdafr"), "romds", 0, 5, S::npos); + test(S("prbhe"), "qhjistlgmr", 0, 0, S::npos); + test(S("lbisk"), "pedfirsglo", 0, 1, S::npos); + test(S("hrlpd"), "aqcoslgrmk", 0, 5, S::npos); + test(S("ehmja"), "dabckmepqj", 0, 9, 0); + test(S("mhqgd"), "pqscrjthli", 0, 10, S::npos); + test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, S::npos); + test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, S::npos); + test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, S::npos); + test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, 0); + test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, 0); + test(S("clrgb"), "", 1, 0, S::npos); + test(S("tjmek"), "osmia", 1, 0, S::npos); + test(S("bgstp"), "ckonl", 1, 1, S::npos); + test(S("hstrk"), "ilcaj", 1, 2, S::npos); + test(S("kmspj"), "lasiq", 1, 4, S::npos); + test(S("tjboh"), "kfqmr", 1, 5, S::npos); + test(S("ilbcj"), "klnitfaobg", 1, 0, S::npos); + test(S("jkngf"), "gjhmdlqikp", 1, 1, S::npos); + test(S("gfcql"), "skbgtahqej", 1, 5, 0); + test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 0); + test(S("bthpg"), "bjgfmnlkio", 1, 10, 0); + test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, S::npos); + test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, S::npos); + test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 1); + test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, 1); + test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, 1); + test(S("ndrhl"), "", 2, 0, S::npos); + test(S("mrecp"), "otkgb", 2, 0, S::npos); + test(S("qlasf"), "cqsjl", 2, 1, S::npos); + test(S("smaqd"), "dpifl", 2, 2, S::npos); + test(S("hjeni"), "oapht", 2, 4, 0); + test(S("ocmfj"), "cifts", 2, 5, 1); + test(S("hmftq"), "nmsckbgalo", 2, 0, S::npos); + test(S("fklad"), "tpksqhamle", 2, 1, S::npos); + test(S("dirnm"), "tpdrchmkji", 2, 5, 2); + test(S("hrgdc"), "ijagfkblst", 2, 9, 2); + test(S("ifakg"), "kpocsignjb", 2, 10, 0); + test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, S::npos); + test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, S::npos); + test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 1); + test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, 2); + test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, 2); + test(S("cjgao"), "", 4, 0, S::npos); + test(S("kjplq"), "mabns", 4, 0, S::npos); + test(S("herni"), "bdnrp", 4, 1, S::npos); + test(S("tadrb"), "scidp", 4, 2, S::npos); + test(S("pkfeo"), "agbjl", 4, 4, S::npos); + test(S("hoser"), "jfmpr", 4, 5, 4); + test(S("kgrsp"), "rbpefghsmj", 4, 0, S::npos); + test(S("pgejb"), "apsfntdoqc", 4, 1, S::npos); + test(S("thlnq"), "ndkjeisgcl", 4, 5, 3); + test(S("nbmit"), "rnfpqatdeo", 4, 9, 4); + test(S("jgmib"), "bntjlqrfik", 4, 10, 4); + test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, S::npos); + test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, S::npos); + test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 4); + test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 4); + test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, 4); + test(S("klopi"), "", 5, 0, S::npos); + test(S("dajhn"), "psthd", 5, 0, S::npos); + test(S("jbgno"), "rpmjd", 5, 1, S::npos); + test(S("hkjae"), "dfsmk", 5, 2, S::npos); +} + +template <class S> +void test1() +{ + test(S("gbhqo"), "skqne", 5, 4, 3); + test(S("ktdor"), "kipnf", 5, 5, 0); + test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos); + test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos); + test(S("armql"), "pcdgltbrfj", 5, 5, 4); + test(S("cdhjo"), "aekfctpirg", 5, 9, 0); + test(S("jcons"), "ledihrsgpf", 5, 10, 4); + test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos); + test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos); + test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, 4); + test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, 4); + test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, 4); + test(S("gajqn"), "", 6, 0, S::npos); + test(S("stedk"), "hrnat", 6, 0, S::npos); + test(S("tjkaf"), "gsqdt", 6, 1, S::npos); + test(S("dthpe"), "bspkd", 6, 2, S::npos); + test(S("klhde"), "ohcmb", 6, 4, 2); + test(S("bhlki"), "heatr", 6, 5, 1); + test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos); + test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos); + test(S("dpqbr"), "lmbtdehjrn", 6, 5, 3); + test(S("kdhmo"), "teqmcrlgib", 6, 9, 3); + test(S("jblqp"), "njolbmspac", 6, 10, 4); + test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos); + test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos); + test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, 4); + test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, 4); + test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, 4); + test(S("jnkrfhotgl"), "", 0, 0, S::npos); + test(S("dltjfngbko"), "rqegt", 0, 0, S::npos); + test(S("bmjlpkiqde"), "dashm", 0, 1, S::npos); + test(S("skrflobnqm"), "jqirk", 0, 2, S::npos); + test(S("jkpldtshrm"), "rckeg", 0, 4, S::npos); + test(S("ghasdbnjqo"), "jscie", 0, 5, S::npos); + test(S("igrkhpbqjt"), "efsphndliq", 0, 0, S::npos); + test(S("ikthdgcamf"), "gdicosleja", 0, 1, S::npos); + test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 0); + test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 0); + test(S("itphbqsker"), "dtablcrseo", 0, 10, S::npos); + test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, S::npos); + test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, S::npos); + test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, S::npos); + test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 0); + test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, 0); + test(S("shbcqnmoar"), "", 1, 0, S::npos); + test(S("bdoshlmfin"), "ontrs", 1, 0, S::npos); + test(S("khfrebnsgq"), "pfkna", 1, 1, S::npos); + test(S("getcrsaoji"), "ekosa", 1, 2, 1); + test(S("fjiknedcpq"), "anqhk", 1, 4, S::npos); + test(S("tkejgnafrm"), "jekca", 1, 5, 1); + test(S("jnakolqrde"), "ikemsjgacf", 1, 0, S::npos); + test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, S::npos); + test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 1); + test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 0); + test(S("cigfqkated"), "sqcflrgtim", 1, 10, 1); + test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, S::npos); + test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, S::npos); + test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 1); + test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 1); + test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, 1); + test(S("ectnhskflp"), "", 5, 0, S::npos); + test(S("fgtianblpq"), "pijag", 5, 0, S::npos); + test(S("mfeqklirnh"), "jrckd", 5, 1, S::npos); + test(S("astedncjhk"), "qcloh", 5, 2, S::npos); + test(S("fhlqgcajbr"), "thlmp", 5, 4, 2); + test(S("epfhocmdng"), "qidmo", 5, 5, 4); + test(S("apcnsibger"), "lnegpsjqrd", 5, 0, S::npos); + test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 5); + test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, S::npos); + test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 5); + test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 4); + test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, S::npos); + test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, S::npos); + test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 5); + test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 5); + test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, 5); + test(S("shoiedtcjb"), "", 9, 0, S::npos); + test(S("ebcinjgads"), "tqbnh", 9, 0, S::npos); + test(S("dqmregkcfl"), "akmle", 9, 1, S::npos); + test(S("ngcrieqajf"), "iqfkm", 9, 2, 6); + test(S("qosmilgnjb"), "tqjsr", 9, 4, 8); + test(S("ikabsjtdfl"), "jplqg", 9, 5, 9); + test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, S::npos); + test(S("fdnplotmgh"), "morkglpesn", 9, 1, 7); + test(S("fdbicojerm"), "dmicerngat", 9, 5, 9); + test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 6); + test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 5); + test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, S::npos); + test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 6); + test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 7); + test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 9); + test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, 9); + test(S("ncjpmaekbs"), "", 10, 0, S::npos); + test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos); + test(S("pqfhsgilen"), "qnpor", 10, 1, 1); + test(S("gqtjsbdckh"), "otdma", 10, 2, 2); + test(S("cfkqpjlegi"), "efhjg", 10, 4, 7); + test(S("beanrfodgj"), "odpte", 10, 5, 7); + test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos); + test(S("iomkfthagj"), "oaklidrbqg", 10, 1, 1); +} + +template <class S> +void test2() +{ + test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, 9); + test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, 8); + test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, 9); + test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos); + test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, 8); + test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, 9); + test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, 9); + test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, 9); + test(S("cqjohampgd"), "", 11, 0, S::npos); + test(S("hobitmpsan"), "aocjb", 11, 0, S::npos); + test(S("tjehkpsalm"), "jbrnk", 11, 1, 1); + test(S("ngfbojitcl"), "tqedg", 11, 2, 7); + test(S("rcfkdbhgjo"), "nqskp", 11, 4, 3); + test(S("qghptonrea"), "eaqkl", 11, 5, 9); + test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos); + test(S("hlmgabenti"), "lsftgajqpm", 11, 1, 1); + test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, 7); + test(S("jqedtkornm"), "shkncmiaqj", 11, 9, 9); + test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, 9); + test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos); + test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos); + test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, 9); + test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, 9); + test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, 9); + test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, S::npos); + test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, S::npos); + test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, S::npos); + test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, S::npos); + test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, S::npos); + test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, S::npos); + test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, S::npos); + test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, S::npos); + test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, S::npos); + test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, S::npos); + test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, S::npos); + test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, S::npos); + test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, S::npos); + test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, S::npos); + test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 0); + test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, 0); + test(S("febhmqtjanokscdirpgl"), "", 1, 0, S::npos); + test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, S::npos); + test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, S::npos); + test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 1); + test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 1); + test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, S::npos); + test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, S::npos); + test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, S::npos); + test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, S::npos); + test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 1); + test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 1); + test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, S::npos); + test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, S::npos); + test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 1); + test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 1); + test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, 1); + test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, S::npos); + test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, S::npos); + test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, S::npos); + test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 7); + test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 10); + test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 6); + test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, S::npos); + test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 9); + test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 5); + test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 10); + test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 9); + test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, S::npos); + test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, S::npos); + test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 10); + test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 10); + test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, 10); + test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, S::npos); + test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, S::npos); + test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 16); + test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 7); + test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 16); + test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 19); + test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, S::npos); + test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 15); + test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 17); + test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 16); + test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 16); + test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, S::npos); + test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 10); + test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 19); + test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 19); + test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, 19); + test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos); + test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos); + test(S("grkpahljcftesdmonqib"), "odife", 20, 1, 15); + test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, 12); + test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, 19); + test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, 19); + test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos); + test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, 3); + test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, 19); + test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, 19); + test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, 19); + test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos); +} + +template <class S> +void test3() +{ + test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, 4); + test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, 17); + test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, 19); + test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, 19); + test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos); + test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos); + test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, 6); + test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, 13); + test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, 10); + test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, 17); + test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos); + test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, 14); + test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, 19); + test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, 14); + test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, 16); + test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos); + test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, 17); + test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, 17); + test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, 19); + test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, 19); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp new file mode 100644 index 000000000000..351c6727de2d --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp @@ -0,0 +1,157 @@ +//===----------------------------------------------------------------------===// +// +// 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 find_last_of(const basic_string& str, size_type pos = npos) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x) +{ + assert(s.find_last_of(str, pos) == x); + if (x != S::npos) + assert(x <= pos && x < s.size()); +} + +template <class S> +void +test(const S& s, const S& str, typename S::size_type x) +{ + assert(s.find_last_of(str) == x); + if (x != S::npos) + assert(x < s.size()); +} + +template <class S> +void test0() +{ + test(S(""), S(""), 0, S::npos); + test(S(""), S("laenf"), 0, S::npos); + test(S(""), S("pqlnkmbdjo"), 0, S::npos); + test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos); + test(S(""), S(""), 1, S::npos); + test(S(""), S("bjaht"), 1, S::npos); + test(S(""), S("hjlcmgpket"), 1, S::npos); + test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos); + test(S("fodgq"), S(""), 0, S::npos); + test(S("qanej"), S("dfkap"), 0, S::npos); + test(S("clbao"), S("ihqrfebgad"), 0, S::npos); + test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, 0); + test(S("srdfq"), S(""), 1, S::npos); + test(S("oemth"), S("ikcrq"), 1, S::npos); + test(S("cdaih"), S("dmajblfhsg"), 1, 1); + test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, 1); + test(S("cshmd"), S(""), 2, S::npos); + test(S("lhcdo"), S("oebqi"), 2, S::npos); + test(S("qnsoh"), S("kojhpmbsfe"), 2, 2); + test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, 2); + test(S("fmtsp"), S(""), 4, S::npos); + test(S("khbpm"), S("aobjd"), 4, 2); + test(S("pbsji"), S("pcbahntsje"), 4, 3); + test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, 4); + test(S("eqmpa"), S(""), 5, S::npos); + test(S("omigs"), S("kocgb"), 5, 3); + test(S("onmje"), S("fbslrjiqkm"), 5, 3); + test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, 4); + test(S("schfa"), S(""), 6, S::npos); + test(S("igdsc"), S("qngpd"), 6, 2); + test(S("brqgo"), S("rodhqklgmb"), 6, 4); + test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, 4); + test(S("hcjitbfapl"), S(""), 0, S::npos); + test(S("daiprenocl"), S("ashjd"), 0, 0); + test(S("litpcfdghe"), S("mgojkldsqh"), 0, 0); + test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, 0); + test(S("qpghtfbaji"), S(""), 1, S::npos); + test(S("gfshlcmdjr"), S("nadkh"), 1, S::npos); + test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 1); + test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, 1); + test(S("crnklpmegd"), S(""), 5, S::npos); + test(S("jsbtafedoc"), S("prqgn"), 5, S::npos); + test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 5); + test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, 5); + test(S("lmofqdhpki"), S(""), 9, S::npos); + test(S("hnefkqimca"), S("rtjpa"), 9, 9); + test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 7); + test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, 9); + test(S("elgofjmbrq"), S(""), 10, S::npos); + test(S("mjqdgalkpc"), S("dplqa"), 10, 8); + test(S("kthqnfcerm"), S("dkacjoptns"), 10, 6); + test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, 9); + test(S("eqsgalomhb"), S(""), 11, S::npos); + test(S("akiteljmoh"), S("lofbc"), 11, 8); + test(S("hlbdfreqjo"), S("astoegbfpn"), 11, 9); + test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, 9); + test(S("snafbdlghrjkpqtoceim"), S(""), 0, S::npos); + test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, S::npos); + test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 0); + test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, 0); + test(S("jlnkraeodhcspfgbqitm"), S(""), 1, S::npos); + test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, S::npos); + test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 1); + test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, 1); + test(S("hdpkobnsalmcfijregtq"), S(""), 10, S::npos); + test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 10); + test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 10); + test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, 10); + test(S("niptglfbosehkamrdqcj"), S(""), 19, S::npos); + test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 16); + test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 19); + test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, 19); + test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos); + test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, 19); + test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, 18); + test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, 19); + test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos); + test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, 12); + test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, 17); + test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, 19); +} + +template <class S> +void test1() +{ + test(S(""), S(""), S::npos); + test(S(""), S("laenf"), S::npos); + test(S(""), S("pqlnkmbdjo"), S::npos); + test(S(""), S("qkamfogpnljdcshbreti"), S::npos); + test(S("nhmko"), S(""), S::npos); + test(S("lahfb"), S("irkhs"), 2); + test(S("gmfhd"), S("kantesmpgj"), 1); + test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), 4); + test(S("eolhfgpjqk"), S(""), S::npos); + test(S("nbatdlmekr"), S("bnrpe"), 9); + test(S("jdmciepkaq"), S("jtdaefblso"), 8); + test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), 9); + test(S("gprdcokbnjhlsfmtieqa"), S(""), S::npos); + test(S("qjghlnftcaismkropdeb"), S("bjaht"), 19); + test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 19); + test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), 19); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find/char_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find/char_size.pass.cpp new file mode 100644 index 000000000000..24e58fc5f1ad --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find/char_size.pass.cpp @@ -0,0 +1,98 @@ +//===----------------------------------------------------------------------===// +// +// 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 find(charT c, size_type pos = 0) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, typename S::value_type c, typename S::size_type pos, + typename S::size_type x) +{ + assert(s.find(c, pos) == x); + if (x != S::npos) + assert(pos <= x && x + 1 <= s.size()); +} + +template <class S> +void +test(const S& s, typename S::value_type c, typename S::size_type x) +{ + assert(s.find(c) == x); + if (x != S::npos) + assert(0 <= x && x + 1 <= s.size()); +} + +int main() +{ + { + typedef std::string S; + test(S(""), 'c', 0, S::npos); + test(S(""), 'c', 1, S::npos); + test(S("abcde"), 'c', 0, 2); + test(S("abcde"), 'c', 1, 2); + test(S("abcde"), 'c', 2, 2); + test(S("abcde"), 'c', 4, S::npos); + test(S("abcde"), 'c', 5, S::npos); + test(S("abcde"), 'c', 6, S::npos); + test(S("abcdeabcde"), 'c', 0, 2); + test(S("abcdeabcde"), 'c', 1, 2); + test(S("abcdeabcde"), 'c', 5, 7); + test(S("abcdeabcde"), 'c', 9, S::npos); + test(S("abcdeabcde"), 'c', 10, S::npos); + test(S("abcdeabcde"), 'c', 11, S::npos); + test(S("abcdeabcdeabcdeabcde"), 'c', 0, 2); + test(S("abcdeabcdeabcdeabcde"), 'c', 1, 2); + test(S("abcdeabcdeabcdeabcde"), 'c', 10, 12); + test(S("abcdeabcdeabcdeabcde"), 'c', 19, S::npos); + test(S("abcdeabcdeabcdeabcde"), 'c', 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), 'c', 21, S::npos); + + test(S(""), 'c', S::npos); + test(S("abcde"), 'c', 2); + test(S("abcdeabcde"), 'c', 2); + test(S("abcdeabcdeabcdeabcde"), 'c', 2); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), 'c', 0, S::npos); + test(S(""), 'c', 1, S::npos); + test(S("abcde"), 'c', 0, 2); + test(S("abcde"), 'c', 1, 2); + test(S("abcde"), 'c', 2, 2); + test(S("abcde"), 'c', 4, S::npos); + test(S("abcde"), 'c', 5, S::npos); + test(S("abcde"), 'c', 6, S::npos); + test(S("abcdeabcde"), 'c', 0, 2); + test(S("abcdeabcde"), 'c', 1, 2); + test(S("abcdeabcde"), 'c', 5, 7); + test(S("abcdeabcde"), 'c', 9, S::npos); + test(S("abcdeabcde"), 'c', 10, S::npos); + test(S("abcdeabcde"), 'c', 11, S::npos); + test(S("abcdeabcdeabcdeabcde"), 'c', 0, 2); + test(S("abcdeabcdeabcdeabcde"), 'c', 1, 2); + test(S("abcdeabcdeabcdeabcde"), 'c', 10, 12); + test(S("abcdeabcdeabcdeabcde"), 'c', 19, S::npos); + test(S("abcdeabcdeabcdeabcde"), 'c', 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), 'c', 21, S::npos); + + test(S(""), 'c', S::npos); + test(S("abcde"), 'c', 2); + test(S("abcdeabcde"), 'c', 2); + test(S("abcdeabcdeabcdeabcde"), 'c', 2); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp new file mode 100644 index 000000000000..e00d7fd8a3dc --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp @@ -0,0 +1,164 @@ +//===----------------------------------------------------------------------===// +// +// 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 find(const charT* s, size_type pos = 0) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type pos, + typename S::size_type x) +{ + assert(s.find(str, pos) == x); + if (x != S::npos) + { + typename S::size_type n = S::traits_type::length(str); + assert(pos <= x && x + n <= s.size()); + } +} + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type x) +{ + assert(s.find(str) == x); + if (x != S::npos) + { + typename S::size_type n = S::traits_type::length(str); + assert(0 <= x && x + n <= s.size()); + } +} + +template <class S> +void test0() +{ + test(S(""), "", 0, 0); + test(S(""), "abcde", 0, S::npos); + test(S(""), "abcdeabcde", 0, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 0, S::npos); + test(S(""), "", 1, S::npos); + test(S(""), "abcde", 1, S::npos); + test(S(""), "abcdeabcde", 1, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 1, S::npos); + test(S("abcde"), "", 0, 0); + test(S("abcde"), "abcde", 0, 0); + test(S("abcde"), "abcdeabcde", 0, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 0, S::npos); + test(S("abcde"), "", 1, 1); + test(S("abcde"), "abcde", 1, S::npos); + test(S("abcde"), "abcdeabcde", 1, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 1, S::npos); + test(S("abcde"), "", 2, 2); + test(S("abcde"), "abcde", 2, S::npos); + test(S("abcde"), "abcdeabcde", 2, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 2, S::npos); + test(S("abcde"), "", 4, 4); + test(S("abcde"), "abcde", 4, S::npos); + test(S("abcde"), "abcdeabcde", 4, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 4, S::npos); + test(S("abcde"), "", 5, 5); + test(S("abcde"), "abcde", 5, S::npos); + test(S("abcde"), "abcdeabcde", 5, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 5, S::npos); + test(S("abcde"), "", 6, S::npos); + test(S("abcde"), "abcde", 6, S::npos); + test(S("abcde"), "abcdeabcde", 6, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 6, S::npos); + test(S("abcdeabcde"), "", 0, 0); + test(S("abcdeabcde"), "abcde", 0, 0); + test(S("abcdeabcde"), "abcdeabcde", 0, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, S::npos); + test(S("abcdeabcde"), "", 1, 1); + test(S("abcdeabcde"), "abcde", 1, 5); + test(S("abcdeabcde"), "abcdeabcde", 1, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos); + test(S("abcdeabcde"), "", 5, 5); + test(S("abcdeabcde"), "abcde", 5, 5); + test(S("abcdeabcde"), "abcdeabcde", 5, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, S::npos); + test(S("abcdeabcde"), "", 9, 9); + test(S("abcdeabcde"), "abcde", 9, S::npos); + test(S("abcdeabcde"), "abcdeabcde", 9, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, S::npos); + test(S("abcdeabcde"), "", 10, 10); + test(S("abcdeabcde"), "abcde", 10, S::npos); + test(S("abcdeabcde"), "abcdeabcde", 10, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos); + test(S("abcdeabcde"), "", 11, S::npos); + test(S("abcdeabcde"), "abcde", 11, S::npos); + test(S("abcdeabcde"), "abcdeabcde", 11, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, S::npos); + test(S("abcdeabcdeabcdeabcde"), "", 0, 0); + test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0); + test(S("abcdeabcdeabcdeabcde"), "", 1, 1); + test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos); + test(S("abcdeabcdeabcdeabcde"), "", 10, 10); + test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos); + test(S("abcdeabcdeabcdeabcde"), "", 19, 19); + test(S("abcdeabcdeabcdeabcde"), "abcde", 19, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, S::npos); + test(S("abcdeabcdeabcdeabcde"), "", 20, 20); + test(S("abcdeabcdeabcdeabcde"), "abcde", 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), "", 21, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcde", 21, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, S::npos); +} + +template <class S> +void test1() +{ + test(S(""), "", 0); + test(S(""), "abcde", S::npos); + test(S(""), "abcdeabcde", S::npos); + test(S(""), "abcdeabcdeabcdeabcde", S::npos); + test(S("abcde"), "", 0); + test(S("abcde"), "abcde", 0); + test(S("abcde"), "abcdeabcde", S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", S::npos); + test(S("abcdeabcde"), "", 0); + test(S("abcdeabcde"), "abcde", 0); + test(S("abcdeabcde"), "abcdeabcde", 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", S::npos); + test(S("abcdeabcdeabcdeabcde"), "", 0); + test(S("abcdeabcdeabcdeabcde"), "abcde", 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp new file mode 100644 index 000000000000..3006c466eed3 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp @@ -0,0 +1,387 @@ +//===----------------------------------------------------------------------===// +// +// 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 find(const charT* s, size_type pos, size_type n) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type pos, + typename S::size_type n, typename S::size_type x) +{ + assert(s.find(str, pos, n) == x); + if (x != S::npos) + assert(pos <= x && x + n <= s.size()); +} + +template <class S> +void test0() +{ + test(S(""), "", 0, 0, 0); + test(S(""), "abcde", 0, 0, 0); + test(S(""), "abcde", 0, 1, S::npos); + test(S(""), "abcde", 0, 2, S::npos); + test(S(""), "abcde", 0, 4, S::npos); + test(S(""), "abcde", 0, 5, S::npos); + test(S(""), "abcdeabcde", 0, 0, 0); + test(S(""), "abcdeabcde", 0, 1, S::npos); + test(S(""), "abcdeabcde", 0, 5, S::npos); + test(S(""), "abcdeabcde", 0, 9, S::npos); + test(S(""), "abcdeabcde", 0, 10, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 0, 0, 0); + test(S(""), "abcdeabcdeabcdeabcde", 0, 1, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 0, 10, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 0, 19, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 0, 20, S::npos); + test(S(""), "", 1, 0, S::npos); + test(S(""), "abcde", 1, 0, S::npos); + test(S(""), "abcde", 1, 1, S::npos); + test(S(""), "abcde", 1, 2, S::npos); + test(S(""), "abcde", 1, 4, S::npos); + test(S(""), "abcde", 1, 5, S::npos); + test(S(""), "abcdeabcde", 1, 0, S::npos); + test(S(""), "abcdeabcde", 1, 1, S::npos); + test(S(""), "abcdeabcde", 1, 5, S::npos); + test(S(""), "abcdeabcde", 1, 9, S::npos); + test(S(""), "abcdeabcde", 1, 10, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 1, 0, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 1, 1, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 1, 10, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 1, 19, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 1, 20, S::npos); + test(S("abcde"), "", 0, 0, 0); + test(S("abcde"), "abcde", 0, 0, 0); + test(S("abcde"), "abcde", 0, 1, 0); + test(S("abcde"), "abcde", 0, 2, 0); + test(S("abcde"), "abcde", 0, 4, 0); + test(S("abcde"), "abcde", 0, 5, 0); + test(S("abcde"), "abcdeabcde", 0, 0, 0); + test(S("abcde"), "abcdeabcde", 0, 1, 0); + test(S("abcde"), "abcdeabcde", 0, 5, 0); + test(S("abcde"), "abcdeabcde", 0, 9, S::npos); + test(S("abcde"), "abcdeabcde", 0, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 0, 0); + test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 1, 0); + test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos); + test(S("abcde"), "", 1, 0, 1); + test(S("abcde"), "abcde", 1, 0, 1); + test(S("abcde"), "abcde", 1, 1, S::npos); + test(S("abcde"), "abcde", 1, 2, S::npos); + test(S("abcde"), "abcde", 1, 4, S::npos); + test(S("abcde"), "abcde", 1, 5, S::npos); + test(S("abcde"), "abcdeabcde", 1, 0, 1); + test(S("abcde"), "abcdeabcde", 1, 1, S::npos); + test(S("abcde"), "abcdeabcde", 1, 5, S::npos); + test(S("abcde"), "abcdeabcde", 1, 9, S::npos); + test(S("abcde"), "abcdeabcde", 1, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 0, 1); + test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 1, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos); + test(S("abcde"), "", 2, 0, 2); + test(S("abcde"), "abcde", 2, 0, 2); + test(S("abcde"), "abcde", 2, 1, S::npos); + test(S("abcde"), "abcde", 2, 2, S::npos); + test(S("abcde"), "abcde", 2, 4, S::npos); + test(S("abcde"), "abcde", 2, 5, S::npos); + test(S("abcde"), "abcdeabcde", 2, 0, 2); + test(S("abcde"), "abcdeabcde", 2, 1, S::npos); + test(S("abcde"), "abcdeabcde", 2, 5, S::npos); + test(S("abcde"), "abcdeabcde", 2, 9, S::npos); + test(S("abcde"), "abcdeabcde", 2, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 0, 2); + test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 1, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 19, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 20, S::npos); + test(S("abcde"), "", 4, 0, 4); + test(S("abcde"), "abcde", 4, 0, 4); + test(S("abcde"), "abcde", 4, 1, S::npos); + test(S("abcde"), "abcde", 4, 2, S::npos); + test(S("abcde"), "abcde", 4, 4, S::npos); + test(S("abcde"), "abcde", 4, 5, S::npos); + test(S("abcde"), "abcdeabcde", 4, 0, 4); + test(S("abcde"), "abcdeabcde", 4, 1, S::npos); + test(S("abcde"), "abcdeabcde", 4, 5, S::npos); + test(S("abcde"), "abcdeabcde", 4, 9, S::npos); + test(S("abcde"), "abcdeabcde", 4, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 0, 4); + test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 1, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 19, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 20, S::npos); + test(S("abcde"), "", 5, 0, 5); + test(S("abcde"), "abcde", 5, 0, 5); + test(S("abcde"), "abcde", 5, 1, S::npos); + test(S("abcde"), "abcde", 5, 2, S::npos); +} + +template <class S> +void test1() +{ + test(S("abcde"), "abcde", 5, 4, S::npos); + test(S("abcde"), "abcde", 5, 5, S::npos); + test(S("abcde"), "abcdeabcde", 5, 0, 5); + test(S("abcde"), "abcdeabcde", 5, 1, S::npos); + test(S("abcde"), "abcdeabcde", 5, 5, S::npos); + test(S("abcde"), "abcdeabcde", 5, 9, S::npos); + test(S("abcde"), "abcdeabcde", 5, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 0, 5); + test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 1, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos); + test(S("abcde"), "", 6, 0, S::npos); + test(S("abcde"), "abcde", 6, 0, S::npos); + test(S("abcde"), "abcde", 6, 1, S::npos); + test(S("abcde"), "abcde", 6, 2, S::npos); + test(S("abcde"), "abcde", 6, 4, S::npos); + test(S("abcde"), "abcde", 6, 5, S::npos); + test(S("abcde"), "abcdeabcde", 6, 0, S::npos); + test(S("abcde"), "abcdeabcde", 6, 1, S::npos); + test(S("abcde"), "abcdeabcde", 6, 5, S::npos); + test(S("abcde"), "abcdeabcde", 6, 9, S::npos); + test(S("abcde"), "abcdeabcde", 6, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 0, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 1, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 19, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 20, S::npos); + test(S("abcdeabcde"), "", 0, 0, 0); + test(S("abcdeabcde"), "abcde", 0, 0, 0); + test(S("abcdeabcde"), "abcde", 0, 1, 0); + test(S("abcdeabcde"), "abcde", 0, 2, 0); + test(S("abcdeabcde"), "abcde", 0, 4, 0); + test(S("abcdeabcde"), "abcde", 0, 5, 0); + test(S("abcdeabcde"), "abcdeabcde", 0, 0, 0); + test(S("abcdeabcde"), "abcdeabcde", 0, 1, 0); + test(S("abcdeabcde"), "abcdeabcde", 0, 5, 0); + test(S("abcdeabcde"), "abcdeabcde", 0, 9, 0); + test(S("abcdeabcde"), "abcdeabcde", 0, 10, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos); + test(S("abcdeabcde"), "", 1, 0, 1); + test(S("abcdeabcde"), "abcde", 1, 0, 1); + test(S("abcdeabcde"), "abcde", 1, 1, 5); + test(S("abcdeabcde"), "abcde", 1, 2, 5); + test(S("abcdeabcde"), "abcde", 1, 4, 5); + test(S("abcdeabcde"), "abcde", 1, 5, 5); + test(S("abcdeabcde"), "abcdeabcde", 1, 0, 1); + test(S("abcdeabcde"), "abcdeabcde", 1, 1, 5); + test(S("abcdeabcde"), "abcdeabcde", 1, 5, 5); + test(S("abcdeabcde"), "abcdeabcde", 1, 9, S::npos); + test(S("abcdeabcde"), "abcdeabcde", 1, 10, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 5); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos); + test(S("abcdeabcde"), "", 5, 0, 5); + test(S("abcdeabcde"), "abcde", 5, 0, 5); + test(S("abcdeabcde"), "abcde", 5, 1, 5); + test(S("abcdeabcde"), "abcde", 5, 2, 5); + test(S("abcdeabcde"), "abcde", 5, 4, 5); + test(S("abcdeabcde"), "abcde", 5, 5, 5); + test(S("abcdeabcde"), "abcdeabcde", 5, 0, 5); + test(S("abcdeabcde"), "abcdeabcde", 5, 1, 5); + test(S("abcdeabcde"), "abcdeabcde", 5, 5, 5); + test(S("abcdeabcde"), "abcdeabcde", 5, 9, S::npos); + test(S("abcdeabcde"), "abcdeabcde", 5, 10, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 0, 5); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 1, 5); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos); + test(S("abcdeabcde"), "", 9, 0, 9); + test(S("abcdeabcde"), "abcde", 9, 0, 9); + test(S("abcdeabcde"), "abcde", 9, 1, S::npos); + test(S("abcdeabcde"), "abcde", 9, 2, S::npos); + test(S("abcdeabcde"), "abcde", 9, 4, S::npos); + test(S("abcdeabcde"), "abcde", 9, 5, S::npos); + test(S("abcdeabcde"), "abcdeabcde", 9, 0, 9); + test(S("abcdeabcde"), "abcdeabcde", 9, 1, S::npos); + test(S("abcdeabcde"), "abcdeabcde", 9, 5, S::npos); + test(S("abcdeabcde"), "abcdeabcde", 9, 9, S::npos); + test(S("abcdeabcde"), "abcdeabcde", 9, 10, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 0, 9); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 1, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 10, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 19, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 20, S::npos); + test(S("abcdeabcde"), "", 10, 0, 10); + test(S("abcdeabcde"), "abcde", 10, 0, 10); + test(S("abcdeabcde"), "abcde", 10, 1, S::npos); + test(S("abcdeabcde"), "abcde", 10, 2, S::npos); + test(S("abcdeabcde"), "abcde", 10, 4, S::npos); + test(S("abcdeabcde"), "abcde", 10, 5, S::npos); + test(S("abcdeabcde"), "abcdeabcde", 10, 0, 10); + test(S("abcdeabcde"), "abcdeabcde", 10, 1, S::npos); +} + +template <class S> +void test2() +{ + test(S("abcdeabcde"), "abcdeabcde", 10, 5, S::npos); + test(S("abcdeabcde"), "abcdeabcde", 10, 9, S::npos); + test(S("abcdeabcde"), "abcdeabcde", 10, 10, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos); + test(S("abcdeabcde"), "", 11, 0, S::npos); + test(S("abcdeabcde"), "abcde", 11, 0, S::npos); + test(S("abcdeabcde"), "abcde", 11, 1, S::npos); + test(S("abcdeabcde"), "abcde", 11, 2, S::npos); + test(S("abcdeabcde"), "abcde", 11, 4, S::npos); + test(S("abcdeabcde"), "abcde", 11, 5, S::npos); + test(S("abcdeabcde"), "abcdeabcde", 11, 0, S::npos); + test(S("abcdeabcde"), "abcdeabcde", 11, 1, S::npos); + test(S("abcdeabcde"), "abcdeabcde", 11, 5, S::npos); + test(S("abcdeabcde"), "abcdeabcde", 11, 9, S::npos); + test(S("abcdeabcde"), "abcdeabcde", 11, 10, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 0, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 1, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 10, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 19, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), "", 0, 0, 0); + test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0, 0); + test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 1, 0); + test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 2, 0); + test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 4, 0); + test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 5, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 1, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 5, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 9, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 10, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, 0); + test(S("abcdeabcdeabcdeabcde"), "", 1, 0, 1); + test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0, 1); + test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 1, 5); + test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 2, 5); + test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 4, 5); + test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5, 5); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0, 1); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 1, 5); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5, 5); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 9, 5); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 10, 5); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 5); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 5); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), "", 10, 0, 10); + test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 0, 10); + test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 1, 10); + test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 2, 10); + test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 4, 10); + test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 5, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 0, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 1, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 5, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 9, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), "", 19, 0, 19); + test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 0, 19); + test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 1, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 2, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 4, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 5, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 0, 19); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 1, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 5, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 9, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0, 19); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 1, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 10, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 19, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), "", 20, 0, 20); + test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 0, 20); + test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 1, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 2, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 4, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 5, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 0, 20); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 1, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 5, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 9, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20); +} + +template <class S> +void test3() +{ + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 1, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 10, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 19, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), "", 21, 0, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 0, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 1, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 2, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 4, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 5, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 0, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 1, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 5, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 9, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 1, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 10, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 19, S::npos); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 20, S::npos); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find/string_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find/string_size.pass.cpp new file mode 100644 index 000000000000..a89df4e3ffa1 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find/string_size.pass.cpp @@ -0,0 +1,157 @@ +//===----------------------------------------------------------------------===// +// +// 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 find(const basic_string& str, size_type pos = 0) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x) +{ + assert(s.find(str, pos) == x); + if (x != S::npos) + assert(pos <= x && x + str.size() <= s.size()); +} + +template <class S> +void +test(const S& s, const S& str, typename S::size_type x) +{ + assert(s.find(str) == x); + if (x != S::npos) + assert(0 <= x && x + str.size() <= s.size()); +} + +template <class S> +void test0() +{ + test(S(""), S(""), 0, 0); + test(S(""), S("abcde"), 0, S::npos); + test(S(""), S("abcdeabcde"), 0, S::npos); + test(S(""), S("abcdeabcdeabcdeabcde"), 0, S::npos); + test(S(""), S(""), 1, S::npos); + test(S(""), S("abcde"), 1, S::npos); + test(S(""), S("abcdeabcde"), 1, S::npos); + test(S(""), S("abcdeabcdeabcdeabcde"), 1, S::npos); + test(S("abcde"), S(""), 0, 0); + test(S("abcde"), S("abcde"), 0, 0); + test(S("abcde"), S("abcdeabcde"), 0, S::npos); + test(S("abcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos); + test(S("abcde"), S(""), 1, 1); + test(S("abcde"), S("abcde"), 1, S::npos); + test(S("abcde"), S("abcdeabcde"), 1, S::npos); + test(S("abcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos); + test(S("abcde"), S(""), 2, 2); + test(S("abcde"), S("abcde"), 2, S::npos); + test(S("abcde"), S("abcdeabcde"), 2, S::npos); + test(S("abcde"), S("abcdeabcdeabcdeabcde"), 2, S::npos); + test(S("abcde"), S(""), 4, 4); + test(S("abcde"), S("abcde"), 4, S::npos); + test(S("abcde"), S("abcdeabcde"), 4, S::npos); + test(S("abcde"), S("abcdeabcdeabcdeabcde"), 4, S::npos); + test(S("abcde"), S(""), 5, 5); + test(S("abcde"), S("abcde"), 5, S::npos); + test(S("abcde"), S("abcdeabcde"), 5, S::npos); + test(S("abcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos); + test(S("abcde"), S(""), 6, S::npos); + test(S("abcde"), S("abcde"), 6, S::npos); + test(S("abcde"), S("abcdeabcde"), 6, S::npos); + test(S("abcde"), S("abcdeabcdeabcdeabcde"), 6, S::npos); + test(S("abcdeabcde"), S(""), 0, 0); + test(S("abcdeabcde"), S("abcde"), 0, 0); + test(S("abcdeabcde"), S("abcdeabcde"), 0, 0); + test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos); + test(S("abcdeabcde"), S(""), 1, 1); + test(S("abcdeabcde"), S("abcde"), 1, 5); + test(S("abcdeabcde"), S("abcdeabcde"), 1, S::npos); + test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos); + test(S("abcdeabcde"), S(""), 5, 5); + test(S("abcdeabcde"), S("abcde"), 5, 5); + test(S("abcdeabcde"), S("abcdeabcde"), 5, S::npos); + test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos); + test(S("abcdeabcde"), S(""), 9, 9); + test(S("abcdeabcde"), S("abcde"), 9, S::npos); + test(S("abcdeabcde"), S("abcdeabcde"), 9, S::npos); + test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 9, S::npos); + test(S("abcdeabcde"), S(""), 10, 10); + test(S("abcdeabcde"), S("abcde"), 10, S::npos); + test(S("abcdeabcde"), S("abcdeabcde"), 10, S::npos); + test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos); + test(S("abcdeabcde"), S(""), 11, S::npos); + test(S("abcdeabcde"), S("abcde"), 11, S::npos); + test(S("abcdeabcde"), S("abcdeabcde"), 11, S::npos); + test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 11, S::npos); + test(S("abcdeabcdeabcdeabcde"), S(""), 0, 0); + test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0, 0); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0, 0); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, 0); + test(S("abcdeabcdeabcdeabcde"), S(""), 1, 1); + test(S("abcdeabcdeabcdeabcde"), S("abcde"), 1, 5); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 1, 5); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos); + test(S("abcdeabcdeabcdeabcde"), S(""), 10, 10); + test(S("abcdeabcdeabcdeabcde"), S("abcde"), 10, 10); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10, 10); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos); + test(S("abcdeabcdeabcdeabcde"), S(""), 19, 19); + test(S("abcdeabcdeabcdeabcde"), S("abcde"), 19, S::npos); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 19, S::npos); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 19, S::npos); + test(S("abcdeabcdeabcdeabcde"), S(""), 20, 20); + test(S("abcdeabcdeabcdeabcde"), S("abcde"), 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), S(""), 21, S::npos); + test(S("abcdeabcdeabcdeabcde"), S("abcde"), 21, S::npos); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 21, S::npos); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 21, S::npos); +} + +template <class S> +void test1() +{ + test(S(""), S(""), 0); + test(S(""), S("abcde"), S::npos); + test(S(""), S("abcdeabcde"), S::npos); + test(S(""), S("abcdeabcdeabcdeabcde"), S::npos); + test(S("abcde"), S(""), 0); + test(S("abcde"), S("abcde"), 0); + test(S("abcde"), S("abcdeabcde"), S::npos); + test(S("abcde"), S("abcdeabcdeabcdeabcde"), S::npos); + test(S("abcdeabcde"), S(""), 0); + test(S("abcdeabcde"), S("abcde"), 0); + test(S("abcdeabcde"), S("abcdeabcde"), 0); + test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), S::npos); + test(S("abcdeabcdeabcdeabcde"), S(""), 0); + test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp new file mode 100644 index 000000000000..cbc0c9b35367 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp @@ -0,0 +1,98 @@ +//===----------------------------------------------------------------------===// +// +// 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 rfind(charT c, size_type pos = npos) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, typename S::value_type c, typename S::size_type pos, + typename S::size_type x) +{ + assert(s.rfind(c, pos) == x); + if (x != S::npos) + assert(x <= pos && x + 1 <= s.size()); +} + +template <class S> +void +test(const S& s, typename S::value_type c, typename S::size_type x) +{ + assert(s.rfind(c) == x); + if (x != S::npos) + assert(x + 1 <= s.size()); +} + +int main() +{ + { + typedef std::string S; + test(S(""), 'b', 0, S::npos); + test(S(""), 'b', 1, S::npos); + test(S("abcde"), 'b', 0, S::npos); + test(S("abcde"), 'b', 1, 1); + test(S("abcde"), 'b', 2, 1); + test(S("abcde"), 'b', 4, 1); + test(S("abcde"), 'b', 5, 1); + test(S("abcde"), 'b', 6, 1); + test(S("abcdeabcde"), 'b', 0, S::npos); + test(S("abcdeabcde"), 'b', 1, 1); + test(S("abcdeabcde"), 'b', 5, 1); + test(S("abcdeabcde"), 'b', 9, 6); + test(S("abcdeabcde"), 'b', 10, 6); + test(S("abcdeabcde"), 'b', 11, 6); + test(S("abcdeabcdeabcdeabcde"), 'b', 0, S::npos); + test(S("abcdeabcdeabcdeabcde"), 'b', 1, 1); + test(S("abcdeabcdeabcdeabcde"), 'b', 10, 6); + test(S("abcdeabcdeabcdeabcde"), 'b', 19, 16); + test(S("abcdeabcdeabcdeabcde"), 'b', 20, 16); + test(S("abcdeabcdeabcdeabcde"), 'b', 21, 16); + + test(S(""), 'b', S::npos); + test(S("abcde"), 'b', 1); + test(S("abcdeabcde"), 'b', 6); + test(S("abcdeabcdeabcdeabcde"), 'b', 16); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), 'b', 0, S::npos); + test(S(""), 'b', 1, S::npos); + test(S("abcde"), 'b', 0, S::npos); + test(S("abcde"), 'b', 1, 1); + test(S("abcde"), 'b', 2, 1); + test(S("abcde"), 'b', 4, 1); + test(S("abcde"), 'b', 5, 1); + test(S("abcde"), 'b', 6, 1); + test(S("abcdeabcde"), 'b', 0, S::npos); + test(S("abcdeabcde"), 'b', 1, 1); + test(S("abcdeabcde"), 'b', 5, 1); + test(S("abcdeabcde"), 'b', 9, 6); + test(S("abcdeabcde"), 'b', 10, 6); + test(S("abcdeabcde"), 'b', 11, 6); + test(S("abcdeabcdeabcdeabcde"), 'b', 0, S::npos); + test(S("abcdeabcdeabcdeabcde"), 'b', 1, 1); + test(S("abcdeabcdeabcdeabcde"), 'b', 10, 6); + test(S("abcdeabcdeabcdeabcde"), 'b', 19, 16); + test(S("abcdeabcdeabcdeabcde"), 'b', 20, 16); + test(S("abcdeabcdeabcdeabcde"), 'b', 21, 16); + + test(S(""), 'b', S::npos); + test(S("abcde"), 'b', 1); + test(S("abcdeabcde"), 'b', 6); + test(S("abcdeabcdeabcdeabcde"), 'b', 16); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp new file mode 100644 index 000000000000..450aebedd59c --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp @@ -0,0 +1,165 @@ +//===----------------------------------------------------------------------===// +// +// 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 rfind(const charT* s, size_type pos = npos) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type pos, + typename S::size_type x) +{ + assert(s.rfind(str, pos) == x); + if (x != S::npos) + { + typename S::size_type n = S::traits_type::length(str); + assert(x <= pos && x + n <= s.size()); + } +} + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type x) +{ + assert(s.rfind(str) == x); + if (x != S::npos) + { + typename S::size_type pos = s.size(); + typename S::size_type n = S::traits_type::length(str); + assert(x <= pos && x + n <= s.size()); + } +} + +template <class S> +void test0() +{ + test(S(""), "", 0, 0); + test(S(""), "abcde", 0, S::npos); + test(S(""), "abcdeabcde", 0, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 0, S::npos); + test(S(""), "", 1, 0); + test(S(""), "abcde", 1, S::npos); + test(S(""), "abcdeabcde", 1, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 1, S::npos); + test(S("abcde"), "", 0, 0); + test(S("abcde"), "abcde", 0, 0); + test(S("abcde"), "abcdeabcde", 0, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 0, S::npos); + test(S("abcde"), "", 1, 1); + test(S("abcde"), "abcde", 1, 0); + test(S("abcde"), "abcdeabcde", 1, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 1, S::npos); + test(S("abcde"), "", 2, 2); + test(S("abcde"), "abcde", 2, 0); + test(S("abcde"), "abcdeabcde", 2, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 2, S::npos); + test(S("abcde"), "", 4, 4); + test(S("abcde"), "abcde", 4, 0); + test(S("abcde"), "abcdeabcde", 4, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 4, S::npos); + test(S("abcde"), "", 5, 5); + test(S("abcde"), "abcde", 5, 0); + test(S("abcde"), "abcdeabcde", 5, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 5, S::npos); + test(S("abcde"), "", 6, 5); + test(S("abcde"), "abcde", 6, 0); + test(S("abcde"), "abcdeabcde", 6, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 6, S::npos); + test(S("abcdeabcde"), "", 0, 0); + test(S("abcdeabcde"), "abcde", 0, 0); + test(S("abcdeabcde"), "abcdeabcde", 0, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, S::npos); + test(S("abcdeabcde"), "", 1, 1); + test(S("abcdeabcde"), "abcde", 1, 0); + test(S("abcdeabcde"), "abcdeabcde", 1, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos); + test(S("abcdeabcde"), "", 5, 5); + test(S("abcdeabcde"), "abcde", 5, 5); + test(S("abcdeabcde"), "abcdeabcde", 5, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, S::npos); + test(S("abcdeabcde"), "", 9, 9); + test(S("abcdeabcde"), "abcde", 9, 5); + test(S("abcdeabcde"), "abcdeabcde", 9, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, S::npos); + test(S("abcdeabcde"), "", 10, 10); + test(S("abcdeabcde"), "abcde", 10, 5); + test(S("abcdeabcde"), "abcdeabcde", 10, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos); + test(S("abcdeabcde"), "", 11, 10); + test(S("abcdeabcde"), "abcde", 11, 5); + test(S("abcdeabcde"), "abcdeabcde", 11, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, S::npos); + test(S("abcdeabcdeabcdeabcde"), "", 0, 0); + test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0); + test(S("abcdeabcdeabcdeabcde"), "", 1, 1); + test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0); + test(S("abcdeabcdeabcdeabcde"), "", 10, 10); + test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0); + test(S("abcdeabcdeabcdeabcde"), "", 19, 19); + test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 15); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0); + test(S("abcdeabcdeabcdeabcde"), "", 20, 20); + test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 15); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0); + test(S("abcdeabcdeabcdeabcde"), "", 21, 20); + test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 15); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0); +} + +template <class S> +void test1() +{ + test(S(""), "", 0); + test(S(""), "abcde", S::npos); + test(S(""), "abcdeabcde", S::npos); + test(S(""), "abcdeabcdeabcdeabcde", S::npos); + test(S("abcde"), "", 5); + test(S("abcde"), "abcde", 0); + test(S("abcde"), "abcdeabcde", S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", S::npos); + test(S("abcdeabcde"), "", 10); + test(S("abcdeabcde"), "abcde", 5); + test(S("abcdeabcde"), "abcdeabcde", 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", S::npos); + test(S("abcdeabcdeabcdeabcde"), "", 20); + test(S("abcdeabcdeabcdeabcde"), "abcde", 15); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp new file mode 100644 index 000000000000..47baf40b265b --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp @@ -0,0 +1,387 @@ +//===----------------------------------------------------------------------===// +// +// 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 rfind(const charT* s, size_type pos, size_type n) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const typename S::value_type* str, typename S::size_type pos, + typename S::size_type n, typename S::size_type x) +{ + assert(s.rfind(str, pos, n) == x); + if (x != S::npos) + assert(x <= pos && x + n <= s.size()); +} + +template <class S> +void test0() +{ + test(S(""), "", 0, 0, 0); + test(S(""), "abcde", 0, 0, 0); + test(S(""), "abcde", 0, 1, S::npos); + test(S(""), "abcde", 0, 2, S::npos); + test(S(""), "abcde", 0, 4, S::npos); + test(S(""), "abcde", 0, 5, S::npos); + test(S(""), "abcdeabcde", 0, 0, 0); + test(S(""), "abcdeabcde", 0, 1, S::npos); + test(S(""), "abcdeabcde", 0, 5, S::npos); + test(S(""), "abcdeabcde", 0, 9, S::npos); + test(S(""), "abcdeabcde", 0, 10, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 0, 0, 0); + test(S(""), "abcdeabcdeabcdeabcde", 0, 1, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 0, 10, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 0, 19, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 0, 20, S::npos); + test(S(""), "", 1, 0, 0); + test(S(""), "abcde", 1, 0, 0); + test(S(""), "abcde", 1, 1, S::npos); + test(S(""), "abcde", 1, 2, S::npos); + test(S(""), "abcde", 1, 4, S::npos); + test(S(""), "abcde", 1, 5, S::npos); + test(S(""), "abcdeabcde", 1, 0, 0); + test(S(""), "abcdeabcde", 1, 1, S::npos); + test(S(""), "abcdeabcde", 1, 5, S::npos); + test(S(""), "abcdeabcde", 1, 9, S::npos); + test(S(""), "abcdeabcde", 1, 10, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 1, 0, 0); + test(S(""), "abcdeabcdeabcdeabcde", 1, 1, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 1, 10, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 1, 19, S::npos); + test(S(""), "abcdeabcdeabcdeabcde", 1, 20, S::npos); + test(S("abcde"), "", 0, 0, 0); + test(S("abcde"), "abcde", 0, 0, 0); + test(S("abcde"), "abcde", 0, 1, 0); + test(S("abcde"), "abcde", 0, 2, 0); + test(S("abcde"), "abcde", 0, 4, 0); + test(S("abcde"), "abcde", 0, 5, 0); + test(S("abcde"), "abcdeabcde", 0, 0, 0); + test(S("abcde"), "abcdeabcde", 0, 1, 0); + test(S("abcde"), "abcdeabcde", 0, 5, 0); + test(S("abcde"), "abcdeabcde", 0, 9, S::npos); + test(S("abcde"), "abcdeabcde", 0, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 0, 0); + test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 1, 0); + test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos); + test(S("abcde"), "", 1, 0, 1); + test(S("abcde"), "abcde", 1, 0, 1); + test(S("abcde"), "abcde", 1, 1, 0); + test(S("abcde"), "abcde", 1, 2, 0); + test(S("abcde"), "abcde", 1, 4, 0); + test(S("abcde"), "abcde", 1, 5, 0); + test(S("abcde"), "abcdeabcde", 1, 0, 1); + test(S("abcde"), "abcdeabcde", 1, 1, 0); + test(S("abcde"), "abcdeabcde", 1, 5, 0); + test(S("abcde"), "abcdeabcde", 1, 9, S::npos); + test(S("abcde"), "abcdeabcde", 1, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 0, 1); + test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 1, 0); + test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos); + test(S("abcde"), "", 2, 0, 2); + test(S("abcde"), "abcde", 2, 0, 2); + test(S("abcde"), "abcde", 2, 1, 0); + test(S("abcde"), "abcde", 2, 2, 0); + test(S("abcde"), "abcde", 2, 4, 0); + test(S("abcde"), "abcde", 2, 5, 0); + test(S("abcde"), "abcdeabcde", 2, 0, 2); + test(S("abcde"), "abcdeabcde", 2, 1, 0); + test(S("abcde"), "abcdeabcde", 2, 5, 0); + test(S("abcde"), "abcdeabcde", 2, 9, S::npos); + test(S("abcde"), "abcdeabcde", 2, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 0, 2); + test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 1, 0); + test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 19, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 20, S::npos); + test(S("abcde"), "", 4, 0, 4); + test(S("abcde"), "abcde", 4, 0, 4); + test(S("abcde"), "abcde", 4, 1, 0); + test(S("abcde"), "abcde", 4, 2, 0); + test(S("abcde"), "abcde", 4, 4, 0); + test(S("abcde"), "abcde", 4, 5, 0); + test(S("abcde"), "abcdeabcde", 4, 0, 4); + test(S("abcde"), "abcdeabcde", 4, 1, 0); + test(S("abcde"), "abcdeabcde", 4, 5, 0); + test(S("abcde"), "abcdeabcde", 4, 9, S::npos); + test(S("abcde"), "abcdeabcde", 4, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 0, 4); + test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 1, 0); + test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 19, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 20, S::npos); + test(S("abcde"), "", 5, 0, 5); + test(S("abcde"), "abcde", 5, 0, 5); + test(S("abcde"), "abcde", 5, 1, 0); + test(S("abcde"), "abcde", 5, 2, 0); +} + +template <class S> +void test1() +{ + test(S("abcde"), "abcde", 5, 4, 0); + test(S("abcde"), "abcde", 5, 5, 0); + test(S("abcde"), "abcdeabcde", 5, 0, 5); + test(S("abcde"), "abcdeabcde", 5, 1, 0); + test(S("abcde"), "abcdeabcde", 5, 5, 0); + test(S("abcde"), "abcdeabcde", 5, 9, S::npos); + test(S("abcde"), "abcdeabcde", 5, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 0, 5); + test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 1, 0); + test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos); + test(S("abcde"), "", 6, 0, 5); + test(S("abcde"), "abcde", 6, 0, 5); + test(S("abcde"), "abcde", 6, 1, 0); + test(S("abcde"), "abcde", 6, 2, 0); + test(S("abcde"), "abcde", 6, 4, 0); + test(S("abcde"), "abcde", 6, 5, 0); + test(S("abcde"), "abcdeabcde", 6, 0, 5); + test(S("abcde"), "abcdeabcde", 6, 1, 0); + test(S("abcde"), "abcdeabcde", 6, 5, 0); + test(S("abcde"), "abcdeabcde", 6, 9, S::npos); + test(S("abcde"), "abcdeabcde", 6, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 0, 5); + test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 1, 0); + test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 10, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 19, S::npos); + test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 20, S::npos); + test(S("abcdeabcde"), "", 0, 0, 0); + test(S("abcdeabcde"), "abcde", 0, 0, 0); + test(S("abcdeabcde"), "abcde", 0, 1, 0); + test(S("abcdeabcde"), "abcde", 0, 2, 0); + test(S("abcdeabcde"), "abcde", 0, 4, 0); + test(S("abcdeabcde"), "abcde", 0, 5, 0); + test(S("abcdeabcde"), "abcdeabcde", 0, 0, 0); + test(S("abcdeabcde"), "abcdeabcde", 0, 1, 0); + test(S("abcdeabcde"), "abcdeabcde", 0, 5, 0); + test(S("abcdeabcde"), "abcdeabcde", 0, 9, 0); + test(S("abcdeabcde"), "abcdeabcde", 0, 10, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos); + test(S("abcdeabcde"), "", 1, 0, 1); + test(S("abcdeabcde"), "abcde", 1, 0, 1); + test(S("abcdeabcde"), "abcde", 1, 1, 0); + test(S("abcdeabcde"), "abcde", 1, 2, 0); + test(S("abcdeabcde"), "abcde", 1, 4, 0); + test(S("abcdeabcde"), "abcde", 1, 5, 0); + test(S("abcdeabcde"), "abcdeabcde", 1, 0, 1); + test(S("abcdeabcde"), "abcdeabcde", 1, 1, 0); + test(S("abcdeabcde"), "abcdeabcde", 1, 5, 0); + test(S("abcdeabcde"), "abcdeabcde", 1, 9, 0); + test(S("abcdeabcde"), "abcdeabcde", 1, 10, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos); + test(S("abcdeabcde"), "", 5, 0, 5); + test(S("abcdeabcde"), "abcde", 5, 0, 5); + test(S("abcdeabcde"), "abcde", 5, 1, 5); + test(S("abcdeabcde"), "abcde", 5, 2, 5); + test(S("abcdeabcde"), "abcde", 5, 4, 5); + test(S("abcdeabcde"), "abcde", 5, 5, 5); + test(S("abcdeabcde"), "abcdeabcde", 5, 0, 5); + test(S("abcdeabcde"), "abcdeabcde", 5, 1, 5); + test(S("abcdeabcde"), "abcdeabcde", 5, 5, 5); + test(S("abcdeabcde"), "abcdeabcde", 5, 9, 0); + test(S("abcdeabcde"), "abcdeabcde", 5, 10, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 0, 5); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 1, 5); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 10, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos); + test(S("abcdeabcde"), "", 9, 0, 9); + test(S("abcdeabcde"), "abcde", 9, 0, 9); + test(S("abcdeabcde"), "abcde", 9, 1, 5); + test(S("abcdeabcde"), "abcde", 9, 2, 5); + test(S("abcdeabcde"), "abcde", 9, 4, 5); + test(S("abcdeabcde"), "abcde", 9, 5, 5); + test(S("abcdeabcde"), "abcdeabcde", 9, 0, 9); + test(S("abcdeabcde"), "abcdeabcde", 9, 1, 5); + test(S("abcdeabcde"), "abcdeabcde", 9, 5, 5); + test(S("abcdeabcde"), "abcdeabcde", 9, 9, 0); + test(S("abcdeabcde"), "abcdeabcde", 9, 10, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 0, 9); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 1, 5); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 10, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 19, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 20, S::npos); + test(S("abcdeabcde"), "", 10, 0, 10); + test(S("abcdeabcde"), "abcde", 10, 0, 10); + test(S("abcdeabcde"), "abcde", 10, 1, 5); + test(S("abcdeabcde"), "abcde", 10, 2, 5); + test(S("abcdeabcde"), "abcde", 10, 4, 5); + test(S("abcdeabcde"), "abcde", 10, 5, 5); + test(S("abcdeabcde"), "abcdeabcde", 10, 0, 10); + test(S("abcdeabcde"), "abcdeabcde", 10, 1, 5); +} + +template <class S> +void test2() +{ + test(S("abcdeabcde"), "abcdeabcde", 10, 5, 5); + test(S("abcdeabcde"), "abcdeabcde", 10, 9, 0); + test(S("abcdeabcde"), "abcdeabcde", 10, 10, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 5); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos); + test(S("abcdeabcde"), "", 11, 0, 10); + test(S("abcdeabcde"), "abcde", 11, 0, 10); + test(S("abcdeabcde"), "abcde", 11, 1, 5); + test(S("abcdeabcde"), "abcde", 11, 2, 5); + test(S("abcdeabcde"), "abcde", 11, 4, 5); + test(S("abcdeabcde"), "abcde", 11, 5, 5); + test(S("abcdeabcde"), "abcdeabcde", 11, 0, 10); + test(S("abcdeabcde"), "abcdeabcde", 11, 1, 5); + test(S("abcdeabcde"), "abcdeabcde", 11, 5, 5); + test(S("abcdeabcde"), "abcdeabcde", 11, 9, 0); + test(S("abcdeabcde"), "abcdeabcde", 11, 10, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 0, 10); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 1, 5); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 10, 0); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 19, S::npos); + test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), "", 0, 0, 0); + test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0, 0); + test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 1, 0); + test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 2, 0); + test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 4, 0); + test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 5, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 1, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 5, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 9, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 10, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, 0); + test(S("abcdeabcdeabcdeabcde"), "", 1, 0, 1); + test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0, 1); + test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 1, 0); + test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 2, 0); + test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 4, 0); + test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0, 1); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 1, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 9, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 10, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, 0); + test(S("abcdeabcdeabcdeabcde"), "", 10, 0, 10); + test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 0, 10); + test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 1, 10); + test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 2, 10); + test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 4, 10); + test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 5, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 0, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 1, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 5, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 9, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, 0); + test(S("abcdeabcdeabcdeabcde"), "", 19, 0, 19); + test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 0, 19); + test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 1, 15); + test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 2, 15); + test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 4, 15); + test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 5, 15); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 0, 19); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 1, 15); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 5, 15); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 9, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0, 19); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 1, 15); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 10, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 19, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 20, 0); + test(S("abcdeabcdeabcdeabcde"), "", 20, 0, 20); + test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 0, 20); + test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 1, 15); + test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 2, 15); + test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 4, 15); + test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 5, 15); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 0, 20); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 1, 15); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 5, 15); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 9, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20); +} + +template <class S> +void test3() +{ + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 1, 15); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 10, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 19, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 20, 0); + test(S("abcdeabcdeabcdeabcde"), "", 21, 0, 20); + test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 0, 20); + test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 1, 15); + test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 2, 15); + test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 4, 15); + test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 5, 15); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 0, 20); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 1, 15); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 5, 15); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 9, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0, 20); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 1, 15); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 10, 10); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 19, 0); + test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 20, 0); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + test2<S>(); + test3<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp new file mode 100644 index 000000000000..05e6e5174232 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp @@ -0,0 +1,157 @@ +//===----------------------------------------------------------------------===// +// +// 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 rfind(const basic_string& str, size_type pos = npos) const; + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x) +{ + assert(s.rfind(str, pos) == x); + if (x != S::npos) + assert(x <= pos && x + str.size() <= s.size()); +} + +template <class S> +void +test(const S& s, const S& str, typename S::size_type x) +{ + assert(s.rfind(str) == x); + if (x != S::npos) + assert(0 <= x && x + str.size() <= s.size()); +} + +template <class S> +void test0() +{ + test(S(""), S(""), 0, 0); + test(S(""), S("abcde"), 0, S::npos); + test(S(""), S("abcdeabcde"), 0, S::npos); + test(S(""), S("abcdeabcdeabcdeabcde"), 0, S::npos); + test(S(""), S(""), 1, 0); + test(S(""), S("abcde"), 1, S::npos); + test(S(""), S("abcdeabcde"), 1, S::npos); + test(S(""), S("abcdeabcdeabcdeabcde"), 1, S::npos); + test(S("abcde"), S(""), 0, 0); + test(S("abcde"), S("abcde"), 0, 0); + test(S("abcde"), S("abcdeabcde"), 0, S::npos); + test(S("abcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos); + test(S("abcde"), S(""), 1, 1); + test(S("abcde"), S("abcde"), 1, 0); + test(S("abcde"), S("abcdeabcde"), 1, S::npos); + test(S("abcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos); + test(S("abcde"), S(""), 2, 2); + test(S("abcde"), S("abcde"), 2, 0); + test(S("abcde"), S("abcdeabcde"), 2, S::npos); + test(S("abcde"), S("abcdeabcdeabcdeabcde"), 2, S::npos); + test(S("abcde"), S(""), 4, 4); + test(S("abcde"), S("abcde"), 4, 0); + test(S("abcde"), S("abcdeabcde"), 4, S::npos); + test(S("abcde"), S("abcdeabcdeabcdeabcde"), 4, S::npos); + test(S("abcde"), S(""), 5, 5); + test(S("abcde"), S("abcde"), 5, 0); + test(S("abcde"), S("abcdeabcde"), 5, S::npos); + test(S("abcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos); + test(S("abcde"), S(""), 6, 5); + test(S("abcde"), S("abcde"), 6, 0); + test(S("abcde"), S("abcdeabcde"), 6, S::npos); + test(S("abcde"), S("abcdeabcdeabcdeabcde"), 6, S::npos); + test(S("abcdeabcde"), S(""), 0, 0); + test(S("abcdeabcde"), S("abcde"), 0, 0); + test(S("abcdeabcde"), S("abcdeabcde"), 0, 0); + test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos); + test(S("abcdeabcde"), S(""), 1, 1); + test(S("abcdeabcde"), S("abcde"), 1, 0); + test(S("abcdeabcde"), S("abcdeabcde"), 1, 0); + test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos); + test(S("abcdeabcde"), S(""), 5, 5); + test(S("abcdeabcde"), S("abcde"), 5, 5); + test(S("abcdeabcde"), S("abcdeabcde"), 5, 0); + test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos); + test(S("abcdeabcde"), S(""), 9, 9); + test(S("abcdeabcde"), S("abcde"), 9, 5); + test(S("abcdeabcde"), S("abcdeabcde"), 9, 0); + test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 9, S::npos); + test(S("abcdeabcde"), S(""), 10, 10); + test(S("abcdeabcde"), S("abcde"), 10, 5); + test(S("abcdeabcde"), S("abcdeabcde"), 10, 0); + test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos); + test(S("abcdeabcde"), S(""), 11, 10); + test(S("abcdeabcde"), S("abcde"), 11, 5); + test(S("abcdeabcde"), S("abcdeabcde"), 11, 0); + test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 11, S::npos); + test(S("abcdeabcdeabcdeabcde"), S(""), 0, 0); + test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0, 0); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0, 0); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, 0); + test(S("abcdeabcdeabcdeabcde"), S(""), 1, 1); + test(S("abcdeabcdeabcdeabcde"), S("abcde"), 1, 0); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 1, 0); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, 0); + test(S("abcdeabcdeabcdeabcde"), S(""), 10, 10); + test(S("abcdeabcdeabcdeabcde"), S("abcde"), 10, 10); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10, 10); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, 0); + test(S("abcdeabcdeabcdeabcde"), S(""), 19, 19); + test(S("abcdeabcdeabcdeabcde"), S("abcde"), 19, 15); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 19, 10); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 19, 0); + test(S("abcdeabcdeabcdeabcde"), S(""), 20, 20); + test(S("abcdeabcdeabcdeabcde"), S("abcde"), 20, 15); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 20, 10); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 20, 0); + test(S("abcdeabcdeabcdeabcde"), S(""), 21, 20); + test(S("abcdeabcdeabcdeabcde"), S("abcde"), 21, 15); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 21, 10); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 21, 0); +} + +template <class S> +void test1() +{ + test(S(""), S(""), 0); + test(S(""), S("abcde"), S::npos); + test(S(""), S("abcdeabcde"), S::npos); + test(S(""), S("abcdeabcdeabcdeabcde"), S::npos); + test(S("abcde"), S(""), 5); + test(S("abcde"), S("abcde"), 0); + test(S("abcde"), S("abcdeabcde"), S::npos); + test(S("abcde"), S("abcdeabcdeabcdeabcde"), S::npos); + test(S("abcdeabcde"), S(""), 10); + test(S("abcdeabcde"), S("abcde"), 5); + test(S("abcdeabcde"), S("abcdeabcde"), 0); + test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), S::npos); + test(S("abcdeabcdeabcdeabcde"), S(""), 20); + test(S("abcdeabcdeabcdeabcde"), S("abcde"), 15); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10); + test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0); +} + +int main() +{ + { + typedef std::string S; + test0<S>(); + test1<S>(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0<S>(); + test1<S>(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp b/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp new file mode 100644 index 000000000000..a73f70cd4b89 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp @@ -0,0 +1,166 @@ +//===----------------------------------------------------------------------===// +// +// 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 substr(size_type pos = 0, size_type n = npos) const; + +#include <string> +#include <stdexcept> +#include <algorithm> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& s, typename S::size_type pos, typename S::size_type n) +{ + try + { + S str = s.substr(pos, n); + assert(str.__invariants()); + assert(pos <= s.size()); + typename S::size_type rlen = std::min(n, s.size() - pos); + assert(str.size() == rlen); + assert(S::traits_type::compare(s.data()+pos, str.data(), rlen) == 0); + } + catch (std::out_of_range&) + { + assert(pos > s.size()); + } +} + +int main() +{ + { + typedef std::string S; + test(S(""), 0, 0); + test(S(""), 1, 0); + test(S("pniot"), 0, 0); + test(S("htaob"), 0, 1); + test(S("fodgq"), 0, 2); + test(S("hpqia"), 0, 4); + test(S("qanej"), 0, 5); + test(S("dfkap"), 1, 0); + test(S("clbao"), 1, 1); + test(S("ihqrf"), 1, 2); + test(S("mekdn"), 1, 3); + test(S("ngtjf"), 1, 4); + test(S("srdfq"), 2, 0); + test(S("qkdrs"), 2, 1); + test(S("ikcrq"), 2, 2); + test(S("cdaih"), 2, 3); + test(S("dmajb"), 4, 0); + test(S("karth"), 4, 1); + test(S("lhcdo"), 5, 0); + test(S("acbsj"), 6, 0); + test(S("pbsjikaole"), 0, 0); + test(S("pcbahntsje"), 0, 1); + test(S("mprdjbeiak"), 0, 5); + test(S("fhepcrntko"), 0, 9); + test(S("eqmpaidtls"), 0, 10); + test(S("joidhalcmq"), 1, 0); + test(S("omigsphflj"), 1, 1); + test(S("kocgbphfji"), 1, 4); + test(S("onmjekafbi"), 1, 8); + test(S("fbslrjiqkm"), 1, 9); + test(S("oqmrjahnkg"), 5, 0); + test(S("jeidpcmalh"), 5, 1); + test(S("schfalibje"), 5, 2); + test(S("crliponbqe"), 5, 4); + test(S("igdscopqtm"), 5, 5); + test(S("qngpdkimlc"), 9, 0); + test(S("thdjgafrlb"), 9, 1); + test(S("hcjitbfapl"), 10, 0); + test(S("mgojkldsqh"), 11, 0); + test(S("gfshlcmdjreqipbontak"), 0, 0); + test(S("nadkhpfemgclosibtjrq"), 0, 1); + test(S("nkodajteqplrbifhmcgs"), 0, 10); + test(S("ofdrqmkeblthacpgijsn"), 0, 19); + test(S("gbmetiprqdoasckjfhln"), 0, 20); + test(S("bdfjqgatlksriohemnpc"), 1, 0); + test(S("crnklpmegdqfiashtojb"), 1, 1); + test(S("ejqcnahdrkfsmptilgbo"), 1, 9); + test(S("jsbtafedocnirgpmkhql"), 1, 18); + test(S("prqgnlbaejsmkhdctoif"), 1, 19); + test(S("qnmodrtkebhpasifgcjl"), 10, 0); + test(S("pejafmnokrqhtisbcdgl"), 10, 1); + test(S("cpebqsfmnjdolhkratgi"), 10, 5); + test(S("odnqkgijrhabfmcestlp"), 10, 9); + test(S("lmofqdhpkibagnrcjste"), 10, 10); + test(S("lgjqketopbfahrmnsicd"), 19, 0); + test(S("ktsrmnqagdecfhijpobl"), 19, 1); + test(S("lsaijeqhtrbgcdmpfkno"), 20, 0); + test(S("dplqartnfgejichmoskb"), 21, 0); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), 0, 0); + test(S(""), 1, 0); + test(S("pniot"), 0, 0); + test(S("htaob"), 0, 1); + test(S("fodgq"), 0, 2); + test(S("hpqia"), 0, 4); + test(S("qanej"), 0, 5); + test(S("dfkap"), 1, 0); + test(S("clbao"), 1, 1); + test(S("ihqrf"), 1, 2); + test(S("mekdn"), 1, 3); + test(S("ngtjf"), 1, 4); + test(S("srdfq"), 2, 0); + test(S("qkdrs"), 2, 1); + test(S("ikcrq"), 2, 2); + test(S("cdaih"), 2, 3); + test(S("dmajb"), 4, 0); + test(S("karth"), 4, 1); + test(S("lhcdo"), 5, 0); + test(S("acbsj"), 6, 0); + test(S("pbsjikaole"), 0, 0); + test(S("pcbahntsje"), 0, 1); + test(S("mprdjbeiak"), 0, 5); + test(S("fhepcrntko"), 0, 9); + test(S("eqmpaidtls"), 0, 10); + test(S("joidhalcmq"), 1, 0); + test(S("omigsphflj"), 1, 1); + test(S("kocgbphfji"), 1, 4); + test(S("onmjekafbi"), 1, 8); + test(S("fbslrjiqkm"), 1, 9); + test(S("oqmrjahnkg"), 5, 0); + test(S("jeidpcmalh"), 5, 1); + test(S("schfalibje"), 5, 2); + test(S("crliponbqe"), 5, 4); + test(S("igdscopqtm"), 5, 5); + test(S("qngpdkimlc"), 9, 0); + test(S("thdjgafrlb"), 9, 1); + test(S("hcjitbfapl"), 10, 0); + test(S("mgojkldsqh"), 11, 0); + test(S("gfshlcmdjreqipbontak"), 0, 0); + test(S("nadkhpfemgclosibtjrq"), 0, 1); + test(S("nkodajteqplrbifhmcgs"), 0, 10); + test(S("ofdrqmkeblthacpgijsn"), 0, 19); + test(S("gbmetiprqdoasckjfhln"), 0, 20); + test(S("bdfjqgatlksriohemnpc"), 1, 0); + test(S("crnklpmegdqfiashtojb"), 1, 1); + test(S("ejqcnahdrkfsmptilgbo"), 1, 9); + test(S("jsbtafedocnirgpmkhql"), 1, 18); + test(S("prqgnlbaejsmkhdctoif"), 1, 19); + test(S("qnmodrtkebhpasifgcjl"), 10, 0); + test(S("pejafmnokrqhtisbcdgl"), 10, 1); + test(S("cpebqsfmnjdolhkratgi"), 10, 5); + test(S("odnqkgijrhabfmcestlp"), 10, 9); + test(S("lmofqdhpkibagnrcjste"), 10, 10); + test(S("lgjqketopbfahrmnsicd"), 19, 0); + test(S("ktsrmnqagdecfhijpobl"), 19, 1); + test(S("lsaijeqhtrbgcdmpfkno"), 20, 0); + test(S("dplqartnfgejichmoskb"), 21, 0); + } +#endif +} diff --git a/test/std/strings/basic.string/string.require/contiguous.pass.cpp b/test/std/strings/basic.string/string.require/contiguous.pass.cpp new file mode 100644 index 000000000000..ca31ace0ef0b --- /dev/null +++ b/test/std/strings/basic.string/string.require/contiguous.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <array> + +// An string is a contiguous container + +#include <string> +#include <cassert> + +#include "test_allocator.h" +#include "min_allocator.h" + + +template <class C> +void test_contiguous ( const C &c ) +{ + for ( size_t i = 0; i < c.size(); ++i ) + assert ( *(c.begin() + i) == *(std::addressof(*c.begin()) + i)); +} + +int main() +{ + { + typedef std::string S; + test_contiguous(S()); + test_contiguous(S("1")); + test_contiguous(S("1234567890123456789012345678901234567890123456789012345678901234567890")); + } + + { + typedef test_allocator<char> A; + typedef std::basic_string<char, std::char_traits<char>, A> S; + test_contiguous(S(A(3))); + test_contiguous(S("1", A(5))); + test_contiguous(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7))); + } +#if __cplusplus >= 201103L + { + typedef min_allocator<char> A; + typedef std::basic_string<char, std::char_traits<char>, A> S; + test_contiguous(S(A{})); + test_contiguous(S("1", A())); + test_contiguous(S("1234567890123456789012345678901234567890123456789012345678901234567890", A())); + } +#endif +} diff --git a/test/std/strings/basic.string/test_traits.h b/test/std/strings/basic.string/test_traits.h new file mode 100644 index 000000000000..f635b1d75162 --- /dev/null +++ b/test/std/strings/basic.string/test_traits.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// 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 TEST_TRAITS_H +#define TEST_TRAITS_H + +template <class charT> +struct test_traits +{ + typedef charT char_type; +}; + +#endif // TEST_TRAITS_H diff --git a/test/std/strings/basic.string/types.pass.cpp b/test/std/strings/basic.string/types.pass.cpp new file mode 100644 index 000000000000..dcb3bbc35ebf --- /dev/null +++ b/test/std/strings/basic.string/types.pass.cpp @@ -0,0 +1,85 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// Test nested types and default template args: + +// template<class charT, class traits = char_traits<charT>, +// class Allocator = allocator<charT> > +// { +// public: +// // types: +// typedef traits traits_type; +// typedef typename traits::char_type value_type; +// typedef Allocator allocator_type; +// typedef typename Allocator::size_type size_type; +// typedef typename Allocator::difference_type difference_type; +// typedef typename Allocator::reference reference; +// typedef typename Allocator::const_reference const_reference; +// typedef typename Allocator::pointer pointer; +// typedef typename Allocator::const_pointer const_pointer; +// typedef implementation-defined iterator; // See 23.1 +// typedef implementation-defined const_iterator; // See 23.1 +// typedef std::reverse_iterator<iterator> reverse_iterator; +// typedef std::reverse_iterator<const_iterator> const_reverse_iterator; +// static const size_type npos = -1; +// }; + +#include <string> +#include <iterator> +#include <type_traits> + +#include "test_traits.h" +#include "test_allocator.h" +#include "min_allocator.h" + +template <class Traits, class Allocator> +void +test() +{ + typedef std::basic_string<typename Traits::char_type, Traits, Allocator> S; + + static_assert((std::is_same<typename S::traits_type, Traits>::value), ""); + static_assert((std::is_same<typename S::value_type, typename Traits::char_type>::value), ""); + static_assert((std::is_same<typename S::value_type, typename Allocator::value_type>::value), ""); + static_assert((std::is_same<typename S::allocator_type, Allocator>::value), ""); + static_assert((std::is_same<typename S::size_type, typename std::allocator_traits<Allocator>::size_type>::value), ""); + static_assert((std::is_same<typename S::difference_type, typename std::allocator_traits<Allocator>::difference_type>::value), ""); + static_assert((std::is_same<typename S::reference, typename S::value_type&>::value), ""); + static_assert((std::is_same<typename S::const_reference, const typename S::value_type&>::value), ""); + static_assert((std::is_same<typename S::pointer, typename std::allocator_traits<Allocator>::pointer>::value), ""); + static_assert((std::is_same<typename S::const_pointer, typename std::allocator_traits<Allocator>::const_pointer>::value), ""); + static_assert((std::is_same< + typename std::iterator_traits<typename S::iterator>::iterator_category, + std::random_access_iterator_tag>::value), ""); + static_assert((std::is_same< + typename std::iterator_traits<typename S::const_iterator>::iterator_category, + std::random_access_iterator_tag>::value), ""); + static_assert((std::is_same< + typename S::reverse_iterator, + std::reverse_iterator<typename S::iterator> >::value), ""); + static_assert((std::is_same< + typename S::const_reverse_iterator, + std::reverse_iterator<typename S::const_iterator> >::value), ""); + static_assert(S::npos == -1, ""); +} + +int main() +{ + test<test_traits<char>, test_allocator<char> >(); + test<std::char_traits<wchar_t>, std::allocator<wchar_t> >(); + static_assert((std::is_same<std::basic_string<char>::traits_type, + std::char_traits<char> >::value), ""); + static_assert((std::is_same<std::basic_string<char>::allocator_type, + std::allocator<char> >::value), ""); +#if __cplusplus >= 201103L + test<std::char_traits<char>, min_allocator<char> >(); +#endif +} diff --git a/test/std/strings/c.strings/cctype.pass.cpp b/test/std/strings/c.strings/cctype.pass.cpp new file mode 100644 index 000000000000..867338fb09c2 --- /dev/null +++ b/test/std/strings/c.strings/cctype.pass.cpp @@ -0,0 +1,103 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <cctype> + +#include <cctype> +#include <type_traits> +#include <cassert> + +#ifdef isalnum +#error isalnum defined +#endif + +#ifdef isalpha +#error isalpha defined +#endif + +#ifdef isblank +#error isblank defined +#endif + +#ifdef iscntrl +#error iscntrl defined +#endif + +#ifdef isdigit +#error isdigit defined +#endif + +#ifdef isgraph +#error isgraph defined +#endif + +#ifdef islower +#error islower defined +#endif + +#ifdef isprint +#error isprint defined +#endif + +#ifdef ispunct +#error ispunct defined +#endif + +#ifdef isspace +#error isspace defined +#endif + +#ifdef isupper +#error isupper defined +#endif + +#ifdef isxdigit +#error isxdigit defined +#endif + +#ifdef tolower +#error tolower defined +#endif + +#ifdef toupper +#error toupper defined +#endif + +int main() +{ + static_assert((std::is_same<decltype(std::isalnum(0)), int>::value), ""); + static_assert((std::is_same<decltype(std::isalpha(0)), int>::value), ""); + static_assert((std::is_same<decltype(std::isblank(0)), int>::value), ""); + static_assert((std::is_same<decltype(std::iscntrl(0)), int>::value), ""); + static_assert((std::is_same<decltype(std::isdigit(0)), int>::value), ""); + static_assert((std::is_same<decltype(std::isgraph(0)), int>::value), ""); + static_assert((std::is_same<decltype(std::islower(0)), int>::value), ""); + static_assert((std::is_same<decltype(std::isprint(0)), int>::value), ""); + static_assert((std::is_same<decltype(std::ispunct(0)), int>::value), ""); + static_assert((std::is_same<decltype(std::isspace(0)), int>::value), ""); + static_assert((std::is_same<decltype(std::isupper(0)), int>::value), ""); + static_assert((std::is_same<decltype(std::isxdigit(0)), int>::value), ""); + static_assert((std::is_same<decltype(std::tolower(0)), int>::value), ""); + static_assert((std::is_same<decltype(std::toupper(0)), int>::value), ""); + + assert(isalnum('a')); + assert(isalpha('a')); + assert(isblank(' ')); + assert(!iscntrl(' ')); + assert(!isdigit('a')); + assert(isgraph('a')); + assert(islower('a')); + assert(isprint('a')); + assert(!ispunct('a')); + assert(!isspace('a')); + assert(!isupper('a')); + assert(isxdigit('a')); + assert(tolower('A') == 'a'); + assert(toupper('a') == 'A'); +} diff --git a/test/std/strings/c.strings/cstring.pass.cpp b/test/std/strings/c.strings/cstring.pass.cpp new file mode 100644 index 000000000000..20f4050cfbdb --- /dev/null +++ b/test/std/strings/c.strings/cstring.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// <cstring> + +#include <cstring> +#include <type_traits> + +#ifndef NULL +#error NULL not defined +#endif + +int main() +{ + std::size_t s = 0; + void* vp = 0; + const void* vpc = 0; + char* cp = 0; + const char* cpc = 0; + static_assert((std::is_same<decltype(std::memcpy(vp, vpc, s)), void*>::value), ""); + static_assert((std::is_same<decltype(std::memmove(vp, vpc, s)), void*>::value), ""); + static_assert((std::is_same<decltype(std::strcpy(cp, cpc)), char*>::value), ""); + static_assert((std::is_same<decltype(std::strncpy(cp, cpc, s)), char*>::value), ""); + static_assert((std::is_same<decltype(std::strcat(cp, cpc)), char*>::value), ""); + static_assert((std::is_same<decltype(std::strncat(cp, cpc, s)), char*>::value), ""); + static_assert((std::is_same<decltype(std::memcmp(vpc, vpc, s)), int>::value), ""); + static_assert((std::is_same<decltype(std::strcmp(cpc, cpc)), int>::value), ""); + static_assert((std::is_same<decltype(std::strncmp(cpc, cpc, s)), int>::value), ""); + static_assert((std::is_same<decltype(std::strcoll(cpc, cpc)), int>::value), ""); + static_assert((std::is_same<decltype(std::strxfrm(cp, cpc, s)), std::size_t>::value), ""); +// static_assert((std::is_same<decltype(std::memchr(vpc, 0, s)), const void*>::value), ""); + static_assert((std::is_same<decltype(std::memchr(vp, 0, s)), void*>::value), ""); +// static_assert((std::is_same<decltype(std::strchr(cpc, 0)), const char*>::value), ""); + static_assert((std::is_same<decltype(std::strchr(cp, 0)), char*>::value), ""); + static_assert((std::is_same<decltype(std::strcspn(cpc, cpc)), std::size_t>::value), ""); +// static_assert((std::is_same<decltype(std::strpbrk(cpc, cpc)), const char*>::value), ""); + static_assert((std::is_same<decltype(std::strpbrk(cp, cpc)), char*>::value), ""); +// static_assert((std::is_same<decltype(std::strrchr(cpc, 0)), const char*>::value), ""); + static_assert((std::is_same<decltype(std::strrchr(cp, 0)), char*>::value), ""); + static_assert((std::is_same<decltype(std::strspn(cpc, cpc)), std::size_t>::value), ""); +// static_assert((std::is_same<decltype(std::strstr(cpc, cpc)), const char*>::value), ""); + static_assert((std::is_same<decltype(std::strstr(cp, cpc)), char*>::value), ""); +#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS + static_assert((std::is_same<decltype(std::strtok(cp, cpc)), char*>::value), ""); +#endif + static_assert((std::is_same<decltype(std::memset(vp, 0, s)), void*>::value), ""); + static_assert((std::is_same<decltype(std::strerror(0)), char*>::value), ""); + static_assert((std::is_same<decltype(std::strlen(cpc)), std::size_t>::value), ""); +} diff --git a/test/std/strings/c.strings/cuchar.pass.cpp b/test/std/strings/c.strings/cuchar.pass.cpp new file mode 100644 index 000000000000..022c656e8a27 --- /dev/null +++ b/test/std/strings/c.strings/cuchar.pass.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: * + +// <cuchar> + +#include <cuchar> + +int main() +{ +} diff --git a/test/std/strings/c.strings/cwchar.pass.cpp b/test/std/strings/c.strings/cwchar.pass.cpp new file mode 100644 index 000000000000..c3d868fbc3b7 --- /dev/null +++ b/test/std/strings/c.strings/cwchar.pass.cpp @@ -0,0 +1,115 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <cwchar> + +#include <cwchar> +#include <type_traits> + +#ifndef NULL +#error NULL not defined +#endif + +#ifndef WCHAR_MAX +#error WCHAR_MAX not defined +#endif + +#ifndef WCHAR_MIN +#error WCHAR_MIN not defined +#endif + +#ifndef WEOF +#error WEOF not defined +#endif + +int main() +{ + std::mbstate_t mb = {0}; + std::size_t s = 0; + std::tm *tm = 0; + std::wint_t w = 0; + ::FILE* fp = 0; +#ifdef __APPLE__ + __darwin_va_list va; +#else + __builtin_va_list va; +#endif + char* ns = 0; + wchar_t* ws = 0; + static_assert((std::is_same<decltype(std::fwprintf(fp, L"")), int>::value), ""); + static_assert((std::is_same<decltype(std::fwscanf(fp, L"")), int>::value), ""); + static_assert((std::is_same<decltype(std::swprintf(ws, s, L"")), int>::value), ""); + static_assert((std::is_same<decltype(std::swscanf(L"", L"")), int>::value), ""); + static_assert((std::is_same<decltype(std::vfwprintf(fp, L"", va)), int>::value), ""); + static_assert((std::is_same<decltype(std::vfwscanf(fp, L"", va)), int>::value), ""); + static_assert((std::is_same<decltype(std::vswprintf(ws, s, L"", va)), int>::value), ""); + static_assert((std::is_same<decltype(std::vswscanf(L"", L"", va)), int>::value), ""); + static_assert((std::is_same<decltype(std::fgetwc(fp)), std::wint_t>::value), ""); + static_assert((std::is_same<decltype(std::fgetws(ws, 0, fp)), wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::fputwc(L' ', fp)), std::wint_t>::value), ""); + static_assert((std::is_same<decltype(std::fputws(L"", fp)), int>::value), ""); + static_assert((std::is_same<decltype(std::fwide(fp, 0)), int>::value), ""); + static_assert((std::is_same<decltype(std::getwc(fp)), std::wint_t>::value), ""); + static_assert((std::is_same<decltype(std::putwc(L' ', fp)), std::wint_t>::value), ""); + static_assert((std::is_same<decltype(std::ungetwc(L' ', fp)), std::wint_t>::value), ""); + static_assert((std::is_same<decltype(std::wcstod(L"", (wchar_t**)0)), double>::value), ""); + static_assert((std::is_same<decltype(std::wcstof(L"", (wchar_t**)0)), float>::value), ""); + static_assert((std::is_same<decltype(std::wcstold(L"", (wchar_t**)0)), long double>::value), ""); + static_assert((std::is_same<decltype(std::wcstol(L"", (wchar_t**)0, 0)), long>::value), ""); + static_assert((std::is_same<decltype(std::wcstoll(L"", (wchar_t**)0, 0)), long long>::value), ""); + static_assert((std::is_same<decltype(std::wcstoul(L"", (wchar_t**)0, 0)), unsigned long>::value), ""); + static_assert((std::is_same<decltype(std::wcstoull(L"", (wchar_t**)0, 0)), unsigned long long>::value), ""); + static_assert((std::is_same<decltype(std::wcscpy(ws, L"")), wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wcsncpy(ws, L"", s)), wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wcscat(ws, L"")), wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wcsncat(ws, L"", s)), wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wcscmp(L"", L"")), int>::value), ""); + static_assert((std::is_same<decltype(std::wcscoll(L"", L"")), int>::value), ""); + static_assert((std::is_same<decltype(std::wcsncmp(L"", L"", s)), int>::value), ""); + static_assert((std::is_same<decltype(std::wcsxfrm(ws, L"", s)), std::size_t>::value), ""); + static_assert((std::is_same<decltype(std::wcschr((const wchar_t*)0, L' ')), const wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wcschr((wchar_t*)0, L' ')), wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wcscspn(L"", L"")), std::size_t>::value), ""); + static_assert((std::is_same<decltype(std::wcslen(L"")), std::size_t>::value), ""); + static_assert((std::is_same<decltype(std::wcspbrk((const wchar_t*)0, L"")), const wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wcspbrk((wchar_t*)0, L"")), wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wcsrchr((const wchar_t*)0, L' ')), const wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wcsrchr((wchar_t*)0, L' ')), wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wcsspn(L"", L"")), std::size_t>::value), ""); + static_assert((std::is_same<decltype(std::wcsstr((const wchar_t*)0, L"")), const wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wcsstr((wchar_t*)0, L"")), wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wcstok(ws, L"", (wchar_t**)0)), wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wmemchr((const wchar_t*)0, L' ', s)), const wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wmemchr((wchar_t*)0, L' ', s)), wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wmemcmp(L"", L"", s)), int>::value), ""); + static_assert((std::is_same<decltype(std::wmemcpy(ws, L"", s)), wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wmemmove(ws, L"", s)), wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wmemset(ws, L' ', s)), wchar_t*>::value), ""); + static_assert((std::is_same<decltype(std::wcsftime(ws, s, L"", tm)), std::size_t>::value), ""); + static_assert((std::is_same<decltype(std::btowc(0)), wint_t>::value), ""); + static_assert((std::is_same<decltype(std::wctob(w)), int>::value), ""); + static_assert((std::is_same<decltype(std::mbsinit(&mb)), int>::value), ""); + static_assert((std::is_same<decltype(std::mbrlen("", s, &mb)), std::size_t>::value), ""); + static_assert((std::is_same<decltype(std::mbrtowc(ws, "", s, &mb)), std::size_t>::value), ""); + static_assert((std::is_same<decltype(std::wcrtomb(ns, L' ', &mb)), std::size_t>::value), ""); + static_assert((std::is_same<decltype(std::mbsrtowcs(ws, (const char**)0, s, &mb)), std::size_t>::value), ""); + static_assert((std::is_same<decltype(std::wcsrtombs(ns, (const wchar_t**)0, s, &mb)), std::size_t>::value), ""); + +#ifndef _LIBCPP_HAS_NO_STDIN + static_assert((std::is_same<decltype(std::getwchar()), std::wint_t>::value), ""); + static_assert((std::is_same<decltype(std::vwscanf(L"", va)), int>::value), ""); + static_assert((std::is_same<decltype(std::wscanf(L"")), int>::value), ""); +#endif + +#ifndef _LIBCPP_HAS_NO_STDOUT + static_assert((std::is_same<decltype(std::putwchar(L' ')), std::wint_t>::value), ""); + static_assert((std::is_same<decltype(std::vwprintf(L"", va)), int>::value), ""); + static_assert((std::is_same<decltype(std::wprintf(L"")), int>::value), ""); +#endif +} diff --git a/test/std/strings/c.strings/cwctype.pass.cpp b/test/std/strings/c.strings/cwctype.pass.cpp new file mode 100644 index 000000000000..6d66415abdc1 --- /dev/null +++ b/test/std/strings/c.strings/cwctype.pass.cpp @@ -0,0 +1,114 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <cwctype> + +#include <cwctype> +#include <type_traits> + +#ifndef WEOF +#error WEOF not defined +#endif + +#ifdef iswalnum +#error iswalnum defined +#endif + +#ifdef iswalpha +#error iswalpha defined +#endif + +#ifdef iswblank +#error iswblank defined +#endif + +#ifdef iswcntrl +#error iswcntrl defined +#endif + +#ifdef iswdigit +#error iswdigit defined +#endif + +#ifdef iswgraph +#error iswgraph defined +#endif + +#ifdef iswlower +#error iswlower defined +#endif + +#ifdef iswprint +#error iswprint defined +#endif + +#ifdef iswpunct +#error iswpunct defined +#endif + +#ifdef iswspace +#error iswspace defined +#endif + +#ifdef iswupper +#error iswupper defined +#endif + +#ifdef iswxdigit +#error iswxdigit defined +#endif + +#ifdef iswctype +#error iswctype defined +#endif + +#ifdef wctype +#error wctype defined +#endif + +#ifdef towlower +#error towlower defined +#endif + +#ifdef towupper +#error towupper defined +#endif + +#ifdef towctrans +#error towctrans defined +#endif + +#ifdef wctrans +#error wctrans defined +#endif + +int main() +{ + std::wint_t w = 0; + std::wctrans_t wctr = 0; + std::wctype_t wct = 0; + static_assert((std::is_same<decltype(std::iswalnum(w)), int>::value), ""); + static_assert((std::is_same<decltype(std::iswalpha(w)), int>::value), ""); + static_assert((std::is_same<decltype(std::iswblank(w)), int>::value), ""); + static_assert((std::is_same<decltype(std::iswcntrl(w)), int>::value), ""); + static_assert((std::is_same<decltype(std::iswdigit(w)), int>::value), ""); + static_assert((std::is_same<decltype(std::iswgraph(w)), int>::value), ""); + static_assert((std::is_same<decltype(std::iswlower(w)), int>::value), ""); + static_assert((std::is_same<decltype(std::iswprint(w)), int>::value), ""); + static_assert((std::is_same<decltype(std::iswpunct(w)), int>::value), ""); + static_assert((std::is_same<decltype(std::iswspace(w)), int>::value), ""); + static_assert((std::is_same<decltype(std::iswupper(w)), int>::value), ""); + static_assert((std::is_same<decltype(std::iswxdigit(w)), int>::value), ""); + static_assert((std::is_same<decltype(std::iswctype(w, wct)), int>::value), ""); + static_assert((std::is_same<decltype(std::wctype("")), std::wctype_t>::value), ""); + static_assert((std::is_same<decltype(std::towlower(w)), std::wint_t>::value), ""); + static_assert((std::is_same<decltype(std::towupper(w)), std::wint_t>::value), ""); + static_assert((std::is_same<decltype(std::towctrans(w, wctr)), std::wint_t>::value), ""); + static_assert((std::is_same<decltype(std::wctrans("")), std::wctrans_t>::value), ""); +} diff --git a/test/std/strings/c.strings/version_cctype.pass.cpp b/test/std/strings/c.strings/version_cctype.pass.cpp new file mode 100644 index 000000000000..e0919d9d27b0 --- /dev/null +++ b/test/std/strings/c.strings/version_cctype.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <cctype> + +#include <cctype> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/strings/c.strings/version_cstring.pass.cpp b/test/std/strings/c.strings/version_cstring.pass.cpp new file mode 100644 index 000000000000..87e705aec4cc --- /dev/null +++ b/test/std/strings/c.strings/version_cstring.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <cstring> + +#include <cstring> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/strings/c.strings/version_cuchar.pass.cpp b/test/std/strings/c.strings/version_cuchar.pass.cpp new file mode 100644 index 000000000000..dcfdcc37ac7e --- /dev/null +++ b/test/std/strings/c.strings/version_cuchar.pass.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: * + +// <cuchar> + +#include <cuchar> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/strings/c.strings/version_cwchar.pass.cpp b/test/std/strings/c.strings/version_cwchar.pass.cpp new file mode 100644 index 000000000000..72e9855c54e5 --- /dev/null +++ b/test/std/strings/c.strings/version_cwchar.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <cwchar> + +#include <cwchar> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/strings/c.strings/version_cwctype.pass.cpp b/test/std/strings/c.strings/version_cwctype.pass.cpp new file mode 100644 index 000000000000..461482abe765 --- /dev/null +++ b/test/std/strings/c.strings/version_cwctype.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <cwctype> + +#include <cwctype> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp b/test/std/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..b58f5c55b643 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp @@ -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() +{ +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp new file mode 100644 index 000000000000..2c3deaefd063 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char> + +// static void assign(char_type& c1, const char_type& c2); + +#include <string> +#include <cassert> + +int main() +{ + char c = '\0'; + std::char_traits<char>::assign(c, 'a'); + assert(c == 'a'); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp new file mode 100644 index 000000000000..a4a0e294c262 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char> + +// static char_type* assign(char_type* s, size_t n, char_type a); + +#include <string> +#include <cassert> + +int main() +{ + char s1[] = {1, 2, 3}; + char s2[3] = {0}; + assert(std::char_traits<char>::assign(s2, 3, char(5)) == s2); + assert(s2[0] == char(5)); + assert(s2[1] == char(5)); + assert(s2[2] == char(5)); + assert(std::char_traits<char>::assign(NULL, 0, char(5)) == NULL); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp new file mode 100644 index 000000000000..ba58684b8e2e --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp @@ -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> + +// template<> struct char_traits<char> + +// static int compare(const char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<char>::compare("", "", 0) == 0); + assert(std::char_traits<char>::compare(NULL, NULL, 0) == 0); + + assert(std::char_traits<char>::compare("1", "1", 1) == 0); + assert(std::char_traits<char>::compare("1", "2", 1) < 0); + assert(std::char_traits<char>::compare("2", "1", 1) > 0); + + assert(std::char_traits<char>::compare("12", "12", 2) == 0); + assert(std::char_traits<char>::compare("12", "13", 2) < 0); + assert(std::char_traits<char>::compare("12", "22", 2) < 0); + assert(std::char_traits<char>::compare("13", "12", 2) > 0); + assert(std::char_traits<char>::compare("22", "12", 2) > 0); + + assert(std::char_traits<char>::compare("123", "123", 3) == 0); + assert(std::char_traits<char>::compare("123", "223", 3) < 0); + assert(std::char_traits<char>::compare("123", "133", 3) < 0); + assert(std::char_traits<char>::compare("123", "124", 3) < 0); + assert(std::char_traits<char>::compare("223", "123", 3) > 0); + assert(std::char_traits<char>::compare("133", "123", 3) > 0); + assert(std::char_traits<char>::compare("124", "123", 3) > 0); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp new file mode 100644 index 000000000000..179df9e19dde --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char> + +// static char_type* copy(char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ + char s1[] = {1, 2, 3}; + char s2[3] = {0}; + assert(std::char_traits<char>::copy(s2, s1, 3) == s2); + assert(s2[0] == char(1)); + assert(s2[1] == char(2)); + assert(s2[2] == char(3)); + assert(std::char_traits<char>::copy(NULL, s1, 0) == NULL); + assert(std::char_traits<char>::copy(s1, NULL, 0) == s1); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp new file mode 100644 index 000000000000..39fba6b1c068 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char> + +// static constexpr int_type eof(); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<char>::eof() == EOF); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp new file mode 100644 index 000000000000..f7f84e85924c --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char> + +// static constexpr bool eq(char_type c1, char_type c2); + +#include <string> +#include <cassert> + +int main() +{ + char c = '\0'; + assert(std::char_traits<char>::eq('a', 'a')); + assert(!std::char_traits<char>::eq('a', 'A')); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp new file mode 100644 index 000000000000..bdaf431db4dc --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char> + +// static constexpr bool eq_int_type(int_type c1, int_type c2); + +#include <string> +#include <cassert> + +int main() +{ + assert( std::char_traits<char>::eq_int_type('a', 'a')); + assert(!std::char_traits<char>::eq_int_type('a', 'A')); + assert(!std::char_traits<char>::eq_int_type(std::char_traits<char>::eof(), 'A')); + assert( std::char_traits<char>::eq_int_type(std::char_traits<char>::eof(), + std::char_traits<char>::eof())); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp new file mode 100644 index 000000000000..a640af28d8ac --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char> + +// static const char_type* find(const char_type* s, size_t n, const char_type& a); + +#include <string> +#include <cassert> + +int main() +{ + char s1[] = {1, 2, 3}; + assert(std::char_traits<char>::find(s1, 3, char(1)) == s1); + assert(std::char_traits<char>::find(s1, 3, char(2)) == s1+1); + assert(std::char_traits<char>::find(s1, 3, char(3)) == s1+2); + assert(std::char_traits<char>::find(s1, 3, char(4)) == 0); + assert(std::char_traits<char>::find(s1, 3, char(0)) == 0); + assert(std::char_traits<char>::find(NULL, 0, char(0)) == 0); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp new file mode 100644 index 000000000000..56844ef46644 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char> + +// static size_t length(const char_type* s); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<char>::length("") == 0); + assert(std::char_traits<char>::length("a") == 1); + assert(std::char_traits<char>::length("aa") == 2); + assert(std::char_traits<char>::length("aaa") == 3); + assert(std::char_traits<char>::length("aaaa") == 4); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp new file mode 100644 index 000000000000..3ff9c0f1ff92 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char> + +// static constexpr bool lt(char_type c1, char_type c2); + +#include <string> +#include <cassert> + +int main() +{ + char c = '\0'; + assert(!std::char_traits<char>::lt('a', 'a')); + assert( std::char_traits<char>::lt('A', 'a')); + assert(!std::char_traits<char>::lt('A' + 127, 'a')); + assert(!std::char_traits<char>::lt('A' - 127, 'a')); + assert( std::char_traits<char>::lt('A', 'a' + 127)); + assert( std::char_traits<char>::lt('A', 'a' - 127)); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp new file mode 100644 index 000000000000..67f0216a28b1 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char> + +// static char_type* move(char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ + char s1[] = {1, 2, 3}; + assert(std::char_traits<char>::move(s1, s1+1, 2) == s1); + assert(s1[0] == char(2)); + assert(s1[1] == char(3)); + assert(s1[2] == char(3)); + s1[2] = char(0); + assert(std::char_traits<char>::move(s1+1, s1, 2) == s1+1); + assert(s1[0] == char(2)); + assert(s1[1] == char(2)); + assert(s1[2] == char(3)); + assert(std::char_traits<char>::move(NULL, s1, 0) == NULL); + assert(std::char_traits<char>::move(s1, NULL, 0) == s1); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp new file mode 100644 index 000000000000..69800969a7f3 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char> + +// static constexpr int_type not_eof(int_type c); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<char>::not_eof('a') == 'a'); + assert(std::char_traits<char>::not_eof('A') == 'A'); + assert(std::char_traits<char>::not_eof(0) == 0); + assert(std::char_traits<char>::not_eof(std::char_traits<char>::eof()) != + std::char_traits<char>::eof()); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp new file mode 100644 index 000000000000..498abfa25fc0 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char> + +// static constexpr char_type to_char_type(int_type c); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<char>::to_char_type('a') == 'a'); + assert(std::char_traits<char>::to_char_type('A') == 'A'); + assert(std::char_traits<char>::to_char_type(0) == 0); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp new file mode 100644 index 000000000000..aa9594cfdc42 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char> + +// static constexpr int_type to_int_type(char_type c); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<char>::to_int_type('a') == 'a'); + assert(std::char_traits<char>::to_int_type('A') == 'A'); + assert(std::char_traits<char>::to_int_type(0) == 0); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp new file mode 100644 index 000000000000..ff4a93af65f2 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char> + +// typedef char char_type; +// typedef int int_type; +// typedef streamoff off_type; +// typedef streampos pos_type; +// typedef mbstate_t state_type; + +#include <string> +#include <type_traits> + +int main() +{ + static_assert((std::is_same<std::char_traits<char>::char_type, char>::value), ""); + static_assert((std::is_same<std::char_traits<char>::int_type, int>::value), ""); + static_assert((std::is_same<std::char_traits<char>::off_type, std::streamoff>::value), ""); + static_assert((std::is_same<std::char_traits<char>::pos_type, std::streampos>::value), ""); + static_assert((std::is_same<std::char_traits<char>::state_type, std::mbstate_t>::value), ""); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp new file mode 100644 index 000000000000..af87052ff219 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char16_t> + +// static void assign(char_type& c1, const char_type& c2); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char16_t c = u'\0'; + std::char_traits<char16_t>::assign(c, u'a'); + assert(c == u'a'); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp new file mode 100644 index 000000000000..fc1ba6e8670a --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char16_t> + +// static char_type* assign(char_type* s, size_t n, char_type a); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char16_t s1[] = {1, 2, 3}; + char16_t s2[3] = {0}; + assert(std::char_traits<char16_t>::assign(s2, 3, char16_t(5)) == s2); + assert(s2[0] == char16_t(5)); + assert(s2[1] == char16_t(5)); + assert(s2[2] == char16_t(5)); + assert(std::char_traits<char16_t>::assign(NULL, 0, char16_t(5)) == NULL); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp new file mode 100644 index 000000000000..b5039072dbfd --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp @@ -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> + +// template<> struct char_traits<char16_t> + +// static int compare(const char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char16_t>::compare(u"", u"", 0) == 0); + assert(std::char_traits<char16_t>::compare(NULL, NULL, 0) == 0); + + assert(std::char_traits<char16_t>::compare(u"1", u"1", 1) == 0); + assert(std::char_traits<char16_t>::compare(u"1", u"2", 1) < 0); + assert(std::char_traits<char16_t>::compare(u"2", u"1", 1) > 0); + + assert(std::char_traits<char16_t>::compare(u"12", u"12", 2) == 0); + assert(std::char_traits<char16_t>::compare(u"12", u"13", 2) < 0); + assert(std::char_traits<char16_t>::compare(u"12", u"22", 2) < 0); + assert(std::char_traits<char16_t>::compare(u"13", u"12", 2) > 0); + assert(std::char_traits<char16_t>::compare(u"22", u"12", 2) > 0); + + assert(std::char_traits<char16_t>::compare(u"123", u"123", 3) == 0); + assert(std::char_traits<char16_t>::compare(u"123", u"223", 3) < 0); + assert(std::char_traits<char16_t>::compare(u"123", u"133", 3) < 0); + assert(std::char_traits<char16_t>::compare(u"123", u"124", 3) < 0); + assert(std::char_traits<char16_t>::compare(u"223", u"123", 3) > 0); + assert(std::char_traits<char16_t>::compare(u"133", u"123", 3) > 0); + assert(std::char_traits<char16_t>::compare(u"124", u"123", 3) > 0); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp new file mode 100644 index 000000000000..4f66d2c2cade --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char16_t> + +// static char_type* copy(char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char16_t s1[] = {1, 2, 3}; + char16_t s2[3] = {0}; + assert(std::char_traits<char16_t>::copy(s2, s1, 3) == s2); + assert(s2[0] == char16_t(1)); + assert(s2[1] == char16_t(2)); + assert(s2[2] == char16_t(3)); + assert(std::char_traits<char16_t>::copy(NULL, s1, 0) == NULL); + assert(std::char_traits<char16_t>::copy(s1, NULL, 0) == s1); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp new file mode 100644 index 000000000000..4e5a1834aeb5 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char16_t> + +// static constexpr int_type eof(); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + std::char_traits<char16_t>::int_type i = std::char_traits<char16_t>::eof(); +#endif +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp new file mode 100644 index 000000000000..8216934658ce --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char16_t> + +// static constexpr bool eq(char_type c1, char_type c2); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char16_t c = u'\0'; + assert(std::char_traits<char16_t>::eq(u'a', u'a')); + assert(!std::char_traits<char16_t>::eq(u'a', u'A')); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp new file mode 100644 index 000000000000..a20aa7d47189 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char16_t> + +// static constexpr bool eq_int_type(int_type c1, int_type c2); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert( std::char_traits<char16_t>::eq_int_type(u'a', u'a')); + assert(!std::char_traits<char16_t>::eq_int_type(u'a', u'A')); + assert(!std::char_traits<char16_t>::eq_int_type(std::char_traits<char16_t>::eof(), u'A')); +#endif + assert( std::char_traits<char16_t>::eq_int_type(std::char_traits<char16_t>::eof(), + std::char_traits<char16_t>::eof())); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp new file mode 100644 index 000000000000..22db05b55a87 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char16_t> + +// static const char_type* find(const char_type* s, size_t n, const char_type& a); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char16_t s1[] = {1, 2, 3}; + assert(std::char_traits<char16_t>::find(s1, 3, char16_t(1)) == s1); + assert(std::char_traits<char16_t>::find(s1, 3, char16_t(2)) == s1+1); + assert(std::char_traits<char16_t>::find(s1, 3, char16_t(3)) == s1+2); + assert(std::char_traits<char16_t>::find(s1, 3, char16_t(4)) == 0); + assert(std::char_traits<char16_t>::find(s1, 3, char16_t(0)) == 0); + assert(std::char_traits<char16_t>::find(NULL, 0, char16_t(0)) == 0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp new file mode 100644 index 000000000000..9f6acca83e36 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char16_t> + +// static size_t length(const char_type* s); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char16_t>::length(u"") == 0); + assert(std::char_traits<char16_t>::length(u"a") == 1); + assert(std::char_traits<char16_t>::length(u"aa") == 2); + assert(std::char_traits<char16_t>::length(u"aaa") == 3); + assert(std::char_traits<char16_t>::length(u"aaaa") == 4); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp new file mode 100644 index 000000000000..135ecc05e199 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char16_t> + +// static constexpr bool lt(char_type c1, char_type c2); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char16_t c = u'\0'; + assert(!std::char_traits<char16_t>::lt(u'a', u'a')); + assert( std::char_traits<char16_t>::lt(u'A', u'a')); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp new file mode 100644 index 000000000000..b2ae8040ec24 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char16_t> + +// static char_type* move(char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char16_t s1[] = {1, 2, 3}; + assert(std::char_traits<char16_t>::move(s1, s1+1, 2) == s1); + assert(s1[0] == char16_t(2)); + assert(s1[1] == char16_t(3)); + assert(s1[2] == char16_t(3)); + s1[2] = char16_t(0); + assert(std::char_traits<char16_t>::move(s1+1, s1, 2) == s1+1); + assert(s1[0] == char16_t(2)); + assert(s1[1] == char16_t(2)); + assert(s1[2] == char16_t(3)); + assert(std::char_traits<char16_t>::move(NULL, s1, 0) == NULL); + assert(std::char_traits<char16_t>::move(s1, NULL, 0) == s1); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp new file mode 100644 index 000000000000..3c213e6e0a37 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char16_t> + +// static constexpr int_type not_eof(int_type c); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char16_t>::not_eof(u'a') == u'a'); + assert(std::char_traits<char16_t>::not_eof(u'A') == u'A'); +#endif + assert(std::char_traits<char16_t>::not_eof(0) == 0); + assert(std::char_traits<char16_t>::not_eof(std::char_traits<char16_t>::eof()) != + std::char_traits<char16_t>::eof()); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp new file mode 100644 index 000000000000..ab47403dbe01 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char16_t> + +// static constexpr char_type to_char_type(int_type c); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char16_t>::to_char_type(u'a') == u'a'); + assert(std::char_traits<char16_t>::to_char_type(u'A') == u'A'); +#endif + assert(std::char_traits<char16_t>::to_char_type(0) == 0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp new file mode 100644 index 000000000000..11eb8f525466 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char16_t> + +// static constexpr int_type to_int_type(char_type c); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char16_t>::to_int_type(u'a') == u'a'); + assert(std::char_traits<char16_t>::to_int_type(u'A') == u'A'); +#endif + assert(std::char_traits<char16_t>::to_int_type(0) == 0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp new file mode 100644 index 000000000000..a40296b25b1d --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char16_t> + +// typedef char16_t char_type; +// typedef uint_least16_t int_type; +// typedef streamoff off_type; +// typedef u16streampos pos_type; +// typedef mbstate_t state_type; + +#include <string> +#include <type_traits> +#include <cstdint> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + static_assert((std::is_same<std::char_traits<char16_t>::char_type, char16_t>::value), ""); + static_assert((std::is_same<std::char_traits<char16_t>::int_type, std::uint_least16_t>::value), ""); + static_assert((std::is_same<std::char_traits<char16_t>::off_type, std::streamoff>::value), ""); + static_assert((std::is_same<std::char_traits<char16_t>::pos_type, std::u16streampos>::value), ""); + static_assert((std::is_same<std::char_traits<char16_t>::state_type, std::mbstate_t>::value), ""); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp new file mode 100644 index 000000000000..35dcd9602d3c --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char32_t> + +// static void assign(char_type& c1, const char_type& c2); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char32_t c = U'\0'; + std::char_traits<char32_t>::assign(c, U'a'); + assert(c == U'a'); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp new file mode 100644 index 000000000000..0c31ea7ae97e --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char32_t> + +// static char_type* assign(char_type* s, size_t n, char_type a); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char32_t s1[] = {1, 2, 3}; + char32_t s2[3] = {0}; + assert(std::char_traits<char32_t>::assign(s2, 3, char32_t(5)) == s2); + assert(s2[0] == char32_t(5)); + assert(s2[1] == char32_t(5)); + assert(s2[2] == char32_t(5)); + assert(std::char_traits<char32_t>::assign(NULL, 0, char32_t(5)) == NULL); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp new file mode 100644 index 000000000000..25f2099896a6 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp @@ -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> + +// template<> struct char_traits<char32_t> + +// static int compare(const char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char32_t>::compare(U"", U"", 0) == 0); + assert(std::char_traits<char32_t>::compare(NULL, NULL, 0) == 0); + + assert(std::char_traits<char32_t>::compare(U"1", U"1", 1) == 0); + assert(std::char_traits<char32_t>::compare(U"1", U"2", 1) < 0); + assert(std::char_traits<char32_t>::compare(U"2", U"1", 1) > 0); + + assert(std::char_traits<char32_t>::compare(U"12", U"12", 2) == 0); + assert(std::char_traits<char32_t>::compare(U"12", U"13", 2) < 0); + assert(std::char_traits<char32_t>::compare(U"12", U"22", 2) < 0); + assert(std::char_traits<char32_t>::compare(U"13", U"12", 2) > 0); + assert(std::char_traits<char32_t>::compare(U"22", U"12", 2) > 0); + + assert(std::char_traits<char32_t>::compare(U"123", U"123", 3) == 0); + assert(std::char_traits<char32_t>::compare(U"123", U"223", 3) < 0); + assert(std::char_traits<char32_t>::compare(U"123", U"133", 3) < 0); + assert(std::char_traits<char32_t>::compare(U"123", U"124", 3) < 0); + assert(std::char_traits<char32_t>::compare(U"223", U"123", 3) > 0); + assert(std::char_traits<char32_t>::compare(U"133", U"123", 3) > 0); + assert(std::char_traits<char32_t>::compare(U"124", U"123", 3) > 0); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp new file mode 100644 index 000000000000..89c22250b306 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char32_t> + +// static char_type* copy(char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char32_t s1[] = {1, 2, 3}; + char32_t s2[3] = {0}; + assert(std::char_traits<char32_t>::copy(s2, s1, 3) == s2); + assert(s2[0] == char32_t(1)); + assert(s2[1] == char32_t(2)); + assert(s2[2] == char32_t(3)); + assert(std::char_traits<char32_t>::copy(NULL, s1, 0) == NULL); + assert(std::char_traits<char32_t>::copy(s1, NULL, 0) == s1); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp new file mode 100644 index 000000000000..8f804aa22e7a --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char32_t> + +// static constexpr int_type eof(); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + std::char_traits<char32_t>::int_type i = std::char_traits<char32_t>::eof(); +#endif +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp new file mode 100644 index 000000000000..ffeff0cf45a4 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char32_t> + +// static constexpr bool eq(char_type c1, char_type c2); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char32_t c = U'\0'; + assert(std::char_traits<char32_t>::eq(U'a', U'a')); + assert(!std::char_traits<char32_t>::eq(U'a', U'A')); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp new file mode 100644 index 000000000000..eb5c69661014 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char32_t> + +// static constexpr bool eq_int_type(int_type c1, int_type c2); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert( std::char_traits<char32_t>::eq_int_type(U'a', U'a')); + assert(!std::char_traits<char32_t>::eq_int_type(U'a', U'A')); + assert(!std::char_traits<char32_t>::eq_int_type(std::char_traits<char32_t>::eof(), U'A')); +#endif + assert( std::char_traits<char32_t>::eq_int_type(std::char_traits<char32_t>::eof(), + std::char_traits<char32_t>::eof())); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp new file mode 100644 index 000000000000..d0b17999d3e1 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char32_t> + +// static const char_type* find(const char_type* s, size_t n, const char_type& a); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char32_t s1[] = {1, 2, 3}; + assert(std::char_traits<char32_t>::find(s1, 3, char32_t(1)) == s1); + assert(std::char_traits<char32_t>::find(s1, 3, char32_t(2)) == s1+1); + assert(std::char_traits<char32_t>::find(s1, 3, char32_t(3)) == s1+2); + assert(std::char_traits<char32_t>::find(s1, 3, char32_t(4)) == 0); + assert(std::char_traits<char32_t>::find(s1, 3, char32_t(0)) == 0); + assert(std::char_traits<char32_t>::find(NULL, 0, char32_t(0)) == 0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp new file mode 100644 index 000000000000..d80ce051d1fa --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char32_t> + +// static size_t length(const char_type* s); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char32_t>::length(U"") == 0); + assert(std::char_traits<char32_t>::length(U"a") == 1); + assert(std::char_traits<char32_t>::length(U"aa") == 2); + assert(std::char_traits<char32_t>::length(U"aaa") == 3); + assert(std::char_traits<char32_t>::length(U"aaaa") == 4); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp new file mode 100644 index 000000000000..f667507f0457 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char32_t> + +// static constexpr bool lt(char_type c1, char_type c2); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char32_t c = U'\0'; + assert(!std::char_traits<char32_t>::lt(U'a', U'a')); + assert( std::char_traits<char32_t>::lt(U'A', U'a')); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp new file mode 100644 index 000000000000..8641525d92bd --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char32_t> + +// static char_type* move(char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char32_t s1[] = {1, 2, 3}; + assert(std::char_traits<char32_t>::move(s1, s1+1, 2) == s1); + assert(s1[0] == char32_t(2)); + assert(s1[1] == char32_t(3)); + assert(s1[2] == char32_t(3)); + s1[2] = char32_t(0); + assert(std::char_traits<char32_t>::move(s1+1, s1, 2) == s1+1); + assert(s1[0] == char32_t(2)); + assert(s1[1] == char32_t(2)); + assert(s1[2] == char32_t(3)); + assert(std::char_traits<char32_t>::move(NULL, s1, 0) == NULL); + assert(std::char_traits<char32_t>::move(s1, NULL, 0) == s1); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp new file mode 100644 index 000000000000..d794417bfd7a --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char32_t> + +// static constexpr int_type not_eof(int_type c); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char32_t>::not_eof(U'a') == U'a'); + assert(std::char_traits<char32_t>::not_eof(U'A') == U'A'); +#endif + assert(std::char_traits<char32_t>::not_eof(0) == 0); + assert(std::char_traits<char32_t>::not_eof(std::char_traits<char32_t>::eof()) != + std::char_traits<char32_t>::eof()); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp new file mode 100644 index 000000000000..1f67242b2aec --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char32_t> + +// static constexpr char_type to_char_type(int_type c); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char32_t>::to_char_type(U'a') == U'a'); + assert(std::char_traits<char32_t>::to_char_type(U'A') == U'A'); +#endif + assert(std::char_traits<char32_t>::to_char_type(0) == 0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp new file mode 100644 index 000000000000..a378186bdd6f --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char32_t> + +// static constexpr int_type to_int_type(char_type c); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char32_t>::to_int_type(U'a') == U'a'); + assert(std::char_traits<char32_t>::to_int_type(U'A') == U'A'); +#endif + assert(std::char_traits<char32_t>::to_int_type(0) == 0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp new file mode 100644 index 000000000000..3b48af14f963 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<char32_t> + +// typedef char32_t char_type; +// typedef uint_least32_t int_type; +// typedef streamoff off_type; +// typedef u32streampos pos_type; +// typedef mbstate_t state_type; + +#include <string> +#include <type_traits> +#include <cstdint> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + static_assert((std::is_same<std::char_traits<char32_t>::char_type, char32_t>::value), ""); + static_assert((std::is_same<std::char_traits<char32_t>::int_type, std::uint_least32_t>::value), ""); + static_assert((std::is_same<std::char_traits<char32_t>::off_type, std::streamoff>::value), ""); + static_assert((std::is_same<std::char_traits<char32_t>::pos_type, std::u32streampos>::value), ""); + static_assert((std::is_same<std::char_traits<char32_t>::state_type, std::mbstate_t>::value), ""); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp new file mode 100644 index 000000000000..7dcf08c2e76f --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<wchar_t> + +// static void assign(char_type& c1, const char_type& c2); + +#include <string> +#include <cassert> + +int main() +{ + wchar_t c = L'\0'; + std::char_traits<wchar_t>::assign(c, L'a'); + assert(c == L'a'); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp new file mode 100644 index 000000000000..2a00fe06e5a2 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<wchar_t> + +// static char_type* assign(char_type* s, size_t n, char_type a); + +#include <string> +#include <cassert> + +int main() +{ + wchar_t s1[] = {1, 2, 3}; + wchar_t s2[3] = {0}; + assert(std::char_traits<wchar_t>::assign(s2, 3, wchar_t(5)) == s2); + assert(s2[0] == wchar_t(5)); + assert(s2[1] == wchar_t(5)); + assert(s2[2] == wchar_t(5)); + assert(std::char_traits<wchar_t>::assign(NULL, 0, wchar_t(5)) == NULL); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp new file mode 100644 index 000000000000..124201bb82f3 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp @@ -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> + +// template<> struct char_traits<wchar_t> + +// static int compare(const char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<wchar_t>::compare(L"", L"", 0) == 0); + assert(std::char_traits<wchar_t>::compare(NULL, NULL, 0) == 0); + + assert(std::char_traits<wchar_t>::compare(L"1", L"1", 1) == 0); + assert(std::char_traits<wchar_t>::compare(L"1", L"2", 1) < 0); + assert(std::char_traits<wchar_t>::compare(L"2", L"1", 1) > 0); + + assert(std::char_traits<wchar_t>::compare(L"12", L"12", 2) == 0); + assert(std::char_traits<wchar_t>::compare(L"12", L"13", 2) < 0); + assert(std::char_traits<wchar_t>::compare(L"12", L"22", 2) < 0); + assert(std::char_traits<wchar_t>::compare(L"13", L"12", 2) > 0); + assert(std::char_traits<wchar_t>::compare(L"22", L"12", 2) > 0); + + assert(std::char_traits<wchar_t>::compare(L"123", L"123", 3) == 0); + assert(std::char_traits<wchar_t>::compare(L"123", L"223", 3) < 0); + assert(std::char_traits<wchar_t>::compare(L"123", L"133", 3) < 0); + assert(std::char_traits<wchar_t>::compare(L"123", L"124", 3) < 0); + assert(std::char_traits<wchar_t>::compare(L"223", L"123", 3) > 0); + assert(std::char_traits<wchar_t>::compare(L"133", L"123", 3) > 0); + assert(std::char_traits<wchar_t>::compare(L"124", L"123", 3) > 0); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp new file mode 100644 index 000000000000..f6d254f4c7c5 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<wchar_t> + +// static char_type* copy(char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ + wchar_t s1[] = {1, 2, 3}; + wchar_t s2[3] = {0}; + assert(std::char_traits<wchar_t>::copy(s2, s1, 3) == s2); + assert(s2[0] == wchar_t(1)); + assert(s2[1] == wchar_t(2)); + assert(s2[2] == wchar_t(3)); + assert(std::char_traits<wchar_t>::copy(NULL, s1, 0) == NULL); + assert(std::char_traits<wchar_t>::copy(s1, NULL, 0) == s1); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp new file mode 100644 index 000000000000..61499b5809f8 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<wchar_t> + +// static constexpr int_type eof(); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<wchar_t>::eof() == WEOF); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp new file mode 100644 index 000000000000..98d0926e3071 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<wchar_t> + +// static constexpr bool eq(char_type c1, char_type c2); + +#include <string> +#include <cassert> + +int main() +{ + wchar_t c = L'\0'; + assert(std::char_traits<wchar_t>::eq(L'a', L'a')); + assert(!std::char_traits<wchar_t>::eq(L'a', L'A')); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp new file mode 100644 index 000000000000..6b523dbdda23 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<wchar_t> + +// static constexpr bool eq_int_type(int_type c1, int_type c2); + +#include <string> +#include <cassert> + +int main() +{ + assert( std::char_traits<wchar_t>::eq_int_type(L'a', L'a')); + assert(!std::char_traits<wchar_t>::eq_int_type(L'a', L'A')); + assert(!std::char_traits<wchar_t>::eq_int_type(std::char_traits<wchar_t>::eof(), L'A')); + assert( std::char_traits<wchar_t>::eq_int_type(std::char_traits<wchar_t>::eof(), + std::char_traits<wchar_t>::eof())); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp new file mode 100644 index 000000000000..ead3f32fcc72 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<wchar_t> + +// static const char_type* find(const char_type* s, size_t n, const char_type& a); + +#include <string> +#include <cassert> + +int main() +{ + wchar_t s1[] = {1, 2, 3}; + assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(1)) == s1); + assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(2)) == s1+1); + assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(3)) == s1+2); + assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(4)) == 0); + assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(0)) == 0); + assert(std::char_traits<wchar_t>::find(NULL, 0, wchar_t(0)) == 0); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp new file mode 100644 index 000000000000..691e968ed246 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<wchar_t> + +// static size_t length(const char_type* s); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<wchar_t>::length(L"") == 0); + assert(std::char_traits<wchar_t>::length(L"a") == 1); + assert(std::char_traits<wchar_t>::length(L"aa") == 2); + assert(std::char_traits<wchar_t>::length(L"aaa") == 3); + assert(std::char_traits<wchar_t>::length(L"aaaa") == 4); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp new file mode 100644 index 000000000000..147a57914e09 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<wchar_t> + +// static constexpr bool lt(char_type c1, char_type c2); + +#include <string> +#include <cassert> + +int main() +{ + wchar_t c = L'\0'; + assert(!std::char_traits<wchar_t>::lt(L'a', L'a')); + assert( std::char_traits<wchar_t>::lt(L'A', L'a')); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp new file mode 100644 index 000000000000..0d80446e7118 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<wchar_t> + +// static char_type* move(char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ + wchar_t s1[] = {1, 2, 3}; + assert(std::char_traits<wchar_t>::move(s1, s1+1, 2) == s1); + assert(s1[0] == wchar_t(2)); + assert(s1[1] == wchar_t(3)); + assert(s1[2] == wchar_t(3)); + s1[2] = wchar_t(0); + assert(std::char_traits<wchar_t>::move(s1+1, s1, 2) == s1+1); + assert(s1[0] == wchar_t(2)); + assert(s1[1] == wchar_t(2)); + assert(s1[2] == wchar_t(3)); + assert(std::char_traits<wchar_t>::move(NULL, s1, 0) == NULL); + assert(std::char_traits<wchar_t>::move(s1, NULL, 0) == s1); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp new file mode 100644 index 000000000000..ee44f313b58c --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<wchar_t> + +// static constexpr int_type not_eof(int_type c); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<wchar_t>::not_eof(L'a') == L'a'); + assert(std::char_traits<wchar_t>::not_eof(L'A') == L'A'); + assert(std::char_traits<wchar_t>::not_eof(0) == 0); + assert(std::char_traits<wchar_t>::not_eof(std::char_traits<wchar_t>::eof()) != + std::char_traits<wchar_t>::eof()); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp new file mode 100644 index 000000000000..9b4c04829a92 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<wchar_t> + +// static constexpr char_type to_char_type(int_type c); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<wchar_t>::to_char_type(L'a') == L'a'); + assert(std::char_traits<wchar_t>::to_char_type(L'A') == L'A'); + assert(std::char_traits<wchar_t>::to_char_type(0) == 0); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp new file mode 100644 index 000000000000..488b03e0f014 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<wchar_t> + +// static constexpr int_type to_int_type(char_type c); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<wchar_t>::to_int_type(L'a') == L'a'); + assert(std::char_traits<wchar_t>::to_int_type(L'A') == L'A'); + assert(std::char_traits<wchar_t>::to_int_type(0) == 0); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp new file mode 100644 index 000000000000..12598975c4fe --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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<> struct char_traits<wchar_t> + +// typedef wchar_t char_type; +// typedef int int_type; +// typedef streamoff off_type; +// typedef streampos pos_type; +// typedef mbstate_t state_type; + +#include <string> +#include <type_traits> + +int main() +{ + static_assert((std::is_same<std::char_traits<wchar_t>::char_type, wchar_t>::value), ""); + static_assert((std::is_same<std::char_traits<wchar_t>::int_type, std::wint_t>::value), ""); + static_assert((std::is_same<std::char_traits<wchar_t>::off_type, std::streamoff>::value), ""); + static_assert((std::is_same<std::char_traits<wchar_t>::pos_type, std::wstreampos>::value), ""); + static_assert((std::is_same<std::char_traits<wchar_t>::state_type, std::mbstate_t>::value), ""); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..b58f5c55b643 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp @@ -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() +{ +} diff --git a/test/std/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp b/test/std/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..b58f5c55b643 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp @@ -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() +{ +} diff --git a/test/std/strings/char.traits/nothing_to_do.pass.cpp b/test/std/strings/char.traits/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..b58f5c55b643 --- /dev/null +++ b/test/std/strings/char.traits/nothing_to_do.pass.cpp @@ -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() +{ +} diff --git a/test/std/strings/string.classes/typedefs.pass.cpp b/test/std/strings/string.classes/typedefs.pass.cpp new file mode 100644 index 000000000000..11ee6c8a1215 --- /dev/null +++ b/test/std/strings/string.classes/typedefs.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// Test for the existence of: + +// basic_string typedef names +// typedef basic_string<char> string; +// typedef basic_string<char16_t> u16string; +// typedef basic_string<char32_t> u32string; +// typedef basic_string<wchar_t> wstring; + +#include <string> + +int main() +{ + typedef std::string test1; + typedef std::wstring test2; +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + typedef std::u16string test3; + typedef std::u32string test4; +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/string.conversions/stod.pass.cpp b/test/std/strings/string.conversions/stod.pass.cpp new file mode 100644 index 000000000000..026d2301e071 --- /dev/null +++ b/test/std/strings/string.conversions/stod.pass.cpp @@ -0,0 +1,166 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// double stod(const string& str, size_t *idx = 0); +// double stod(const wstring& str, size_t *idx = 0); + +#include <string> +#include <cmath> +#include <cassert> + +int main() +{ + assert(std::stod("0") == 0); + assert(std::stod(L"0") == 0); + assert(std::stod("-0") == 0); + assert(std::stod(L"-0") == 0); + assert(std::stod("-10") == -10); + assert(std::stod(L"-10.5") == -10.5); + assert(std::stod(" 10") == 10); + assert(std::stod(L" 10") == 10); + size_t idx = 0; + assert(std::stod("10g", &idx) == 10); + assert(idx == 2); + idx = 0; + assert(std::stod(L"10g", &idx) == 10); + assert(idx == 2); + try + { + assert(std::stod("1.e60", &idx) == 1.e60); + assert(idx == 5); + } + catch (const std::out_of_range&) + { + assert(false); + } + try + { + assert(std::stod(L"1.e60", &idx) == 1.e60); + assert(idx == 5); + } + catch (const std::out_of_range&) + { + assert(false); + } + idx = 0; + try + { + assert(std::stod("1.e360", &idx) == INFINITY); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } + try + { + assert(std::stod(L"1.e360", &idx) == INFINITY); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } + try + { + assert(std::stod("INF", &idx) == INFINITY); + assert(idx == 3); + } + catch (const std::out_of_range&) + { + assert(false); + } + idx = 0; + try + { + assert(std::stod(L"INF", &idx) == INFINITY); + assert(idx == 3); + } + catch (const std::out_of_range&) + { + assert(false); + } + idx = 0; + try + { + assert(std::isnan(std::stod("NAN", &idx))); + assert(idx == 3); + } + catch (const std::out_of_range&) + { + assert(false); + } + idx = 0; + try + { + assert(std::isnan(std::stod(L"NAN", &idx))); + assert(idx == 3); + } + catch (const std::out_of_range&) + { + assert(false); + } + idx = 0; + try + { + std::stod("", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stod(L"", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stod(" - 8", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stod(L" - 8", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stod("a1", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stod(L"a1", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } +} diff --git a/test/std/strings/string.conversions/stof.pass.cpp b/test/std/strings/string.conversions/stof.pass.cpp new file mode 100644 index 000000000000..3e9b681ddeb1 --- /dev/null +++ b/test/std/strings/string.conversions/stof.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 +// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 + +// <string> + +// float stof(const string& str, size_t *idx = 0); +// float stof(const wstring& str, size_t *idx = 0); + +#include <string> +#include <cmath> +#include <cassert> + +int main() +{ + assert(std::stof("0") == 0); + assert(std::stof(L"0") == 0); + assert(std::stof("-0") == 0); + assert(std::stof(L"-0") == 0); + assert(std::stof("-10") == -10); + assert(std::stof(L"-10.5") == -10.5); + assert(std::stof(" 10") == 10); + assert(std::stof(L" 10") == 10); + size_t idx = 0; + assert(std::stof("10g", &idx) == 10); + assert(idx == 2); + idx = 0; + assert(std::stof(L"10g", &idx) == 10); + assert(idx == 2); + idx = 0; + try + { + assert(std::stof("1.e60", &idx) == INFINITY); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } + try + { + assert(std::stof(L"1.e60", &idx) == INFINITY); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } + idx = 0; + try + { + assert(std::stof("1.e360", &idx) == INFINITY); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } + try + { + assert(std::stof(L"1.e360", &idx) == INFINITY); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } + try + { + assert(std::stof("INF", &idx) == INFINITY); + assert(idx == 3); + } + catch (const std::out_of_range&) + { + assert(false); + } + idx = 0; + try + { + assert(std::stof(L"INF", &idx) == INFINITY); + assert(idx == 3); + } + catch (const std::out_of_range&) + { + assert(false); + } + idx = 0; + try + { + assert(std::isnan(std::stof("NAN", &idx))); + assert(idx == 3); + } + catch (const std::out_of_range&) + { + assert(false); + } + idx = 0; + try + { + assert(std::isnan(std::stof(L"NAN", &idx))); + assert(idx == 3); + } + catch (const std::out_of_range&) + { + assert(false); + } + idx = 0; + try + { + std::stof("", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stof(L"", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stof(" - 8", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stof(L" - 8", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stof("a1", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stof(L"a1", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } +} diff --git a/test/std/strings/string.conversions/stoi.pass.cpp b/test/std/strings/string.conversions/stoi.pass.cpp new file mode 100644 index 000000000000..c2fc2103579d --- /dev/null +++ b/test/std/strings/string.conversions/stoi.pass.cpp @@ -0,0 +1,108 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// int stoi(const string& str, size_t *idx = 0, int base = 10); +// int stoi(const wstring& str, size_t *idx = 0, int base = 10); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::stoi("0") == 0); + assert(std::stoi(L"0") == 0); + assert(std::stoi("-0") == 0); + assert(std::stoi(L"-0") == 0); + assert(std::stoi("-10") == -10); + assert(std::stoi(L"-10") == -10); + assert(std::stoi(" 10") == 10); + assert(std::stoi(L" 10") == 10); + size_t idx = 0; + assert(std::stoi("10g", &idx, 16) == 16); + assert(idx == 2); + idx = 0; + assert(std::stoi(L"10g", &idx, 16) == 16); + assert(idx == 2); + if (std::numeric_limits<long>::max() > std::numeric_limits<int>::max()) + { + try + { + std::stoi("0x100000000", &idx, 16); + assert(false); + } + catch (const std::out_of_range&) + { + } + try + { + std::stoi(L"0x100000000", &idx, 16); + assert(false); + } + catch (const std::out_of_range&) + { + } + } + idx = 0; + try + { + std::stoi("", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoi(L"", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoi(" - 8", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoi(L" - 8", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoi("a1", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoi(L"a1", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } +} diff --git a/test/std/strings/string.conversions/stol.pass.cpp b/test/std/strings/string.conversions/stol.pass.cpp new file mode 100644 index 000000000000..dbbccc92799c --- /dev/null +++ b/test/std/strings/string.conversions/stol.pass.cpp @@ -0,0 +1,111 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 +// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 + +// <string> + +// long stol(const string& str, size_t *idx = 0, int base = 10); +// long stol(const wstring& str, size_t *idx = 0, int base = 10); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::stol("0") == 0); + assert(std::stol(L"0") == 0); + assert(std::stol("-0") == 0); + assert(std::stol(L"-0") == 0); + assert(std::stol("-10") == -10); + assert(std::stol(L"-10") == -10); + assert(std::stol(" 10") == 10); + assert(std::stol(L" 10") == 10); + size_t idx = 0; + assert(std::stol("10g", &idx, 16) == 16); + assert(idx == 2); + idx = 0; + assert(std::stol(L"10g", &idx, 16) == 16); + assert(idx == 2); + idx = 0; + try + { + std::stol("", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stol(L"", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stol(" - 8", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stol(L" - 8", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stol("a1", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stol(L"a1", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } +// LWG issue #2009 + try + { + std::stol("9999999999999999999999999999999999999999999999999", &idx); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } + try + { + std::stol(L"9999999999999999999999999999999999999999999999999", &idx); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } +} diff --git a/test/std/strings/string.conversions/stold.pass.cpp b/test/std/strings/string.conversions/stold.pass.cpp new file mode 100644 index 000000000000..93c59fe09a11 --- /dev/null +++ b/test/std/strings/string.conversions/stold.pass.cpp @@ -0,0 +1,168 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// long double stold(const string& str, size_t *idx = 0); +// long double stold(const wstring& str, size_t *idx = 0); + +#include <iostream> + +#include <string> +#include <cmath> +#include <cassert> + +int main() +{ + assert(std::stold("0") == 0); + assert(std::stold(L"0") == 0); + assert(std::stold("-0") == 0); + assert(std::stold(L"-0") == 0); + assert(std::stold("-10") == -10); + assert(std::stold(L"-10.5") == -10.5); + assert(std::stold(" 10") == 10); + assert(std::stold(L" 10") == 10); + size_t idx = 0; + assert(std::stold("10g", &idx) == 10); + assert(idx == 2); + idx = 0; + assert(std::stold(L"10g", &idx) == 10); + assert(idx == 2); + try + { + assert(std::stold("1.e60", &idx) == 1.e60L); + assert(idx == 5); + } + catch (const std::out_of_range&) + { + assert(false); + } + try + { + assert(std::stold(L"1.e60", &idx) == 1.e60L); + assert(idx == 5); + } + catch (const std::out_of_range&) + { + assert(false); + } + idx = 0; + try + { + assert(std::stold("1.e6000", &idx) == INFINITY); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } + try + { + assert(std::stold(L"1.e6000", &idx) == INFINITY); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } + try + { + assert(std::stold("INF", &idx) == INFINITY); + assert(idx == 3); + } + catch (const std::out_of_range&) + { + assert(false); + } + idx = 0; + try + { + assert(std::stold(L"INF", &idx) == INFINITY); + assert(idx == 3); + } + catch (const std::out_of_range&) + { + assert(false); + } + idx = 0; + try + { + assert(std::isnan(std::stold("NAN", &idx))); + assert(idx == 3); + } + catch (const std::out_of_range&) + { + assert(false); + } + idx = 0; + try + { + assert(std::isnan(std::stold(L"NAN", &idx))); + assert(idx == 3); + } + catch (const std::out_of_range&) + { + assert(false); + } + idx = 0; + try + { + std::stold("", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stold(L"", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stold(" - 8", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stold(L" - 8", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stold("a1", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stold(L"a1", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } +} diff --git a/test/std/strings/string.conversions/stoll.pass.cpp b/test/std/strings/string.conversions/stoll.pass.cpp new file mode 100644 index 000000000000..f68490ed13ae --- /dev/null +++ b/test/std/strings/string.conversions/stoll.pass.cpp @@ -0,0 +1,110 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 +// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 + +// <string> + +// long long stoll(const string& str, size_t *idx = 0, int base = 10); +// long long stoll(const wstring& str, size_t *idx = 0, int base = 10); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::stoll("0") == 0); + assert(std::stoll(L"0") == 0); + assert(std::stoll("-0") == 0); + assert(std::stoll(L"-0") == 0); + assert(std::stoll("-10") == -10); + assert(std::stoll(L"-10") == -10); + assert(std::stoll(" 10") == 10); + assert(std::stoll(L" 10") == 10); + size_t idx = 0; + assert(std::stoll("10g", &idx, 16) == 16); + assert(idx == 2); + idx = 0; + assert(std::stoll(L"10g", &idx, 16) == 16); + assert(idx == 2); + idx = 0; + try + { + std::stoll("", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoll(L"", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoll(" - 8", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoll(L" - 8", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoll("a1", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoll(L"a1", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoll("99999999999999999999999999", &idx); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } + try + { + std::stoll(L"99999999999999999999999999", &idx); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } +} diff --git a/test/std/strings/string.conversions/stoul.pass.cpp b/test/std/strings/string.conversions/stoul.pass.cpp new file mode 100644 index 000000000000..37d33c4a9091 --- /dev/null +++ b/test/std/strings/string.conversions/stoul.pass.cpp @@ -0,0 +1,109 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 +// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 + +// <string> + +// unsigned long stoul(const string& str, size_t *idx = 0, int base = 10); +// unsigned long stoul(const wstring& str, size_t *idx = 0, int base = 10); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::stoul("0") == 0); + assert(std::stoul(L"0") == 0); + assert(std::stoul("-0") == 0); + assert(std::stoul(L"-0") == 0); + assert(std::stoul(" 10") == 10); + assert(std::stoul(L" 10") == 10); + size_t idx = 0; + assert(std::stoul("10g", &idx, 16) == 16); + assert(idx == 2); + idx = 0; + assert(std::stoul(L"10g", &idx, 16) == 16); + assert(idx == 2); + idx = 0; + try + { + std::stoul("", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoul(L"", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoul(" - 8", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoul(L" - 8", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoul("a1", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoul(L"a1", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } +// LWG issue #2009 + try + { + std::stoul("9999999999999999999999999999999999999999999999999", &idx); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } + try + { + std::stoul(L"9999999999999999999999999999999999999999999999999", &idx); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } +} diff --git a/test/std/strings/string.conversions/stoull.pass.cpp b/test/std/strings/string.conversions/stoull.pass.cpp new file mode 100644 index 000000000000..c0667edb385e --- /dev/null +++ b/test/std/strings/string.conversions/stoull.pass.cpp @@ -0,0 +1,110 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 +// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 + +// <string> + +// unsigned long long stoull(const string& str, size_t *idx = 0, int base = 10); +// unsigned long long stoull(const wstring& str, size_t *idx = 0, int base = 10); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::stoull("0") == 0); + assert(std::stoull(L"0") == 0); + assert(std::stoull("-0") == 0); + assert(std::stoull(L"-0") == 0); + assert(std::stoull(" 10") == 10); + assert(std::stoull(L" 10") == 10); + size_t idx = 0; + assert(std::stoull("10g", &idx, 16) == 16); + assert(idx == 2); + idx = 0; + assert(std::stoull(L"10g", &idx, 16) == 16); + assert(idx == 2); + idx = 0; + try + { + std::stoull("", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + idx = 0; + try + { + std::stoull(L"", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoull(" - 8", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoull(L" - 8", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoull("a1", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } + try + { + std::stoull(L"a1", &idx); + assert(false); + } + catch (const std::invalid_argument&) + { + assert(idx == 0); + } +// LWG issue #2009 + try + { + std::stoull("9999999999999999999999999999999999999999999999999", &idx); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } + try + { + std::stoull(L"9999999999999999999999999999999999999999999999999", &idx); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } +} diff --git a/test/std/strings/string.conversions/to_string.pass.cpp b/test/std/strings/string.conversions/to_string.pass.cpp new file mode 100644 index 000000000000..05e5e4b922a5 --- /dev/null +++ b/test/std/strings/string.conversions/to_string.pass.cpp @@ -0,0 +1,126 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// string to_string(int val); +// string to_string(unsigned val); +// string to_string(long val); +// string to_string(unsigned long val); +// string to_string(long long val); +// string to_string(unsigned long long val); +// string to_string(float val); +// string to_string(double val); +// string to_string(long double val); + +#include <string> +#include <cassert> +#include <sstream> + +template <class T> +void +test_signed() +{ + { + std::string s = std::to_string(T(0)); + assert(s.size() == 1); + assert(s[s.size()] == 0); + assert(s == "0"); + } + { + std::string s = std::to_string(T(12345)); + assert(s.size() == 5); + assert(s[s.size()] == 0); + assert(s == "12345"); + } + { + std::string s = std::to_string(T(-12345)); + assert(s.size() == 6); + assert(s[s.size()] == 0); + assert(s == "-12345"); + } + { + std::string s = std::to_string(std::numeric_limits<T>::max()); + assert(s.size() == std::numeric_limits<T>::digits10 + 1); + std::istringstream is(s); + T t(0); + is >> t; + assert(t == std::numeric_limits<T>::max()); + } + { + std::string s = std::to_string(std::numeric_limits<T>::min()); + std::istringstream is(s); + T t(0); + is >> t; + assert(t == std::numeric_limits<T>::min()); + } +} + +template <class T> +void +test_unsigned() +{ + { + std::string s = std::to_string(T(0)); + assert(s.size() == 1); + assert(s[s.size()] == 0); + assert(s == "0"); + } + { + std::string s = std::to_string(T(12345)); + assert(s.size() == 5); + assert(s[s.size()] == 0); + assert(s == "12345"); + } + { + std::string s = std::to_string(std::numeric_limits<T>::max()); + assert(s.size() == std::numeric_limits<T>::digits10 + 1); + std::istringstream is(s); + T t(0); + is >> t; + assert(t == std::numeric_limits<T>::max()); + } +} + +template <class T> +void +test_float() +{ + { + std::string s = std::to_string(T(0)); + assert(s.size() == 8); + assert(s[s.size()] == 0); + assert(s == "0.000000"); + } + { + std::string s = std::to_string(T(12345)); + assert(s.size() == 12); + assert(s[s.size()] == 0); + assert(s == "12345.000000"); + } + { + std::string s = std::to_string(T(-12345)); + assert(s.size() == 13); + assert(s[s.size()] == 0); + assert(s == "-12345.000000"); + } +} + +int main() +{ + test_signed<int>(); + test_signed<long>(); + test_signed<long long>(); + test_unsigned<unsigned>(); + test_unsigned<unsigned long>(); + test_unsigned<unsigned long long>(); + test_float<float>(); + test_float<double>(); + test_float<long double>(); +} diff --git a/test/std/strings/string.conversions/to_wstring.pass.cpp b/test/std/strings/string.conversions/to_wstring.pass.cpp new file mode 100644 index 000000000000..281aa1a5e79b --- /dev/null +++ b/test/std/strings/string.conversions/to_wstring.pass.cpp @@ -0,0 +1,126 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// wstring to_wstring(int val); +// wstring to_wstring(unsigned val); +// wstring to_wstring(long val); +// wstring to_wstring(unsigned long val); +// wstring to_wstring(long long val); +// wstring to_wstring(unsigned long long val); +// wstring to_wstring(float val); +// wstring to_wstring(double val); +// wstring to_wstring(long double val); + +#include <string> +#include <cassert> +#include <sstream> + +template <class T> +void +test_signed() +{ + { + std::wstring s = std::to_wstring(T(0)); + assert(s.size() == 1); + assert(s[s.size()] == 0); + assert(s == L"0"); + } + { + std::wstring s = std::to_wstring(T(12345)); + assert(s.size() == 5); + assert(s[s.size()] == 0); + assert(s == L"12345"); + } + { + std::wstring s = std::to_wstring(T(-12345)); + assert(s.size() == 6); + assert(s[s.size()] == 0); + assert(s == L"-12345"); + } + { + std::wstring s = std::to_wstring(std::numeric_limits<T>::max()); + assert(s.size() == std::numeric_limits<T>::digits10 + 1); + std::wistringstream is(s); + T t(0); + is >> t; + assert(t == std::numeric_limits<T>::max()); + } + { + std::wstring s = std::to_wstring(std::numeric_limits<T>::min()); + std::wistringstream is(s); + T t(0); + is >> t; + assert(t == std::numeric_limits<T>::min()); + } +} + +template <class T> +void +test_unsigned() +{ + { + std::wstring s = std::to_wstring(T(0)); + assert(s.size() == 1); + assert(s[s.size()] == 0); + assert(s == L"0"); + } + { + std::wstring s = std::to_wstring(T(12345)); + assert(s.size() == 5); + assert(s[s.size()] == 0); + assert(s == L"12345"); + } + { + std::wstring s = std::to_wstring(std::numeric_limits<T>::max()); + assert(s.size() == std::numeric_limits<T>::digits10 + 1); + std::wistringstream is(s); + T t(0); + is >> t; + assert(t == std::numeric_limits<T>::max()); + } +} + +template <class T> +void +test_float() +{ + { + std::wstring s = std::to_wstring(T(0)); + assert(s.size() == 8); + assert(s[s.size()] == 0); + assert(s == L"0.000000"); + } + { + std::wstring s = std::to_wstring(T(12345)); + assert(s.size() == 12); + assert(s[s.size()] == 0); + assert(s == L"12345.000000"); + } + { + std::wstring s = std::to_wstring(T(-12345)); + assert(s.size() == 13); + assert(s[s.size()] == 0); + assert(s == L"-12345.000000"); + } +} + +int main() +{ + test_signed<int>(); + test_signed<long>(); + test_signed<long long>(); + test_unsigned<unsigned>(); + test_unsigned<unsigned long>(); + test_unsigned<unsigned long long>(); + test_float<float>(); + test_float<double>(); + test_float<long double>(); +} diff --git a/test/std/strings/strings.general/nothing_to_do.pass.cpp b/test/std/strings/strings.general/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..9a59227abdd9 --- /dev/null +++ b/test/std/strings/strings.general/nothing_to_do.pass.cpp @@ -0,0 +1,13 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/test/std/strings/version.pass.cpp b/test/std/strings/version.pass.cpp new file mode 100644 index 000000000000..0c79c1af2ce8 --- /dev/null +++ b/test/std/strings/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +#include <string> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} |