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