]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp
Vendor import of libc++ trunk r290819:
[FreeBSD/FreeBSD.git] / test / std / strings / basic.string / string.modifiers / string_replace / size_size_pointer_size.pass.cpp
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <string>
11
12 // basic_string<charT,traits,Allocator>&
13 //   replace(size_type pos, size_type n1, const charT* s, size_type n2);
14
15 #include <string>
16 #include <stdexcept>
17 #include <algorithm>
18 #include <cassert>
19
20 #include "test_macros.h"
21 #include "min_allocator.h"
22
23 template <class S>
24 void
25 test(S s, typename S::size_type pos, typename S::size_type n1,
26      const typename S::value_type* str, typename S::size_type n2,
27      S expected)
28 {
29     const typename S::size_type old_size = s.size();
30     S s0 = s;
31     if (pos <= old_size)
32     {
33         s.replace(pos, n1, str, n2);
34         LIBCPP_ASSERT(s.__invariants());
35         assert(s == expected);
36         typename S::size_type xlen = std::min(n1, old_size - pos);
37         typename S::size_type rlen = n2;
38         assert(s.size() == old_size - xlen + rlen);
39     }
40 #ifndef TEST_HAS_NO_EXCEPTIONS
41     else
42     {
43         try
44         {
45             s.replace(pos, n1, str, n2);
46             assert(false);
47         }
48         catch (std::out_of_range&)
49         {
50             assert(pos > old_size);
51             assert(s == s0);
52         }
53     }
54 #endif
55 }
56
57 template <class S>
58 void test0()
59 {
60     test(S(""), 0, 0, "", 0, S(""));
61     test(S(""), 0, 0, "12345", 0, S(""));
62     test(S(""), 0, 0, "12345", 1, S("1"));
63     test(S(""), 0, 0, "12345", 2, S("12"));
64     test(S(""), 0, 0, "12345", 4, S("1234"));
65     test(S(""), 0, 0, "12345", 5, S("12345"));
66     test(S(""), 0, 0, "1234567890", 0, S(""));
67     test(S(""), 0, 0, "1234567890", 1, S("1"));
68     test(S(""), 0, 0, "1234567890", 5, S("12345"));
69     test(S(""), 0, 0, "1234567890", 9, S("123456789"));
70     test(S(""), 0, 0, "1234567890", 10, S("1234567890"));
71     test(S(""), 0, 0, "12345678901234567890", 0, S(""));
72     test(S(""), 0, 0, "12345678901234567890", 1, S("1"));
73     test(S(""), 0, 0, "12345678901234567890", 10, S("1234567890"));
74     test(S(""), 0, 0, "12345678901234567890", 19, S("1234567890123456789"));
75     test(S(""), 0, 0, "12345678901234567890", 20, S("12345678901234567890"));
76     test(S(""), 0, 1, "", 0, S(""));
77     test(S(""), 0, 1, "12345", 0, S(""));
78     test(S(""), 0, 1, "12345", 1, S("1"));
79     test(S(""), 0, 1, "12345", 2, S("12"));
80     test(S(""), 0, 1, "12345", 4, S("1234"));
81     test(S(""), 0, 1, "12345", 5, S("12345"));
82     test(S(""), 0, 1, "1234567890", 0, S(""));
83     test(S(""), 0, 1, "1234567890", 1, S("1"));
84     test(S(""), 0, 1, "1234567890", 5, S("12345"));
85     test(S(""), 0, 1, "1234567890", 9, S("123456789"));
86     test(S(""), 0, 1, "1234567890", 10, S("1234567890"));
87     test(S(""), 0, 1, "12345678901234567890", 0, S(""));
88     test(S(""), 0, 1, "12345678901234567890", 1, S("1"));
89     test(S(""), 0, 1, "12345678901234567890", 10, S("1234567890"));
90     test(S(""), 0, 1, "12345678901234567890", 19, S("1234567890123456789"));
91     test(S(""), 0, 1, "12345678901234567890", 20, S("12345678901234567890"));
92     test(S(""), 1, 0, "", 0, S("can't happen"));
93     test(S(""), 1, 0, "12345", 0, S("can't happen"));
94     test(S(""), 1, 0, "12345", 1, S("can't happen"));
95     test(S(""), 1, 0, "12345", 2, S("can't happen"));
96     test(S(""), 1, 0, "12345", 4, S("can't happen"));
97     test(S(""), 1, 0, "12345", 5, S("can't happen"));
98     test(S(""), 1, 0, "1234567890", 0, S("can't happen"));
99     test(S(""), 1, 0, "1234567890", 1, S("can't happen"));
100     test(S(""), 1, 0, "1234567890", 5, S("can't happen"));
101     test(S(""), 1, 0, "1234567890", 9, S("can't happen"));
102     test(S(""), 1, 0, "1234567890", 10, S("can't happen"));
103     test(S(""), 1, 0, "12345678901234567890", 0, S("can't happen"));
104     test(S(""), 1, 0, "12345678901234567890", 1, S("can't happen"));
105     test(S(""), 1, 0, "12345678901234567890", 10, S("can't happen"));
106     test(S(""), 1, 0, "12345678901234567890", 19, S("can't happen"));
107     test(S(""), 1, 0, "12345678901234567890", 20, S("can't happen"));
108     test(S("abcde"), 0, 0, "", 0, S("abcde"));
109     test(S("abcde"), 0, 0, "12345", 0, S("abcde"));
110     test(S("abcde"), 0, 0, "12345", 1, S("1abcde"));
111     test(S("abcde"), 0, 0, "12345", 2, S("12abcde"));
112     test(S("abcde"), 0, 0, "12345", 4, S("1234abcde"));
113     test(S("abcde"), 0, 0, "12345", 5, S("12345abcde"));
114     test(S("abcde"), 0, 0, "1234567890", 0, S("abcde"));
115     test(S("abcde"), 0, 0, "1234567890", 1, S("1abcde"));
116     test(S("abcde"), 0, 0, "1234567890", 5, S("12345abcde"));
117     test(S("abcde"), 0, 0, "1234567890", 9, S("123456789abcde"));
118     test(S("abcde"), 0, 0, "1234567890", 10, S("1234567890abcde"));
119     test(S("abcde"), 0, 0, "12345678901234567890", 0, S("abcde"));
120     test(S("abcde"), 0, 0, "12345678901234567890", 1, S("1abcde"));
121     test(S("abcde"), 0, 0, "12345678901234567890", 10, S("1234567890abcde"));
122     test(S("abcde"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcde"));
123     test(S("abcde"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcde"));
124     test(S("abcde"), 0, 1, "", 0, S("bcde"));
125     test(S("abcde"), 0, 1, "12345", 0, S("bcde"));
126     test(S("abcde"), 0, 1, "12345", 1, S("1bcde"));
127     test(S("abcde"), 0, 1, "12345", 2, S("12bcde"));
128     test(S("abcde"), 0, 1, "12345", 4, S("1234bcde"));
129     test(S("abcde"), 0, 1, "12345", 5, S("12345bcde"));
130     test(S("abcde"), 0, 1, "1234567890", 0, S("bcde"));
131     test(S("abcde"), 0, 1, "1234567890", 1, S("1bcde"));
132     test(S("abcde"), 0, 1, "1234567890", 5, S("12345bcde"));
133     test(S("abcde"), 0, 1, "1234567890", 9, S("123456789bcde"));
134     test(S("abcde"), 0, 1, "1234567890", 10, S("1234567890bcde"));
135     test(S("abcde"), 0, 1, "12345678901234567890", 0, S("bcde"));
136     test(S("abcde"), 0, 1, "12345678901234567890", 1, S("1bcde"));
137     test(S("abcde"), 0, 1, "12345678901234567890", 10, S("1234567890bcde"));
138     test(S("abcde"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcde"));
139     test(S("abcde"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcde"));
140     test(S("abcde"), 0, 2, "", 0, S("cde"));
141     test(S("abcde"), 0, 2, "12345", 0, S("cde"));
142     test(S("abcde"), 0, 2, "12345", 1, S("1cde"));
143     test(S("abcde"), 0, 2, "12345", 2, S("12cde"));
144     test(S("abcde"), 0, 2, "12345", 4, S("1234cde"));
145     test(S("abcde"), 0, 2, "12345", 5, S("12345cde"));
146     test(S("abcde"), 0, 2, "1234567890", 0, S("cde"));
147     test(S("abcde"), 0, 2, "1234567890", 1, S("1cde"));
148     test(S("abcde"), 0, 2, "1234567890", 5, S("12345cde"));
149     test(S("abcde"), 0, 2, "1234567890", 9, S("123456789cde"));
150     test(S("abcde"), 0, 2, "1234567890", 10, S("1234567890cde"));
151     test(S("abcde"), 0, 2, "12345678901234567890", 0, S("cde"));
152     test(S("abcde"), 0, 2, "12345678901234567890", 1, S("1cde"));
153     test(S("abcde"), 0, 2, "12345678901234567890", 10, S("1234567890cde"));
154     test(S("abcde"), 0, 2, "12345678901234567890", 19, S("1234567890123456789cde"));
155     test(S("abcde"), 0, 2, "12345678901234567890", 20, S("12345678901234567890cde"));
156     test(S("abcde"), 0, 4, "", 0, S("e"));
157     test(S("abcde"), 0, 4, "12345", 0, S("e"));
158     test(S("abcde"), 0, 4, "12345", 1, S("1e"));
159     test(S("abcde"), 0, 4, "12345", 2, S("12e"));
160 }
161
162 template <class S>
163 void test1()
164 {
165     test(S("abcde"), 0, 4, "12345", 4, S("1234e"));
166     test(S("abcde"), 0, 4, "12345", 5, S("12345e"));
167     test(S("abcde"), 0, 4, "1234567890", 0, S("e"));
168     test(S("abcde"), 0, 4, "1234567890", 1, S("1e"));
169     test(S("abcde"), 0, 4, "1234567890", 5, S("12345e"));
170     test(S("abcde"), 0, 4, "1234567890", 9, S("123456789e"));
171     test(S("abcde"), 0, 4, "1234567890", 10, S("1234567890e"));
172     test(S("abcde"), 0, 4, "12345678901234567890", 0, S("e"));
173     test(S("abcde"), 0, 4, "12345678901234567890", 1, S("1e"));
174     test(S("abcde"), 0, 4, "12345678901234567890", 10, S("1234567890e"));
175     test(S("abcde"), 0, 4, "12345678901234567890", 19, S("1234567890123456789e"));
176     test(S("abcde"), 0, 4, "12345678901234567890", 20, S("12345678901234567890e"));
177     test(S("abcde"), 0, 5, "", 0, S(""));
178     test(S("abcde"), 0, 5, "12345", 0, S(""));
179     test(S("abcde"), 0, 5, "12345", 1, S("1"));
180     test(S("abcde"), 0, 5, "12345", 2, S("12"));
181     test(S("abcde"), 0, 5, "12345", 4, S("1234"));
182     test(S("abcde"), 0, 5, "12345", 5, S("12345"));
183     test(S("abcde"), 0, 5, "1234567890", 0, S(""));
184     test(S("abcde"), 0, 5, "1234567890", 1, S("1"));
185     test(S("abcde"), 0, 5, "1234567890", 5, S("12345"));
186     test(S("abcde"), 0, 5, "1234567890", 9, S("123456789"));
187     test(S("abcde"), 0, 5, "1234567890", 10, S("1234567890"));
188     test(S("abcde"), 0, 5, "12345678901234567890", 0, S(""));
189     test(S("abcde"), 0, 5, "12345678901234567890", 1, S("1"));
190     test(S("abcde"), 0, 5, "12345678901234567890", 10, S("1234567890"));
191     test(S("abcde"), 0, 5, "12345678901234567890", 19, S("1234567890123456789"));
192     test(S("abcde"), 0, 5, "12345678901234567890", 20, S("12345678901234567890"));
193     test(S("abcde"), 0, 6, "", 0, S(""));
194     test(S("abcde"), 0, 6, "12345", 0, S(""));
195     test(S("abcde"), 0, 6, "12345", 1, S("1"));
196     test(S("abcde"), 0, 6, "12345", 2, S("12"));
197     test(S("abcde"), 0, 6, "12345", 4, S("1234"));
198     test(S("abcde"), 0, 6, "12345", 5, S("12345"));
199     test(S("abcde"), 0, 6, "1234567890", 0, S(""));
200     test(S("abcde"), 0, 6, "1234567890", 1, S("1"));
201     test(S("abcde"), 0, 6, "1234567890", 5, S("12345"));
202     test(S("abcde"), 0, 6, "1234567890", 9, S("123456789"));
203     test(S("abcde"), 0, 6, "1234567890", 10, S("1234567890"));
204     test(S("abcde"), 0, 6, "12345678901234567890", 0, S(""));
205     test(S("abcde"), 0, 6, "12345678901234567890", 1, S("1"));
206     test(S("abcde"), 0, 6, "12345678901234567890", 10, S("1234567890"));
207     test(S("abcde"), 0, 6, "12345678901234567890", 19, S("1234567890123456789"));
208     test(S("abcde"), 0, 6, "12345678901234567890", 20, S("12345678901234567890"));
209     test(S("abcde"), 1, 0, "", 0, S("abcde"));
210     test(S("abcde"), 1, 0, "12345", 0, S("abcde"));
211     test(S("abcde"), 1, 0, "12345", 1, S("a1bcde"));
212     test(S("abcde"), 1, 0, "12345", 2, S("a12bcde"));
213     test(S("abcde"), 1, 0, "12345", 4, S("a1234bcde"));
214     test(S("abcde"), 1, 0, "12345", 5, S("a12345bcde"));
215     test(S("abcde"), 1, 0, "1234567890", 0, S("abcde"));
216     test(S("abcde"), 1, 0, "1234567890", 1, S("a1bcde"));
217     test(S("abcde"), 1, 0, "1234567890", 5, S("a12345bcde"));
218     test(S("abcde"), 1, 0, "1234567890", 9, S("a123456789bcde"));
219     test(S("abcde"), 1, 0, "1234567890", 10, S("a1234567890bcde"));
220     test(S("abcde"), 1, 0, "12345678901234567890", 0, S("abcde"));
221     test(S("abcde"), 1, 0, "12345678901234567890", 1, S("a1bcde"));
222     test(S("abcde"), 1, 0, "12345678901234567890", 10, S("a1234567890bcde"));
223     test(S("abcde"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcde"));
224     test(S("abcde"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcde"));
225     test(S("abcde"), 1, 1, "", 0, S("acde"));
226     test(S("abcde"), 1, 1, "12345", 0, S("acde"));
227     test(S("abcde"), 1, 1, "12345", 1, S("a1cde"));
228     test(S("abcde"), 1, 1, "12345", 2, S("a12cde"));
229     test(S("abcde"), 1, 1, "12345", 4, S("a1234cde"));
230     test(S("abcde"), 1, 1, "12345", 5, S("a12345cde"));
231     test(S("abcde"), 1, 1, "1234567890", 0, S("acde"));
232     test(S("abcde"), 1, 1, "1234567890", 1, S("a1cde"));
233     test(S("abcde"), 1, 1, "1234567890", 5, S("a12345cde"));
234     test(S("abcde"), 1, 1, "1234567890", 9, S("a123456789cde"));
235     test(S("abcde"), 1, 1, "1234567890", 10, S("a1234567890cde"));
236     test(S("abcde"), 1, 1, "12345678901234567890", 0, S("acde"));
237     test(S("abcde"), 1, 1, "12345678901234567890", 1, S("a1cde"));
238     test(S("abcde"), 1, 1, "12345678901234567890", 10, S("a1234567890cde"));
239     test(S("abcde"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cde"));
240     test(S("abcde"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cde"));
241     test(S("abcde"), 1, 2, "", 0, S("ade"));
242     test(S("abcde"), 1, 2, "12345", 0, S("ade"));
243     test(S("abcde"), 1, 2, "12345", 1, S("a1de"));
244     test(S("abcde"), 1, 2, "12345", 2, S("a12de"));
245     test(S("abcde"), 1, 2, "12345", 4, S("a1234de"));
246     test(S("abcde"), 1, 2, "12345", 5, S("a12345de"));
247     test(S("abcde"), 1, 2, "1234567890", 0, S("ade"));
248     test(S("abcde"), 1, 2, "1234567890", 1, S("a1de"));
249     test(S("abcde"), 1, 2, "1234567890", 5, S("a12345de"));
250     test(S("abcde"), 1, 2, "1234567890", 9, S("a123456789de"));
251     test(S("abcde"), 1, 2, "1234567890", 10, S("a1234567890de"));
252     test(S("abcde"), 1, 2, "12345678901234567890", 0, S("ade"));
253     test(S("abcde"), 1, 2, "12345678901234567890", 1, S("a1de"));
254     test(S("abcde"), 1, 2, "12345678901234567890", 10, S("a1234567890de"));
255     test(S("abcde"), 1, 2, "12345678901234567890", 19, S("a1234567890123456789de"));
256     test(S("abcde"), 1, 2, "12345678901234567890", 20, S("a12345678901234567890de"));
257     test(S("abcde"), 1, 3, "", 0, S("ae"));
258     test(S("abcde"), 1, 3, "12345", 0, S("ae"));
259     test(S("abcde"), 1, 3, "12345", 1, S("a1e"));
260     test(S("abcde"), 1, 3, "12345", 2, S("a12e"));
261     test(S("abcde"), 1, 3, "12345", 4, S("a1234e"));
262     test(S("abcde"), 1, 3, "12345", 5, S("a12345e"));
263     test(S("abcde"), 1, 3, "1234567890", 0, S("ae"));
264     test(S("abcde"), 1, 3, "1234567890", 1, S("a1e"));
265 }
266
267 template <class S>
268 void test2()
269 {
270     test(S("abcde"), 1, 3, "1234567890", 5, S("a12345e"));
271     test(S("abcde"), 1, 3, "1234567890", 9, S("a123456789e"));
272     test(S("abcde"), 1, 3, "1234567890", 10, S("a1234567890e"));
273     test(S("abcde"), 1, 3, "12345678901234567890", 0, S("ae"));
274     test(S("abcde"), 1, 3, "12345678901234567890", 1, S("a1e"));
275     test(S("abcde"), 1, 3, "12345678901234567890", 10, S("a1234567890e"));
276     test(S("abcde"), 1, 3, "12345678901234567890", 19, S("a1234567890123456789e"));
277     test(S("abcde"), 1, 3, "12345678901234567890", 20, S("a12345678901234567890e"));
278     test(S("abcde"), 1, 4, "", 0, S("a"));
279     test(S("abcde"), 1, 4, "12345", 0, S("a"));
280     test(S("abcde"), 1, 4, "12345", 1, S("a1"));
281     test(S("abcde"), 1, 4, "12345", 2, S("a12"));
282     test(S("abcde"), 1, 4, "12345", 4, S("a1234"));
283     test(S("abcde"), 1, 4, "12345", 5, S("a12345"));
284     test(S("abcde"), 1, 4, "1234567890", 0, S("a"));
285     test(S("abcde"), 1, 4, "1234567890", 1, S("a1"));
286     test(S("abcde"), 1, 4, "1234567890", 5, S("a12345"));
287     test(S("abcde"), 1, 4, "1234567890", 9, S("a123456789"));
288     test(S("abcde"), 1, 4, "1234567890", 10, S("a1234567890"));
289     test(S("abcde"), 1, 4, "12345678901234567890", 0, S("a"));
290     test(S("abcde"), 1, 4, "12345678901234567890", 1, S("a1"));
291     test(S("abcde"), 1, 4, "12345678901234567890", 10, S("a1234567890"));
292     test(S("abcde"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789"));
293     test(S("abcde"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890"));
294     test(S("abcde"), 1, 5, "", 0, S("a"));
295     test(S("abcde"), 1, 5, "12345", 0, S("a"));
296     test(S("abcde"), 1, 5, "12345", 1, S("a1"));
297     test(S("abcde"), 1, 5, "12345", 2, S("a12"));
298     test(S("abcde"), 1, 5, "12345", 4, S("a1234"));
299     test(S("abcde"), 1, 5, "12345", 5, S("a12345"));
300     test(S("abcde"), 1, 5, "1234567890", 0, S("a"));
301     test(S("abcde"), 1, 5, "1234567890", 1, S("a1"));
302     test(S("abcde"), 1, 5, "1234567890", 5, S("a12345"));
303     test(S("abcde"), 1, 5, "1234567890", 9, S("a123456789"));
304     test(S("abcde"), 1, 5, "1234567890", 10, S("a1234567890"));
305     test(S("abcde"), 1, 5, "12345678901234567890", 0, S("a"));
306     test(S("abcde"), 1, 5, "12345678901234567890", 1, S("a1"));
307     test(S("abcde"), 1, 5, "12345678901234567890", 10, S("a1234567890"));
308     test(S("abcde"), 1, 5, "12345678901234567890", 19, S("a1234567890123456789"));
309     test(S("abcde"), 1, 5, "12345678901234567890", 20, S("a12345678901234567890"));
310     test(S("abcde"), 2, 0, "", 0, S("abcde"));
311     test(S("abcde"), 2, 0, "12345", 0, S("abcde"));
312     test(S("abcde"), 2, 0, "12345", 1, S("ab1cde"));
313     test(S("abcde"), 2, 0, "12345", 2, S("ab12cde"));
314     test(S("abcde"), 2, 0, "12345", 4, S("ab1234cde"));
315     test(S("abcde"), 2, 0, "12345", 5, S("ab12345cde"));
316     test(S("abcde"), 2, 0, "1234567890", 0, S("abcde"));
317     test(S("abcde"), 2, 0, "1234567890", 1, S("ab1cde"));
318     test(S("abcde"), 2, 0, "1234567890", 5, S("ab12345cde"));
319     test(S("abcde"), 2, 0, "1234567890", 9, S("ab123456789cde"));
320     test(S("abcde"), 2, 0, "1234567890", 10, S("ab1234567890cde"));
321     test(S("abcde"), 2, 0, "12345678901234567890", 0, S("abcde"));
322     test(S("abcde"), 2, 0, "12345678901234567890", 1, S("ab1cde"));
323     test(S("abcde"), 2, 0, "12345678901234567890", 10, S("ab1234567890cde"));
324     test(S("abcde"), 2, 0, "12345678901234567890", 19, S("ab1234567890123456789cde"));
325     test(S("abcde"), 2, 0, "12345678901234567890", 20, S("ab12345678901234567890cde"));
326     test(S("abcde"), 2, 1, "", 0, S("abde"));
327     test(S("abcde"), 2, 1, "12345", 0, S("abde"));
328     test(S("abcde"), 2, 1, "12345", 1, S("ab1de"));
329     test(S("abcde"), 2, 1, "12345", 2, S("ab12de"));
330     test(S("abcde"), 2, 1, "12345", 4, S("ab1234de"));
331     test(S("abcde"), 2, 1, "12345", 5, S("ab12345de"));
332     test(S("abcde"), 2, 1, "1234567890", 0, S("abde"));
333     test(S("abcde"), 2, 1, "1234567890", 1, S("ab1de"));
334     test(S("abcde"), 2, 1, "1234567890", 5, S("ab12345de"));
335     test(S("abcde"), 2, 1, "1234567890", 9, S("ab123456789de"));
336     test(S("abcde"), 2, 1, "1234567890", 10, S("ab1234567890de"));
337     test(S("abcde"), 2, 1, "12345678901234567890", 0, S("abde"));
338     test(S("abcde"), 2, 1, "12345678901234567890", 1, S("ab1de"));
339     test(S("abcde"), 2, 1, "12345678901234567890", 10, S("ab1234567890de"));
340     test(S("abcde"), 2, 1, "12345678901234567890", 19, S("ab1234567890123456789de"));
341     test(S("abcde"), 2, 1, "12345678901234567890", 20, S("ab12345678901234567890de"));
342     test(S("abcde"), 2, 2, "", 0, S("abe"));
343     test(S("abcde"), 2, 2, "12345", 0, S("abe"));
344     test(S("abcde"), 2, 2, "12345", 1, S("ab1e"));
345     test(S("abcde"), 2, 2, "12345", 2, S("ab12e"));
346     test(S("abcde"), 2, 2, "12345", 4, S("ab1234e"));
347     test(S("abcde"), 2, 2, "12345", 5, S("ab12345e"));
348     test(S("abcde"), 2, 2, "1234567890", 0, S("abe"));
349     test(S("abcde"), 2, 2, "1234567890", 1, S("ab1e"));
350     test(S("abcde"), 2, 2, "1234567890", 5, S("ab12345e"));
351     test(S("abcde"), 2, 2, "1234567890", 9, S("ab123456789e"));
352     test(S("abcde"), 2, 2, "1234567890", 10, S("ab1234567890e"));
353     test(S("abcde"), 2, 2, "12345678901234567890", 0, S("abe"));
354     test(S("abcde"), 2, 2, "12345678901234567890", 1, S("ab1e"));
355     test(S("abcde"), 2, 2, "12345678901234567890", 10, S("ab1234567890e"));
356     test(S("abcde"), 2, 2, "12345678901234567890", 19, S("ab1234567890123456789e"));
357     test(S("abcde"), 2, 2, "12345678901234567890", 20, S("ab12345678901234567890e"));
358     test(S("abcde"), 2, 3, "", 0, S("ab"));
359     test(S("abcde"), 2, 3, "12345", 0, S("ab"));
360     test(S("abcde"), 2, 3, "12345", 1, S("ab1"));
361     test(S("abcde"), 2, 3, "12345", 2, S("ab12"));
362     test(S("abcde"), 2, 3, "12345", 4, S("ab1234"));
363     test(S("abcde"), 2, 3, "12345", 5, S("ab12345"));
364     test(S("abcde"), 2, 3, "1234567890", 0, S("ab"));
365     test(S("abcde"), 2, 3, "1234567890", 1, S("ab1"));
366     test(S("abcde"), 2, 3, "1234567890", 5, S("ab12345"));
367     test(S("abcde"), 2, 3, "1234567890", 9, S("ab123456789"));
368     test(S("abcde"), 2, 3, "1234567890", 10, S("ab1234567890"));
369     test(S("abcde"), 2, 3, "12345678901234567890", 0, S("ab"));
370 }
371
372 template <class S>
373 void test3()
374 {
375     test(S("abcde"), 2, 3, "12345678901234567890", 1, S("ab1"));
376     test(S("abcde"), 2, 3, "12345678901234567890", 10, S("ab1234567890"));
377     test(S("abcde"), 2, 3, "12345678901234567890", 19, S("ab1234567890123456789"));
378     test(S("abcde"), 2, 3, "12345678901234567890", 20, S("ab12345678901234567890"));
379     test(S("abcde"), 2, 4, "", 0, S("ab"));
380     test(S("abcde"), 2, 4, "12345", 0, S("ab"));
381     test(S("abcde"), 2, 4, "12345", 1, S("ab1"));
382     test(S("abcde"), 2, 4, "12345", 2, S("ab12"));
383     test(S("abcde"), 2, 4, "12345", 4, S("ab1234"));
384     test(S("abcde"), 2, 4, "12345", 5, S("ab12345"));
385     test(S("abcde"), 2, 4, "1234567890", 0, S("ab"));
386     test(S("abcde"), 2, 4, "1234567890", 1, S("ab1"));
387     test(S("abcde"), 2, 4, "1234567890", 5, S("ab12345"));
388     test(S("abcde"), 2, 4, "1234567890", 9, S("ab123456789"));
389     test(S("abcde"), 2, 4, "1234567890", 10, S("ab1234567890"));
390     test(S("abcde"), 2, 4, "12345678901234567890", 0, S("ab"));
391     test(S("abcde"), 2, 4, "12345678901234567890", 1, S("ab1"));
392     test(S("abcde"), 2, 4, "12345678901234567890", 10, S("ab1234567890"));
393     test(S("abcde"), 2, 4, "12345678901234567890", 19, S("ab1234567890123456789"));
394     test(S("abcde"), 2, 4, "12345678901234567890", 20, S("ab12345678901234567890"));
395     test(S("abcde"), 4, 0, "", 0, S("abcde"));
396     test(S("abcde"), 4, 0, "12345", 0, S("abcde"));
397     test(S("abcde"), 4, 0, "12345", 1, S("abcd1e"));
398     test(S("abcde"), 4, 0, "12345", 2, S("abcd12e"));
399     test(S("abcde"), 4, 0, "12345", 4, S("abcd1234e"));
400     test(S("abcde"), 4, 0, "12345", 5, S("abcd12345e"));
401     test(S("abcde"), 4, 0, "1234567890", 0, S("abcde"));
402     test(S("abcde"), 4, 0, "1234567890", 1, S("abcd1e"));
403     test(S("abcde"), 4, 0, "1234567890", 5, S("abcd12345e"));
404     test(S("abcde"), 4, 0, "1234567890", 9, S("abcd123456789e"));
405     test(S("abcde"), 4, 0, "1234567890", 10, S("abcd1234567890e"));
406     test(S("abcde"), 4, 0, "12345678901234567890", 0, S("abcde"));
407     test(S("abcde"), 4, 0, "12345678901234567890", 1, S("abcd1e"));
408     test(S("abcde"), 4, 0, "12345678901234567890", 10, S("abcd1234567890e"));
409     test(S("abcde"), 4, 0, "12345678901234567890", 19, S("abcd1234567890123456789e"));
410     test(S("abcde"), 4, 0, "12345678901234567890", 20, S("abcd12345678901234567890e"));
411     test(S("abcde"), 4, 1, "", 0, S("abcd"));
412     test(S("abcde"), 4, 1, "12345", 0, S("abcd"));
413     test(S("abcde"), 4, 1, "12345", 1, S("abcd1"));
414     test(S("abcde"), 4, 1, "12345", 2, S("abcd12"));
415     test(S("abcde"), 4, 1, "12345", 4, S("abcd1234"));
416     test(S("abcde"), 4, 1, "12345", 5, S("abcd12345"));
417     test(S("abcde"), 4, 1, "1234567890", 0, S("abcd"));
418     test(S("abcde"), 4, 1, "1234567890", 1, S("abcd1"));
419     test(S("abcde"), 4, 1, "1234567890", 5, S("abcd12345"));
420     test(S("abcde"), 4, 1, "1234567890", 9, S("abcd123456789"));
421     test(S("abcde"), 4, 1, "1234567890", 10, S("abcd1234567890"));
422     test(S("abcde"), 4, 1, "12345678901234567890", 0, S("abcd"));
423     test(S("abcde"), 4, 1, "12345678901234567890", 1, S("abcd1"));
424     test(S("abcde"), 4, 1, "12345678901234567890", 10, S("abcd1234567890"));
425     test(S("abcde"), 4, 1, "12345678901234567890", 19, S("abcd1234567890123456789"));
426     test(S("abcde"), 4, 1, "12345678901234567890", 20, S("abcd12345678901234567890"));
427     test(S("abcde"), 4, 2, "", 0, S("abcd"));
428     test(S("abcde"), 4, 2, "12345", 0, S("abcd"));
429     test(S("abcde"), 4, 2, "12345", 1, S("abcd1"));
430     test(S("abcde"), 4, 2, "12345", 2, S("abcd12"));
431     test(S("abcde"), 4, 2, "12345", 4, S("abcd1234"));
432     test(S("abcde"), 4, 2, "12345", 5, S("abcd12345"));
433     test(S("abcde"), 4, 2, "1234567890", 0, S("abcd"));
434     test(S("abcde"), 4, 2, "1234567890", 1, S("abcd1"));
435     test(S("abcde"), 4, 2, "1234567890", 5, S("abcd12345"));
436     test(S("abcde"), 4, 2, "1234567890", 9, S("abcd123456789"));
437     test(S("abcde"), 4, 2, "1234567890", 10, S("abcd1234567890"));
438     test(S("abcde"), 4, 2, "12345678901234567890", 0, S("abcd"));
439     test(S("abcde"), 4, 2, "12345678901234567890", 1, S("abcd1"));
440     test(S("abcde"), 4, 2, "12345678901234567890", 10, S("abcd1234567890"));
441     test(S("abcde"), 4, 2, "12345678901234567890", 19, S("abcd1234567890123456789"));
442     test(S("abcde"), 4, 2, "12345678901234567890", 20, S("abcd12345678901234567890"));
443     test(S("abcde"), 5, 0, "", 0, S("abcde"));
444     test(S("abcde"), 5, 0, "12345", 0, S("abcde"));
445     test(S("abcde"), 5, 0, "12345", 1, S("abcde1"));
446     test(S("abcde"), 5, 0, "12345", 2, S("abcde12"));
447     test(S("abcde"), 5, 0, "12345", 4, S("abcde1234"));
448     test(S("abcde"), 5, 0, "12345", 5, S("abcde12345"));
449     test(S("abcde"), 5, 0, "1234567890", 0, S("abcde"));
450     test(S("abcde"), 5, 0, "1234567890", 1, S("abcde1"));
451     test(S("abcde"), 5, 0, "1234567890", 5, S("abcde12345"));
452     test(S("abcde"), 5, 0, "1234567890", 9, S("abcde123456789"));
453     test(S("abcde"), 5, 0, "1234567890", 10, S("abcde1234567890"));
454     test(S("abcde"), 5, 0, "12345678901234567890", 0, S("abcde"));
455     test(S("abcde"), 5, 0, "12345678901234567890", 1, S("abcde1"));
456     test(S("abcde"), 5, 0, "12345678901234567890", 10, S("abcde1234567890"));
457     test(S("abcde"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789"));
458     test(S("abcde"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890"));
459     test(S("abcde"), 5, 1, "", 0, S("abcde"));
460     test(S("abcde"), 5, 1, "12345", 0, S("abcde"));
461     test(S("abcde"), 5, 1, "12345", 1, S("abcde1"));
462     test(S("abcde"), 5, 1, "12345", 2, S("abcde12"));
463     test(S("abcde"), 5, 1, "12345", 4, S("abcde1234"));
464     test(S("abcde"), 5, 1, "12345", 5, S("abcde12345"));
465     test(S("abcde"), 5, 1, "1234567890", 0, S("abcde"));
466     test(S("abcde"), 5, 1, "1234567890", 1, S("abcde1"));
467     test(S("abcde"), 5, 1, "1234567890", 5, S("abcde12345"));
468     test(S("abcde"), 5, 1, "1234567890", 9, S("abcde123456789"));
469     test(S("abcde"), 5, 1, "1234567890", 10, S("abcde1234567890"));
470     test(S("abcde"), 5, 1, "12345678901234567890", 0, S("abcde"));
471     test(S("abcde"), 5, 1, "12345678901234567890", 1, S("abcde1"));
472     test(S("abcde"), 5, 1, "12345678901234567890", 10, S("abcde1234567890"));
473     test(S("abcde"), 5, 1, "12345678901234567890", 19, S("abcde1234567890123456789"));
474     test(S("abcde"), 5, 1, "12345678901234567890", 20, S("abcde12345678901234567890"));
475 }
476
477 template <class S>
478 void test4()
479 {
480     test(S("abcde"), 6, 0, "", 0, S("can't happen"));
481     test(S("abcde"), 6, 0, "12345", 0, S("can't happen"));
482     test(S("abcde"), 6, 0, "12345", 1, S("can't happen"));
483     test(S("abcde"), 6, 0, "12345", 2, S("can't happen"));
484     test(S("abcde"), 6, 0, "12345", 4, S("can't happen"));
485     test(S("abcde"), 6, 0, "12345", 5, S("can't happen"));
486     test(S("abcde"), 6, 0, "1234567890", 0, S("can't happen"));
487     test(S("abcde"), 6, 0, "1234567890", 1, S("can't happen"));
488     test(S("abcde"), 6, 0, "1234567890", 5, S("can't happen"));
489     test(S("abcde"), 6, 0, "1234567890", 9, S("can't happen"));
490     test(S("abcde"), 6, 0, "1234567890", 10, S("can't happen"));
491     test(S("abcde"), 6, 0, "12345678901234567890", 0, S("can't happen"));
492     test(S("abcde"), 6, 0, "12345678901234567890", 1, S("can't happen"));
493     test(S("abcde"), 6, 0, "12345678901234567890", 10, S("can't happen"));
494     test(S("abcde"), 6, 0, "12345678901234567890", 19, S("can't happen"));
495     test(S("abcde"), 6, 0, "12345678901234567890", 20, S("can't happen"));
496     test(S("abcdefghij"), 0, 0, "", 0, S("abcdefghij"));
497     test(S("abcdefghij"), 0, 0, "12345", 0, S("abcdefghij"));
498     test(S("abcdefghij"), 0, 0, "12345", 1, S("1abcdefghij"));
499     test(S("abcdefghij"), 0, 0, "12345", 2, S("12abcdefghij"));
500     test(S("abcdefghij"), 0, 0, "12345", 4, S("1234abcdefghij"));
501     test(S("abcdefghij"), 0, 0, "12345", 5, S("12345abcdefghij"));
502     test(S("abcdefghij"), 0, 0, "1234567890", 0, S("abcdefghij"));
503     test(S("abcdefghij"), 0, 0, "1234567890", 1, S("1abcdefghij"));
504     test(S("abcdefghij"), 0, 0, "1234567890", 5, S("12345abcdefghij"));
505     test(S("abcdefghij"), 0, 0, "1234567890", 9, S("123456789abcdefghij"));
506     test(S("abcdefghij"), 0, 0, "1234567890", 10, S("1234567890abcdefghij"));
507     test(S("abcdefghij"), 0, 0, "12345678901234567890", 0, S("abcdefghij"));
508     test(S("abcdefghij"), 0, 0, "12345678901234567890", 1, S("1abcdefghij"));
509     test(S("abcdefghij"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghij"));
510     test(S("abcdefghij"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij"));
511     test(S("abcdefghij"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij"));
512     test(S("abcdefghij"), 0, 1, "", 0, S("bcdefghij"));
513     test(S("abcdefghij"), 0, 1, "12345", 0, S("bcdefghij"));
514     test(S("abcdefghij"), 0, 1, "12345", 1, S("1bcdefghij"));
515     test(S("abcdefghij"), 0, 1, "12345", 2, S("12bcdefghij"));
516     test(S("abcdefghij"), 0, 1, "12345", 4, S("1234bcdefghij"));
517     test(S("abcdefghij"), 0, 1, "12345", 5, S("12345bcdefghij"));
518     test(S("abcdefghij"), 0, 1, "1234567890", 0, S("bcdefghij"));
519     test(S("abcdefghij"), 0, 1, "1234567890", 1, S("1bcdefghij"));
520     test(S("abcdefghij"), 0, 1, "1234567890", 5, S("12345bcdefghij"));
521     test(S("abcdefghij"), 0, 1, "1234567890", 9, S("123456789bcdefghij"));
522     test(S("abcdefghij"), 0, 1, "1234567890", 10, S("1234567890bcdefghij"));
523     test(S("abcdefghij"), 0, 1, "12345678901234567890", 0, S("bcdefghij"));
524     test(S("abcdefghij"), 0, 1, "12345678901234567890", 1, S("1bcdefghij"));
525     test(S("abcdefghij"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghij"));
526     test(S("abcdefghij"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghij"));
527     test(S("abcdefghij"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghij"));
528     test(S("abcdefghij"), 0, 5, "", 0, S("fghij"));
529     test(S("abcdefghij"), 0, 5, "12345", 0, S("fghij"));
530     test(S("abcdefghij"), 0, 5, "12345", 1, S("1fghij"));
531     test(S("abcdefghij"), 0, 5, "12345", 2, S("12fghij"));
532     test(S("abcdefghij"), 0, 5, "12345", 4, S("1234fghij"));
533     test(S("abcdefghij"), 0, 5, "12345", 5, S("12345fghij"));
534     test(S("abcdefghij"), 0, 5, "1234567890", 0, S("fghij"));
535     test(S("abcdefghij"), 0, 5, "1234567890", 1, S("1fghij"));
536     test(S("abcdefghij"), 0, 5, "1234567890", 5, S("12345fghij"));
537     test(S("abcdefghij"), 0, 5, "1234567890", 9, S("123456789fghij"));
538     test(S("abcdefghij"), 0, 5, "1234567890", 10, S("1234567890fghij"));
539     test(S("abcdefghij"), 0, 5, "12345678901234567890", 0, S("fghij"));
540     test(S("abcdefghij"), 0, 5, "12345678901234567890", 1, S("1fghij"));
541     test(S("abcdefghij"), 0, 5, "12345678901234567890", 10, S("1234567890fghij"));
542     test(S("abcdefghij"), 0, 5, "12345678901234567890", 19, S("1234567890123456789fghij"));
543     test(S("abcdefghij"), 0, 5, "12345678901234567890", 20, S("12345678901234567890fghij"));
544     test(S("abcdefghij"), 0, 9, "", 0, S("j"));
545     test(S("abcdefghij"), 0, 9, "12345", 0, S("j"));
546     test(S("abcdefghij"), 0, 9, "12345", 1, S("1j"));
547     test(S("abcdefghij"), 0, 9, "12345", 2, S("12j"));
548     test(S("abcdefghij"), 0, 9, "12345", 4, S("1234j"));
549     test(S("abcdefghij"), 0, 9, "12345", 5, S("12345j"));
550     test(S("abcdefghij"), 0, 9, "1234567890", 0, S("j"));
551     test(S("abcdefghij"), 0, 9, "1234567890", 1, S("1j"));
552     test(S("abcdefghij"), 0, 9, "1234567890", 5, S("12345j"));
553     test(S("abcdefghij"), 0, 9, "1234567890", 9, S("123456789j"));
554     test(S("abcdefghij"), 0, 9, "1234567890", 10, S("1234567890j"));
555     test(S("abcdefghij"), 0, 9, "12345678901234567890", 0, S("j"));
556     test(S("abcdefghij"), 0, 9, "12345678901234567890", 1, S("1j"));
557     test(S("abcdefghij"), 0, 9, "12345678901234567890", 10, S("1234567890j"));
558     test(S("abcdefghij"), 0, 9, "12345678901234567890", 19, S("1234567890123456789j"));
559     test(S("abcdefghij"), 0, 9, "12345678901234567890", 20, S("12345678901234567890j"));
560     test(S("abcdefghij"), 0, 10, "", 0, S(""));
561     test(S("abcdefghij"), 0, 10, "12345", 0, S(""));
562     test(S("abcdefghij"), 0, 10, "12345", 1, S("1"));
563     test(S("abcdefghij"), 0, 10, "12345", 2, S("12"));
564     test(S("abcdefghij"), 0, 10, "12345", 4, S("1234"));
565     test(S("abcdefghij"), 0, 10, "12345", 5, S("12345"));
566     test(S("abcdefghij"), 0, 10, "1234567890", 0, S(""));
567     test(S("abcdefghij"), 0, 10, "1234567890", 1, S("1"));
568     test(S("abcdefghij"), 0, 10, "1234567890", 5, S("12345"));
569     test(S("abcdefghij"), 0, 10, "1234567890", 9, S("123456789"));
570     test(S("abcdefghij"), 0, 10, "1234567890", 10, S("1234567890"));
571     test(S("abcdefghij"), 0, 10, "12345678901234567890", 0, S(""));
572     test(S("abcdefghij"), 0, 10, "12345678901234567890", 1, S("1"));
573     test(S("abcdefghij"), 0, 10, "12345678901234567890", 10, S("1234567890"));
574     test(S("abcdefghij"), 0, 10, "12345678901234567890", 19, S("1234567890123456789"));
575     test(S("abcdefghij"), 0, 10, "12345678901234567890", 20, S("12345678901234567890"));
576     test(S("abcdefghij"), 0, 11, "", 0, S(""));
577     test(S("abcdefghij"), 0, 11, "12345", 0, S(""));
578     test(S("abcdefghij"), 0, 11, "12345", 1, S("1"));
579     test(S("abcdefghij"), 0, 11, "12345", 2, S("12"));
580 }
581
582 template <class S>
583 void test5()
584 {
585     test(S("abcdefghij"), 0, 11, "12345", 4, S("1234"));
586     test(S("abcdefghij"), 0, 11, "12345", 5, S("12345"));
587     test(S("abcdefghij"), 0, 11, "1234567890", 0, S(""));
588     test(S("abcdefghij"), 0, 11, "1234567890", 1, S("1"));
589     test(S("abcdefghij"), 0, 11, "1234567890", 5, S("12345"));
590     test(S("abcdefghij"), 0, 11, "1234567890", 9, S("123456789"));
591     test(S("abcdefghij"), 0, 11, "1234567890", 10, S("1234567890"));
592     test(S("abcdefghij"), 0, 11, "12345678901234567890", 0, S(""));
593     test(S("abcdefghij"), 0, 11, "12345678901234567890", 1, S("1"));
594     test(S("abcdefghij"), 0, 11, "12345678901234567890", 10, S("1234567890"));
595     test(S("abcdefghij"), 0, 11, "12345678901234567890", 19, S("1234567890123456789"));
596     test(S("abcdefghij"), 0, 11, "12345678901234567890", 20, S("12345678901234567890"));
597     test(S("abcdefghij"), 1, 0, "", 0, S("abcdefghij"));
598     test(S("abcdefghij"), 1, 0, "12345", 0, S("abcdefghij"));
599     test(S("abcdefghij"), 1, 0, "12345", 1, S("a1bcdefghij"));
600     test(S("abcdefghij"), 1, 0, "12345", 2, S("a12bcdefghij"));
601     test(S("abcdefghij"), 1, 0, "12345", 4, S("a1234bcdefghij"));
602     test(S("abcdefghij"), 1, 0, "12345", 5, S("a12345bcdefghij"));
603     test(S("abcdefghij"), 1, 0, "1234567890", 0, S("abcdefghij"));
604     test(S("abcdefghij"), 1, 0, "1234567890", 1, S("a1bcdefghij"));
605     test(S("abcdefghij"), 1, 0, "1234567890", 5, S("a12345bcdefghij"));
606     test(S("abcdefghij"), 1, 0, "1234567890", 9, S("a123456789bcdefghij"));
607     test(S("abcdefghij"), 1, 0, "1234567890", 10, S("a1234567890bcdefghij"));
608     test(S("abcdefghij"), 1, 0, "12345678901234567890", 0, S("abcdefghij"));
609     test(S("abcdefghij"), 1, 0, "12345678901234567890", 1, S("a1bcdefghij"));
610     test(S("abcdefghij"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghij"));
611     test(S("abcdefghij"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghij"));
612     test(S("abcdefghij"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghij"));
613     test(S("abcdefghij"), 1, 1, "", 0, S("acdefghij"));
614     test(S("abcdefghij"), 1, 1, "12345", 0, S("acdefghij"));
615     test(S("abcdefghij"), 1, 1, "12345", 1, S("a1cdefghij"));
616     test(S("abcdefghij"), 1, 1, "12345", 2, S("a12cdefghij"));
617     test(S("abcdefghij"), 1, 1, "12345", 4, S("a1234cdefghij"));
618     test(S("abcdefghij"), 1, 1, "12345", 5, S("a12345cdefghij"));
619     test(S("abcdefghij"), 1, 1, "1234567890", 0, S("acdefghij"));
620     test(S("abcdefghij"), 1, 1, "1234567890", 1, S("a1cdefghij"));
621     test(S("abcdefghij"), 1, 1, "1234567890", 5, S("a12345cdefghij"));
622     test(S("abcdefghij"), 1, 1, "1234567890", 9, S("a123456789cdefghij"));
623     test(S("abcdefghij"), 1, 1, "1234567890", 10, S("a1234567890cdefghij"));
624     test(S("abcdefghij"), 1, 1, "12345678901234567890", 0, S("acdefghij"));
625     test(S("abcdefghij"), 1, 1, "12345678901234567890", 1, S("a1cdefghij"));
626     test(S("abcdefghij"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghij"));
627     test(S("abcdefghij"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghij"));
628     test(S("abcdefghij"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghij"));
629     test(S("abcdefghij"), 1, 4, "", 0, S("afghij"));
630     test(S("abcdefghij"), 1, 4, "12345", 0, S("afghij"));
631     test(S("abcdefghij"), 1, 4, "12345", 1, S("a1fghij"));
632     test(S("abcdefghij"), 1, 4, "12345", 2, S("a12fghij"));
633     test(S("abcdefghij"), 1, 4, "12345", 4, S("a1234fghij"));
634     test(S("abcdefghij"), 1, 4, "12345", 5, S("a12345fghij"));
635     test(S("abcdefghij"), 1, 4, "1234567890", 0, S("afghij"));
636     test(S("abcdefghij"), 1, 4, "1234567890", 1, S("a1fghij"));
637     test(S("abcdefghij"), 1, 4, "1234567890", 5, S("a12345fghij"));
638     test(S("abcdefghij"), 1, 4, "1234567890", 9, S("a123456789fghij"));
639     test(S("abcdefghij"), 1, 4, "1234567890", 10, S("a1234567890fghij"));
640     test(S("abcdefghij"), 1, 4, "12345678901234567890", 0, S("afghij"));
641     test(S("abcdefghij"), 1, 4, "12345678901234567890", 1, S("a1fghij"));
642     test(S("abcdefghij"), 1, 4, "12345678901234567890", 10, S("a1234567890fghij"));
643     test(S("abcdefghij"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789fghij"));
644     test(S("abcdefghij"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890fghij"));
645     test(S("abcdefghij"), 1, 8, "", 0, S("aj"));
646     test(S("abcdefghij"), 1, 8, "12345", 0, S("aj"));
647     test(S("abcdefghij"), 1, 8, "12345", 1, S("a1j"));
648     test(S("abcdefghij"), 1, 8, "12345", 2, S("a12j"));
649     test(S("abcdefghij"), 1, 8, "12345", 4, S("a1234j"));
650     test(S("abcdefghij"), 1, 8, "12345", 5, S("a12345j"));
651     test(S("abcdefghij"), 1, 8, "1234567890", 0, S("aj"));
652     test(S("abcdefghij"), 1, 8, "1234567890", 1, S("a1j"));
653     test(S("abcdefghij"), 1, 8, "1234567890", 5, S("a12345j"));
654     test(S("abcdefghij"), 1, 8, "1234567890", 9, S("a123456789j"));
655     test(S("abcdefghij"), 1, 8, "1234567890", 10, S("a1234567890j"));
656     test(S("abcdefghij"), 1, 8, "12345678901234567890", 0, S("aj"));
657     test(S("abcdefghij"), 1, 8, "12345678901234567890", 1, S("a1j"));
658     test(S("abcdefghij"), 1, 8, "12345678901234567890", 10, S("a1234567890j"));
659     test(S("abcdefghij"), 1, 8, "12345678901234567890", 19, S("a1234567890123456789j"));
660     test(S("abcdefghij"), 1, 8, "12345678901234567890", 20, S("a12345678901234567890j"));
661     test(S("abcdefghij"), 1, 9, "", 0, S("a"));
662     test(S("abcdefghij"), 1, 9, "12345", 0, S("a"));
663     test(S("abcdefghij"), 1, 9, "12345", 1, S("a1"));
664     test(S("abcdefghij"), 1, 9, "12345", 2, S("a12"));
665     test(S("abcdefghij"), 1, 9, "12345", 4, S("a1234"));
666     test(S("abcdefghij"), 1, 9, "12345", 5, S("a12345"));
667     test(S("abcdefghij"), 1, 9, "1234567890", 0, S("a"));
668     test(S("abcdefghij"), 1, 9, "1234567890", 1, S("a1"));
669     test(S("abcdefghij"), 1, 9, "1234567890", 5, S("a12345"));
670     test(S("abcdefghij"), 1, 9, "1234567890", 9, S("a123456789"));
671     test(S("abcdefghij"), 1, 9, "1234567890", 10, S("a1234567890"));
672     test(S("abcdefghij"), 1, 9, "12345678901234567890", 0, S("a"));
673     test(S("abcdefghij"), 1, 9, "12345678901234567890", 1, S("a1"));
674     test(S("abcdefghij"), 1, 9, "12345678901234567890", 10, S("a1234567890"));
675     test(S("abcdefghij"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789"));
676     test(S("abcdefghij"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890"));
677     test(S("abcdefghij"), 1, 10, "", 0, S("a"));
678     test(S("abcdefghij"), 1, 10, "12345", 0, S("a"));
679     test(S("abcdefghij"), 1, 10, "12345", 1, S("a1"));
680     test(S("abcdefghij"), 1, 10, "12345", 2, S("a12"));
681     test(S("abcdefghij"), 1, 10, "12345", 4, S("a1234"));
682     test(S("abcdefghij"), 1, 10, "12345", 5, S("a12345"));
683     test(S("abcdefghij"), 1, 10, "1234567890", 0, S("a"));
684     test(S("abcdefghij"), 1, 10, "1234567890", 1, S("a1"));
685 }
686
687 template <class S>
688 void test6()
689 {
690     test(S("abcdefghij"), 1, 10, "1234567890", 5, S("a12345"));
691     test(S("abcdefghij"), 1, 10, "1234567890", 9, S("a123456789"));
692     test(S("abcdefghij"), 1, 10, "1234567890", 10, S("a1234567890"));
693     test(S("abcdefghij"), 1, 10, "12345678901234567890", 0, S("a"));
694     test(S("abcdefghij"), 1, 10, "12345678901234567890", 1, S("a1"));
695     test(S("abcdefghij"), 1, 10, "12345678901234567890", 10, S("a1234567890"));
696     test(S("abcdefghij"), 1, 10, "12345678901234567890", 19, S("a1234567890123456789"));
697     test(S("abcdefghij"), 1, 10, "12345678901234567890", 20, S("a12345678901234567890"));
698     test(S("abcdefghij"), 5, 0, "", 0, S("abcdefghij"));
699     test(S("abcdefghij"), 5, 0, "12345", 0, S("abcdefghij"));
700     test(S("abcdefghij"), 5, 0, "12345", 1, S("abcde1fghij"));
701     test(S("abcdefghij"), 5, 0, "12345", 2, S("abcde12fghij"));
702     test(S("abcdefghij"), 5, 0, "12345", 4, S("abcde1234fghij"));
703     test(S("abcdefghij"), 5, 0, "12345", 5, S("abcde12345fghij"));
704     test(S("abcdefghij"), 5, 0, "1234567890", 0, S("abcdefghij"));
705     test(S("abcdefghij"), 5, 0, "1234567890", 1, S("abcde1fghij"));
706     test(S("abcdefghij"), 5, 0, "1234567890", 5, S("abcde12345fghij"));
707     test(S("abcdefghij"), 5, 0, "1234567890", 9, S("abcde123456789fghij"));
708     test(S("abcdefghij"), 5, 0, "1234567890", 10, S("abcde1234567890fghij"));
709     test(S("abcdefghij"), 5, 0, "12345678901234567890", 0, S("abcdefghij"));
710     test(S("abcdefghij"), 5, 0, "12345678901234567890", 1, S("abcde1fghij"));
711     test(S("abcdefghij"), 5, 0, "12345678901234567890", 10, S("abcde1234567890fghij"));
712     test(S("abcdefghij"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789fghij"));
713     test(S("abcdefghij"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890fghij"));
714     test(S("abcdefghij"), 5, 1, "", 0, S("abcdeghij"));
715     test(S("abcdefghij"), 5, 1, "12345", 0, S("abcdeghij"));
716     test(S("abcdefghij"), 5, 1, "12345", 1, S("abcde1ghij"));
717     test(S("abcdefghij"), 5, 1, "12345", 2, S("abcde12ghij"));
718     test(S("abcdefghij"), 5, 1, "12345", 4, S("abcde1234ghij"));
719     test(S("abcdefghij"), 5, 1, "12345", 5, S("abcde12345ghij"));
720     test(S("abcdefghij"), 5, 1, "1234567890", 0, S("abcdeghij"));
721     test(S("abcdefghij"), 5, 1, "1234567890", 1, S("abcde1ghij"));
722     test(S("abcdefghij"), 5, 1, "1234567890", 5, S("abcde12345ghij"));
723     test(S("abcdefghij"), 5, 1, "1234567890", 9, S("abcde123456789ghij"));
724     test(S("abcdefghij"), 5, 1, "1234567890", 10, S("abcde1234567890ghij"));
725     test(S("abcdefghij"), 5, 1, "12345678901234567890", 0, S("abcdeghij"));
726     test(S("abcdefghij"), 5, 1, "12345678901234567890", 1, S("abcde1ghij"));
727     test(S("abcdefghij"), 5, 1, "12345678901234567890", 10, S("abcde1234567890ghij"));
728     test(S("abcdefghij"), 5, 1, "12345678901234567890", 19, S("abcde1234567890123456789ghij"));
729     test(S("abcdefghij"), 5, 1, "12345678901234567890", 20, S("abcde12345678901234567890ghij"));
730     test(S("abcdefghij"), 5, 2, "", 0, S("abcdehij"));
731     test(S("abcdefghij"), 5, 2, "12345", 0, S("abcdehij"));
732     test(S("abcdefghij"), 5, 2, "12345", 1, S("abcde1hij"));
733     test(S("abcdefghij"), 5, 2, "12345", 2, S("abcde12hij"));
734     test(S("abcdefghij"), 5, 2, "12345", 4, S("abcde1234hij"));
735     test(S("abcdefghij"), 5, 2, "12345", 5, S("abcde12345hij"));
736     test(S("abcdefghij"), 5, 2, "1234567890", 0, S("abcdehij"));
737     test(S("abcdefghij"), 5, 2, "1234567890", 1, S("abcde1hij"));
738     test(S("abcdefghij"), 5, 2, "1234567890", 5, S("abcde12345hij"));
739     test(S("abcdefghij"), 5, 2, "1234567890", 9, S("abcde123456789hij"));
740     test(S("abcdefghij"), 5, 2, "1234567890", 10, S("abcde1234567890hij"));
741     test(S("abcdefghij"), 5, 2, "12345678901234567890", 0, S("abcdehij"));
742     test(S("abcdefghij"), 5, 2, "12345678901234567890", 1, S("abcde1hij"));
743     test(S("abcdefghij"), 5, 2, "12345678901234567890", 10, S("abcde1234567890hij"));
744     test(S("abcdefghij"), 5, 2, "12345678901234567890", 19, S("abcde1234567890123456789hij"));
745     test(S("abcdefghij"), 5, 2, "12345678901234567890", 20, S("abcde12345678901234567890hij"));
746     test(S("abcdefghij"), 5, 4, "", 0, S("abcdej"));
747     test(S("abcdefghij"), 5, 4, "12345", 0, S("abcdej"));
748     test(S("abcdefghij"), 5, 4, "12345", 1, S("abcde1j"));
749     test(S("abcdefghij"), 5, 4, "12345", 2, S("abcde12j"));
750     test(S("abcdefghij"), 5, 4, "12345", 4, S("abcde1234j"));
751     test(S("abcdefghij"), 5, 4, "12345", 5, S("abcde12345j"));
752     test(S("abcdefghij"), 5, 4, "1234567890", 0, S("abcdej"));
753     test(S("abcdefghij"), 5, 4, "1234567890", 1, S("abcde1j"));
754     test(S("abcdefghij"), 5, 4, "1234567890", 5, S("abcde12345j"));
755     test(S("abcdefghij"), 5, 4, "1234567890", 9, S("abcde123456789j"));
756     test(S("abcdefghij"), 5, 4, "1234567890", 10, S("abcde1234567890j"));
757     test(S("abcdefghij"), 5, 4, "12345678901234567890", 0, S("abcdej"));
758     test(S("abcdefghij"), 5, 4, "12345678901234567890", 1, S("abcde1j"));
759     test(S("abcdefghij"), 5, 4, "12345678901234567890", 10, S("abcde1234567890j"));
760     test(S("abcdefghij"), 5, 4, "12345678901234567890", 19, S("abcde1234567890123456789j"));
761     test(S("abcdefghij"), 5, 4, "12345678901234567890", 20, S("abcde12345678901234567890j"));
762     test(S("abcdefghij"), 5, 5, "", 0, S("abcde"));
763     test(S("abcdefghij"), 5, 5, "12345", 0, S("abcde"));
764     test(S("abcdefghij"), 5, 5, "12345", 1, S("abcde1"));
765     test(S("abcdefghij"), 5, 5, "12345", 2, S("abcde12"));
766     test(S("abcdefghij"), 5, 5, "12345", 4, S("abcde1234"));
767     test(S("abcdefghij"), 5, 5, "12345", 5, S("abcde12345"));
768     test(S("abcdefghij"), 5, 5, "1234567890", 0, S("abcde"));
769     test(S("abcdefghij"), 5, 5, "1234567890", 1, S("abcde1"));
770     test(S("abcdefghij"), 5, 5, "1234567890", 5, S("abcde12345"));
771     test(S("abcdefghij"), 5, 5, "1234567890", 9, S("abcde123456789"));
772     test(S("abcdefghij"), 5, 5, "1234567890", 10, S("abcde1234567890"));
773     test(S("abcdefghij"), 5, 5, "12345678901234567890", 0, S("abcde"));
774     test(S("abcdefghij"), 5, 5, "12345678901234567890", 1, S("abcde1"));
775     test(S("abcdefghij"), 5, 5, "12345678901234567890", 10, S("abcde1234567890"));
776     test(S("abcdefghij"), 5, 5, "12345678901234567890", 19, S("abcde1234567890123456789"));
777     test(S("abcdefghij"), 5, 5, "12345678901234567890", 20, S("abcde12345678901234567890"));
778     test(S("abcdefghij"), 5, 6, "", 0, S("abcde"));
779     test(S("abcdefghij"), 5, 6, "12345", 0, S("abcde"));
780     test(S("abcdefghij"), 5, 6, "12345", 1, S("abcde1"));
781     test(S("abcdefghij"), 5, 6, "12345", 2, S("abcde12"));
782     test(S("abcdefghij"), 5, 6, "12345", 4, S("abcde1234"));
783     test(S("abcdefghij"), 5, 6, "12345", 5, S("abcde12345"));
784     test(S("abcdefghij"), 5, 6, "1234567890", 0, S("abcde"));
785     test(S("abcdefghij"), 5, 6, "1234567890", 1, S("abcde1"));
786     test(S("abcdefghij"), 5, 6, "1234567890", 5, S("abcde12345"));
787     test(S("abcdefghij"), 5, 6, "1234567890", 9, S("abcde123456789"));
788     test(S("abcdefghij"), 5, 6, "1234567890", 10, S("abcde1234567890"));
789     test(S("abcdefghij"), 5, 6, "12345678901234567890", 0, S("abcde"));
790 }
791
792 template <class S>
793 void test7()
794 {
795     test(S("abcdefghij"), 5, 6, "12345678901234567890", 1, S("abcde1"));
796     test(S("abcdefghij"), 5, 6, "12345678901234567890", 10, S("abcde1234567890"));
797     test(S("abcdefghij"), 5, 6, "12345678901234567890", 19, S("abcde1234567890123456789"));
798     test(S("abcdefghij"), 5, 6, "12345678901234567890", 20, S("abcde12345678901234567890"));
799     test(S("abcdefghij"), 9, 0, "", 0, S("abcdefghij"));
800     test(S("abcdefghij"), 9, 0, "12345", 0, S("abcdefghij"));
801     test(S("abcdefghij"), 9, 0, "12345", 1, S("abcdefghi1j"));
802     test(S("abcdefghij"), 9, 0, "12345", 2, S("abcdefghi12j"));
803     test(S("abcdefghij"), 9, 0, "12345", 4, S("abcdefghi1234j"));
804     test(S("abcdefghij"), 9, 0, "12345", 5, S("abcdefghi12345j"));
805     test(S("abcdefghij"), 9, 0, "1234567890", 0, S("abcdefghij"));
806     test(S("abcdefghij"), 9, 0, "1234567890", 1, S("abcdefghi1j"));
807     test(S("abcdefghij"), 9, 0, "1234567890", 5, S("abcdefghi12345j"));
808     test(S("abcdefghij"), 9, 0, "1234567890", 9, S("abcdefghi123456789j"));
809     test(S("abcdefghij"), 9, 0, "1234567890", 10, S("abcdefghi1234567890j"));
810     test(S("abcdefghij"), 9, 0, "12345678901234567890", 0, S("abcdefghij"));
811     test(S("abcdefghij"), 9, 0, "12345678901234567890", 1, S("abcdefghi1j"));
812     test(S("abcdefghij"), 9, 0, "12345678901234567890", 10, S("abcdefghi1234567890j"));
813     test(S("abcdefghij"), 9, 0, "12345678901234567890", 19, S("abcdefghi1234567890123456789j"));
814     test(S("abcdefghij"), 9, 0, "12345678901234567890", 20, S("abcdefghi12345678901234567890j"));
815     test(S("abcdefghij"), 9, 1, "", 0, S("abcdefghi"));
816     test(S("abcdefghij"), 9, 1, "12345", 0, S("abcdefghi"));
817     test(S("abcdefghij"), 9, 1, "12345", 1, S("abcdefghi1"));
818     test(S("abcdefghij"), 9, 1, "12345", 2, S("abcdefghi12"));
819     test(S("abcdefghij"), 9, 1, "12345", 4, S("abcdefghi1234"));
820     test(S("abcdefghij"), 9, 1, "12345", 5, S("abcdefghi12345"));
821     test(S("abcdefghij"), 9, 1, "1234567890", 0, S("abcdefghi"));
822     test(S("abcdefghij"), 9, 1, "1234567890", 1, S("abcdefghi1"));
823     test(S("abcdefghij"), 9, 1, "1234567890", 5, S("abcdefghi12345"));
824     test(S("abcdefghij"), 9, 1, "1234567890", 9, S("abcdefghi123456789"));
825     test(S("abcdefghij"), 9, 1, "1234567890", 10, S("abcdefghi1234567890"));
826     test(S("abcdefghij"), 9, 1, "12345678901234567890", 0, S("abcdefghi"));
827     test(S("abcdefghij"), 9, 1, "12345678901234567890", 1, S("abcdefghi1"));
828     test(S("abcdefghij"), 9, 1, "12345678901234567890", 10, S("abcdefghi1234567890"));
829     test(S("abcdefghij"), 9, 1, "12345678901234567890", 19, S("abcdefghi1234567890123456789"));
830     test(S("abcdefghij"), 9, 1, "12345678901234567890", 20, S("abcdefghi12345678901234567890"));
831     test(S("abcdefghij"), 9, 2, "", 0, S("abcdefghi"));
832     test(S("abcdefghij"), 9, 2, "12345", 0, S("abcdefghi"));
833     test(S("abcdefghij"), 9, 2, "12345", 1, S("abcdefghi1"));
834     test(S("abcdefghij"), 9, 2, "12345", 2, S("abcdefghi12"));
835     test(S("abcdefghij"), 9, 2, "12345", 4, S("abcdefghi1234"));
836     test(S("abcdefghij"), 9, 2, "12345", 5, S("abcdefghi12345"));
837     test(S("abcdefghij"), 9, 2, "1234567890", 0, S("abcdefghi"));
838     test(S("abcdefghij"), 9, 2, "1234567890", 1, S("abcdefghi1"));
839     test(S("abcdefghij"), 9, 2, "1234567890", 5, S("abcdefghi12345"));
840     test(S("abcdefghij"), 9, 2, "1234567890", 9, S("abcdefghi123456789"));
841     test(S("abcdefghij"), 9, 2, "1234567890", 10, S("abcdefghi1234567890"));
842     test(S("abcdefghij"), 9, 2, "12345678901234567890", 0, S("abcdefghi"));
843     test(S("abcdefghij"), 9, 2, "12345678901234567890", 1, S("abcdefghi1"));
844     test(S("abcdefghij"), 9, 2, "12345678901234567890", 10, S("abcdefghi1234567890"));
845     test(S("abcdefghij"), 9, 2, "12345678901234567890", 19, S("abcdefghi1234567890123456789"));
846     test(S("abcdefghij"), 9, 2, "12345678901234567890", 20, S("abcdefghi12345678901234567890"));
847     test(S("abcdefghij"), 10, 0, "", 0, S("abcdefghij"));
848     test(S("abcdefghij"), 10, 0, "12345", 0, S("abcdefghij"));
849     test(S("abcdefghij"), 10, 0, "12345", 1, S("abcdefghij1"));
850     test(S("abcdefghij"), 10, 0, "12345", 2, S("abcdefghij12"));
851     test(S("abcdefghij"), 10, 0, "12345", 4, S("abcdefghij1234"));
852     test(S("abcdefghij"), 10, 0, "12345", 5, S("abcdefghij12345"));
853     test(S("abcdefghij"), 10, 0, "1234567890", 0, S("abcdefghij"));
854     test(S("abcdefghij"), 10, 0, "1234567890", 1, S("abcdefghij1"));
855     test(S("abcdefghij"), 10, 0, "1234567890", 5, S("abcdefghij12345"));
856     test(S("abcdefghij"), 10, 0, "1234567890", 9, S("abcdefghij123456789"));
857     test(S("abcdefghij"), 10, 0, "1234567890", 10, S("abcdefghij1234567890"));
858     test(S("abcdefghij"), 10, 0, "12345678901234567890", 0, S("abcdefghij"));
859     test(S("abcdefghij"), 10, 0, "12345678901234567890", 1, S("abcdefghij1"));
860     test(S("abcdefghij"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890"));
861     test(S("abcdefghij"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
862     test(S("abcdefghij"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
863     test(S("abcdefghij"), 10, 1, "", 0, S("abcdefghij"));
864     test(S("abcdefghij"), 10, 1, "12345", 0, S("abcdefghij"));
865     test(S("abcdefghij"), 10, 1, "12345", 1, S("abcdefghij1"));
866     test(S("abcdefghij"), 10, 1, "12345", 2, S("abcdefghij12"));
867     test(S("abcdefghij"), 10, 1, "12345", 4, S("abcdefghij1234"));
868     test(S("abcdefghij"), 10, 1, "12345", 5, S("abcdefghij12345"));
869     test(S("abcdefghij"), 10, 1, "1234567890", 0, S("abcdefghij"));
870     test(S("abcdefghij"), 10, 1, "1234567890", 1, S("abcdefghij1"));
871     test(S("abcdefghij"), 10, 1, "1234567890", 5, S("abcdefghij12345"));
872     test(S("abcdefghij"), 10, 1, "1234567890", 9, S("abcdefghij123456789"));
873     test(S("abcdefghij"), 10, 1, "1234567890", 10, S("abcdefghij1234567890"));
874     test(S("abcdefghij"), 10, 1, "12345678901234567890", 0, S("abcdefghij"));
875     test(S("abcdefghij"), 10, 1, "12345678901234567890", 1, S("abcdefghij1"));
876     test(S("abcdefghij"), 10, 1, "12345678901234567890", 10, S("abcdefghij1234567890"));
877     test(S("abcdefghij"), 10, 1, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
878     test(S("abcdefghij"), 10, 1, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
879     test(S("abcdefghij"), 11, 0, "", 0, S("can't happen"));
880     test(S("abcdefghij"), 11, 0, "12345", 0, S("can't happen"));
881     test(S("abcdefghij"), 11, 0, "12345", 1, S("can't happen"));
882     test(S("abcdefghij"), 11, 0, "12345", 2, S("can't happen"));
883     test(S("abcdefghij"), 11, 0, "12345", 4, S("can't happen"));
884     test(S("abcdefghij"), 11, 0, "12345", 5, S("can't happen"));
885     test(S("abcdefghij"), 11, 0, "1234567890", 0, S("can't happen"));
886     test(S("abcdefghij"), 11, 0, "1234567890", 1, S("can't happen"));
887     test(S("abcdefghij"), 11, 0, "1234567890", 5, S("can't happen"));
888     test(S("abcdefghij"), 11, 0, "1234567890", 9, S("can't happen"));
889     test(S("abcdefghij"), 11, 0, "1234567890", 10, S("can't happen"));
890     test(S("abcdefghij"), 11, 0, "12345678901234567890", 0, S("can't happen"));
891     test(S("abcdefghij"), 11, 0, "12345678901234567890", 1, S("can't happen"));
892     test(S("abcdefghij"), 11, 0, "12345678901234567890", 10, S("can't happen"));
893     test(S("abcdefghij"), 11, 0, "12345678901234567890", 19, S("can't happen"));
894     test(S("abcdefghij"), 11, 0, "12345678901234567890", 20, S("can't happen"));
895 }
896
897 template <class S>
898 void test8()
899 {
900     test(S("abcdefghijklmnopqrst"), 0, 0, "", 0, S("abcdefghijklmnopqrst"));
901     test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 0, S("abcdefghijklmnopqrst"));
902     test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 1, S("1abcdefghijklmnopqrst"));
903     test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 2, S("12abcdefghijklmnopqrst"));
904     test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 4, S("1234abcdefghijklmnopqrst"));
905     test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 5, S("12345abcdefghijklmnopqrst"));
906     test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
907     test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 1, S("1abcdefghijklmnopqrst"));
908     test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 5, S("12345abcdefghijklmnopqrst"));
909     test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst"));
910     test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst"));
911     test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
912     test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst"));
913     test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst"));
914     test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst"));
915     test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst"));
916     test(S("abcdefghijklmnopqrst"), 0, 1, "", 0, S("bcdefghijklmnopqrst"));
917     test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 0, S("bcdefghijklmnopqrst"));
918     test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 1, S("1bcdefghijklmnopqrst"));
919     test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 2, S("12bcdefghijklmnopqrst"));
920     test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 4, S("1234bcdefghijklmnopqrst"));
921     test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 5, S("12345bcdefghijklmnopqrst"));
922     test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 0, S("bcdefghijklmnopqrst"));
923     test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 1, S("1bcdefghijklmnopqrst"));
924     test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 5, S("12345bcdefghijklmnopqrst"));
925     test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 9, S("123456789bcdefghijklmnopqrst"));
926     test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 10, S("1234567890bcdefghijklmnopqrst"));
927     test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 0, S("bcdefghijklmnopqrst"));
928     test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 1, S("1bcdefghijklmnopqrst"));
929     test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghijklmnopqrst"));
930     test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghijklmnopqrst"));
931     test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghijklmnopqrst"));
932     test(S("abcdefghijklmnopqrst"), 0, 10, "", 0, S("klmnopqrst"));
933     test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 0, S("klmnopqrst"));
934     test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 1, S("1klmnopqrst"));
935     test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 2, S("12klmnopqrst"));
936     test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 4, S("1234klmnopqrst"));
937     test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 5, S("12345klmnopqrst"));
938     test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 0, S("klmnopqrst"));
939     test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 1, S("1klmnopqrst"));
940     test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 5, S("12345klmnopqrst"));
941     test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 9, S("123456789klmnopqrst"));
942     test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 10, S("1234567890klmnopqrst"));
943     test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 0, S("klmnopqrst"));
944     test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 1, S("1klmnopqrst"));
945     test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 10, S("1234567890klmnopqrst"));
946     test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 19, S("1234567890123456789klmnopqrst"));
947     test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 20, S("12345678901234567890klmnopqrst"));
948     test(S("abcdefghijklmnopqrst"), 0, 19, "", 0, S("t"));
949     test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 0, S("t"));
950     test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 1, S("1t"));
951     test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 2, S("12t"));
952     test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 4, S("1234t"));
953     test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 5, S("12345t"));
954     test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 0, S("t"));
955     test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 1, S("1t"));
956     test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 5, S("12345t"));
957     test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 9, S("123456789t"));
958     test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 10, S("1234567890t"));
959     test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 0, S("t"));
960     test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 1, S("1t"));
961     test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 10, S("1234567890t"));
962     test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 19, S("1234567890123456789t"));
963     test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 20, S("12345678901234567890t"));
964     test(S("abcdefghijklmnopqrst"), 0, 20, "", 0, S(""));
965     test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 0, S(""));
966     test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 1, S("1"));
967     test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 2, S("12"));
968     test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 4, S("1234"));
969     test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 5, S("12345"));
970     test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 0, S(""));
971     test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 1, S("1"));
972     test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 5, S("12345"));
973     test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 9, S("123456789"));
974     test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 10, S("1234567890"));
975     test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 0, S(""));
976     test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 1, S("1"));
977     test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 10, S("1234567890"));
978     test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 19, S("1234567890123456789"));
979     test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 20, S("12345678901234567890"));
980     test(S("abcdefghijklmnopqrst"), 0, 21, "", 0, S(""));
981     test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 0, S(""));
982     test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 1, S("1"));
983     test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 2, S("12"));
984     test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 4, S("1234"));
985     test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 5, S("12345"));
986     test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 0, S(""));
987     test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 1, S("1"));
988     test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 5, S("12345"));
989     test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 9, S("123456789"));
990     test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 10, S("1234567890"));
991     test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 0, S(""));
992     test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 1, S("1"));
993     test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 10, S("1234567890"));
994     test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 19, S("1234567890123456789"));
995     test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 20, S("12345678901234567890"));
996     test(S("abcdefghijklmnopqrst"), 1, 0, "", 0, S("abcdefghijklmnopqrst"));
997     test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 0, S("abcdefghijklmnopqrst"));
998     test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 1, S("a1bcdefghijklmnopqrst"));
999     test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 2, S("a12bcdefghijklmnopqrst"));
1000 }
1001
1002 template <class S>
1003 void test9()
1004 {
1005     test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 4, S("a1234bcdefghijklmnopqrst"));
1006     test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 5, S("a12345bcdefghijklmnopqrst"));
1007     test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
1008     test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 1, S("a1bcdefghijklmnopqrst"));
1009     test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 5, S("a12345bcdefghijklmnopqrst"));
1010     test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 9, S("a123456789bcdefghijklmnopqrst"));
1011     test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
1012     test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
1013     test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst"));
1014     test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
1015     test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst"));
1016     test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst"));
1017     test(S("abcdefghijklmnopqrst"), 1, 1, "", 0, S("acdefghijklmnopqrst"));
1018     test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 0, S("acdefghijklmnopqrst"));
1019     test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 1, S("a1cdefghijklmnopqrst"));
1020     test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 2, S("a12cdefghijklmnopqrst"));
1021     test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 4, S("a1234cdefghijklmnopqrst"));
1022     test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 5, S("a12345cdefghijklmnopqrst"));
1023     test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 0, S("acdefghijklmnopqrst"));
1024     test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 1, S("a1cdefghijklmnopqrst"));
1025     test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 5, S("a12345cdefghijklmnopqrst"));
1026     test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 9, S("a123456789cdefghijklmnopqrst"));
1027     test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 10, S("a1234567890cdefghijklmnopqrst"));
1028     test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 0, S("acdefghijklmnopqrst"));
1029     test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 1, S("a1cdefghijklmnopqrst"));
1030     test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghijklmnopqrst"));
1031     test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghijklmnopqrst"));
1032     test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghijklmnopqrst"));
1033     test(S("abcdefghijklmnopqrst"), 1, 9, "", 0, S("aklmnopqrst"));
1034     test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 0, S("aklmnopqrst"));
1035     test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 1, S("a1klmnopqrst"));
1036     test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 2, S("a12klmnopqrst"));
1037     test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 4, S("a1234klmnopqrst"));
1038     test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 5, S("a12345klmnopqrst"));
1039     test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 0, S("aklmnopqrst"));
1040     test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 1, S("a1klmnopqrst"));
1041     test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 5, S("a12345klmnopqrst"));
1042     test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 9, S("a123456789klmnopqrst"));
1043     test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 10, S("a1234567890klmnopqrst"));
1044     test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 0, S("aklmnopqrst"));
1045     test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 1, S("a1klmnopqrst"));
1046     test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 10, S("a1234567890klmnopqrst"));
1047     test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789klmnopqrst"));
1048     test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890klmnopqrst"));
1049     test(S("abcdefghijklmnopqrst"), 1, 18, "", 0, S("at"));
1050     test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 0, S("at"));
1051     test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 1, S("a1t"));
1052     test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 2, S("a12t"));
1053     test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 4, S("a1234t"));
1054     test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 5, S("a12345t"));
1055     test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 0, S("at"));
1056     test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 1, S("a1t"));
1057     test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 5, S("a12345t"));
1058     test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 9, S("a123456789t"));
1059     test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 10, S("a1234567890t"));
1060     test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 0, S("at"));
1061     test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 1, S("a1t"));
1062     test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 10, S("a1234567890t"));
1063     test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 19, S("a1234567890123456789t"));
1064     test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 20, S("a12345678901234567890t"));
1065     test(S("abcdefghijklmnopqrst"), 1, 19, "", 0, S("a"));
1066     test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 0, S("a"));
1067     test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 1, S("a1"));
1068     test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 2, S("a12"));
1069     test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 4, S("a1234"));
1070     test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 5, S("a12345"));
1071     test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 0, S("a"));
1072     test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 1, S("a1"));
1073     test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 5, S("a12345"));
1074     test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 9, S("a123456789"));
1075     test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 10, S("a1234567890"));
1076     test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 0, S("a"));
1077     test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 1, S("a1"));
1078     test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 10, S("a1234567890"));
1079     test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 19, S("a1234567890123456789"));
1080     test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 20, S("a12345678901234567890"));
1081     test(S("abcdefghijklmnopqrst"), 1, 20, "", 0, S("a"));
1082     test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 0, S("a"));
1083     test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 1, S("a1"));
1084     test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 2, S("a12"));
1085     test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 4, S("a1234"));
1086     test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 5, S("a12345"));
1087     test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 0, S("a"));
1088     test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 1, S("a1"));
1089     test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 5, S("a12345"));
1090     test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 9, S("a123456789"));
1091     test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 10, S("a1234567890"));
1092     test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 0, S("a"));
1093     test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 1, S("a1"));
1094     test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 10, S("a1234567890"));
1095     test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 19, S("a1234567890123456789"));
1096     test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 20, S("a12345678901234567890"));
1097     test(S("abcdefghijklmnopqrst"), 10, 0, "", 0, S("abcdefghijklmnopqrst"));
1098     test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 0, S("abcdefghijklmnopqrst"));
1099     test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 1, S("abcdefghij1klmnopqrst"));
1100     test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 2, S("abcdefghij12klmnopqrst"));
1101     test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 4, S("abcdefghij1234klmnopqrst"));
1102     test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 5, S("abcdefghij12345klmnopqrst"));
1103     test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
1104     test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 1, S("abcdefghij1klmnopqrst"));
1105 }
1106
1107 template <class S>
1108 void test10()
1109 {
1110     test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 5, S("abcdefghij12345klmnopqrst"));
1111     test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 9, S("abcdefghij123456789klmnopqrst"));
1112     test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 10, S("abcdefghij1234567890klmnopqrst"));
1113     test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
1114     test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 1, S("abcdefghij1klmnopqrst"));
1115     test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst"));
1116     test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst"));
1117     test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst"));
1118     test(S("abcdefghijklmnopqrst"), 10, 1, "", 0, S("abcdefghijlmnopqrst"));
1119     test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 0, S("abcdefghijlmnopqrst"));
1120     test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 1, S("abcdefghij1lmnopqrst"));
1121     test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 2, S("abcdefghij12lmnopqrst"));
1122     test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 4, S("abcdefghij1234lmnopqrst"));
1123     test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 5, S("abcdefghij12345lmnopqrst"));
1124     test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 0, S("abcdefghijlmnopqrst"));
1125     test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 1, S("abcdefghij1lmnopqrst"));
1126     test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 5, S("abcdefghij12345lmnopqrst"));
1127     test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 9, S("abcdefghij123456789lmnopqrst"));
1128     test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 10, S("abcdefghij1234567890lmnopqrst"));
1129     test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 0, S("abcdefghijlmnopqrst"));
1130     test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 1, S("abcdefghij1lmnopqrst"));
1131     test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 10, S("abcdefghij1234567890lmnopqrst"));
1132     test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 19, S("abcdefghij1234567890123456789lmnopqrst"));
1133     test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 20, S("abcdefghij12345678901234567890lmnopqrst"));
1134     test(S("abcdefghijklmnopqrst"), 10, 5, "", 0, S("abcdefghijpqrst"));
1135     test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 0, S("abcdefghijpqrst"));
1136     test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 1, S("abcdefghij1pqrst"));
1137     test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 2, S("abcdefghij12pqrst"));
1138     test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 4, S("abcdefghij1234pqrst"));
1139     test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 5, S("abcdefghij12345pqrst"));
1140     test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 0, S("abcdefghijpqrst"));
1141     test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 1, S("abcdefghij1pqrst"));
1142     test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 5, S("abcdefghij12345pqrst"));
1143     test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 9, S("abcdefghij123456789pqrst"));
1144     test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 10, S("abcdefghij1234567890pqrst"));
1145     test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 0, S("abcdefghijpqrst"));
1146     test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 1, S("abcdefghij1pqrst"));
1147     test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 10, S("abcdefghij1234567890pqrst"));
1148     test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 19, S("abcdefghij1234567890123456789pqrst"));
1149     test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 20, S("abcdefghij12345678901234567890pqrst"));
1150     test(S("abcdefghijklmnopqrst"), 10, 9, "", 0, S("abcdefghijt"));
1151     test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 0, S("abcdefghijt"));
1152     test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 1, S("abcdefghij1t"));
1153     test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 2, S("abcdefghij12t"));
1154     test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 4, S("abcdefghij1234t"));
1155     test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 5, S("abcdefghij12345t"));
1156     test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 0, S("abcdefghijt"));
1157     test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 1, S("abcdefghij1t"));
1158     test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 5, S("abcdefghij12345t"));
1159     test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 9, S("abcdefghij123456789t"));
1160     test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 10, S("abcdefghij1234567890t"));
1161     test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 0, S("abcdefghijt"));
1162     test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 1, S("abcdefghij1t"));
1163     test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 10, S("abcdefghij1234567890t"));
1164     test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 19, S("abcdefghij1234567890123456789t"));
1165     test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 20, S("abcdefghij12345678901234567890t"));
1166     test(S("abcdefghijklmnopqrst"), 10, 10, "", 0, S("abcdefghij"));
1167     test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 0, S("abcdefghij"));
1168     test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 1, S("abcdefghij1"));
1169     test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 2, S("abcdefghij12"));
1170     test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 4, S("abcdefghij1234"));
1171     test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 5, S("abcdefghij12345"));
1172     test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 0, S("abcdefghij"));
1173     test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 1, S("abcdefghij1"));
1174     test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 5, S("abcdefghij12345"));
1175     test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 9, S("abcdefghij123456789"));
1176     test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 10, S("abcdefghij1234567890"));
1177     test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 0, S("abcdefghij"));
1178     test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 1, S("abcdefghij1"));
1179     test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 10, S("abcdefghij1234567890"));
1180     test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
1181     test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
1182     test(S("abcdefghijklmnopqrst"), 10, 11, "", 0, S("abcdefghij"));
1183     test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 0, S("abcdefghij"));
1184     test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 1, S("abcdefghij1"));
1185     test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 2, S("abcdefghij12"));
1186     test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 4, S("abcdefghij1234"));
1187     test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 5, S("abcdefghij12345"));
1188     test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 0, S("abcdefghij"));
1189     test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 1, S("abcdefghij1"));
1190     test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 5, S("abcdefghij12345"));
1191     test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 9, S("abcdefghij123456789"));
1192     test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 10, S("abcdefghij1234567890"));
1193     test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 0, S("abcdefghij"));
1194     test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 1, S("abcdefghij1"));
1195     test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 10, S("abcdefghij1234567890"));
1196     test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
1197     test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
1198     test(S("abcdefghijklmnopqrst"), 19, 0, "", 0, S("abcdefghijklmnopqrst"));
1199     test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 0, S("abcdefghijklmnopqrst"));
1200     test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 1, S("abcdefghijklmnopqrs1t"));
1201     test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 2, S("abcdefghijklmnopqrs12t"));
1202     test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 4, S("abcdefghijklmnopqrs1234t"));
1203     test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 5, S("abcdefghijklmnopqrs12345t"));
1204     test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
1205     test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 1, S("abcdefghijklmnopqrs1t"));
1206     test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 5, S("abcdefghijklmnopqrs12345t"));
1207     test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 9, S("abcdefghijklmnopqrs123456789t"));
1208     test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
1209     test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
1210 }
1211
1212 template <class S>
1213 void test11()
1214 {
1215     test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t"));
1216     test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
1217     test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t"));
1218     test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t"));
1219     test(S("abcdefghijklmnopqrst"), 19, 1, "", 0, S("abcdefghijklmnopqrs"));
1220     test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 0, S("abcdefghijklmnopqrs"));
1221     test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 1, S("abcdefghijklmnopqrs1"));
1222     test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 2, S("abcdefghijklmnopqrs12"));
1223     test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 4, S("abcdefghijklmnopqrs1234"));
1224     test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 5, S("abcdefghijklmnopqrs12345"));
1225     test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 0, S("abcdefghijklmnopqrs"));
1226     test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 1, S("abcdefghijklmnopqrs1"));
1227     test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 5, S("abcdefghijklmnopqrs12345"));
1228     test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 9, S("abcdefghijklmnopqrs123456789"));
1229     test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 10, S("abcdefghijklmnopqrs1234567890"));
1230     test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 0, S("abcdefghijklmnopqrs"));
1231     test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 1, S("abcdefghijklmnopqrs1"));
1232     test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890"));
1233     test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789"));
1234     test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890"));
1235     test(S("abcdefghijklmnopqrst"), 19, 2, "", 0, S("abcdefghijklmnopqrs"));
1236     test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 0, S("abcdefghijklmnopqrs"));
1237     test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 1, S("abcdefghijklmnopqrs1"));
1238     test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 2, S("abcdefghijklmnopqrs12"));
1239     test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 4, S("abcdefghijklmnopqrs1234"));
1240     test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 5, S("abcdefghijklmnopqrs12345"));
1241     test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 0, S("abcdefghijklmnopqrs"));
1242     test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 1, S("abcdefghijklmnopqrs1"));
1243     test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 5, S("abcdefghijklmnopqrs12345"));
1244     test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 9, S("abcdefghijklmnopqrs123456789"));
1245     test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 10, S("abcdefghijklmnopqrs1234567890"));
1246     test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 0, S("abcdefghijklmnopqrs"));
1247     test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 1, S("abcdefghijklmnopqrs1"));
1248     test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890"));
1249     test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789"));
1250     test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890"));
1251     test(S("abcdefghijklmnopqrst"), 20, 0, "", 0, S("abcdefghijklmnopqrst"));
1252     test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 0, S("abcdefghijklmnopqrst"));
1253     test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 1, S("abcdefghijklmnopqrst1"));
1254     test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 2, S("abcdefghijklmnopqrst12"));
1255     test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 4, S("abcdefghijklmnopqrst1234"));
1256     test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 5, S("abcdefghijklmnopqrst12345"));
1257     test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
1258     test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 1, S("abcdefghijklmnopqrst1"));
1259     test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 5, S("abcdefghijklmnopqrst12345"));
1260     test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 9, S("abcdefghijklmnopqrst123456789"));
1261     test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 10, S("abcdefghijklmnopqrst1234567890"));
1262     test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
1263     test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrst1"));
1264     test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890"));
1265     test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789"));
1266     test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890"));
1267     test(S("abcdefghijklmnopqrst"), 20, 1, "", 0, S("abcdefghijklmnopqrst"));
1268     test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 0, S("abcdefghijklmnopqrst"));
1269     test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 1, S("abcdefghijklmnopqrst1"));
1270     test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 2, S("abcdefghijklmnopqrst12"));
1271     test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 4, S("abcdefghijklmnopqrst1234"));
1272     test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 5, S("abcdefghijklmnopqrst12345"));
1273     test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 0, S("abcdefghijklmnopqrst"));
1274     test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 1, S("abcdefghijklmnopqrst1"));
1275     test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 5, S("abcdefghijklmnopqrst12345"));
1276     test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 9, S("abcdefghijklmnopqrst123456789"));
1277     test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 10, S("abcdefghijklmnopqrst1234567890"));
1278     test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
1279     test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 1, S("abcdefghijklmnopqrst1"));
1280     test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890"));
1281     test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789"));
1282     test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890"));
1283     test(S("abcdefghijklmnopqrst"), 21, 0, "", 0, S("can't happen"));
1284     test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 0, S("can't happen"));
1285     test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 1, S("can't happen"));
1286     test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 2, S("can't happen"));
1287     test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 4, S("can't happen"));
1288     test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 5, S("can't happen"));
1289     test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 0, S("can't happen"));
1290     test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 1, S("can't happen"));
1291     test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 5, S("can't happen"));
1292     test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 9, S("can't happen"));
1293     test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 10, S("can't happen"));
1294     test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 0, S("can't happen"));
1295     test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 1, S("can't happen"));
1296     test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 10, S("can't happen"));
1297     test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 19, S("can't happen"));
1298     test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 20, S("can't happen"));
1299 }
1300
1301 int main()
1302 {
1303     {
1304     typedef std::string S;
1305     test0<S>();
1306     test1<S>();
1307     test2<S>();
1308     test3<S>();
1309     test4<S>();
1310     test5<S>();
1311     test6<S>();
1312     test7<S>();
1313     test8<S>();
1314     test9<S>();
1315     test10<S>();
1316     test11<S>();
1317     }
1318 #if TEST_STD_VER >= 11
1319     {
1320     typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
1321     test0<S>();
1322     test1<S>();
1323     test2<S>();
1324     test3<S>();
1325     test4<S>();
1326     test5<S>();
1327     test6<S>();
1328     test7<S>();
1329     test8<S>();
1330     test9<S>();
1331     test10<S>();
1332     test11<S>();
1333     }
1334 #endif
1335 }