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 pos1, size_type n1, const basic_string<charT,traits,Allocator>& str,
13 //           size_type pos2, size_type n2=npos);
14 //  the "=npos" was added in C++14
15 
16 #include <string>
17 #include <stdexcept>
18 #include <algorithm>
19 #include <cassert>
20 
21 #include "test_macros.h"
22 #include "min_allocator.h"
23 
24 template <class S>
25 void
26 test(S s, typename S::size_type pos1, typename S::size_type n1,
27      S str, typename S::size_type pos2, typename S::size_type n2,
28      S expected)
29 {
30     const typename S::size_type old_size = s.size();
31     S s0 = s;
32     if (pos1 <= old_size && pos2 <= str.size())
33     {
34         s.replace(pos1, n1, str, pos2, n2);
35         LIBCPP_ASSERT(s.__invariants());
36         assert(s == expected);
37         typename S::size_type xlen = std::min(n1, old_size - pos1);
38         typename S::size_type rlen = std::min(n2, str.size() - pos2);
39         assert(s.size() == old_size - xlen + rlen);
40     }
41 #ifndef TEST_HAS_NO_EXCEPTIONS
42     else
43     {
44         try
45         {
46             s.replace(pos1, n1, str, pos2, n2);
47             assert(false);
48         }
49         catch (std::out_of_range&)
50         {
51             assert(pos1 > old_size || pos2 > str.size());
52             assert(s == s0);
53         }
54     }
55 #endif
56 }
57 
58 template <class S>
59 void
60 test_npos(S s, typename S::size_type pos1, typename S::size_type n1,
61      S str, typename S::size_type pos2,
62      S expected)
63 {
64     const typename S::size_type old_size = s.size();
65     S s0 = s;
66     if (pos1 <= old_size && pos2 <= str.size())
67     {
68         s.replace(pos1, n1, str, pos2);
69         LIBCPP_ASSERT(s.__invariants());
70         assert(s == expected);
71         typename S::size_type xlen = std::min(n1, old_size - pos1);
72         typename S::size_type rlen = std::min(S::npos, str.size() - pos2);
73         assert(s.size() == old_size - xlen + rlen);
74     }
75 #ifndef TEST_HAS_NO_EXCEPTIONS
76     else
77     {
78         try
79         {
80             s.replace(pos1, n1, str, pos2);
81             assert(false);
82         }
83         catch (std::out_of_range&)
84         {
85             assert(pos1 > old_size || pos2 > str.size());
86             assert(s == s0);
87         }
88     }
89 #endif
90 }
91 
92 
93 template <class S>
94 void test0()
95 {
96     test(S(""), 0, 0, S(""), 0, 0, S(""));
97     test(S(""), 0, 0, S(""), 0, 1, S(""));
98     test(S(""), 0, 0, S(""), 1, 0, S("can't happen"));
99     test(S(""), 0, 0, S("12345"), 0, 0, S(""));
100     test(S(""), 0, 0, S("12345"), 0, 1, S("1"));
101     test(S(""), 0, 0, S("12345"), 0, 2, S("12"));
102     test(S(""), 0, 0, S("12345"), 0, 4, S("1234"));
103     test(S(""), 0, 0, S("12345"), 0, 5, S("12345"));
104     test(S(""), 0, 0, S("12345"), 0, 6, S("12345"));
105     test(S(""), 0, 0, S("12345"), 1, 0, S(""));
106     test(S(""), 0, 0, S("12345"), 1, 1, S("2"));
107     test(S(""), 0, 0, S("12345"), 1, 2, S("23"));
108     test(S(""), 0, 0, S("12345"), 1, 3, S("234"));
109     test(S(""), 0, 0, S("12345"), 1, 4, S("2345"));
110     test(S(""), 0, 0, S("12345"), 1, 5, S("2345"));
111     test(S(""), 0, 0, S("12345"), 2, 0, S(""));
112     test(S(""), 0, 0, S("12345"), 2, 1, S("3"));
113     test(S(""), 0, 0, S("12345"), 2, 2, S("34"));
114     test(S(""), 0, 0, S("12345"), 2, 3, S("345"));
115     test(S(""), 0, 0, S("12345"), 2, 4, S("345"));
116     test(S(""), 0, 0, S("12345"), 4, 0, S(""));
117     test(S(""), 0, 0, S("12345"), 4, 1, S("5"));
118     test(S(""), 0, 0, S("12345"), 4, 2, S("5"));
119     test(S(""), 0, 0, S("12345"), 5, 0, S(""));
120     test(S(""), 0, 0, S("12345"), 5, 1, S(""));
121     test(S(""), 0, 0, S("12345"), 6, 0, S("can't happen"));
122     test(S(""), 0, 0, S("1234567890"), 0, 0, S(""));
123     test(S(""), 0, 0, S("1234567890"), 0, 1, S("1"));
124     test(S(""), 0, 0, S("1234567890"), 0, 5, S("12345"));
125     test(S(""), 0, 0, S("1234567890"), 0, 9, S("123456789"));
126     test(S(""), 0, 0, S("1234567890"), 0, 10, S("1234567890"));
127     test(S(""), 0, 0, S("1234567890"), 0, 11, S("1234567890"));
128     test(S(""), 0, 0, S("1234567890"), 1, 0, S(""));
129     test(S(""), 0, 0, S("1234567890"), 1, 1, S("2"));
130     test(S(""), 0, 0, S("1234567890"), 1, 4, S("2345"));
131     test(S(""), 0, 0, S("1234567890"), 1, 8, S("23456789"));
132     test(S(""), 0, 0, S("1234567890"), 1, 9, S("234567890"));
133     test(S(""), 0, 0, S("1234567890"), 1, 10, S("234567890"));
134     test(S(""), 0, 0, S("1234567890"), 5, 0, S(""));
135     test(S(""), 0, 0, S("1234567890"), 5, 1, S("6"));
136     test(S(""), 0, 0, S("1234567890"), 5, 2, S("67"));
137     test(S(""), 0, 0, S("1234567890"), 5, 4, S("6789"));
138     test(S(""), 0, 0, S("1234567890"), 5, 5, S("67890"));
139     test(S(""), 0, 0, S("1234567890"), 5, 6, S("67890"));
140     test(S(""), 0, 0, S("1234567890"), 9, 0, S(""));
141     test(S(""), 0, 0, S("1234567890"), 9, 1, S("0"));
142     test(S(""), 0, 0, S("1234567890"), 9, 2, S("0"));
143     test(S(""), 0, 0, S("1234567890"), 10, 0, S(""));
144     test(S(""), 0, 0, S("1234567890"), 10, 1, S(""));
145     test(S(""), 0, 0, S("1234567890"), 11, 0, S("can't happen"));
146     test(S(""), 0, 0, S("12345678901234567890"), 0, 0, S(""));
147     test(S(""), 0, 0, S("12345678901234567890"), 0, 1, S("1"));
148     test(S(""), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890"));
149     test(S(""), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
150     test(S(""), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
151     test(S(""), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
152     test(S(""), 0, 0, S("12345678901234567890"), 1, 0, S(""));
153     test(S(""), 0, 0, S("12345678901234567890"), 1, 1, S("2"));
154     test(S(""), 0, 0, S("12345678901234567890"), 1, 9, S("234567890"));
155     test(S(""), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789"));
156     test(S(""), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
157     test(S(""), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
158     test(S(""), 0, 0, S("12345678901234567890"), 10, 0, S(""));
159     test(S(""), 0, 0, S("12345678901234567890"), 10, 1, S("1"));
160     test(S(""), 0, 0, S("12345678901234567890"), 10, 5, S("12345"));
161     test(S(""), 0, 0, S("12345678901234567890"), 10, 9, S("123456789"));
162     test(S(""), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890"));
163     test(S(""), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890"));
164     test(S(""), 0, 0, S("12345678901234567890"), 19, 0, S(""));
165     test(S(""), 0, 0, S("12345678901234567890"), 19, 1, S("0"));
166     test(S(""), 0, 0, S("12345678901234567890"), 19, 2, S("0"));
167     test(S(""), 0, 0, S("12345678901234567890"), 20, 0, S(""));
168     test(S(""), 0, 0, S("12345678901234567890"), 20, 1, S(""));
169     test(S(""), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
170     test(S(""), 0, 1, S(""), 0, 0, S(""));
171     test(S(""), 0, 1, S(""), 0, 1, S(""));
172     test(S(""), 0, 1, S(""), 1, 0, S("can't happen"));
173     test(S(""), 0, 1, S("12345"), 0, 0, S(""));
174     test(S(""), 0, 1, S("12345"), 0, 1, S("1"));
175     test(S(""), 0, 1, S("12345"), 0, 2, S("12"));
176     test(S(""), 0, 1, S("12345"), 0, 4, S("1234"));
177     test(S(""), 0, 1, S("12345"), 0, 5, S("12345"));
178     test(S(""), 0, 1, S("12345"), 0, 6, S("12345"));
179     test(S(""), 0, 1, S("12345"), 1, 0, S(""));
180     test(S(""), 0, 1, S("12345"), 1, 1, S("2"));
181     test(S(""), 0, 1, S("12345"), 1, 2, S("23"));
182     test(S(""), 0, 1, S("12345"), 1, 3, S("234"));
183     test(S(""), 0, 1, S("12345"), 1, 4, S("2345"));
184     test(S(""), 0, 1, S("12345"), 1, 5, S("2345"));
185     test(S(""), 0, 1, S("12345"), 2, 0, S(""));
186     test(S(""), 0, 1, S("12345"), 2, 1, S("3"));
187     test(S(""), 0, 1, S("12345"), 2, 2, S("34"));
188     test(S(""), 0, 1, S("12345"), 2, 3, S("345"));
189     test(S(""), 0, 1, S("12345"), 2, 4, S("345"));
190     test(S(""), 0, 1, S("12345"), 4, 0, S(""));
191     test(S(""), 0, 1, S("12345"), 4, 1, S("5"));
192     test(S(""), 0, 1, S("12345"), 4, 2, S("5"));
193     test(S(""), 0, 1, S("12345"), 5, 0, S(""));
194     test(S(""), 0, 1, S("12345"), 5, 1, S(""));
195     test(S(""), 0, 1, S("12345"), 6, 0, S("can't happen"));
196 }
197 
198 template <class S>
199 void test1()
200 {
201     test(S(""), 0, 1, S("1234567890"), 0, 0, S(""));
202     test(S(""), 0, 1, S("1234567890"), 0, 1, S("1"));
203     test(S(""), 0, 1, S("1234567890"), 0, 5, S("12345"));
204     test(S(""), 0, 1, S("1234567890"), 0, 9, S("123456789"));
205     test(S(""), 0, 1, S("1234567890"), 0, 10, S("1234567890"));
206     test(S(""), 0, 1, S("1234567890"), 0, 11, S("1234567890"));
207     test(S(""), 0, 1, S("1234567890"), 1, 0, S(""));
208     test(S(""), 0, 1, S("1234567890"), 1, 1, S("2"));
209     test(S(""), 0, 1, S("1234567890"), 1, 4, S("2345"));
210     test(S(""), 0, 1, S("1234567890"), 1, 8, S("23456789"));
211     test(S(""), 0, 1, S("1234567890"), 1, 9, S("234567890"));
212     test(S(""), 0, 1, S("1234567890"), 1, 10, S("234567890"));
213     test(S(""), 0, 1, S("1234567890"), 5, 0, S(""));
214     test(S(""), 0, 1, S("1234567890"), 5, 1, S("6"));
215     test(S(""), 0, 1, S("1234567890"), 5, 2, S("67"));
216     test(S(""), 0, 1, S("1234567890"), 5, 4, S("6789"));
217     test(S(""), 0, 1, S("1234567890"), 5, 5, S("67890"));
218     test(S(""), 0, 1, S("1234567890"), 5, 6, S("67890"));
219     test(S(""), 0, 1, S("1234567890"), 9, 0, S(""));
220     test(S(""), 0, 1, S("1234567890"), 9, 1, S("0"));
221     test(S(""), 0, 1, S("1234567890"), 9, 2, S("0"));
222     test(S(""), 0, 1, S("1234567890"), 10, 0, S(""));
223     test(S(""), 0, 1, S("1234567890"), 10, 1, S(""));
224     test(S(""), 0, 1, S("1234567890"), 11, 0, S("can't happen"));
225     test(S(""), 0, 1, S("12345678901234567890"), 0, 0, S(""));
226     test(S(""), 0, 1, S("12345678901234567890"), 0, 1, S("1"));
227     test(S(""), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890"));
228     test(S(""), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
229     test(S(""), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
230     test(S(""), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
231     test(S(""), 0, 1, S("12345678901234567890"), 1, 0, S(""));
232     test(S(""), 0, 1, S("12345678901234567890"), 1, 1, S("2"));
233     test(S(""), 0, 1, S("12345678901234567890"), 1, 9, S("234567890"));
234     test(S(""), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789"));
235     test(S(""), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
236     test(S(""), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
237     test(S(""), 0, 1, S("12345678901234567890"), 10, 0, S(""));
238     test(S(""), 0, 1, S("12345678901234567890"), 10, 1, S("1"));
239     test(S(""), 0, 1, S("12345678901234567890"), 10, 5, S("12345"));
240     test(S(""), 0, 1, S("12345678901234567890"), 10, 9, S("123456789"));
241     test(S(""), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890"));
242     test(S(""), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890"));
243     test(S(""), 0, 1, S("12345678901234567890"), 19, 0, S(""));
244     test(S(""), 0, 1, S("12345678901234567890"), 19, 1, S("0"));
245     test(S(""), 0, 1, S("12345678901234567890"), 19, 2, S("0"));
246     test(S(""), 0, 1, S("12345678901234567890"), 20, 0, S(""));
247     test(S(""), 0, 1, S("12345678901234567890"), 20, 1, S(""));
248     test(S(""), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
249     test(S(""), 1, 0, S(""), 0, 0, S("can't happen"));
250     test(S(""), 1, 0, S(""), 0, 1, S("can't happen"));
251     test(S(""), 1, 0, S(""), 1, 0, S("can't happen"));
252     test(S(""), 1, 0, S("12345"), 0, 0, S("can't happen"));
253     test(S(""), 1, 0, S("12345"), 0, 1, S("can't happen"));
254     test(S(""), 1, 0, S("12345"), 0, 2, S("can't happen"));
255     test(S(""), 1, 0, S("12345"), 0, 4, S("can't happen"));
256     test(S(""), 1, 0, S("12345"), 0, 5, S("can't happen"));
257     test(S(""), 1, 0, S("12345"), 0, 6, S("can't happen"));
258     test(S(""), 1, 0, S("12345"), 1, 0, S("can't happen"));
259     test(S(""), 1, 0, S("12345"), 1, 1, S("can't happen"));
260     test(S(""), 1, 0, S("12345"), 1, 2, S("can't happen"));
261     test(S(""), 1, 0, S("12345"), 1, 3, S("can't happen"));
262     test(S(""), 1, 0, S("12345"), 1, 4, S("can't happen"));
263     test(S(""), 1, 0, S("12345"), 1, 5, S("can't happen"));
264     test(S(""), 1, 0, S("12345"), 2, 0, S("can't happen"));
265     test(S(""), 1, 0, S("12345"), 2, 1, S("can't happen"));
266     test(S(""), 1, 0, S("12345"), 2, 2, S("can't happen"));
267     test(S(""), 1, 0, S("12345"), 2, 3, S("can't happen"));
268     test(S(""), 1, 0, S("12345"), 2, 4, S("can't happen"));
269     test(S(""), 1, 0, S("12345"), 4, 0, S("can't happen"));
270     test(S(""), 1, 0, S("12345"), 4, 1, S("can't happen"));
271     test(S(""), 1, 0, S("12345"), 4, 2, S("can't happen"));
272     test(S(""), 1, 0, S("12345"), 5, 0, S("can't happen"));
273     test(S(""), 1, 0, S("12345"), 5, 1, S("can't happen"));
274     test(S(""), 1, 0, S("12345"), 6, 0, S("can't happen"));
275     test(S(""), 1, 0, S("1234567890"), 0, 0, S("can't happen"));
276     test(S(""), 1, 0, S("1234567890"), 0, 1, S("can't happen"));
277     test(S(""), 1, 0, S("1234567890"), 0, 5, S("can't happen"));
278     test(S(""), 1, 0, S("1234567890"), 0, 9, S("can't happen"));
279     test(S(""), 1, 0, S("1234567890"), 0, 10, S("can't happen"));
280     test(S(""), 1, 0, S("1234567890"), 0, 11, S("can't happen"));
281     test(S(""), 1, 0, S("1234567890"), 1, 0, S("can't happen"));
282     test(S(""), 1, 0, S("1234567890"), 1, 1, S("can't happen"));
283     test(S(""), 1, 0, S("1234567890"), 1, 4, S("can't happen"));
284     test(S(""), 1, 0, S("1234567890"), 1, 8, S("can't happen"));
285     test(S(""), 1, 0, S("1234567890"), 1, 9, S("can't happen"));
286     test(S(""), 1, 0, S("1234567890"), 1, 10, S("can't happen"));
287     test(S(""), 1, 0, S("1234567890"), 5, 0, S("can't happen"));
288     test(S(""), 1, 0, S("1234567890"), 5, 1, S("can't happen"));
289     test(S(""), 1, 0, S("1234567890"), 5, 2, S("can't happen"));
290     test(S(""), 1, 0, S("1234567890"), 5, 4, S("can't happen"));
291     test(S(""), 1, 0, S("1234567890"), 5, 5, S("can't happen"));
292     test(S(""), 1, 0, S("1234567890"), 5, 6, S("can't happen"));
293     test(S(""), 1, 0, S("1234567890"), 9, 0, S("can't happen"));
294     test(S(""), 1, 0, S("1234567890"), 9, 1, S("can't happen"));
295     test(S(""), 1, 0, S("1234567890"), 9, 2, S("can't happen"));
296     test(S(""), 1, 0, S("1234567890"), 10, 0, S("can't happen"));
297     test(S(""), 1, 0, S("1234567890"), 10, 1, S("can't happen"));
298     test(S(""), 1, 0, S("1234567890"), 11, 0, S("can't happen"));
299     test(S(""), 1, 0, S("12345678901234567890"), 0, 0, S("can't happen"));
300     test(S(""), 1, 0, S("12345678901234567890"), 0, 1, S("can't happen"));
301 }
302 
303 template <class S>
304 void test2()
305 {
306     test(S(""), 1, 0, S("12345678901234567890"), 0, 10, S("can't happen"));
307     test(S(""), 1, 0, S("12345678901234567890"), 0, 19, S("can't happen"));
308     test(S(""), 1, 0, S("12345678901234567890"), 0, 20, S("can't happen"));
309     test(S(""), 1, 0, S("12345678901234567890"), 0, 21, S("can't happen"));
310     test(S(""), 1, 0, S("12345678901234567890"), 1, 0, S("can't happen"));
311     test(S(""), 1, 0, S("12345678901234567890"), 1, 1, S("can't happen"));
312     test(S(""), 1, 0, S("12345678901234567890"), 1, 9, S("can't happen"));
313     test(S(""), 1, 0, S("12345678901234567890"), 1, 18, S("can't happen"));
314     test(S(""), 1, 0, S("12345678901234567890"), 1, 19, S("can't happen"));
315     test(S(""), 1, 0, S("12345678901234567890"), 1, 20, S("can't happen"));
316     test(S(""), 1, 0, S("12345678901234567890"), 10, 0, S("can't happen"));
317     test(S(""), 1, 0, S("12345678901234567890"), 10, 1, S("can't happen"));
318     test(S(""), 1, 0, S("12345678901234567890"), 10, 5, S("can't happen"));
319     test(S(""), 1, 0, S("12345678901234567890"), 10, 9, S("can't happen"));
320     test(S(""), 1, 0, S("12345678901234567890"), 10, 10, S("can't happen"));
321     test(S(""), 1, 0, S("12345678901234567890"), 10, 11, S("can't happen"));
322     test(S(""), 1, 0, S("12345678901234567890"), 19, 0, S("can't happen"));
323     test(S(""), 1, 0, S("12345678901234567890"), 19, 1, S("can't happen"));
324     test(S(""), 1, 0, S("12345678901234567890"), 19, 2, S("can't happen"));
325     test(S(""), 1, 0, S("12345678901234567890"), 20, 0, S("can't happen"));
326     test(S(""), 1, 0, S("12345678901234567890"), 20, 1, S("can't happen"));
327     test(S(""), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
328     test(S("abcde"), 0, 0, S(""), 0, 0, S("abcde"));
329     test(S("abcde"), 0, 0, S(""), 0, 1, S("abcde"));
330     test(S("abcde"), 0, 0, S(""), 1, 0, S("can't happen"));
331     test(S("abcde"), 0, 0, S("12345"), 0, 0, S("abcde"));
332     test(S("abcde"), 0, 0, S("12345"), 0, 1, S("1abcde"));
333     test(S("abcde"), 0, 0, S("12345"), 0, 2, S("12abcde"));
334     test(S("abcde"), 0, 0, S("12345"), 0, 4, S("1234abcde"));
335     test(S("abcde"), 0, 0, S("12345"), 0, 5, S("12345abcde"));
336     test(S("abcde"), 0, 0, S("12345"), 0, 6, S("12345abcde"));
337     test(S("abcde"), 0, 0, S("12345"), 1, 0, S("abcde"));
338     test(S("abcde"), 0, 0, S("12345"), 1, 1, S("2abcde"));
339     test(S("abcde"), 0, 0, S("12345"), 1, 2, S("23abcde"));
340     test(S("abcde"), 0, 0, S("12345"), 1, 3, S("234abcde"));
341     test(S("abcde"), 0, 0, S("12345"), 1, 4, S("2345abcde"));
342     test(S("abcde"), 0, 0, S("12345"), 1, 5, S("2345abcde"));
343     test(S("abcde"), 0, 0, S("12345"), 2, 0, S("abcde"));
344     test(S("abcde"), 0, 0, S("12345"), 2, 1, S("3abcde"));
345     test(S("abcde"), 0, 0, S("12345"), 2, 2, S("34abcde"));
346     test(S("abcde"), 0, 0, S("12345"), 2, 3, S("345abcde"));
347     test(S("abcde"), 0, 0, S("12345"), 2, 4, S("345abcde"));
348     test(S("abcde"), 0, 0, S("12345"), 4, 0, S("abcde"));
349     test(S("abcde"), 0, 0, S("12345"), 4, 1, S("5abcde"));
350     test(S("abcde"), 0, 0, S("12345"), 4, 2, S("5abcde"));
351     test(S("abcde"), 0, 0, S("12345"), 5, 0, S("abcde"));
352     test(S("abcde"), 0, 0, S("12345"), 5, 1, S("abcde"));
353     test(S("abcde"), 0, 0, S("12345"), 6, 0, S("can't happen"));
354     test(S("abcde"), 0, 0, S("1234567890"), 0, 0, S("abcde"));
355     test(S("abcde"), 0, 0, S("1234567890"), 0, 1, S("1abcde"));
356     test(S("abcde"), 0, 0, S("1234567890"), 0, 5, S("12345abcde"));
357     test(S("abcde"), 0, 0, S("1234567890"), 0, 9, S("123456789abcde"));
358     test(S("abcde"), 0, 0, S("1234567890"), 0, 10, S("1234567890abcde"));
359     test(S("abcde"), 0, 0, S("1234567890"), 0, 11, S("1234567890abcde"));
360     test(S("abcde"), 0, 0, S("1234567890"), 1, 0, S("abcde"));
361     test(S("abcde"), 0, 0, S("1234567890"), 1, 1, S("2abcde"));
362     test(S("abcde"), 0, 0, S("1234567890"), 1, 4, S("2345abcde"));
363     test(S("abcde"), 0, 0, S("1234567890"), 1, 8, S("23456789abcde"));
364     test(S("abcde"), 0, 0, S("1234567890"), 1, 9, S("234567890abcde"));
365     test(S("abcde"), 0, 0, S("1234567890"), 1, 10, S("234567890abcde"));
366     test(S("abcde"), 0, 0, S("1234567890"), 5, 0, S("abcde"));
367     test(S("abcde"), 0, 0, S("1234567890"), 5, 1, S("6abcde"));
368     test(S("abcde"), 0, 0, S("1234567890"), 5, 2, S("67abcde"));
369     test(S("abcde"), 0, 0, S("1234567890"), 5, 4, S("6789abcde"));
370     test(S("abcde"), 0, 0, S("1234567890"), 5, 5, S("67890abcde"));
371     test(S("abcde"), 0, 0, S("1234567890"), 5, 6, S("67890abcde"));
372     test(S("abcde"), 0, 0, S("1234567890"), 9, 0, S("abcde"));
373     test(S("abcde"), 0, 0, S("1234567890"), 9, 1, S("0abcde"));
374     test(S("abcde"), 0, 0, S("1234567890"), 9, 2, S("0abcde"));
375     test(S("abcde"), 0, 0, S("1234567890"), 10, 0, S("abcde"));
376     test(S("abcde"), 0, 0, S("1234567890"), 10, 1, S("abcde"));
377     test(S("abcde"), 0, 0, S("1234567890"), 11, 0, S("can't happen"));
378     test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 0, S("abcde"));
379     test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 1, S("1abcde"));
380     test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890abcde"));
381     test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcde"));
382     test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcde"));
383     test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcde"));
384     test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 0, S("abcde"));
385     test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 1, S("2abcde"));
386     test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 9, S("234567890abcde"));
387     test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcde"));
388     test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcde"));
389     test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcde"));
390     test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 0, S("abcde"));
391     test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 1, S("1abcde"));
392     test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 5, S("12345abcde"));
393     test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 9, S("123456789abcde"));
394     test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890abcde"));
395     test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890abcde"));
396     test(S("abcde"), 0, 0, S("12345678901234567890"), 19, 0, S("abcde"));
397     test(S("abcde"), 0, 0, S("12345678901234567890"), 19, 1, S("0abcde"));
398     test(S("abcde"), 0, 0, S("12345678901234567890"), 19, 2, S("0abcde"));
399     test(S("abcde"), 0, 0, S("12345678901234567890"), 20, 0, S("abcde"));
400     test(S("abcde"), 0, 0, S("12345678901234567890"), 20, 1, S("abcde"));
401     test(S("abcde"), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
402     test(S("abcde"), 0, 1, S(""), 0, 0, S("bcde"));
403     test(S("abcde"), 0, 1, S(""), 0, 1, S("bcde"));
404     test(S("abcde"), 0, 1, S(""), 1, 0, S("can't happen"));
405     test(S("abcde"), 0, 1, S("12345"), 0, 0, S("bcde"));
406 }
407 
408 template <class S>
409 void test3()
410 {
411     test(S("abcde"), 0, 1, S("12345"), 0, 1, S("1bcde"));
412     test(S("abcde"), 0, 1, S("12345"), 0, 2, S("12bcde"));
413     test(S("abcde"), 0, 1, S("12345"), 0, 4, S("1234bcde"));
414     test(S("abcde"), 0, 1, S("12345"), 0, 5, S("12345bcde"));
415     test(S("abcde"), 0, 1, S("12345"), 0, 6, S("12345bcde"));
416     test(S("abcde"), 0, 1, S("12345"), 1, 0, S("bcde"));
417     test(S("abcde"), 0, 1, S("12345"), 1, 1, S("2bcde"));
418     test(S("abcde"), 0, 1, S("12345"), 1, 2, S("23bcde"));
419     test(S("abcde"), 0, 1, S("12345"), 1, 3, S("234bcde"));
420     test(S("abcde"), 0, 1, S("12345"), 1, 4, S("2345bcde"));
421     test(S("abcde"), 0, 1, S("12345"), 1, 5, S("2345bcde"));
422     test(S("abcde"), 0, 1, S("12345"), 2, 0, S("bcde"));
423     test(S("abcde"), 0, 1, S("12345"), 2, 1, S("3bcde"));
424     test(S("abcde"), 0, 1, S("12345"), 2, 2, S("34bcde"));
425     test(S("abcde"), 0, 1, S("12345"), 2, 3, S("345bcde"));
426     test(S("abcde"), 0, 1, S("12345"), 2, 4, S("345bcde"));
427     test(S("abcde"), 0, 1, S("12345"), 4, 0, S("bcde"));
428     test(S("abcde"), 0, 1, S("12345"), 4, 1, S("5bcde"));
429     test(S("abcde"), 0, 1, S("12345"), 4, 2, S("5bcde"));
430     test(S("abcde"), 0, 1, S("12345"), 5, 0, S("bcde"));
431     test(S("abcde"), 0, 1, S("12345"), 5, 1, S("bcde"));
432     test(S("abcde"), 0, 1, S("12345"), 6, 0, S("can't happen"));
433     test(S("abcde"), 0, 1, S("1234567890"), 0, 0, S("bcde"));
434     test(S("abcde"), 0, 1, S("1234567890"), 0, 1, S("1bcde"));
435     test(S("abcde"), 0, 1, S("1234567890"), 0, 5, S("12345bcde"));
436     test(S("abcde"), 0, 1, S("1234567890"), 0, 9, S("123456789bcde"));
437     test(S("abcde"), 0, 1, S("1234567890"), 0, 10, S("1234567890bcde"));
438     test(S("abcde"), 0, 1, S("1234567890"), 0, 11, S("1234567890bcde"));
439     test(S("abcde"), 0, 1, S("1234567890"), 1, 0, S("bcde"));
440     test(S("abcde"), 0, 1, S("1234567890"), 1, 1, S("2bcde"));
441     test(S("abcde"), 0, 1, S("1234567890"), 1, 4, S("2345bcde"));
442     test(S("abcde"), 0, 1, S("1234567890"), 1, 8, S("23456789bcde"));
443     test(S("abcde"), 0, 1, S("1234567890"), 1, 9, S("234567890bcde"));
444     test(S("abcde"), 0, 1, S("1234567890"), 1, 10, S("234567890bcde"));
445     test(S("abcde"), 0, 1, S("1234567890"), 5, 0, S("bcde"));
446     test(S("abcde"), 0, 1, S("1234567890"), 5, 1, S("6bcde"));
447     test(S("abcde"), 0, 1, S("1234567890"), 5, 2, S("67bcde"));
448     test(S("abcde"), 0, 1, S("1234567890"), 5, 4, S("6789bcde"));
449     test(S("abcde"), 0, 1, S("1234567890"), 5, 5, S("67890bcde"));
450     test(S("abcde"), 0, 1, S("1234567890"), 5, 6, S("67890bcde"));
451     test(S("abcde"), 0, 1, S("1234567890"), 9, 0, S("bcde"));
452     test(S("abcde"), 0, 1, S("1234567890"), 9, 1, S("0bcde"));
453     test(S("abcde"), 0, 1, S("1234567890"), 9, 2, S("0bcde"));
454     test(S("abcde"), 0, 1, S("1234567890"), 10, 0, S("bcde"));
455     test(S("abcde"), 0, 1, S("1234567890"), 10, 1, S("bcde"));
456     test(S("abcde"), 0, 1, S("1234567890"), 11, 0, S("can't happen"));
457     test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 0, S("bcde"));
458     test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 1, S("1bcde"));
459     test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890bcde"));
460     test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789bcde"));
461     test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890bcde"));
462     test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890bcde"));
463     test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 0, S("bcde"));
464     test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 1, S("2bcde"));
465     test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 9, S("234567890bcde"));
466     test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789bcde"));
467     test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890bcde"));
468     test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890bcde"));
469     test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 0, S("bcde"));
470     test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 1, S("1bcde"));
471     test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 5, S("12345bcde"));
472     test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 9, S("123456789bcde"));
473     test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890bcde"));
474     test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890bcde"));
475     test(S("abcde"), 0, 1, S("12345678901234567890"), 19, 0, S("bcde"));
476     test(S("abcde"), 0, 1, S("12345678901234567890"), 19, 1, S("0bcde"));
477     test(S("abcde"), 0, 1, S("12345678901234567890"), 19, 2, S("0bcde"));
478     test(S("abcde"), 0, 1, S("12345678901234567890"), 20, 0, S("bcde"));
479     test(S("abcde"), 0, 1, S("12345678901234567890"), 20, 1, S("bcde"));
480     test(S("abcde"), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
481     test(S("abcde"), 0, 2, S(""), 0, 0, S("cde"));
482     test(S("abcde"), 0, 2, S(""), 0, 1, S("cde"));
483     test(S("abcde"), 0, 2, S(""), 1, 0, S("can't happen"));
484     test(S("abcde"), 0, 2, S("12345"), 0, 0, S("cde"));
485     test(S("abcde"), 0, 2, S("12345"), 0, 1, S("1cde"));
486     test(S("abcde"), 0, 2, S("12345"), 0, 2, S("12cde"));
487     test(S("abcde"), 0, 2, S("12345"), 0, 4, S("1234cde"));
488     test(S("abcde"), 0, 2, S("12345"), 0, 5, S("12345cde"));
489     test(S("abcde"), 0, 2, S("12345"), 0, 6, S("12345cde"));
490     test(S("abcde"), 0, 2, S("12345"), 1, 0, S("cde"));
491     test(S("abcde"), 0, 2, S("12345"), 1, 1, S("2cde"));
492     test(S("abcde"), 0, 2, S("12345"), 1, 2, S("23cde"));
493     test(S("abcde"), 0, 2, S("12345"), 1, 3, S("234cde"));
494     test(S("abcde"), 0, 2, S("12345"), 1, 4, S("2345cde"));
495     test(S("abcde"), 0, 2, S("12345"), 1, 5, S("2345cde"));
496     test(S("abcde"), 0, 2, S("12345"), 2, 0, S("cde"));
497     test(S("abcde"), 0, 2, S("12345"), 2, 1, S("3cde"));
498     test(S("abcde"), 0, 2, S("12345"), 2, 2, S("34cde"));
499     test(S("abcde"), 0, 2, S("12345"), 2, 3, S("345cde"));
500     test(S("abcde"), 0, 2, S("12345"), 2, 4, S("345cde"));
501     test(S("abcde"), 0, 2, S("12345"), 4, 0, S("cde"));
502     test(S("abcde"), 0, 2, S("12345"), 4, 1, S("5cde"));
503     test(S("abcde"), 0, 2, S("12345"), 4, 2, S("5cde"));
504     test(S("abcde"), 0, 2, S("12345"), 5, 0, S("cde"));
505     test(S("abcde"), 0, 2, S("12345"), 5, 1, S("cde"));
506     test(S("abcde"), 0, 2, S("12345"), 6, 0, S("can't happen"));
507     test(S("abcde"), 0, 2, S("1234567890"), 0, 0, S("cde"));
508     test(S("abcde"), 0, 2, S("1234567890"), 0, 1, S("1cde"));
509     test(S("abcde"), 0, 2, S("1234567890"), 0, 5, S("12345cde"));
510     test(S("abcde"), 0, 2, S("1234567890"), 0, 9, S("123456789cde"));
511 }
512 
513 template <class S>
514 void test4()
515 {
516     test(S("abcde"), 0, 2, S("1234567890"), 0, 10, S("1234567890cde"));
517     test(S("abcde"), 0, 2, S("1234567890"), 0, 11, S("1234567890cde"));
518     test(S("abcde"), 0, 2, S("1234567890"), 1, 0, S("cde"));
519     test(S("abcde"), 0, 2, S("1234567890"), 1, 1, S("2cde"));
520     test(S("abcde"), 0, 2, S("1234567890"), 1, 4, S("2345cde"));
521     test(S("abcde"), 0, 2, S("1234567890"), 1, 8, S("23456789cde"));
522     test(S("abcde"), 0, 2, S("1234567890"), 1, 9, S("234567890cde"));
523     test(S("abcde"), 0, 2, S("1234567890"), 1, 10, S("234567890cde"));
524     test(S("abcde"), 0, 2, S("1234567890"), 5, 0, S("cde"));
525     test(S("abcde"), 0, 2, S("1234567890"), 5, 1, S("6cde"));
526     test(S("abcde"), 0, 2, S("1234567890"), 5, 2, S("67cde"));
527     test(S("abcde"), 0, 2, S("1234567890"), 5, 4, S("6789cde"));
528     test(S("abcde"), 0, 2, S("1234567890"), 5, 5, S("67890cde"));
529     test(S("abcde"), 0, 2, S("1234567890"), 5, 6, S("67890cde"));
530     test(S("abcde"), 0, 2, S("1234567890"), 9, 0, S("cde"));
531     test(S("abcde"), 0, 2, S("1234567890"), 9, 1, S("0cde"));
532     test(S("abcde"), 0, 2, S("1234567890"), 9, 2, S("0cde"));
533     test(S("abcde"), 0, 2, S("1234567890"), 10, 0, S("cde"));
534     test(S("abcde"), 0, 2, S("1234567890"), 10, 1, S("cde"));
535     test(S("abcde"), 0, 2, S("1234567890"), 11, 0, S("can't happen"));
536     test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 0, S("cde"));
537     test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 1, S("1cde"));
538     test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 10, S("1234567890cde"));
539     test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 19, S("1234567890123456789cde"));
540     test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 20, S("12345678901234567890cde"));
541     test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 21, S("12345678901234567890cde"));
542     test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 0, S("cde"));
543     test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 1, S("2cde"));
544     test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 9, S("234567890cde"));
545     test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 18, S("234567890123456789cde"));
546     test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 19, S("2345678901234567890cde"));
547     test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 20, S("2345678901234567890cde"));
548     test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 0, S("cde"));
549     test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 1, S("1cde"));
550     test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 5, S("12345cde"));
551     test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 9, S("123456789cde"));
552     test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 10, S("1234567890cde"));
553     test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 11, S("1234567890cde"));
554     test(S("abcde"), 0, 2, S("12345678901234567890"), 19, 0, S("cde"));
555     test(S("abcde"), 0, 2, S("12345678901234567890"), 19, 1, S("0cde"));
556     test(S("abcde"), 0, 2, S("12345678901234567890"), 19, 2, S("0cde"));
557     test(S("abcde"), 0, 2, S("12345678901234567890"), 20, 0, S("cde"));
558     test(S("abcde"), 0, 2, S("12345678901234567890"), 20, 1, S("cde"));
559     test(S("abcde"), 0, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
560     test(S("abcde"), 0, 4, S(""), 0, 0, S("e"));
561     test(S("abcde"), 0, 4, S(""), 0, 1, S("e"));
562     test(S("abcde"), 0, 4, S(""), 1, 0, S("can't happen"));
563     test(S("abcde"), 0, 4, S("12345"), 0, 0, S("e"));
564     test(S("abcde"), 0, 4, S("12345"), 0, 1, S("1e"));
565     test(S("abcde"), 0, 4, S("12345"), 0, 2, S("12e"));
566     test(S("abcde"), 0, 4, S("12345"), 0, 4, S("1234e"));
567     test(S("abcde"), 0, 4, S("12345"), 0, 5, S("12345e"));
568     test(S("abcde"), 0, 4, S("12345"), 0, 6, S("12345e"));
569     test(S("abcde"), 0, 4, S("12345"), 1, 0, S("e"));
570     test(S("abcde"), 0, 4, S("12345"), 1, 1, S("2e"));
571     test(S("abcde"), 0, 4, S("12345"), 1, 2, S("23e"));
572     test(S("abcde"), 0, 4, S("12345"), 1, 3, S("234e"));
573     test(S("abcde"), 0, 4, S("12345"), 1, 4, S("2345e"));
574     test(S("abcde"), 0, 4, S("12345"), 1, 5, S("2345e"));
575     test(S("abcde"), 0, 4, S("12345"), 2, 0, S("e"));
576     test(S("abcde"), 0, 4, S("12345"), 2, 1, S("3e"));
577     test(S("abcde"), 0, 4, S("12345"), 2, 2, S("34e"));
578     test(S("abcde"), 0, 4, S("12345"), 2, 3, S("345e"));
579     test(S("abcde"), 0, 4, S("12345"), 2, 4, S("345e"));
580     test(S("abcde"), 0, 4, S("12345"), 4, 0, S("e"));
581     test(S("abcde"), 0, 4, S("12345"), 4, 1, S("5e"));
582     test(S("abcde"), 0, 4, S("12345"), 4, 2, S("5e"));
583     test(S("abcde"), 0, 4, S("12345"), 5, 0, S("e"));
584     test(S("abcde"), 0, 4, S("12345"), 5, 1, S("e"));
585     test(S("abcde"), 0, 4, S("12345"), 6, 0, S("can't happen"));
586     test(S("abcde"), 0, 4, S("1234567890"), 0, 0, S("e"));
587     test(S("abcde"), 0, 4, S("1234567890"), 0, 1, S("1e"));
588     test(S("abcde"), 0, 4, S("1234567890"), 0, 5, S("12345e"));
589     test(S("abcde"), 0, 4, S("1234567890"), 0, 9, S("123456789e"));
590     test(S("abcde"), 0, 4, S("1234567890"), 0, 10, S("1234567890e"));
591     test(S("abcde"), 0, 4, S("1234567890"), 0, 11, S("1234567890e"));
592     test(S("abcde"), 0, 4, S("1234567890"), 1, 0, S("e"));
593     test(S("abcde"), 0, 4, S("1234567890"), 1, 1, S("2e"));
594     test(S("abcde"), 0, 4, S("1234567890"), 1, 4, S("2345e"));
595     test(S("abcde"), 0, 4, S("1234567890"), 1, 8, S("23456789e"));
596     test(S("abcde"), 0, 4, S("1234567890"), 1, 9, S("234567890e"));
597     test(S("abcde"), 0, 4, S("1234567890"), 1, 10, S("234567890e"));
598     test(S("abcde"), 0, 4, S("1234567890"), 5, 0, S("e"));
599     test(S("abcde"), 0, 4, S("1234567890"), 5, 1, S("6e"));
600     test(S("abcde"), 0, 4, S("1234567890"), 5, 2, S("67e"));
601     test(S("abcde"), 0, 4, S("1234567890"), 5, 4, S("6789e"));
602     test(S("abcde"), 0, 4, S("1234567890"), 5, 5, S("67890e"));
603     test(S("abcde"), 0, 4, S("1234567890"), 5, 6, S("67890e"));
604     test(S("abcde"), 0, 4, S("1234567890"), 9, 0, S("e"));
605     test(S("abcde"), 0, 4, S("1234567890"), 9, 1, S("0e"));
606     test(S("abcde"), 0, 4, S("1234567890"), 9, 2, S("0e"));
607     test(S("abcde"), 0, 4, S("1234567890"), 10, 0, S("e"));
608     test(S("abcde"), 0, 4, S("1234567890"), 10, 1, S("e"));
609     test(S("abcde"), 0, 4, S("1234567890"), 11, 0, S("can't happen"));
610     test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 0, S("e"));
611     test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 1, S("1e"));
612     test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 10, S("1234567890e"));
613     test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 19, S("1234567890123456789e"));
614     test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 20, S("12345678901234567890e"));
615     test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 21, S("12345678901234567890e"));
616 }
617 
618 template <class S>
619 void test5()
620 {
621     test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 0, S("e"));
622     test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 1, S("2e"));
623     test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 9, S("234567890e"));
624     test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 18, S("234567890123456789e"));
625     test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 19, S("2345678901234567890e"));
626     test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 20, S("2345678901234567890e"));
627     test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 0, S("e"));
628     test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 1, S("1e"));
629     test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 5, S("12345e"));
630     test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 9, S("123456789e"));
631     test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 10, S("1234567890e"));
632     test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 11, S("1234567890e"));
633     test(S("abcde"), 0, 4, S("12345678901234567890"), 19, 0, S("e"));
634     test(S("abcde"), 0, 4, S("12345678901234567890"), 19, 1, S("0e"));
635     test(S("abcde"), 0, 4, S("12345678901234567890"), 19, 2, S("0e"));
636     test(S("abcde"), 0, 4, S("12345678901234567890"), 20, 0, S("e"));
637     test(S("abcde"), 0, 4, S("12345678901234567890"), 20, 1, S("e"));
638     test(S("abcde"), 0, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
639     test(S("abcde"), 0, 5, S(""), 0, 0, S(""));
640     test(S("abcde"), 0, 5, S(""), 0, 1, S(""));
641     test(S("abcde"), 0, 5, S(""), 1, 0, S("can't happen"));
642     test(S("abcde"), 0, 5, S("12345"), 0, 0, S(""));
643     test(S("abcde"), 0, 5, S("12345"), 0, 1, S("1"));
644     test(S("abcde"), 0, 5, S("12345"), 0, 2, S("12"));
645     test(S("abcde"), 0, 5, S("12345"), 0, 4, S("1234"));
646     test(S("abcde"), 0, 5, S("12345"), 0, 5, S("12345"));
647     test(S("abcde"), 0, 5, S("12345"), 0, 6, S("12345"));
648     test(S("abcde"), 0, 5, S("12345"), 1, 0, S(""));
649     test(S("abcde"), 0, 5, S("12345"), 1, 1, S("2"));
650     test(S("abcde"), 0, 5, S("12345"), 1, 2, S("23"));
651     test(S("abcde"), 0, 5, S("12345"), 1, 3, S("234"));
652     test(S("abcde"), 0, 5, S("12345"), 1, 4, S("2345"));
653     test(S("abcde"), 0, 5, S("12345"), 1, 5, S("2345"));
654     test(S("abcde"), 0, 5, S("12345"), 2, 0, S(""));
655     test(S("abcde"), 0, 5, S("12345"), 2, 1, S("3"));
656     test(S("abcde"), 0, 5, S("12345"), 2, 2, S("34"));
657     test(S("abcde"), 0, 5, S("12345"), 2, 3, S("345"));
658     test(S("abcde"), 0, 5, S("12345"), 2, 4, S("345"));
659     test(S("abcde"), 0, 5, S("12345"), 4, 0, S(""));
660     test(S("abcde"), 0, 5, S("12345"), 4, 1, S("5"));
661     test(S("abcde"), 0, 5, S("12345"), 4, 2, S("5"));
662     test(S("abcde"), 0, 5, S("12345"), 5, 0, S(""));
663     test(S("abcde"), 0, 5, S("12345"), 5, 1, S(""));
664     test(S("abcde"), 0, 5, S("12345"), 6, 0, S("can't happen"));
665     test(S("abcde"), 0, 5, S("1234567890"), 0, 0, S(""));
666     test(S("abcde"), 0, 5, S("1234567890"), 0, 1, S("1"));
667     test(S("abcde"), 0, 5, S("1234567890"), 0, 5, S("12345"));
668     test(S("abcde"), 0, 5, S("1234567890"), 0, 9, S("123456789"));
669     test(S("abcde"), 0, 5, S("1234567890"), 0, 10, S("1234567890"));
670     test(S("abcde"), 0, 5, S("1234567890"), 0, 11, S("1234567890"));
671     test(S("abcde"), 0, 5, S("1234567890"), 1, 0, S(""));
672     test(S("abcde"), 0, 5, S("1234567890"), 1, 1, S("2"));
673     test(S("abcde"), 0, 5, S("1234567890"), 1, 4, S("2345"));
674     test(S("abcde"), 0, 5, S("1234567890"), 1, 8, S("23456789"));
675     test(S("abcde"), 0, 5, S("1234567890"), 1, 9, S("234567890"));
676     test(S("abcde"), 0, 5, S("1234567890"), 1, 10, S("234567890"));
677     test(S("abcde"), 0, 5, S("1234567890"), 5, 0, S(""));
678     test(S("abcde"), 0, 5, S("1234567890"), 5, 1, S("6"));
679     test(S("abcde"), 0, 5, S("1234567890"), 5, 2, S("67"));
680     test(S("abcde"), 0, 5, S("1234567890"), 5, 4, S("6789"));
681     test(S("abcde"), 0, 5, S("1234567890"), 5, 5, S("67890"));
682     test(S("abcde"), 0, 5, S("1234567890"), 5, 6, S("67890"));
683     test(S("abcde"), 0, 5, S("1234567890"), 9, 0, S(""));
684     test(S("abcde"), 0, 5, S("1234567890"), 9, 1, S("0"));
685     test(S("abcde"), 0, 5, S("1234567890"), 9, 2, S("0"));
686     test(S("abcde"), 0, 5, S("1234567890"), 10, 0, S(""));
687     test(S("abcde"), 0, 5, S("1234567890"), 10, 1, S(""));
688     test(S("abcde"), 0, 5, S("1234567890"), 11, 0, S("can't happen"));
689     test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 0, S(""));
690     test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 1, S("1"));
691     test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 10, S("1234567890"));
692     test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
693     test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
694     test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
695     test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 0, S(""));
696     test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 1, S("2"));
697     test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 9, S("234567890"));
698     test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 18, S("234567890123456789"));
699     test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
700     test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
701     test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 0, S(""));
702     test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 1, S("1"));
703     test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 5, S("12345"));
704     test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 9, S("123456789"));
705     test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 10, S("1234567890"));
706     test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 11, S("1234567890"));
707     test(S("abcde"), 0, 5, S("12345678901234567890"), 19, 0, S(""));
708     test(S("abcde"), 0, 5, S("12345678901234567890"), 19, 1, S("0"));
709     test(S("abcde"), 0, 5, S("12345678901234567890"), 19, 2, S("0"));
710     test(S("abcde"), 0, 5, S("12345678901234567890"), 20, 0, S(""));
711     test(S("abcde"), 0, 5, S("12345678901234567890"), 20, 1, S(""));
712     test(S("abcde"), 0, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
713     test(S("abcde"), 0, 6, S(""), 0, 0, S(""));
714     test(S("abcde"), 0, 6, S(""), 0, 1, S(""));
715     test(S("abcde"), 0, 6, S(""), 1, 0, S("can't happen"));
716     test(S("abcde"), 0, 6, S("12345"), 0, 0, S(""));
717     test(S("abcde"), 0, 6, S("12345"), 0, 1, S("1"));
718     test(S("abcde"), 0, 6, S("12345"), 0, 2, S("12"));
719     test(S("abcde"), 0, 6, S("12345"), 0, 4, S("1234"));
720     test(S("abcde"), 0, 6, S("12345"), 0, 5, S("12345"));
721 }
722 
723 template <class S>
724 void test6()
725 {
726     test(S("abcde"), 0, 6, S("12345"), 0, 6, S("12345"));
727     test(S("abcde"), 0, 6, S("12345"), 1, 0, S(""));
728     test(S("abcde"), 0, 6, S("12345"), 1, 1, S("2"));
729     test(S("abcde"), 0, 6, S("12345"), 1, 2, S("23"));
730     test(S("abcde"), 0, 6, S("12345"), 1, 3, S("234"));
731     test(S("abcde"), 0, 6, S("12345"), 1, 4, S("2345"));
732     test(S("abcde"), 0, 6, S("12345"), 1, 5, S("2345"));
733     test(S("abcde"), 0, 6, S("12345"), 2, 0, S(""));
734     test(S("abcde"), 0, 6, S("12345"), 2, 1, S("3"));
735     test(S("abcde"), 0, 6, S("12345"), 2, 2, S("34"));
736     test(S("abcde"), 0, 6, S("12345"), 2, 3, S("345"));
737     test(S("abcde"), 0, 6, S("12345"), 2, 4, S("345"));
738     test(S("abcde"), 0, 6, S("12345"), 4, 0, S(""));
739     test(S("abcde"), 0, 6, S("12345"), 4, 1, S("5"));
740     test(S("abcde"), 0, 6, S("12345"), 4, 2, S("5"));
741     test(S("abcde"), 0, 6, S("12345"), 5, 0, S(""));
742     test(S("abcde"), 0, 6, S("12345"), 5, 1, S(""));
743     test(S("abcde"), 0, 6, S("12345"), 6, 0, S("can't happen"));
744     test(S("abcde"), 0, 6, S("1234567890"), 0, 0, S(""));
745     test(S("abcde"), 0, 6, S("1234567890"), 0, 1, S("1"));
746     test(S("abcde"), 0, 6, S("1234567890"), 0, 5, S("12345"));
747     test(S("abcde"), 0, 6, S("1234567890"), 0, 9, S("123456789"));
748     test(S("abcde"), 0, 6, S("1234567890"), 0, 10, S("1234567890"));
749     test(S("abcde"), 0, 6, S("1234567890"), 0, 11, S("1234567890"));
750     test(S("abcde"), 0, 6, S("1234567890"), 1, 0, S(""));
751     test(S("abcde"), 0, 6, S("1234567890"), 1, 1, S("2"));
752     test(S("abcde"), 0, 6, S("1234567890"), 1, 4, S("2345"));
753     test(S("abcde"), 0, 6, S("1234567890"), 1, 8, S("23456789"));
754     test(S("abcde"), 0, 6, S("1234567890"), 1, 9, S("234567890"));
755     test(S("abcde"), 0, 6, S("1234567890"), 1, 10, S("234567890"));
756     test(S("abcde"), 0, 6, S("1234567890"), 5, 0, S(""));
757     test(S("abcde"), 0, 6, S("1234567890"), 5, 1, S("6"));
758     test(S("abcde"), 0, 6, S("1234567890"), 5, 2, S("67"));
759     test(S("abcde"), 0, 6, S("1234567890"), 5, 4, S("6789"));
760     test(S("abcde"), 0, 6, S("1234567890"), 5, 5, S("67890"));
761     test(S("abcde"), 0, 6, S("1234567890"), 5, 6, S("67890"));
762     test(S("abcde"), 0, 6, S("1234567890"), 9, 0, S(""));
763     test(S("abcde"), 0, 6, S("1234567890"), 9, 1, S("0"));
764     test(S("abcde"), 0, 6, S("1234567890"), 9, 2, S("0"));
765     test(S("abcde"), 0, 6, S("1234567890"), 10, 0, S(""));
766     test(S("abcde"), 0, 6, S("1234567890"), 10, 1, S(""));
767     test(S("abcde"), 0, 6, S("1234567890"), 11, 0, S("can't happen"));
768     test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 0, S(""));
769     test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 1, S("1"));
770     test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 10, S("1234567890"));
771     test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
772     test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
773     test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
774     test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 0, S(""));
775     test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 1, S("2"));
776     test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 9, S("234567890"));
777     test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 18, S("234567890123456789"));
778     test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
779     test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
780     test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 0, S(""));
781     test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 1, S("1"));
782     test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 5, S("12345"));
783     test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 9, S("123456789"));
784     test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 10, S("1234567890"));
785     test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 11, S("1234567890"));
786     test(S("abcde"), 0, 6, S("12345678901234567890"), 19, 0, S(""));
787     test(S("abcde"), 0, 6, S("12345678901234567890"), 19, 1, S("0"));
788     test(S("abcde"), 0, 6, S("12345678901234567890"), 19, 2, S("0"));
789     test(S("abcde"), 0, 6, S("12345678901234567890"), 20, 0, S(""));
790     test(S("abcde"), 0, 6, S("12345678901234567890"), 20, 1, S(""));
791     test(S("abcde"), 0, 6, S("12345678901234567890"), 21, 0, S("can't happen"));
792     test(S("abcde"), 1, 0, S(""), 0, 0, S("abcde"));
793     test(S("abcde"), 1, 0, S(""), 0, 1, S("abcde"));
794     test(S("abcde"), 1, 0, S(""), 1, 0, S("can't happen"));
795     test(S("abcde"), 1, 0, S("12345"), 0, 0, S("abcde"));
796     test(S("abcde"), 1, 0, S("12345"), 0, 1, S("a1bcde"));
797     test(S("abcde"), 1, 0, S("12345"), 0, 2, S("a12bcde"));
798     test(S("abcde"), 1, 0, S("12345"), 0, 4, S("a1234bcde"));
799     test(S("abcde"), 1, 0, S("12345"), 0, 5, S("a12345bcde"));
800     test(S("abcde"), 1, 0, S("12345"), 0, 6, S("a12345bcde"));
801     test(S("abcde"), 1, 0, S("12345"), 1, 0, S("abcde"));
802     test(S("abcde"), 1, 0, S("12345"), 1, 1, S("a2bcde"));
803     test(S("abcde"), 1, 0, S("12345"), 1, 2, S("a23bcde"));
804     test(S("abcde"), 1, 0, S("12345"), 1, 3, S("a234bcde"));
805     test(S("abcde"), 1, 0, S("12345"), 1, 4, S("a2345bcde"));
806     test(S("abcde"), 1, 0, S("12345"), 1, 5, S("a2345bcde"));
807     test(S("abcde"), 1, 0, S("12345"), 2, 0, S("abcde"));
808     test(S("abcde"), 1, 0, S("12345"), 2, 1, S("a3bcde"));
809     test(S("abcde"), 1, 0, S("12345"), 2, 2, S("a34bcde"));
810     test(S("abcde"), 1, 0, S("12345"), 2, 3, S("a345bcde"));
811     test(S("abcde"), 1, 0, S("12345"), 2, 4, S("a345bcde"));
812     test(S("abcde"), 1, 0, S("12345"), 4, 0, S("abcde"));
813     test(S("abcde"), 1, 0, S("12345"), 4, 1, S("a5bcde"));
814     test(S("abcde"), 1, 0, S("12345"), 4, 2, S("a5bcde"));
815     test(S("abcde"), 1, 0, S("12345"), 5, 0, S("abcde"));
816     test(S("abcde"), 1, 0, S("12345"), 5, 1, S("abcde"));
817     test(S("abcde"), 1, 0, S("12345"), 6, 0, S("can't happen"));
818     test(S("abcde"), 1, 0, S("1234567890"), 0, 0, S("abcde"));
819     test(S("abcde"), 1, 0, S("1234567890"), 0, 1, S("a1bcde"));
820     test(S("abcde"), 1, 0, S("1234567890"), 0, 5, S("a12345bcde"));
821     test(S("abcde"), 1, 0, S("1234567890"), 0, 9, S("a123456789bcde"));
822     test(S("abcde"), 1, 0, S("1234567890"), 0, 10, S("a1234567890bcde"));
823     test(S("abcde"), 1, 0, S("1234567890"), 0, 11, S("a1234567890bcde"));
824     test(S("abcde"), 1, 0, S("1234567890"), 1, 0, S("abcde"));
825     test(S("abcde"), 1, 0, S("1234567890"), 1, 1, S("a2bcde"));
826 }
827 
828 template <class S>
829 void test7()
830 {
831     test(S("abcde"), 1, 0, S("1234567890"), 1, 4, S("a2345bcde"));
832     test(S("abcde"), 1, 0, S("1234567890"), 1, 8, S("a23456789bcde"));
833     test(S("abcde"), 1, 0, S("1234567890"), 1, 9, S("a234567890bcde"));
834     test(S("abcde"), 1, 0, S("1234567890"), 1, 10, S("a234567890bcde"));
835     test(S("abcde"), 1, 0, S("1234567890"), 5, 0, S("abcde"));
836     test(S("abcde"), 1, 0, S("1234567890"), 5, 1, S("a6bcde"));
837     test(S("abcde"), 1, 0, S("1234567890"), 5, 2, S("a67bcde"));
838     test(S("abcde"), 1, 0, S("1234567890"), 5, 4, S("a6789bcde"));
839     test(S("abcde"), 1, 0, S("1234567890"), 5, 5, S("a67890bcde"));
840     test(S("abcde"), 1, 0, S("1234567890"), 5, 6, S("a67890bcde"));
841     test(S("abcde"), 1, 0, S("1234567890"), 9, 0, S("abcde"));
842     test(S("abcde"), 1, 0, S("1234567890"), 9, 1, S("a0bcde"));
843     test(S("abcde"), 1, 0, S("1234567890"), 9, 2, S("a0bcde"));
844     test(S("abcde"), 1, 0, S("1234567890"), 10, 0, S("abcde"));
845     test(S("abcde"), 1, 0, S("1234567890"), 10, 1, S("abcde"));
846     test(S("abcde"), 1, 0, S("1234567890"), 11, 0, S("can't happen"));
847     test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 0, S("abcde"));
848     test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 1, S("a1bcde"));
849     test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 10, S("a1234567890bcde"));
850     test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcde"));
851     test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcde"));
852     test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcde"));
853     test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 0, S("abcde"));
854     test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 1, S("a2bcde"));
855     test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 9, S("a234567890bcde"));
856     test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 18, S("a234567890123456789bcde"));
857     test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcde"));
858     test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcde"));
859     test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 0, S("abcde"));
860     test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 1, S("a1bcde"));
861     test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 5, S("a12345bcde"));
862     test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 9, S("a123456789bcde"));
863     test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 10, S("a1234567890bcde"));
864     test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 11, S("a1234567890bcde"));
865     test(S("abcde"), 1, 0, S("12345678901234567890"), 19, 0, S("abcde"));
866     test(S("abcde"), 1, 0, S("12345678901234567890"), 19, 1, S("a0bcde"));
867     test(S("abcde"), 1, 0, S("12345678901234567890"), 19, 2, S("a0bcde"));
868     test(S("abcde"), 1, 0, S("12345678901234567890"), 20, 0, S("abcde"));
869     test(S("abcde"), 1, 0, S("12345678901234567890"), 20, 1, S("abcde"));
870     test(S("abcde"), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
871     test(S("abcde"), 1, 1, S(""), 0, 0, S("acde"));
872     test(S("abcde"), 1, 1, S(""), 0, 1, S("acde"));
873     test(S("abcde"), 1, 1, S(""), 1, 0, S("can't happen"));
874     test(S("abcde"), 1, 1, S("12345"), 0, 0, S("acde"));
875     test(S("abcde"), 1, 1, S("12345"), 0, 1, S("a1cde"));
876     test(S("abcde"), 1, 1, S("12345"), 0, 2, S("a12cde"));
877     test(S("abcde"), 1, 1, S("12345"), 0, 4, S("a1234cde"));
878     test(S("abcde"), 1, 1, S("12345"), 0, 5, S("a12345cde"));
879     test(S("abcde"), 1, 1, S("12345"), 0, 6, S("a12345cde"));
880     test(S("abcde"), 1, 1, S("12345"), 1, 0, S("acde"));
881     test(S("abcde"), 1, 1, S("12345"), 1, 1, S("a2cde"));
882     test(S("abcde"), 1, 1, S("12345"), 1, 2, S("a23cde"));
883     test(S("abcde"), 1, 1, S("12345"), 1, 3, S("a234cde"));
884     test(S("abcde"), 1, 1, S("12345"), 1, 4, S("a2345cde"));
885     test(S("abcde"), 1, 1, S("12345"), 1, 5, S("a2345cde"));
886     test(S("abcde"), 1, 1, S("12345"), 2, 0, S("acde"));
887     test(S("abcde"), 1, 1, S("12345"), 2, 1, S("a3cde"));
888     test(S("abcde"), 1, 1, S("12345"), 2, 2, S("a34cde"));
889     test(S("abcde"), 1, 1, S("12345"), 2, 3, S("a345cde"));
890     test(S("abcde"), 1, 1, S("12345"), 2, 4, S("a345cde"));
891     test(S("abcde"), 1, 1, S("12345"), 4, 0, S("acde"));
892     test(S("abcde"), 1, 1, S("12345"), 4, 1, S("a5cde"));
893     test(S("abcde"), 1, 1, S("12345"), 4, 2, S("a5cde"));
894     test(S("abcde"), 1, 1, S("12345"), 5, 0, S("acde"));
895     test(S("abcde"), 1, 1, S("12345"), 5, 1, S("acde"));
896     test(S("abcde"), 1, 1, S("12345"), 6, 0, S("can't happen"));
897     test(S("abcde"), 1, 1, S("1234567890"), 0, 0, S("acde"));
898     test(S("abcde"), 1, 1, S("1234567890"), 0, 1, S("a1cde"));
899     test(S("abcde"), 1, 1, S("1234567890"), 0, 5, S("a12345cde"));
900     test(S("abcde"), 1, 1, S("1234567890"), 0, 9, S("a123456789cde"));
901     test(S("abcde"), 1, 1, S("1234567890"), 0, 10, S("a1234567890cde"));
902     test(S("abcde"), 1, 1, S("1234567890"), 0, 11, S("a1234567890cde"));
903     test(S("abcde"), 1, 1, S("1234567890"), 1, 0, S("acde"));
904     test(S("abcde"), 1, 1, S("1234567890"), 1, 1, S("a2cde"));
905     test(S("abcde"), 1, 1, S("1234567890"), 1, 4, S("a2345cde"));
906     test(S("abcde"), 1, 1, S("1234567890"), 1, 8, S("a23456789cde"));
907     test(S("abcde"), 1, 1, S("1234567890"), 1, 9, S("a234567890cde"));
908     test(S("abcde"), 1, 1, S("1234567890"), 1, 10, S("a234567890cde"));
909     test(S("abcde"), 1, 1, S("1234567890"), 5, 0, S("acde"));
910     test(S("abcde"), 1, 1, S("1234567890"), 5, 1, S("a6cde"));
911     test(S("abcde"), 1, 1, S("1234567890"), 5, 2, S("a67cde"));
912     test(S("abcde"), 1, 1, S("1234567890"), 5, 4, S("a6789cde"));
913     test(S("abcde"), 1, 1, S("1234567890"), 5, 5, S("a67890cde"));
914     test(S("abcde"), 1, 1, S("1234567890"), 5, 6, S("a67890cde"));
915     test(S("abcde"), 1, 1, S("1234567890"), 9, 0, S("acde"));
916     test(S("abcde"), 1, 1, S("1234567890"), 9, 1, S("a0cde"));
917     test(S("abcde"), 1, 1, S("1234567890"), 9, 2, S("a0cde"));
918     test(S("abcde"), 1, 1, S("1234567890"), 10, 0, S("acde"));
919     test(S("abcde"), 1, 1, S("1234567890"), 10, 1, S("acde"));
920     test(S("abcde"), 1, 1, S("1234567890"), 11, 0, S("can't happen"));
921     test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 0, S("acde"));
922     test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 1, S("a1cde"));
923     test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 10, S("a1234567890cde"));
924     test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789cde"));
925     test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890cde"));
926     test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890cde"));
927     test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 0, S("acde"));
928     test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 1, S("a2cde"));
929     test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 9, S("a234567890cde"));
930     test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 18, S("a234567890123456789cde"));
931 }
932 
933 template <class S>
934 void test8()
935 {
936     test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890cde"));
937     test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890cde"));
938     test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 0, S("acde"));
939     test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 1, S("a1cde"));
940     test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 5, S("a12345cde"));
941     test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 9, S("a123456789cde"));
942     test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 10, S("a1234567890cde"));
943     test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 11, S("a1234567890cde"));
944     test(S("abcde"), 1, 1, S("12345678901234567890"), 19, 0, S("acde"));
945     test(S("abcde"), 1, 1, S("12345678901234567890"), 19, 1, S("a0cde"));
946     test(S("abcde"), 1, 1, S("12345678901234567890"), 19, 2, S("a0cde"));
947     test(S("abcde"), 1, 1, S("12345678901234567890"), 20, 0, S("acde"));
948     test(S("abcde"), 1, 1, S("12345678901234567890"), 20, 1, S("acde"));
949     test(S("abcde"), 1, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
950     test(S("abcde"), 1, 2, S(""), 0, 0, S("ade"));
951     test(S("abcde"), 1, 2, S(""), 0, 1, S("ade"));
952     test(S("abcde"), 1, 2, S(""), 1, 0, S("can't happen"));
953     test(S("abcde"), 1, 2, S("12345"), 0, 0, S("ade"));
954     test(S("abcde"), 1, 2, S("12345"), 0, 1, S("a1de"));
955     test(S("abcde"), 1, 2, S("12345"), 0, 2, S("a12de"));
956     test(S("abcde"), 1, 2, S("12345"), 0, 4, S("a1234de"));
957     test(S("abcde"), 1, 2, S("12345"), 0, 5, S("a12345de"));
958     test(S("abcde"), 1, 2, S("12345"), 0, 6, S("a12345de"));
959     test(S("abcde"), 1, 2, S("12345"), 1, 0, S("ade"));
960     test(S("abcde"), 1, 2, S("12345"), 1, 1, S("a2de"));
961     test(S("abcde"), 1, 2, S("12345"), 1, 2, S("a23de"));
962     test(S("abcde"), 1, 2, S("12345"), 1, 3, S("a234de"));
963     test(S("abcde"), 1, 2, S("12345"), 1, 4, S("a2345de"));
964     test(S("abcde"), 1, 2, S("12345"), 1, 5, S("a2345de"));
965     test(S("abcde"), 1, 2, S("12345"), 2, 0, S("ade"));
966     test(S("abcde"), 1, 2, S("12345"), 2, 1, S("a3de"));
967     test(S("abcde"), 1, 2, S("12345"), 2, 2, S("a34de"));
968     test(S("abcde"), 1, 2, S("12345"), 2, 3, S("a345de"));
969     test(S("abcde"), 1, 2, S("12345"), 2, 4, S("a345de"));
970     test(S("abcde"), 1, 2, S("12345"), 4, 0, S("ade"));
971     test(S("abcde"), 1, 2, S("12345"), 4, 1, S("a5de"));
972     test(S("abcde"), 1, 2, S("12345"), 4, 2, S("a5de"));
973     test(S("abcde"), 1, 2, S("12345"), 5, 0, S("ade"));
974     test(S("abcde"), 1, 2, S("12345"), 5, 1, S("ade"));
975     test(S("abcde"), 1, 2, S("12345"), 6, 0, S("can't happen"));
976     test(S("abcde"), 1, 2, S("1234567890"), 0, 0, S("ade"));
977     test(S("abcde"), 1, 2, S("1234567890"), 0, 1, S("a1de"));
978     test(S("abcde"), 1, 2, S("1234567890"), 0, 5, S("a12345de"));
979     test(S("abcde"), 1, 2, S("1234567890"), 0, 9, S("a123456789de"));
980     test(S("abcde"), 1, 2, S("1234567890"), 0, 10, S("a1234567890de"));
981     test(S("abcde"), 1, 2, S("1234567890"), 0, 11, S("a1234567890de"));
982     test(S("abcde"), 1, 2, S("1234567890"), 1, 0, S("ade"));
983     test(S("abcde"), 1, 2, S("1234567890"), 1, 1, S("a2de"));
984     test(S("abcde"), 1, 2, S("1234567890"), 1, 4, S("a2345de"));
985     test(S("abcde"), 1, 2, S("1234567890"), 1, 8, S("a23456789de"));
986     test(S("abcde"), 1, 2, S("1234567890"), 1, 9, S("a234567890de"));
987     test(S("abcde"), 1, 2, S("1234567890"), 1, 10, S("a234567890de"));
988     test(S("abcde"), 1, 2, S("1234567890"), 5, 0, S("ade"));
989     test(S("abcde"), 1, 2, S("1234567890"), 5, 1, S("a6de"));
990     test(S("abcde"), 1, 2, S("1234567890"), 5, 2, S("a67de"));
991     test(S("abcde"), 1, 2, S("1234567890"), 5, 4, S("a6789de"));
992     test(S("abcde"), 1, 2, S("1234567890"), 5, 5, S("a67890de"));
993     test(S("abcde"), 1, 2, S("1234567890"), 5, 6, S("a67890de"));
994     test(S("abcde"), 1, 2, S("1234567890"), 9, 0, S("ade"));
995     test(S("abcde"), 1, 2, S("1234567890"), 9, 1, S("a0de"));
996     test(S("abcde"), 1, 2, S("1234567890"), 9, 2, S("a0de"));
997     test(S("abcde"), 1, 2, S("1234567890"), 10, 0, S("ade"));
998     test(S("abcde"), 1, 2, S("1234567890"), 10, 1, S("ade"));
999     test(S("abcde"), 1, 2, S("1234567890"), 11, 0, S("can't happen"));
1000     test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 0, S("ade"));
1001     test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 1, S("a1de"));
1002     test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 10, S("a1234567890de"));
1003     test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 19, S("a1234567890123456789de"));
1004     test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 20, S("a12345678901234567890de"));
1005     test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 21, S("a12345678901234567890de"));
1006     test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 0, S("ade"));
1007     test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 1, S("a2de"));
1008     test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 9, S("a234567890de"));
1009     test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 18, S("a234567890123456789de"));
1010     test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 19, S("a2345678901234567890de"));
1011     test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 20, S("a2345678901234567890de"));
1012     test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 0, S("ade"));
1013     test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 1, S("a1de"));
1014     test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 5, S("a12345de"));
1015     test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 9, S("a123456789de"));
1016     test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 10, S("a1234567890de"));
1017     test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 11, S("a1234567890de"));
1018     test(S("abcde"), 1, 2, S("12345678901234567890"), 19, 0, S("ade"));
1019     test(S("abcde"), 1, 2, S("12345678901234567890"), 19, 1, S("a0de"));
1020     test(S("abcde"), 1, 2, S("12345678901234567890"), 19, 2, S("a0de"));
1021     test(S("abcde"), 1, 2, S("12345678901234567890"), 20, 0, S("ade"));
1022     test(S("abcde"), 1, 2, S("12345678901234567890"), 20, 1, S("ade"));
1023     test(S("abcde"), 1, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
1024     test(S("abcde"), 1, 3, S(""), 0, 0, S("ae"));
1025     test(S("abcde"), 1, 3, S(""), 0, 1, S("ae"));
1026     test(S("abcde"), 1, 3, S(""), 1, 0, S("can't happen"));
1027     test(S("abcde"), 1, 3, S("12345"), 0, 0, S("ae"));
1028     test(S("abcde"), 1, 3, S("12345"), 0, 1, S("a1e"));
1029     test(S("abcde"), 1, 3, S("12345"), 0, 2, S("a12e"));
1030     test(S("abcde"), 1, 3, S("12345"), 0, 4, S("a1234e"));
1031     test(S("abcde"), 1, 3, S("12345"), 0, 5, S("a12345e"));
1032     test(S("abcde"), 1, 3, S("12345"), 0, 6, S("a12345e"));
1033     test(S("abcde"), 1, 3, S("12345"), 1, 0, S("ae"));
1034     test(S("abcde"), 1, 3, S("12345"), 1, 1, S("a2e"));
1035     test(S("abcde"), 1, 3, S("12345"), 1, 2, S("a23e"));
1036 }
1037 
1038 template <class S>
1039 void test9()
1040 {
1041     test(S("abcde"), 1, 3, S("12345"), 1, 3, S("a234e"));
1042     test(S("abcde"), 1, 3, S("12345"), 1, 4, S("a2345e"));
1043     test(S("abcde"), 1, 3, S("12345"), 1, 5, S("a2345e"));
1044     test(S("abcde"), 1, 3, S("12345"), 2, 0, S("ae"));
1045     test(S("abcde"), 1, 3, S("12345"), 2, 1, S("a3e"));
1046     test(S("abcde"), 1, 3, S("12345"), 2, 2, S("a34e"));
1047     test(S("abcde"), 1, 3, S("12345"), 2, 3, S("a345e"));
1048     test(S("abcde"), 1, 3, S("12345"), 2, 4, S("a345e"));
1049     test(S("abcde"), 1, 3, S("12345"), 4, 0, S("ae"));
1050     test(S("abcde"), 1, 3, S("12345"), 4, 1, S("a5e"));
1051     test(S("abcde"), 1, 3, S("12345"), 4, 2, S("a5e"));
1052     test(S("abcde"), 1, 3, S("12345"), 5, 0, S("ae"));
1053     test(S("abcde"), 1, 3, S("12345"), 5, 1, S("ae"));
1054     test(S("abcde"), 1, 3, S("12345"), 6, 0, S("can't happen"));
1055     test(S("abcde"), 1, 3, S("1234567890"), 0, 0, S("ae"));
1056     test(S("abcde"), 1, 3, S("1234567890"), 0, 1, S("a1e"));
1057     test(S("abcde"), 1, 3, S("1234567890"), 0, 5, S("a12345e"));
1058     test(S("abcde"), 1, 3, S("1234567890"), 0, 9, S("a123456789e"));
1059     test(S("abcde"), 1, 3, S("1234567890"), 0, 10, S("a1234567890e"));
1060     test(S("abcde"), 1, 3, S("1234567890"), 0, 11, S("a1234567890e"));
1061     test(S("abcde"), 1, 3, S("1234567890"), 1, 0, S("ae"));
1062     test(S("abcde"), 1, 3, S("1234567890"), 1, 1, S("a2e"));
1063     test(S("abcde"), 1, 3, S("1234567890"), 1, 4, S("a2345e"));
1064     test(S("abcde"), 1, 3, S("1234567890"), 1, 8, S("a23456789e"));
1065     test(S("abcde"), 1, 3, S("1234567890"), 1, 9, S("a234567890e"));
1066     test(S("abcde"), 1, 3, S("1234567890"), 1, 10, S("a234567890e"));
1067     test(S("abcde"), 1, 3, S("1234567890"), 5, 0, S("ae"));
1068     test(S("abcde"), 1, 3, S("1234567890"), 5, 1, S("a6e"));
1069     test(S("abcde"), 1, 3, S("1234567890"), 5, 2, S("a67e"));
1070     test(S("abcde"), 1, 3, S("1234567890"), 5, 4, S("a6789e"));
1071     test(S("abcde"), 1, 3, S("1234567890"), 5, 5, S("a67890e"));
1072     test(S("abcde"), 1, 3, S("1234567890"), 5, 6, S("a67890e"));
1073     test(S("abcde"), 1, 3, S("1234567890"), 9, 0, S("ae"));
1074     test(S("abcde"), 1, 3, S("1234567890"), 9, 1, S("a0e"));
1075     test(S("abcde"), 1, 3, S("1234567890"), 9, 2, S("a0e"));
1076     test(S("abcde"), 1, 3, S("1234567890"), 10, 0, S("ae"));
1077     test(S("abcde"), 1, 3, S("1234567890"), 10, 1, S("ae"));
1078     test(S("abcde"), 1, 3, S("1234567890"), 11, 0, S("can't happen"));
1079     test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 0, S("ae"));
1080     test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 1, S("a1e"));
1081     test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 10, S("a1234567890e"));
1082     test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 19, S("a1234567890123456789e"));
1083     test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 20, S("a12345678901234567890e"));
1084     test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 21, S("a12345678901234567890e"));
1085     test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 0, S("ae"));
1086     test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 1, S("a2e"));
1087     test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 9, S("a234567890e"));
1088     test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 18, S("a234567890123456789e"));
1089     test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 19, S("a2345678901234567890e"));
1090     test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 20, S("a2345678901234567890e"));
1091     test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 0, S("ae"));
1092     test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 1, S("a1e"));
1093     test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 5, S("a12345e"));
1094     test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 9, S("a123456789e"));
1095     test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 10, S("a1234567890e"));
1096     test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 11, S("a1234567890e"));
1097     test(S("abcde"), 1, 3, S("12345678901234567890"), 19, 0, S("ae"));
1098     test(S("abcde"), 1, 3, S("12345678901234567890"), 19, 1, S("a0e"));
1099     test(S("abcde"), 1, 3, S("12345678901234567890"), 19, 2, S("a0e"));
1100     test(S("abcde"), 1, 3, S("12345678901234567890"), 20, 0, S("ae"));
1101     test(S("abcde"), 1, 3, S("12345678901234567890"), 20, 1, S("ae"));
1102     test(S("abcde"), 1, 3, S("12345678901234567890"), 21, 0, S("can't happen"));
1103     test(S("abcde"), 1, 4, S(""), 0, 0, S("a"));
1104     test(S("abcde"), 1, 4, S(""), 0, 1, S("a"));
1105     test(S("abcde"), 1, 4, S(""), 1, 0, S("can't happen"));
1106     test(S("abcde"), 1, 4, S("12345"), 0, 0, S("a"));
1107     test(S("abcde"), 1, 4, S("12345"), 0, 1, S("a1"));
1108     test(S("abcde"), 1, 4, S("12345"), 0, 2, S("a12"));
1109     test(S("abcde"), 1, 4, S("12345"), 0, 4, S("a1234"));
1110     test(S("abcde"), 1, 4, S("12345"), 0, 5, S("a12345"));
1111     test(S("abcde"), 1, 4, S("12345"), 0, 6, S("a12345"));
1112     test(S("abcde"), 1, 4, S("12345"), 1, 0, S("a"));
1113     test(S("abcde"), 1, 4, S("12345"), 1, 1, S("a2"));
1114     test(S("abcde"), 1, 4, S("12345"), 1, 2, S("a23"));
1115     test(S("abcde"), 1, 4, S("12345"), 1, 3, S("a234"));
1116     test(S("abcde"), 1, 4, S("12345"), 1, 4, S("a2345"));
1117     test(S("abcde"), 1, 4, S("12345"), 1, 5, S("a2345"));
1118     test(S("abcde"), 1, 4, S("12345"), 2, 0, S("a"));
1119     test(S("abcde"), 1, 4, S("12345"), 2, 1, S("a3"));
1120     test(S("abcde"), 1, 4, S("12345"), 2, 2, S("a34"));
1121     test(S("abcde"), 1, 4, S("12345"), 2, 3, S("a345"));
1122     test(S("abcde"), 1, 4, S("12345"), 2, 4, S("a345"));
1123     test(S("abcde"), 1, 4, S("12345"), 4, 0, S("a"));
1124     test(S("abcde"), 1, 4, S("12345"), 4, 1, S("a5"));
1125     test(S("abcde"), 1, 4, S("12345"), 4, 2, S("a5"));
1126     test(S("abcde"), 1, 4, S("12345"), 5, 0, S("a"));
1127     test(S("abcde"), 1, 4, S("12345"), 5, 1, S("a"));
1128     test(S("abcde"), 1, 4, S("12345"), 6, 0, S("can't happen"));
1129     test(S("abcde"), 1, 4, S("1234567890"), 0, 0, S("a"));
1130     test(S("abcde"), 1, 4, S("1234567890"), 0, 1, S("a1"));
1131     test(S("abcde"), 1, 4, S("1234567890"), 0, 5, S("a12345"));
1132     test(S("abcde"), 1, 4, S("1234567890"), 0, 9, S("a123456789"));
1133     test(S("abcde"), 1, 4, S("1234567890"), 0, 10, S("a1234567890"));
1134     test(S("abcde"), 1, 4, S("1234567890"), 0, 11, S("a1234567890"));
1135     test(S("abcde"), 1, 4, S("1234567890"), 1, 0, S("a"));
1136     test(S("abcde"), 1, 4, S("1234567890"), 1, 1, S("a2"));
1137     test(S("abcde"), 1, 4, S("1234567890"), 1, 4, S("a2345"));
1138     test(S("abcde"), 1, 4, S("1234567890"), 1, 8, S("a23456789"));
1139     test(S("abcde"), 1, 4, S("1234567890"), 1, 9, S("a234567890"));
1140     test(S("abcde"), 1, 4, S("1234567890"), 1, 10, S("a234567890"));
1141 }
1142 
1143 template <class S>
1144 void test10()
1145 {
1146     test(S("abcde"), 1, 4, S("1234567890"), 5, 0, S("a"));
1147     test(S("abcde"), 1, 4, S("1234567890"), 5, 1, S("a6"));
1148     test(S("abcde"), 1, 4, S("1234567890"), 5, 2, S("a67"));
1149     test(S("abcde"), 1, 4, S("1234567890"), 5, 4, S("a6789"));
1150     test(S("abcde"), 1, 4, S("1234567890"), 5, 5, S("a67890"));
1151     test(S("abcde"), 1, 4, S("1234567890"), 5, 6, S("a67890"));
1152     test(S("abcde"), 1, 4, S("1234567890"), 9, 0, S("a"));
1153     test(S("abcde"), 1, 4, S("1234567890"), 9, 1, S("a0"));
1154     test(S("abcde"), 1, 4, S("1234567890"), 9, 2, S("a0"));
1155     test(S("abcde"), 1, 4, S("1234567890"), 10, 0, S("a"));
1156     test(S("abcde"), 1, 4, S("1234567890"), 10, 1, S("a"));
1157     test(S("abcde"), 1, 4, S("1234567890"), 11, 0, S("can't happen"));
1158     test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 0, S("a"));
1159     test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 1, S("a1"));
1160     test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 10, S("a1234567890"));
1161     test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
1162     test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
1163     test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
1164     test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 0, S("a"));
1165     test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 1, S("a2"));
1166     test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 9, S("a234567890"));
1167     test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
1168     test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
1169     test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
1170     test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 0, S("a"));
1171     test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 1, S("a1"));
1172     test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 5, S("a12345"));
1173     test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 9, S("a123456789"));
1174     test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 10, S("a1234567890"));
1175     test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 11, S("a1234567890"));
1176     test(S("abcde"), 1, 4, S("12345678901234567890"), 19, 0, S("a"));
1177     test(S("abcde"), 1, 4, S("12345678901234567890"), 19, 1, S("a0"));
1178     test(S("abcde"), 1, 4, S("12345678901234567890"), 19, 2, S("a0"));
1179     test(S("abcde"), 1, 4, S("12345678901234567890"), 20, 0, S("a"));
1180     test(S("abcde"), 1, 4, S("12345678901234567890"), 20, 1, S("a"));
1181     test(S("abcde"), 1, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
1182     test(S("abcde"), 1, 5, S(""), 0, 0, S("a"));
1183     test(S("abcde"), 1, 5, S(""), 0, 1, S("a"));
1184     test(S("abcde"), 1, 5, S(""), 1, 0, S("can't happen"));
1185     test(S("abcde"), 1, 5, S("12345"), 0, 0, S("a"));
1186     test(S("abcde"), 1, 5, S("12345"), 0, 1, S("a1"));
1187     test(S("abcde"), 1, 5, S("12345"), 0, 2, S("a12"));
1188     test(S("abcde"), 1, 5, S("12345"), 0, 4, S("a1234"));
1189     test(S("abcde"), 1, 5, S("12345"), 0, 5, S("a12345"));
1190     test(S("abcde"), 1, 5, S("12345"), 0, 6, S("a12345"));
1191     test(S("abcde"), 1, 5, S("12345"), 1, 0, S("a"));
1192     test(S("abcde"), 1, 5, S("12345"), 1, 1, S("a2"));
1193     test(S("abcde"), 1, 5, S("12345"), 1, 2, S("a23"));
1194     test(S("abcde"), 1, 5, S("12345"), 1, 3, S("a234"));
1195     test(S("abcde"), 1, 5, S("12345"), 1, 4, S("a2345"));
1196     test(S("abcde"), 1, 5, S("12345"), 1, 5, S("a2345"));
1197     test(S("abcde"), 1, 5, S("12345"), 2, 0, S("a"));
1198     test(S("abcde"), 1, 5, S("12345"), 2, 1, S("a3"));
1199     test(S("abcde"), 1, 5, S("12345"), 2, 2, S("a34"));
1200     test(S("abcde"), 1, 5, S("12345"), 2, 3, S("a345"));
1201     test(S("abcde"), 1, 5, S("12345"), 2, 4, S("a345"));
1202     test(S("abcde"), 1, 5, S("12345"), 4, 0, S("a"));
1203     test(S("abcde"), 1, 5, S("12345"), 4, 1, S("a5"));
1204     test(S("abcde"), 1, 5, S("12345"), 4, 2, S("a5"));
1205     test(S("abcde"), 1, 5, S("12345"), 5, 0, S("a"));
1206     test(S("abcde"), 1, 5, S("12345"), 5, 1, S("a"));
1207     test(S("abcde"), 1, 5, S("12345"), 6, 0, S("can't happen"));
1208     test(S("abcde"), 1, 5, S("1234567890"), 0, 0, S("a"));
1209     test(S("abcde"), 1, 5, S("1234567890"), 0, 1, S("a1"));
1210     test(S("abcde"), 1, 5, S("1234567890"), 0, 5, S("a12345"));
1211     test(S("abcde"), 1, 5, S("1234567890"), 0, 9, S("a123456789"));
1212     test(S("abcde"), 1, 5, S("1234567890"), 0, 10, S("a1234567890"));
1213     test(S("abcde"), 1, 5, S("1234567890"), 0, 11, S("a1234567890"));
1214     test(S("abcde"), 1, 5, S("1234567890"), 1, 0, S("a"));
1215     test(S("abcde"), 1, 5, S("1234567890"), 1, 1, S("a2"));
1216     test(S("abcde"), 1, 5, S("1234567890"), 1, 4, S("a2345"));
1217     test(S("abcde"), 1, 5, S("1234567890"), 1, 8, S("a23456789"));
1218     test(S("abcde"), 1, 5, S("1234567890"), 1, 9, S("a234567890"));
1219     test(S("abcde"), 1, 5, S("1234567890"), 1, 10, S("a234567890"));
1220     test(S("abcde"), 1, 5, S("1234567890"), 5, 0, S("a"));
1221     test(S("abcde"), 1, 5, S("1234567890"), 5, 1, S("a6"));
1222     test(S("abcde"), 1, 5, S("1234567890"), 5, 2, S("a67"));
1223     test(S("abcde"), 1, 5, S("1234567890"), 5, 4, S("a6789"));
1224     test(S("abcde"), 1, 5, S("1234567890"), 5, 5, S("a67890"));
1225     test(S("abcde"), 1, 5, S("1234567890"), 5, 6, S("a67890"));
1226     test(S("abcde"), 1, 5, S("1234567890"), 9, 0, S("a"));
1227     test(S("abcde"), 1, 5, S("1234567890"), 9, 1, S("a0"));
1228     test(S("abcde"), 1, 5, S("1234567890"), 9, 2, S("a0"));
1229     test(S("abcde"), 1, 5, S("1234567890"), 10, 0, S("a"));
1230     test(S("abcde"), 1, 5, S("1234567890"), 10, 1, S("a"));
1231     test(S("abcde"), 1, 5, S("1234567890"), 11, 0, S("can't happen"));
1232     test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 0, S("a"));
1233     test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 1, S("a1"));
1234     test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 10, S("a1234567890"));
1235     test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
1236     test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
1237     test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
1238     test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 0, S("a"));
1239     test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 1, S("a2"));
1240     test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 9, S("a234567890"));
1241     test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
1242     test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
1243     test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
1244     test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 0, S("a"));
1245     test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 1, S("a1"));
1246 }
1247 
1248 template <class S>
1249 void test11()
1250 {
1251     test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 5, S("a12345"));
1252     test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 9, S("a123456789"));
1253     test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 10, S("a1234567890"));
1254     test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 11, S("a1234567890"));
1255     test(S("abcde"), 1, 5, S("12345678901234567890"), 19, 0, S("a"));
1256     test(S("abcde"), 1, 5, S("12345678901234567890"), 19, 1, S("a0"));
1257     test(S("abcde"), 1, 5, S("12345678901234567890"), 19, 2, S("a0"));
1258     test(S("abcde"), 1, 5, S("12345678901234567890"), 20, 0, S("a"));
1259     test(S("abcde"), 1, 5, S("12345678901234567890"), 20, 1, S("a"));
1260     test(S("abcde"), 1, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
1261     test(S("abcde"), 2, 0, S(""), 0, 0, S("abcde"));
1262     test(S("abcde"), 2, 0, S(""), 0, 1, S("abcde"));
1263     test(S("abcde"), 2, 0, S(""), 1, 0, S("can't happen"));
1264     test(S("abcde"), 2, 0, S("12345"), 0, 0, S("abcde"));
1265     test(S("abcde"), 2, 0, S("12345"), 0, 1, S("ab1cde"));
1266     test(S("abcde"), 2, 0, S("12345"), 0, 2, S("ab12cde"));
1267     test(S("abcde"), 2, 0, S("12345"), 0, 4, S("ab1234cde"));
1268     test(S("abcde"), 2, 0, S("12345"), 0, 5, S("ab12345cde"));
1269     test(S("abcde"), 2, 0, S("12345"), 0, 6, S("ab12345cde"));
1270     test(S("abcde"), 2, 0, S("12345"), 1, 0, S("abcde"));
1271     test(S("abcde"), 2, 0, S("12345"), 1, 1, S("ab2cde"));
1272     test(S("abcde"), 2, 0, S("12345"), 1, 2, S("ab23cde"));
1273     test(S("abcde"), 2, 0, S("12345"), 1, 3, S("ab234cde"));
1274     test(S("abcde"), 2, 0, S("12345"), 1, 4, S("ab2345cde"));
1275     test(S("abcde"), 2, 0, S("12345"), 1, 5, S("ab2345cde"));
1276     test(S("abcde"), 2, 0, S("12345"), 2, 0, S("abcde"));
1277     test(S("abcde"), 2, 0, S("12345"), 2, 1, S("ab3cde"));
1278     test(S("abcde"), 2, 0, S("12345"), 2, 2, S("ab34cde"));
1279     test(S("abcde"), 2, 0, S("12345"), 2, 3, S("ab345cde"));
1280     test(S("abcde"), 2, 0, S("12345"), 2, 4, S("ab345cde"));
1281     test(S("abcde"), 2, 0, S("12345"), 4, 0, S("abcde"));
1282     test(S("abcde"), 2, 0, S("12345"), 4, 1, S("ab5cde"));
1283     test(S("abcde"), 2, 0, S("12345"), 4, 2, S("ab5cde"));
1284     test(S("abcde"), 2, 0, S("12345"), 5, 0, S("abcde"));
1285     test(S("abcde"), 2, 0, S("12345"), 5, 1, S("abcde"));
1286     test(S("abcde"), 2, 0, S("12345"), 6, 0, S("can't happen"));
1287     test(S("abcde"), 2, 0, S("1234567890"), 0, 0, S("abcde"));
1288     test(S("abcde"), 2, 0, S("1234567890"), 0, 1, S("ab1cde"));
1289     test(S("abcde"), 2, 0, S("1234567890"), 0, 5, S("ab12345cde"));
1290     test(S("abcde"), 2, 0, S("1234567890"), 0, 9, S("ab123456789cde"));
1291     test(S("abcde"), 2, 0, S("1234567890"), 0, 10, S("ab1234567890cde"));
1292     test(S("abcde"), 2, 0, S("1234567890"), 0, 11, S("ab1234567890cde"));
1293     test(S("abcde"), 2, 0, S("1234567890"), 1, 0, S("abcde"));
1294     test(S("abcde"), 2, 0, S("1234567890"), 1, 1, S("ab2cde"));
1295     test(S("abcde"), 2, 0, S("1234567890"), 1, 4, S("ab2345cde"));
1296     test(S("abcde"), 2, 0, S("1234567890"), 1, 8, S("ab23456789cde"));
1297     test(S("abcde"), 2, 0, S("1234567890"), 1, 9, S("ab234567890cde"));
1298     test(S("abcde"), 2, 0, S("1234567890"), 1, 10, S("ab234567890cde"));
1299     test(S("abcde"), 2, 0, S("1234567890"), 5, 0, S("abcde"));
1300     test(S("abcde"), 2, 0, S("1234567890"), 5, 1, S("ab6cde"));
1301     test(S("abcde"), 2, 0, S("1234567890"), 5, 2, S("ab67cde"));
1302     test(S("abcde"), 2, 0, S("1234567890"), 5, 4, S("ab6789cde"));
1303     test(S("abcde"), 2, 0, S("1234567890"), 5, 5, S("ab67890cde"));
1304     test(S("abcde"), 2, 0, S("1234567890"), 5, 6, S("ab67890cde"));
1305     test(S("abcde"), 2, 0, S("1234567890"), 9, 0, S("abcde"));
1306     test(S("abcde"), 2, 0, S("1234567890"), 9, 1, S("ab0cde"));
1307     test(S("abcde"), 2, 0, S("1234567890"), 9, 2, S("ab0cde"));
1308     test(S("abcde"), 2, 0, S("1234567890"), 10, 0, S("abcde"));
1309     test(S("abcde"), 2, 0, S("1234567890"), 10, 1, S("abcde"));
1310     test(S("abcde"), 2, 0, S("1234567890"), 11, 0, S("can't happen"));
1311     test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 0, S("abcde"));
1312     test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 1, S("ab1cde"));
1313     test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 10, S("ab1234567890cde"));
1314     test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 19, S("ab1234567890123456789cde"));
1315     test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 20, S("ab12345678901234567890cde"));
1316     test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 21, S("ab12345678901234567890cde"));
1317     test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 0, S("abcde"));
1318     test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 1, S("ab2cde"));
1319     test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 9, S("ab234567890cde"));
1320     test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 18, S("ab234567890123456789cde"));
1321     test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 19, S("ab2345678901234567890cde"));
1322     test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 20, S("ab2345678901234567890cde"));
1323     test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 0, S("abcde"));
1324     test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 1, S("ab1cde"));
1325     test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 5, S("ab12345cde"));
1326     test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 9, S("ab123456789cde"));
1327     test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 10, S("ab1234567890cde"));
1328     test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 11, S("ab1234567890cde"));
1329     test(S("abcde"), 2, 0, S("12345678901234567890"), 19, 0, S("abcde"));
1330     test(S("abcde"), 2, 0, S("12345678901234567890"), 19, 1, S("ab0cde"));
1331     test(S("abcde"), 2, 0, S("12345678901234567890"), 19, 2, S("ab0cde"));
1332     test(S("abcde"), 2, 0, S("12345678901234567890"), 20, 0, S("abcde"));
1333     test(S("abcde"), 2, 0, S("12345678901234567890"), 20, 1, S("abcde"));
1334     test(S("abcde"), 2, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
1335     test(S("abcde"), 2, 1, S(""), 0, 0, S("abde"));
1336     test(S("abcde"), 2, 1, S(""), 0, 1, S("abde"));
1337     test(S("abcde"), 2, 1, S(""), 1, 0, S("can't happen"));
1338     test(S("abcde"), 2, 1, S("12345"), 0, 0, S("abde"));
1339     test(S("abcde"), 2, 1, S("12345"), 0, 1, S("ab1de"));
1340     test(S("abcde"), 2, 1, S("12345"), 0, 2, S("ab12de"));
1341     test(S("abcde"), 2, 1, S("12345"), 0, 4, S("ab1234de"));
1342     test(S("abcde"), 2, 1, S("12345"), 0, 5, S("ab12345de"));
1343     test(S("abcde"), 2, 1, S("12345"), 0, 6, S("ab12345de"));
1344     test(S("abcde"), 2, 1, S("12345"), 1, 0, S("abde"));
1345     test(S("abcde"), 2, 1, S("12345"), 1, 1, S("ab2de"));
1346     test(S("abcde"), 2, 1, S("12345"), 1, 2, S("ab23de"));
1347     test(S("abcde"), 2, 1, S("12345"), 1, 3, S("ab234de"));
1348     test(S("abcde"), 2, 1, S("12345"), 1, 4, S("ab2345de"));
1349     test(S("abcde"), 2, 1, S("12345"), 1, 5, S("ab2345de"));
1350     test(S("abcde"), 2, 1, S("12345"), 2, 0, S("abde"));
1351 }
1352 
1353 template <class S>
1354 void test12()
1355 {
1356     test(S("abcde"), 2, 1, S("12345"), 2, 1, S("ab3de"));
1357     test(S("abcde"), 2, 1, S("12345"), 2, 2, S("ab34de"));
1358     test(S("abcde"), 2, 1, S("12345"), 2, 3, S("ab345de"));
1359     test(S("abcde"), 2, 1, S("12345"), 2, 4, S("ab345de"));
1360     test(S("abcde"), 2, 1, S("12345"), 4, 0, S("abde"));
1361     test(S("abcde"), 2, 1, S("12345"), 4, 1, S("ab5de"));
1362     test(S("abcde"), 2, 1, S("12345"), 4, 2, S("ab5de"));
1363     test(S("abcde"), 2, 1, S("12345"), 5, 0, S("abde"));
1364     test(S("abcde"), 2, 1, S("12345"), 5, 1, S("abde"));
1365     test(S("abcde"), 2, 1, S("12345"), 6, 0, S("can't happen"));
1366     test(S("abcde"), 2, 1, S("1234567890"), 0, 0, S("abde"));
1367     test(S("abcde"), 2, 1, S("1234567890"), 0, 1, S("ab1de"));
1368     test(S("abcde"), 2, 1, S("1234567890"), 0, 5, S("ab12345de"));
1369     test(S("abcde"), 2, 1, S("1234567890"), 0, 9, S("ab123456789de"));
1370     test(S("abcde"), 2, 1, S("1234567890"), 0, 10, S("ab1234567890de"));
1371     test(S("abcde"), 2, 1, S("1234567890"), 0, 11, S("ab1234567890de"));
1372     test(S("abcde"), 2, 1, S("1234567890"), 1, 0, S("abde"));
1373     test(S("abcde"), 2, 1, S("1234567890"), 1, 1, S("ab2de"));
1374     test(S("abcde"), 2, 1, S("1234567890"), 1, 4, S("ab2345de"));
1375     test(S("abcde"), 2, 1, S("1234567890"), 1, 8, S("ab23456789de"));
1376     test(S("abcde"), 2, 1, S("1234567890"), 1, 9, S("ab234567890de"));
1377     test(S("abcde"), 2, 1, S("1234567890"), 1, 10, S("ab234567890de"));
1378     test(S("abcde"), 2, 1, S("1234567890"), 5, 0, S("abde"));
1379     test(S("abcde"), 2, 1, S("1234567890"), 5, 1, S("ab6de"));
1380     test(S("abcde"), 2, 1, S("1234567890"), 5, 2, S("ab67de"));
1381     test(S("abcde"), 2, 1, S("1234567890"), 5, 4, S("ab6789de"));
1382     test(S("abcde"), 2, 1, S("1234567890"), 5, 5, S("ab67890de"));
1383     test(S("abcde"), 2, 1, S("1234567890"), 5, 6, S("ab67890de"));
1384     test(S("abcde"), 2, 1, S("1234567890"), 9, 0, S("abde"));
1385     test(S("abcde"), 2, 1, S("1234567890"), 9, 1, S("ab0de"));
1386     test(S("abcde"), 2, 1, S("1234567890"), 9, 2, S("ab0de"));
1387     test(S("abcde"), 2, 1, S("1234567890"), 10, 0, S("abde"));
1388     test(S("abcde"), 2, 1, S("1234567890"), 10, 1, S("abde"));
1389     test(S("abcde"), 2, 1, S("1234567890"), 11, 0, S("can't happen"));
1390     test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 0, S("abde"));
1391     test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 1, S("ab1de"));
1392     test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 10, S("ab1234567890de"));
1393     test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 19, S("ab1234567890123456789de"));
1394     test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 20, S("ab12345678901234567890de"));
1395     test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 21, S("ab12345678901234567890de"));
1396     test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 0, S("abde"));
1397     test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 1, S("ab2de"));
1398     test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 9, S("ab234567890de"));
1399     test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 18, S("ab234567890123456789de"));
1400     test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 19, S("ab2345678901234567890de"));
1401     test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 20, S("ab2345678901234567890de"));
1402     test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 0, S("abde"));
1403     test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 1, S("ab1de"));
1404     test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 5, S("ab12345de"));
1405     test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 9, S("ab123456789de"));
1406     test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 10, S("ab1234567890de"));
1407     test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 11, S("ab1234567890de"));
1408     test(S("abcde"), 2, 1, S("12345678901234567890"), 19, 0, S("abde"));
1409     test(S("abcde"), 2, 1, S("12345678901234567890"), 19, 1, S("ab0de"));
1410     test(S("abcde"), 2, 1, S("12345678901234567890"), 19, 2, S("ab0de"));
1411     test(S("abcde"), 2, 1, S("12345678901234567890"), 20, 0, S("abde"));
1412     test(S("abcde"), 2, 1, S("12345678901234567890"), 20, 1, S("abde"));
1413     test(S("abcde"), 2, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
1414     test(S("abcde"), 2, 2, S(""), 0, 0, S("abe"));
1415     test(S("abcde"), 2, 2, S(""), 0, 1, S("abe"));
1416     test(S("abcde"), 2, 2, S(""), 1, 0, S("can't happen"));
1417     test(S("abcde"), 2, 2, S("12345"), 0, 0, S("abe"));
1418     test(S("abcde"), 2, 2, S("12345"), 0, 1, S("ab1e"));
1419     test(S("abcde"), 2, 2, S("12345"), 0, 2, S("ab12e"));
1420     test(S("abcde"), 2, 2, S("12345"), 0, 4, S("ab1234e"));
1421     test(S("abcde"), 2, 2, S("12345"), 0, 5, S("ab12345e"));
1422     test(S("abcde"), 2, 2, S("12345"), 0, 6, S("ab12345e"));
1423     test(S("abcde"), 2, 2, S("12345"), 1, 0, S("abe"));
1424     test(S("abcde"), 2, 2, S("12345"), 1, 1, S("ab2e"));
1425     test(S("abcde"), 2, 2, S("12345"), 1, 2, S("ab23e"));
1426     test(S("abcde"), 2, 2, S("12345"), 1, 3, S("ab234e"));
1427     test(S("abcde"), 2, 2, S("12345"), 1, 4, S("ab2345e"));
1428     test(S("abcde"), 2, 2, S("12345"), 1, 5, S("ab2345e"));
1429     test(S("abcde"), 2, 2, S("12345"), 2, 0, S("abe"));
1430     test(S("abcde"), 2, 2, S("12345"), 2, 1, S("ab3e"));
1431     test(S("abcde"), 2, 2, S("12345"), 2, 2, S("ab34e"));
1432     test(S("abcde"), 2, 2, S("12345"), 2, 3, S("ab345e"));
1433     test(S("abcde"), 2, 2, S("12345"), 2, 4, S("ab345e"));
1434     test(S("abcde"), 2, 2, S("12345"), 4, 0, S("abe"));
1435     test(S("abcde"), 2, 2, S("12345"), 4, 1, S("ab5e"));
1436     test(S("abcde"), 2, 2, S("12345"), 4, 2, S("ab5e"));
1437     test(S("abcde"), 2, 2, S("12345"), 5, 0, S("abe"));
1438     test(S("abcde"), 2, 2, S("12345"), 5, 1, S("abe"));
1439     test(S("abcde"), 2, 2, S("12345"), 6, 0, S("can't happen"));
1440     test(S("abcde"), 2, 2, S("1234567890"), 0, 0, S("abe"));
1441     test(S("abcde"), 2, 2, S("1234567890"), 0, 1, S("ab1e"));
1442     test(S("abcde"), 2, 2, S("1234567890"), 0, 5, S("ab12345e"));
1443     test(S("abcde"), 2, 2, S("1234567890"), 0, 9, S("ab123456789e"));
1444     test(S("abcde"), 2, 2, S("1234567890"), 0, 10, S("ab1234567890e"));
1445     test(S("abcde"), 2, 2, S("1234567890"), 0, 11, S("ab1234567890e"));
1446     test(S("abcde"), 2, 2, S("1234567890"), 1, 0, S("abe"));
1447     test(S("abcde"), 2, 2, S("1234567890"), 1, 1, S("ab2e"));
1448     test(S("abcde"), 2, 2, S("1234567890"), 1, 4, S("ab2345e"));
1449     test(S("abcde"), 2, 2, S("1234567890"), 1, 8, S("ab23456789e"));
1450     test(S("abcde"), 2, 2, S("1234567890"), 1, 9, S("ab234567890e"));
1451     test(S("abcde"), 2, 2, S("1234567890"), 1, 10, S("ab234567890e"));
1452     test(S("abcde"), 2, 2, S("1234567890"), 5, 0, S("abe"));
1453     test(S("abcde"), 2, 2, S("1234567890"), 5, 1, S("ab6e"));
1454     test(S("abcde"), 2, 2, S("1234567890"), 5, 2, S("ab67e"));
1455     test(S("abcde"), 2, 2, S("1234567890"), 5, 4, S("ab6789e"));
1456 }
1457 
1458 template <class S>
1459 void test13()
1460 {
1461     test(S("abcde"), 2, 2, S("1234567890"), 5, 5, S("ab67890e"));
1462     test(S("abcde"), 2, 2, S("1234567890"), 5, 6, S("ab67890e"));
1463     test(S("abcde"), 2, 2, S("1234567890"), 9, 0, S("abe"));
1464     test(S("abcde"), 2, 2, S("1234567890"), 9, 1, S("ab0e"));
1465     test(S("abcde"), 2, 2, S("1234567890"), 9, 2, S("ab0e"));
1466     test(S("abcde"), 2, 2, S("1234567890"), 10, 0, S("abe"));
1467     test(S("abcde"), 2, 2, S("1234567890"), 10, 1, S("abe"));
1468     test(S("abcde"), 2, 2, S("1234567890"), 11, 0, S("can't happen"));
1469     test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 0, S("abe"));
1470     test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 1, S("ab1e"));
1471     test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 10, S("ab1234567890e"));
1472     test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 19, S("ab1234567890123456789e"));
1473     test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 20, S("ab12345678901234567890e"));
1474     test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 21, S("ab12345678901234567890e"));
1475     test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 0, S("abe"));
1476     test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 1, S("ab2e"));
1477     test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 9, S("ab234567890e"));
1478     test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 18, S("ab234567890123456789e"));
1479     test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 19, S("ab2345678901234567890e"));
1480     test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 20, S("ab2345678901234567890e"));
1481     test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 0, S("abe"));
1482     test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 1, S("ab1e"));
1483     test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 5, S("ab12345e"));
1484     test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 9, S("ab123456789e"));
1485     test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 10, S("ab1234567890e"));
1486     test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 11, S("ab1234567890e"));
1487     test(S("abcde"), 2, 2, S("12345678901234567890"), 19, 0, S("abe"));
1488     test(S("abcde"), 2, 2, S("12345678901234567890"), 19, 1, S("ab0e"));
1489     test(S("abcde"), 2, 2, S("12345678901234567890"), 19, 2, S("ab0e"));
1490     test(S("abcde"), 2, 2, S("12345678901234567890"), 20, 0, S("abe"));
1491     test(S("abcde"), 2, 2, S("12345678901234567890"), 20, 1, S("abe"));
1492     test(S("abcde"), 2, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
1493     test(S("abcde"), 2, 3, S(""), 0, 0, S("ab"));
1494     test(S("abcde"), 2, 3, S(""), 0, 1, S("ab"));
1495     test(S("abcde"), 2, 3, S(""), 1, 0, S("can't happen"));
1496     test(S("abcde"), 2, 3, S("12345"), 0, 0, S("ab"));
1497     test(S("abcde"), 2, 3, S("12345"), 0, 1, S("ab1"));
1498     test(S("abcde"), 2, 3, S("12345"), 0, 2, S("ab12"));
1499     test(S("abcde"), 2, 3, S("12345"), 0, 4, S("ab1234"));
1500     test(S("abcde"), 2, 3, S("12345"), 0, 5, S("ab12345"));
1501     test(S("abcde"), 2, 3, S("12345"), 0, 6, S("ab12345"));
1502     test(S("abcde"), 2, 3, S("12345"), 1, 0, S("ab"));
1503     test(S("abcde"), 2, 3, S("12345"), 1, 1, S("ab2"));
1504     test(S("abcde"), 2, 3, S("12345"), 1, 2, S("ab23"));
1505     test(S("abcde"), 2, 3, S("12345"), 1, 3, S("ab234"));
1506     test(S("abcde"), 2, 3, S("12345"), 1, 4, S("ab2345"));
1507     test(S("abcde"), 2, 3, S("12345"), 1, 5, S("ab2345"));
1508     test(S("abcde"), 2, 3, S("12345"), 2, 0, S("ab"));
1509     test(S("abcde"), 2, 3, S("12345"), 2, 1, S("ab3"));
1510     test(S("abcde"), 2, 3, S("12345"), 2, 2, S("ab34"));
1511     test(S("abcde"), 2, 3, S("12345"), 2, 3, S("ab345"));
1512     test(S("abcde"), 2, 3, S("12345"), 2, 4, S("ab345"));
1513     test(S("abcde"), 2, 3, S("12345"), 4, 0, S("ab"));
1514     test(S("abcde"), 2, 3, S("12345"), 4, 1, S("ab5"));
1515     test(S("abcde"), 2, 3, S("12345"), 4, 2, S("ab5"));
1516     test(S("abcde"), 2, 3, S("12345"), 5, 0, S("ab"));
1517     test(S("abcde"), 2, 3, S("12345"), 5, 1, S("ab"));
1518     test(S("abcde"), 2, 3, S("12345"), 6, 0, S("can't happen"));
1519     test(S("abcde"), 2, 3, S("1234567890"), 0, 0, S("ab"));
1520     test(S("abcde"), 2, 3, S("1234567890"), 0, 1, S("ab1"));
1521     test(S("abcde"), 2, 3, S("1234567890"), 0, 5, S("ab12345"));
1522     test(S("abcde"), 2, 3, S("1234567890"), 0, 9, S("ab123456789"));
1523     test(S("abcde"), 2, 3, S("1234567890"), 0, 10, S("ab1234567890"));
1524     test(S("abcde"), 2, 3, S("1234567890"), 0, 11, S("ab1234567890"));
1525     test(S("abcde"), 2, 3, S("1234567890"), 1, 0, S("ab"));
1526     test(S("abcde"), 2, 3, S("1234567890"), 1, 1, S("ab2"));
1527     test(S("abcde"), 2, 3, S("1234567890"), 1, 4, S("ab2345"));
1528     test(S("abcde"), 2, 3, S("1234567890"), 1, 8, S("ab23456789"));
1529     test(S("abcde"), 2, 3, S("1234567890"), 1, 9, S("ab234567890"));
1530     test(S("abcde"), 2, 3, S("1234567890"), 1, 10, S("ab234567890"));
1531     test(S("abcde"), 2, 3, S("1234567890"), 5, 0, S("ab"));
1532     test(S("abcde"), 2, 3, S("1234567890"), 5, 1, S("ab6"));
1533     test(S("abcde"), 2, 3, S("1234567890"), 5, 2, S("ab67"));
1534     test(S("abcde"), 2, 3, S("1234567890"), 5, 4, S("ab6789"));
1535     test(S("abcde"), 2, 3, S("1234567890"), 5, 5, S("ab67890"));
1536     test(S("abcde"), 2, 3, S("1234567890"), 5, 6, S("ab67890"));
1537     test(S("abcde"), 2, 3, S("1234567890"), 9, 0, S("ab"));
1538     test(S("abcde"), 2, 3, S("1234567890"), 9, 1, S("ab0"));
1539     test(S("abcde"), 2, 3, S("1234567890"), 9, 2, S("ab0"));
1540     test(S("abcde"), 2, 3, S("1234567890"), 10, 0, S("ab"));
1541     test(S("abcde"), 2, 3, S("1234567890"), 10, 1, S("ab"));
1542     test(S("abcde"), 2, 3, S("1234567890"), 11, 0, S("can't happen"));
1543     test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 0, S("ab"));
1544     test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 1, S("ab1"));
1545     test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 10, S("ab1234567890"));
1546     test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 19, S("ab1234567890123456789"));
1547     test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 20, S("ab12345678901234567890"));
1548     test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 21, S("ab12345678901234567890"));
1549     test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 0, S("ab"));
1550     test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 1, S("ab2"));
1551     test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 9, S("ab234567890"));
1552     test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 18, S("ab234567890123456789"));
1553     test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 19, S("ab2345678901234567890"));
1554     test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 20, S("ab2345678901234567890"));
1555     test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 0, S("ab"));
1556     test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 1, S("ab1"));
1557     test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 5, S("ab12345"));
1558     test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 9, S("ab123456789"));
1559     test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 10, S("ab1234567890"));
1560     test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 11, S("ab1234567890"));
1561 }
1562 
1563 template <class S>
1564 void test14()
1565 {
1566     test(S("abcde"), 2, 3, S("12345678901234567890"), 19, 0, S("ab"));
1567     test(S("abcde"), 2, 3, S("12345678901234567890"), 19, 1, S("ab0"));
1568     test(S("abcde"), 2, 3, S("12345678901234567890"), 19, 2, S("ab0"));
1569     test(S("abcde"), 2, 3, S("12345678901234567890"), 20, 0, S("ab"));
1570     test(S("abcde"), 2, 3, S("12345678901234567890"), 20, 1, S("ab"));
1571     test(S("abcde"), 2, 3, S("12345678901234567890"), 21, 0, S("can't happen"));
1572     test(S("abcde"), 2, 4, S(""), 0, 0, S("ab"));
1573     test(S("abcde"), 2, 4, S(""), 0, 1, S("ab"));
1574     test(S("abcde"), 2, 4, S(""), 1, 0, S("can't happen"));
1575     test(S("abcde"), 2, 4, S("12345"), 0, 0, S("ab"));
1576     test(S("abcde"), 2, 4, S("12345"), 0, 1, S("ab1"));
1577     test(S("abcde"), 2, 4, S("12345"), 0, 2, S("ab12"));
1578     test(S("abcde"), 2, 4, S("12345"), 0, 4, S("ab1234"));
1579     test(S("abcde"), 2, 4, S("12345"), 0, 5, S("ab12345"));
1580     test(S("abcde"), 2, 4, S("12345"), 0, 6, S("ab12345"));
1581     test(S("abcde"), 2, 4, S("12345"), 1, 0, S("ab"));
1582     test(S("abcde"), 2, 4, S("12345"), 1, 1, S("ab2"));
1583     test(S("abcde"), 2, 4, S("12345"), 1, 2, S("ab23"));
1584     test(S("abcde"), 2, 4, S("12345"), 1, 3, S("ab234"));
1585     test(S("abcde"), 2, 4, S("12345"), 1, 4, S("ab2345"));
1586     test(S("abcde"), 2, 4, S("12345"), 1, 5, S("ab2345"));
1587     test(S("abcde"), 2, 4, S("12345"), 2, 0, S("ab"));
1588     test(S("abcde"), 2, 4, S("12345"), 2, 1, S("ab3"));
1589     test(S("abcde"), 2, 4, S("12345"), 2, 2, S("ab34"));
1590     test(S("abcde"), 2, 4, S("12345"), 2, 3, S("ab345"));
1591     test(S("abcde"), 2, 4, S("12345"), 2, 4, S("ab345"));
1592     test(S("abcde"), 2, 4, S("12345"), 4, 0, S("ab"));
1593     test(S("abcde"), 2, 4, S("12345"), 4, 1, S("ab5"));
1594     test(S("abcde"), 2, 4, S("12345"), 4, 2, S("ab5"));
1595     test(S("abcde"), 2, 4, S("12345"), 5, 0, S("ab"));
1596     test(S("abcde"), 2, 4, S("12345"), 5, 1, S("ab"));
1597     test(S("abcde"), 2, 4, S("12345"), 6, 0, S("can't happen"));
1598     test(S("abcde"), 2, 4, S("1234567890"), 0, 0, S("ab"));
1599     test(S("abcde"), 2, 4, S("1234567890"), 0, 1, S("ab1"));
1600     test(S("abcde"), 2, 4, S("1234567890"), 0, 5, S("ab12345"));
1601     test(S("abcde"), 2, 4, S("1234567890"), 0, 9, S("ab123456789"));
1602     test(S("abcde"), 2, 4, S("1234567890"), 0, 10, S("ab1234567890"));
1603     test(S("abcde"), 2, 4, S("1234567890"), 0, 11, S("ab1234567890"));
1604     test(S("abcde"), 2, 4, S("1234567890"), 1, 0, S("ab"));
1605     test(S("abcde"), 2, 4, S("1234567890"), 1, 1, S("ab2"));
1606     test(S("abcde"), 2, 4, S("1234567890"), 1, 4, S("ab2345"));
1607     test(S("abcde"), 2, 4, S("1234567890"), 1, 8, S("ab23456789"));
1608     test(S("abcde"), 2, 4, S("1234567890"), 1, 9, S("ab234567890"));
1609     test(S("abcde"), 2, 4, S("1234567890"), 1, 10, S("ab234567890"));
1610     test(S("abcde"), 2, 4, S("1234567890"), 5, 0, S("ab"));
1611     test(S("abcde"), 2, 4, S("1234567890"), 5, 1, S("ab6"));
1612     test(S("abcde"), 2, 4, S("1234567890"), 5, 2, S("ab67"));
1613     test(S("abcde"), 2, 4, S("1234567890"), 5, 4, S("ab6789"));
1614     test(S("abcde"), 2, 4, S("1234567890"), 5, 5, S("ab67890"));
1615     test(S("abcde"), 2, 4, S("1234567890"), 5, 6, S("ab67890"));
1616     test(S("abcde"), 2, 4, S("1234567890"), 9, 0, S("ab"));
1617     test(S("abcde"), 2, 4, S("1234567890"), 9, 1, S("ab0"));
1618     test(S("abcde"), 2, 4, S("1234567890"), 9, 2, S("ab0"));
1619     test(S("abcde"), 2, 4, S("1234567890"), 10, 0, S("ab"));
1620     test(S("abcde"), 2, 4, S("1234567890"), 10, 1, S("ab"));
1621     test(S("abcde"), 2, 4, S("1234567890"), 11, 0, S("can't happen"));
1622     test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 0, S("ab"));
1623     test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 1, S("ab1"));
1624     test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 10, S("ab1234567890"));
1625     test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 19, S("ab1234567890123456789"));
1626     test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 20, S("ab12345678901234567890"));
1627     test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 21, S("ab12345678901234567890"));
1628     test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 0, S("ab"));
1629     test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 1, S("ab2"));
1630     test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 9, S("ab234567890"));
1631     test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 18, S("ab234567890123456789"));
1632     test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 19, S("ab2345678901234567890"));
1633     test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 20, S("ab2345678901234567890"));
1634     test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 0, S("ab"));
1635     test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 1, S("ab1"));
1636     test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 5, S("ab12345"));
1637     test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 9, S("ab123456789"));
1638     test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 10, S("ab1234567890"));
1639     test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 11, S("ab1234567890"));
1640     test(S("abcde"), 2, 4, S("12345678901234567890"), 19, 0, S("ab"));
1641     test(S("abcde"), 2, 4, S("12345678901234567890"), 19, 1, S("ab0"));
1642     test(S("abcde"), 2, 4, S("12345678901234567890"), 19, 2, S("ab0"));
1643     test(S("abcde"), 2, 4, S("12345678901234567890"), 20, 0, S("ab"));
1644     test(S("abcde"), 2, 4, S("12345678901234567890"), 20, 1, S("ab"));
1645     test(S("abcde"), 2, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
1646     test(S("abcde"), 4, 0, S(""), 0, 0, S("abcde"));
1647     test(S("abcde"), 4, 0, S(""), 0, 1, S("abcde"));
1648     test(S("abcde"), 4, 0, S(""), 1, 0, S("can't happen"));
1649     test(S("abcde"), 4, 0, S("12345"), 0, 0, S("abcde"));
1650     test(S("abcde"), 4, 0, S("12345"), 0, 1, S("abcd1e"));
1651     test(S("abcde"), 4, 0, S("12345"), 0, 2, S("abcd12e"));
1652     test(S("abcde"), 4, 0, S("12345"), 0, 4, S("abcd1234e"));
1653     test(S("abcde"), 4, 0, S("12345"), 0, 5, S("abcd12345e"));
1654     test(S("abcde"), 4, 0, S("12345"), 0, 6, S("abcd12345e"));
1655     test(S("abcde"), 4, 0, S("12345"), 1, 0, S("abcde"));
1656     test(S("abcde"), 4, 0, S("12345"), 1, 1, S("abcd2e"));
1657     test(S("abcde"), 4, 0, S("12345"), 1, 2, S("abcd23e"));
1658     test(S("abcde"), 4, 0, S("12345"), 1, 3, S("abcd234e"));
1659     test(S("abcde"), 4, 0, S("12345"), 1, 4, S("abcd2345e"));
1660     test(S("abcde"), 4, 0, S("12345"), 1, 5, S("abcd2345e"));
1661     test(S("abcde"), 4, 0, S("12345"), 2, 0, S("abcde"));
1662     test(S("abcde"), 4, 0, S("12345"), 2, 1, S("abcd3e"));
1663     test(S("abcde"), 4, 0, S("12345"), 2, 2, S("abcd34e"));
1664     test(S("abcde"), 4, 0, S("12345"), 2, 3, S("abcd345e"));
1665     test(S("abcde"), 4, 0, S("12345"), 2, 4, S("abcd345e"));
1666 }
1667 
1668 template <class S>
1669 void test15()
1670 {
1671     test(S("abcde"), 4, 0, S("12345"), 4, 0, S("abcde"));
1672     test(S("abcde"), 4, 0, S("12345"), 4, 1, S("abcd5e"));
1673     test(S("abcde"), 4, 0, S("12345"), 4, 2, S("abcd5e"));
1674     test(S("abcde"), 4, 0, S("12345"), 5, 0, S("abcde"));
1675     test(S("abcde"), 4, 0, S("12345"), 5, 1, S("abcde"));
1676     test(S("abcde"), 4, 0, S("12345"), 6, 0, S("can't happen"));
1677     test(S("abcde"), 4, 0, S("1234567890"), 0, 0, S("abcde"));
1678     test(S("abcde"), 4, 0, S("1234567890"), 0, 1, S("abcd1e"));
1679     test(S("abcde"), 4, 0, S("1234567890"), 0, 5, S("abcd12345e"));
1680     test(S("abcde"), 4, 0, S("1234567890"), 0, 9, S("abcd123456789e"));
1681     test(S("abcde"), 4, 0, S("1234567890"), 0, 10, S("abcd1234567890e"));
1682     test(S("abcde"), 4, 0, S("1234567890"), 0, 11, S("abcd1234567890e"));
1683     test(S("abcde"), 4, 0, S("1234567890"), 1, 0, S("abcde"));
1684     test(S("abcde"), 4, 0, S("1234567890"), 1, 1, S("abcd2e"));
1685     test(S("abcde"), 4, 0, S("1234567890"), 1, 4, S("abcd2345e"));
1686     test(S("abcde"), 4, 0, S("1234567890"), 1, 8, S("abcd23456789e"));
1687     test(S("abcde"), 4, 0, S("1234567890"), 1, 9, S("abcd234567890e"));
1688     test(S("abcde"), 4, 0, S("1234567890"), 1, 10, S("abcd234567890e"));
1689     test(S("abcde"), 4, 0, S("1234567890"), 5, 0, S("abcde"));
1690     test(S("abcde"), 4, 0, S("1234567890"), 5, 1, S("abcd6e"));
1691     test(S("abcde"), 4, 0, S("1234567890"), 5, 2, S("abcd67e"));
1692     test(S("abcde"), 4, 0, S("1234567890"), 5, 4, S("abcd6789e"));
1693     test(S("abcde"), 4, 0, S("1234567890"), 5, 5, S("abcd67890e"));
1694     test(S("abcde"), 4, 0, S("1234567890"), 5, 6, S("abcd67890e"));
1695     test(S("abcde"), 4, 0, S("1234567890"), 9, 0, S("abcde"));
1696     test(S("abcde"), 4, 0, S("1234567890"), 9, 1, S("abcd0e"));
1697     test(S("abcde"), 4, 0, S("1234567890"), 9, 2, S("abcd0e"));
1698     test(S("abcde"), 4, 0, S("1234567890"), 10, 0, S("abcde"));
1699     test(S("abcde"), 4, 0, S("1234567890"), 10, 1, S("abcde"));
1700     test(S("abcde"), 4, 0, S("1234567890"), 11, 0, S("can't happen"));
1701     test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 0, S("abcde"));
1702     test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 1, S("abcd1e"));
1703     test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 10, S("abcd1234567890e"));
1704     test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789e"));
1705     test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890e"));
1706     test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890e"));
1707     test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 0, S("abcde"));
1708     test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 1, S("abcd2e"));
1709     test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 9, S("abcd234567890e"));
1710     test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 18, S("abcd234567890123456789e"));
1711     test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890e"));
1712     test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890e"));
1713     test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 0, S("abcde"));
1714     test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 1, S("abcd1e"));
1715     test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 5, S("abcd12345e"));
1716     test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 9, S("abcd123456789e"));
1717     test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 10, S("abcd1234567890e"));
1718     test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 11, S("abcd1234567890e"));
1719     test(S("abcde"), 4, 0, S("12345678901234567890"), 19, 0, S("abcde"));
1720     test(S("abcde"), 4, 0, S("12345678901234567890"), 19, 1, S("abcd0e"));
1721     test(S("abcde"), 4, 0, S("12345678901234567890"), 19, 2, S("abcd0e"));
1722     test(S("abcde"), 4, 0, S("12345678901234567890"), 20, 0, S("abcde"));
1723     test(S("abcde"), 4, 0, S("12345678901234567890"), 20, 1, S("abcde"));
1724     test(S("abcde"), 4, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
1725     test(S("abcde"), 4, 1, S(""), 0, 0, S("abcd"));
1726     test(S("abcde"), 4, 1, S(""), 0, 1, S("abcd"));
1727     test(S("abcde"), 4, 1, S(""), 1, 0, S("can't happen"));
1728     test(S("abcde"), 4, 1, S("12345"), 0, 0, S("abcd"));
1729     test(S("abcde"), 4, 1, S("12345"), 0, 1, S("abcd1"));
1730     test(S("abcde"), 4, 1, S("12345"), 0, 2, S("abcd12"));
1731     test(S("abcde"), 4, 1, S("12345"), 0, 4, S("abcd1234"));
1732     test(S("abcde"), 4, 1, S("12345"), 0, 5, S("abcd12345"));
1733     test(S("abcde"), 4, 1, S("12345"), 0, 6, S("abcd12345"));
1734     test(S("abcde"), 4, 1, S("12345"), 1, 0, S("abcd"));
1735     test(S("abcde"), 4, 1, S("12345"), 1, 1, S("abcd2"));
1736     test(S("abcde"), 4, 1, S("12345"), 1, 2, S("abcd23"));
1737     test(S("abcde"), 4, 1, S("12345"), 1, 3, S("abcd234"));
1738     test(S("abcde"), 4, 1, S("12345"), 1, 4, S("abcd2345"));
1739     test(S("abcde"), 4, 1, S("12345"), 1, 5, S("abcd2345"));
1740     test(S("abcde"), 4, 1, S("12345"), 2, 0, S("abcd"));
1741     test(S("abcde"), 4, 1, S("12345"), 2, 1, S("abcd3"));
1742     test(S("abcde"), 4, 1, S("12345"), 2, 2, S("abcd34"));
1743     test(S("abcde"), 4, 1, S("12345"), 2, 3, S("abcd345"));
1744     test(S("abcde"), 4, 1, S("12345"), 2, 4, S("abcd345"));
1745     test(S("abcde"), 4, 1, S("12345"), 4, 0, S("abcd"));
1746     test(S("abcde"), 4, 1, S("12345"), 4, 1, S("abcd5"));
1747     test(S("abcde"), 4, 1, S("12345"), 4, 2, S("abcd5"));
1748     test(S("abcde"), 4, 1, S("12345"), 5, 0, S("abcd"));
1749     test(S("abcde"), 4, 1, S("12345"), 5, 1, S("abcd"));
1750     test(S("abcde"), 4, 1, S("12345"), 6, 0, S("can't happen"));
1751     test(S("abcde"), 4, 1, S("1234567890"), 0, 0, S("abcd"));
1752     test(S("abcde"), 4, 1, S("1234567890"), 0, 1, S("abcd1"));
1753     test(S("abcde"), 4, 1, S("1234567890"), 0, 5, S("abcd12345"));
1754     test(S("abcde"), 4, 1, S("1234567890"), 0, 9, S("abcd123456789"));
1755     test(S("abcde"), 4, 1, S("1234567890"), 0, 10, S("abcd1234567890"));
1756     test(S("abcde"), 4, 1, S("1234567890"), 0, 11, S("abcd1234567890"));
1757     test(S("abcde"), 4, 1, S("1234567890"), 1, 0, S("abcd"));
1758     test(S("abcde"), 4, 1, S("1234567890"), 1, 1, S("abcd2"));
1759     test(S("abcde"), 4, 1, S("1234567890"), 1, 4, S("abcd2345"));
1760     test(S("abcde"), 4, 1, S("1234567890"), 1, 8, S("abcd23456789"));
1761     test(S("abcde"), 4, 1, S("1234567890"), 1, 9, S("abcd234567890"));
1762     test(S("abcde"), 4, 1, S("1234567890"), 1, 10, S("abcd234567890"));
1763     test(S("abcde"), 4, 1, S("1234567890"), 5, 0, S("abcd"));
1764     test(S("abcde"), 4, 1, S("1234567890"), 5, 1, S("abcd6"));
1765     test(S("abcde"), 4, 1, S("1234567890"), 5, 2, S("abcd67"));
1766     test(S("abcde"), 4, 1, S("1234567890"), 5, 4, S("abcd6789"));
1767     test(S("abcde"), 4, 1, S("1234567890"), 5, 5, S("abcd67890"));
1768     test(S("abcde"), 4, 1, S("1234567890"), 5, 6, S("abcd67890"));
1769     test(S("abcde"), 4, 1, S("1234567890"), 9, 0, S("abcd"));
1770     test(S("abcde"), 4, 1, S("1234567890"), 9, 1, S("abcd0"));
1771 }
1772 
1773 template <class S>
1774 void test16()
1775 {
1776     test(S("abcde"), 4, 1, S("1234567890"), 9, 2, S("abcd0"));
1777     test(S("abcde"), 4, 1, S("1234567890"), 10, 0, S("abcd"));
1778     test(S("abcde"), 4, 1, S("1234567890"), 10, 1, S("abcd"));
1779     test(S("abcde"), 4, 1, S("1234567890"), 11, 0, S("can't happen"));
1780     test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 0, S("abcd"));
1781     test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 1, S("abcd1"));
1782     test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 10, S("abcd1234567890"));
1783     test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789"));
1784     test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890"));
1785     test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890"));
1786     test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 0, S("abcd"));
1787     test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 1, S("abcd2"));
1788     test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 9, S("abcd234567890"));
1789     test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 18, S("abcd234567890123456789"));
1790     test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890"));
1791     test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890"));
1792     test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 0, S("abcd"));
1793     test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 1, S("abcd1"));
1794     test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 5, S("abcd12345"));
1795     test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 9, S("abcd123456789"));
1796     test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 10, S("abcd1234567890"));
1797     test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 11, S("abcd1234567890"));
1798     test(S("abcde"), 4, 1, S("12345678901234567890"), 19, 0, S("abcd"));
1799     test(S("abcde"), 4, 1, S("12345678901234567890"), 19, 1, S("abcd0"));
1800     test(S("abcde"), 4, 1, S("12345678901234567890"), 19, 2, S("abcd0"));
1801     test(S("abcde"), 4, 1, S("12345678901234567890"), 20, 0, S("abcd"));
1802     test(S("abcde"), 4, 1, S("12345678901234567890"), 20, 1, S("abcd"));
1803     test(S("abcde"), 4, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
1804     test(S("abcde"), 4, 2, S(""), 0, 0, S("abcd"));
1805     test(S("abcde"), 4, 2, S(""), 0, 1, S("abcd"));
1806     test(S("abcde"), 4, 2, S(""), 1, 0, S("can't happen"));
1807     test(S("abcde"), 4, 2, S("12345"), 0, 0, S("abcd"));
1808     test(S("abcde"), 4, 2, S("12345"), 0, 1, S("abcd1"));
1809     test(S("abcde"), 4, 2, S("12345"), 0, 2, S("abcd12"));
1810     test(S("abcde"), 4, 2, S("12345"), 0, 4, S("abcd1234"));
1811     test(S("abcde"), 4, 2, S("12345"), 0, 5, S("abcd12345"));
1812     test(S("abcde"), 4, 2, S("12345"), 0, 6, S("abcd12345"));
1813     test(S("abcde"), 4, 2, S("12345"), 1, 0, S("abcd"));
1814     test(S("abcde"), 4, 2, S("12345"), 1, 1, S("abcd2"));
1815     test(S("abcde"), 4, 2, S("12345"), 1, 2, S("abcd23"));
1816     test(S("abcde"), 4, 2, S("12345"), 1, 3, S("abcd234"));
1817     test(S("abcde"), 4, 2, S("12345"), 1, 4, S("abcd2345"));
1818     test(S("abcde"), 4, 2, S("12345"), 1, 5, S("abcd2345"));
1819     test(S("abcde"), 4, 2, S("12345"), 2, 0, S("abcd"));
1820     test(S("abcde"), 4, 2, S("12345"), 2, 1, S("abcd3"));
1821     test(S("abcde"), 4, 2, S("12345"), 2, 2, S("abcd34"));
1822     test(S("abcde"), 4, 2, S("12345"), 2, 3, S("abcd345"));
1823     test(S("abcde"), 4, 2, S("12345"), 2, 4, S("abcd345"));
1824     test(S("abcde"), 4, 2, S("12345"), 4, 0, S("abcd"));
1825     test(S("abcde"), 4, 2, S("12345"), 4, 1, S("abcd5"));
1826     test(S("abcde"), 4, 2, S("12345"), 4, 2, S("abcd5"));
1827     test(S("abcde"), 4, 2, S("12345"), 5, 0, S("abcd"));
1828     test(S("abcde"), 4, 2, S("12345"), 5, 1, S("abcd"));
1829     test(S("abcde"), 4, 2, S("12345"), 6, 0, S("can't happen"));
1830     test(S("abcde"), 4, 2, S("1234567890"), 0, 0, S("abcd"));
1831     test(S("abcde"), 4, 2, S("1234567890"), 0, 1, S("abcd1"));
1832     test(S("abcde"), 4, 2, S("1234567890"), 0, 5, S("abcd12345"));
1833     test(S("abcde"), 4, 2, S("1234567890"), 0, 9, S("abcd123456789"));
1834     test(S("abcde"), 4, 2, S("1234567890"), 0, 10, S("abcd1234567890"));
1835     test(S("abcde"), 4, 2, S("1234567890"), 0, 11, S("abcd1234567890"));
1836     test(S("abcde"), 4, 2, S("1234567890"), 1, 0, S("abcd"));
1837     test(S("abcde"), 4, 2, S("1234567890"), 1, 1, S("abcd2"));
1838     test(S("abcde"), 4, 2, S("1234567890"), 1, 4, S("abcd2345"));
1839     test(S("abcde"), 4, 2, S("1234567890"), 1, 8, S("abcd23456789"));
1840     test(S("abcde"), 4, 2, S("1234567890"), 1, 9, S("abcd234567890"));
1841     test(S("abcde"), 4, 2, S("1234567890"), 1, 10, S("abcd234567890"));
1842     test(S("abcde"), 4, 2, S("1234567890"), 5, 0, S("abcd"));
1843     test(S("abcde"), 4, 2, S("1234567890"), 5, 1, S("abcd6"));
1844     test(S("abcde"), 4, 2, S("1234567890"), 5, 2, S("abcd67"));
1845     test(S("abcde"), 4, 2, S("1234567890"), 5, 4, S("abcd6789"));
1846     test(S("abcde"), 4, 2, S("1234567890"), 5, 5, S("abcd67890"));
1847     test(S("abcde"), 4, 2, S("1234567890"), 5, 6, S("abcd67890"));
1848     test(S("abcde"), 4, 2, S("1234567890"), 9, 0, S("abcd"));
1849     test(S("abcde"), 4, 2, S("1234567890"), 9, 1, S("abcd0"));
1850     test(S("abcde"), 4, 2, S("1234567890"), 9, 2, S("abcd0"));
1851     test(S("abcde"), 4, 2, S("1234567890"), 10, 0, S("abcd"));
1852     test(S("abcde"), 4, 2, S("1234567890"), 10, 1, S("abcd"));
1853     test(S("abcde"), 4, 2, S("1234567890"), 11, 0, S("can't happen"));
1854     test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 0, S("abcd"));
1855     test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 1, S("abcd1"));
1856     test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 10, S("abcd1234567890"));
1857     test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789"));
1858     test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890"));
1859     test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890"));
1860     test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 0, S("abcd"));
1861     test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 1, S("abcd2"));
1862     test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 9, S("abcd234567890"));
1863     test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 18, S("abcd234567890123456789"));
1864     test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890"));
1865     test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890"));
1866     test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 0, S("abcd"));
1867     test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 1, S("abcd1"));
1868     test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 5, S("abcd12345"));
1869     test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 9, S("abcd123456789"));
1870     test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 10, S("abcd1234567890"));
1871     test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 11, S("abcd1234567890"));
1872     test(S("abcde"), 4, 2, S("12345678901234567890"), 19, 0, S("abcd"));
1873     test(S("abcde"), 4, 2, S("12345678901234567890"), 19, 1, S("abcd0"));
1874     test(S("abcde"), 4, 2, S("12345678901234567890"), 19, 2, S("abcd0"));
1875     test(S("abcde"), 4, 2, S("12345678901234567890"), 20, 0, S("abcd"));
1876 }
1877 
1878 template <class S>
1879 void test17()
1880 {
1881     test(S("abcde"), 4, 2, S("12345678901234567890"), 20, 1, S("abcd"));
1882     test(S("abcde"), 4, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
1883     test(S("abcde"), 5, 0, S(""), 0, 0, S("abcde"));
1884     test(S("abcde"), 5, 0, S(""), 0, 1, S("abcde"));
1885     test(S("abcde"), 5, 0, S(""), 1, 0, S("can't happen"));
1886     test(S("abcde"), 5, 0, S("12345"), 0, 0, S("abcde"));
1887     test(S("abcde"), 5, 0, S("12345"), 0, 1, S("abcde1"));
1888     test(S("abcde"), 5, 0, S("12345"), 0, 2, S("abcde12"));
1889     test(S("abcde"), 5, 0, S("12345"), 0, 4, S("abcde1234"));
1890     test(S("abcde"), 5, 0, S("12345"), 0, 5, S("abcde12345"));
1891     test(S("abcde"), 5, 0, S("12345"), 0, 6, S("abcde12345"));
1892     test(S("abcde"), 5, 0, S("12345"), 1, 0, S("abcde"));
1893     test(S("abcde"), 5, 0, S("12345"), 1, 1, S("abcde2"));
1894     test(S("abcde"), 5, 0, S("12345"), 1, 2, S("abcde23"));
1895     test(S("abcde"), 5, 0, S("12345"), 1, 3, S("abcde234"));
1896     test(S("abcde"), 5, 0, S("12345"), 1, 4, S("abcde2345"));
1897     test(S("abcde"), 5, 0, S("12345"), 1, 5, S("abcde2345"));
1898     test(S("abcde"), 5, 0, S("12345"), 2, 0, S("abcde"));
1899     test(S("abcde"), 5, 0, S("12345"), 2, 1, S("abcde3"));
1900     test(S("abcde"), 5, 0, S("12345"), 2, 2, S("abcde34"));
1901     test(S("abcde"), 5, 0, S("12345"), 2, 3, S("abcde345"));
1902     test(S("abcde"), 5, 0, S("12345"), 2, 4, S("abcde345"));
1903     test(S("abcde"), 5, 0, S("12345"), 4, 0, S("abcde"));
1904     test(S("abcde"), 5, 0, S("12345"), 4, 1, S("abcde5"));
1905     test(S("abcde"), 5, 0, S("12345"), 4, 2, S("abcde5"));
1906     test(S("abcde"), 5, 0, S("12345"), 5, 0, S("abcde"));
1907     test(S("abcde"), 5, 0, S("12345"), 5, 1, S("abcde"));
1908     test(S("abcde"), 5, 0, S("12345"), 6, 0, S("can't happen"));
1909     test(S("abcde"), 5, 0, S("1234567890"), 0, 0, S("abcde"));
1910     test(S("abcde"), 5, 0, S("1234567890"), 0, 1, S("abcde1"));
1911     test(S("abcde"), 5, 0, S("1234567890"), 0, 5, S("abcde12345"));
1912     test(S("abcde"), 5, 0, S("1234567890"), 0, 9, S("abcde123456789"));
1913     test(S("abcde"), 5, 0, S("1234567890"), 0, 10, S("abcde1234567890"));
1914     test(S("abcde"), 5, 0, S("1234567890"), 0, 11, S("abcde1234567890"));
1915     test(S("abcde"), 5, 0, S("1234567890"), 1, 0, S("abcde"));
1916     test(S("abcde"), 5, 0, S("1234567890"), 1, 1, S("abcde2"));
1917     test(S("abcde"), 5, 0, S("1234567890"), 1, 4, S("abcde2345"));
1918     test(S("abcde"), 5, 0, S("1234567890"), 1, 8, S("abcde23456789"));
1919     test(S("abcde"), 5, 0, S("1234567890"), 1, 9, S("abcde234567890"));
1920     test(S("abcde"), 5, 0, S("1234567890"), 1, 10, S("abcde234567890"));
1921     test(S("abcde"), 5, 0, S("1234567890"), 5, 0, S("abcde"));
1922     test(S("abcde"), 5, 0, S("1234567890"), 5, 1, S("abcde6"));
1923     test(S("abcde"), 5, 0, S("1234567890"), 5, 2, S("abcde67"));
1924     test(S("abcde"), 5, 0, S("1234567890"), 5, 4, S("abcde6789"));
1925     test(S("abcde"), 5, 0, S("1234567890"), 5, 5, S("abcde67890"));
1926     test(S("abcde"), 5, 0, S("1234567890"), 5, 6, S("abcde67890"));
1927     test(S("abcde"), 5, 0, S("1234567890"), 9, 0, S("abcde"));
1928     test(S("abcde"), 5, 0, S("1234567890"), 9, 1, S("abcde0"));
1929     test(S("abcde"), 5, 0, S("1234567890"), 9, 2, S("abcde0"));
1930     test(S("abcde"), 5, 0, S("1234567890"), 10, 0, S("abcde"));
1931     test(S("abcde"), 5, 0, S("1234567890"), 10, 1, S("abcde"));
1932     test(S("abcde"), 5, 0, S("1234567890"), 11, 0, S("can't happen"));
1933     test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 0, S("abcde"));
1934     test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 1, S("abcde1"));
1935     test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
1936     test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
1937     test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
1938     test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
1939     test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 0, S("abcde"));
1940     test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 1, S("abcde2"));
1941     test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 9, S("abcde234567890"));
1942     test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
1943     test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
1944     test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
1945     test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 0, S("abcde"));
1946     test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 1, S("abcde1"));
1947     test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 5, S("abcde12345"));
1948     test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 9, S("abcde123456789"));
1949     test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
1950     test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
1951     test(S("abcde"), 5, 0, S("12345678901234567890"), 19, 0, S("abcde"));
1952     test(S("abcde"), 5, 0, S("12345678901234567890"), 19, 1, S("abcde0"));
1953     test(S("abcde"), 5, 0, S("12345678901234567890"), 19, 2, S("abcde0"));
1954     test(S("abcde"), 5, 0, S("12345678901234567890"), 20, 0, S("abcde"));
1955     test(S("abcde"), 5, 0, S("12345678901234567890"), 20, 1, S("abcde"));
1956     test(S("abcde"), 5, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
1957     test(S("abcde"), 5, 1, S(""), 0, 0, S("abcde"));
1958     test(S("abcde"), 5, 1, S(""), 0, 1, S("abcde"));
1959     test(S("abcde"), 5, 1, S(""), 1, 0, S("can't happen"));
1960     test(S("abcde"), 5, 1, S("12345"), 0, 0, S("abcde"));
1961     test(S("abcde"), 5, 1, S("12345"), 0, 1, S("abcde1"));
1962     test(S("abcde"), 5, 1, S("12345"), 0, 2, S("abcde12"));
1963     test(S("abcde"), 5, 1, S("12345"), 0, 4, S("abcde1234"));
1964     test(S("abcde"), 5, 1, S("12345"), 0, 5, S("abcde12345"));
1965     test(S("abcde"), 5, 1, S("12345"), 0, 6, S("abcde12345"));
1966     test(S("abcde"), 5, 1, S("12345"), 1, 0, S("abcde"));
1967     test(S("abcde"), 5, 1, S("12345"), 1, 1, S("abcde2"));
1968     test(S("abcde"), 5, 1, S("12345"), 1, 2, S("abcde23"));
1969     test(S("abcde"), 5, 1, S("12345"), 1, 3, S("abcde234"));
1970     test(S("abcde"), 5, 1, S("12345"), 1, 4, S("abcde2345"));
1971     test(S("abcde"), 5, 1, S("12345"), 1, 5, S("abcde2345"));
1972     test(S("abcde"), 5, 1, S("12345"), 2, 0, S("abcde"));
1973     test(S("abcde"), 5, 1, S("12345"), 2, 1, S("abcde3"));
1974     test(S("abcde"), 5, 1, S("12345"), 2, 2, S("abcde34"));
1975     test(S("abcde"), 5, 1, S("12345"), 2, 3, S("abcde345"));
1976     test(S("abcde"), 5, 1, S("12345"), 2, 4, S("abcde345"));
1977     test(S("abcde"), 5, 1, S("12345"), 4, 0, S("abcde"));
1978     test(S("abcde"), 5, 1, S("12345"), 4, 1, S("abcde5"));
1979     test(S("abcde"), 5, 1, S("12345"), 4, 2, S("abcde5"));
1980     test(S("abcde"), 5, 1, S("12345"), 5, 0, S("abcde"));
1981 }
1982 
1983 template <class S>
1984 void test18()
1985 {
1986     test(S("abcde"), 5, 1, S("12345"), 5, 1, S("abcde"));
1987     test(S("abcde"), 5, 1, S("12345"), 6, 0, S("can't happen"));
1988     test(S("abcde"), 5, 1, S("1234567890"), 0, 0, S("abcde"));
1989     test(S("abcde"), 5, 1, S("1234567890"), 0, 1, S("abcde1"));
1990     test(S("abcde"), 5, 1, S("1234567890"), 0, 5, S("abcde12345"));
1991     test(S("abcde"), 5, 1, S("1234567890"), 0, 9, S("abcde123456789"));
1992     test(S("abcde"), 5, 1, S("1234567890"), 0, 10, S("abcde1234567890"));
1993     test(S("abcde"), 5, 1, S("1234567890"), 0, 11, S("abcde1234567890"));
1994     test(S("abcde"), 5, 1, S("1234567890"), 1, 0, S("abcde"));
1995     test(S("abcde"), 5, 1, S("1234567890"), 1, 1, S("abcde2"));
1996     test(S("abcde"), 5, 1, S("1234567890"), 1, 4, S("abcde2345"));
1997     test(S("abcde"), 5, 1, S("1234567890"), 1, 8, S("abcde23456789"));
1998     test(S("abcde"), 5, 1, S("1234567890"), 1, 9, S("abcde234567890"));
1999     test(S("abcde"), 5, 1, S("1234567890"), 1, 10, S("abcde234567890"));
2000     test(S("abcde"), 5, 1, S("1234567890"), 5, 0, S("abcde"));
2001     test(S("abcde"), 5, 1, S("1234567890"), 5, 1, S("abcde6"));
2002     test(S("abcde"), 5, 1, S("1234567890"), 5, 2, S("abcde67"));
2003     test(S("abcde"), 5, 1, S("1234567890"), 5, 4, S("abcde6789"));
2004     test(S("abcde"), 5, 1, S("1234567890"), 5, 5, S("abcde67890"));
2005     test(S("abcde"), 5, 1, S("1234567890"), 5, 6, S("abcde67890"));
2006     test(S("abcde"), 5, 1, S("1234567890"), 9, 0, S("abcde"));
2007     test(S("abcde"), 5, 1, S("1234567890"), 9, 1, S("abcde0"));
2008     test(S("abcde"), 5, 1, S("1234567890"), 9, 2, S("abcde0"));
2009     test(S("abcde"), 5, 1, S("1234567890"), 10, 0, S("abcde"));
2010     test(S("abcde"), 5, 1, S("1234567890"), 10, 1, S("abcde"));
2011     test(S("abcde"), 5, 1, S("1234567890"), 11, 0, S("can't happen"));
2012     test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 0, S("abcde"));
2013     test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 1, S("abcde1"));
2014     test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
2015     test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
2016     test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
2017     test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
2018     test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 0, S("abcde"));
2019     test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 1, S("abcde2"));
2020     test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 9, S("abcde234567890"));
2021     test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
2022     test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
2023     test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
2024     test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 0, S("abcde"));
2025     test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 1, S("abcde1"));
2026     test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 5, S("abcde12345"));
2027     test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 9, S("abcde123456789"));
2028     test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
2029     test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
2030     test(S("abcde"), 5, 1, S("12345678901234567890"), 19, 0, S("abcde"));
2031     test(S("abcde"), 5, 1, S("12345678901234567890"), 19, 1, S("abcde0"));
2032     test(S("abcde"), 5, 1, S("12345678901234567890"), 19, 2, S("abcde0"));
2033     test(S("abcde"), 5, 1, S("12345678901234567890"), 20, 0, S("abcde"));
2034     test(S("abcde"), 5, 1, S("12345678901234567890"), 20, 1, S("abcde"));
2035     test(S("abcde"), 5, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
2036     test(S("abcde"), 6, 0, S(""), 0, 0, S("can't happen"));
2037     test(S("abcde"), 6, 0, S(""), 0, 1, S("can't happen"));
2038     test(S("abcde"), 6, 0, S(""), 1, 0, S("can't happen"));
2039     test(S("abcde"), 6, 0, S("12345"), 0, 0, S("can't happen"));
2040     test(S("abcde"), 6, 0, S("12345"), 0, 1, S("can't happen"));
2041     test(S("abcde"), 6, 0, S("12345"), 0, 2, S("can't happen"));
2042     test(S("abcde"), 6, 0, S("12345"), 0, 4, S("can't happen"));
2043     test(S("abcde"), 6, 0, S("12345"), 0, 5, S("can't happen"));
2044     test(S("abcde"), 6, 0, S("12345"), 0, 6, S("can't happen"));
2045     test(S("abcde"), 6, 0, S("12345"), 1, 0, S("can't happen"));
2046     test(S("abcde"), 6, 0, S("12345"), 1, 1, S("can't happen"));
2047     test(S("abcde"), 6, 0, S("12345"), 1, 2, S("can't happen"));
2048     test(S("abcde"), 6, 0, S("12345"), 1, 3, S("can't happen"));
2049     test(S("abcde"), 6, 0, S("12345"), 1, 4, S("can't happen"));
2050     test(S("abcde"), 6, 0, S("12345"), 1, 5, S("can't happen"));
2051     test(S("abcde"), 6, 0, S("12345"), 2, 0, S("can't happen"));
2052     test(S("abcde"), 6, 0, S("12345"), 2, 1, S("can't happen"));
2053     test(S("abcde"), 6, 0, S("12345"), 2, 2, S("can't happen"));
2054     test(S("abcde"), 6, 0, S("12345"), 2, 3, S("can't happen"));
2055     test(S("abcde"), 6, 0, S("12345"), 2, 4, S("can't happen"));
2056     test(S("abcde"), 6, 0, S("12345"), 4, 0, S("can't happen"));
2057     test(S("abcde"), 6, 0, S("12345"), 4, 1, S("can't happen"));
2058     test(S("abcde"), 6, 0, S("12345"), 4, 2, S("can't happen"));
2059     test(S("abcde"), 6, 0, S("12345"), 5, 0, S("can't happen"));
2060     test(S("abcde"), 6, 0, S("12345"), 5, 1, S("can't happen"));
2061     test(S("abcde"), 6, 0, S("12345"), 6, 0, S("can't happen"));
2062     test(S("abcde"), 6, 0, S("1234567890"), 0, 0, S("can't happen"));
2063     test(S("abcde"), 6, 0, S("1234567890"), 0, 1, S("can't happen"));
2064     test(S("abcde"), 6, 0, S("1234567890"), 0, 5, S("can't happen"));
2065     test(S("abcde"), 6, 0, S("1234567890"), 0, 9, S("can't happen"));
2066     test(S("abcde"), 6, 0, S("1234567890"), 0, 10, S("can't happen"));
2067     test(S("abcde"), 6, 0, S("1234567890"), 0, 11, S("can't happen"));
2068     test(S("abcde"), 6, 0, S("1234567890"), 1, 0, S("can't happen"));
2069     test(S("abcde"), 6, 0, S("1234567890"), 1, 1, S("can't happen"));
2070     test(S("abcde"), 6, 0, S("1234567890"), 1, 4, S("can't happen"));
2071     test(S("abcde"), 6, 0, S("1234567890"), 1, 8, S("can't happen"));
2072     test(S("abcde"), 6, 0, S("1234567890"), 1, 9, S("can't happen"));
2073     test(S("abcde"), 6, 0, S("1234567890"), 1, 10, S("can't happen"));
2074     test(S("abcde"), 6, 0, S("1234567890"), 5, 0, S("can't happen"));
2075     test(S("abcde"), 6, 0, S("1234567890"), 5, 1, S("can't happen"));
2076     test(S("abcde"), 6, 0, S("1234567890"), 5, 2, S("can't happen"));
2077     test(S("abcde"), 6, 0, S("1234567890"), 5, 4, S("can't happen"));
2078     test(S("abcde"), 6, 0, S("1234567890"), 5, 5, S("can't happen"));
2079     test(S("abcde"), 6, 0, S("1234567890"), 5, 6, S("can't happen"));
2080     test(S("abcde"), 6, 0, S("1234567890"), 9, 0, S("can't happen"));
2081     test(S("abcde"), 6, 0, S("1234567890"), 9, 1, S("can't happen"));
2082     test(S("abcde"), 6, 0, S("1234567890"), 9, 2, S("can't happen"));
2083     test(S("abcde"), 6, 0, S("1234567890"), 10, 0, S("can't happen"));
2084     test(S("abcde"), 6, 0, S("1234567890"), 10, 1, S("can't happen"));
2085     test(S("abcde"), 6, 0, S("1234567890"), 11, 0, S("can't happen"));
2086 }
2087 
2088 template <class S>
2089 void test19()
2090 {
2091     test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 0, S("can't happen"));
2092     test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 1, S("can't happen"));
2093     test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 10, S("can't happen"));
2094     test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 19, S("can't happen"));
2095     test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 20, S("can't happen"));
2096     test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 21, S("can't happen"));
2097     test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 0, S("can't happen"));
2098     test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 1, S("can't happen"));
2099     test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 9, S("can't happen"));
2100     test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 18, S("can't happen"));
2101     test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 19, S("can't happen"));
2102     test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 20, S("can't happen"));
2103     test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 0, S("can't happen"));
2104     test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 1, S("can't happen"));
2105     test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 5, S("can't happen"));
2106     test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 9, S("can't happen"));
2107     test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 10, S("can't happen"));
2108     test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 11, S("can't happen"));
2109     test(S("abcde"), 6, 0, S("12345678901234567890"), 19, 0, S("can't happen"));
2110     test(S("abcde"), 6, 0, S("12345678901234567890"), 19, 1, S("can't happen"));
2111     test(S("abcde"), 6, 0, S("12345678901234567890"), 19, 2, S("can't happen"));
2112     test(S("abcde"), 6, 0, S("12345678901234567890"), 20, 0, S("can't happen"));
2113     test(S("abcde"), 6, 0, S("12345678901234567890"), 20, 1, S("can't happen"));
2114     test(S("abcde"), 6, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
2115     test(S("abcdefghij"), 0, 0, S(""), 0, 0, S("abcdefghij"));
2116     test(S("abcdefghij"), 0, 0, S(""), 0, 1, S("abcdefghij"));
2117     test(S("abcdefghij"), 0, 0, S(""), 1, 0, S("can't happen"));
2118     test(S("abcdefghij"), 0, 0, S("12345"), 0, 0, S("abcdefghij"));
2119     test(S("abcdefghij"), 0, 0, S("12345"), 0, 1, S("1abcdefghij"));
2120     test(S("abcdefghij"), 0, 0, S("12345"), 0, 2, S("12abcdefghij"));
2121     test(S("abcdefghij"), 0, 0, S("12345"), 0, 4, S("1234abcdefghij"));
2122     test(S("abcdefghij"), 0, 0, S("12345"), 0, 5, S("12345abcdefghij"));
2123     test(S("abcdefghij"), 0, 0, S("12345"), 0, 6, S("12345abcdefghij"));
2124     test(S("abcdefghij"), 0, 0, S("12345"), 1, 0, S("abcdefghij"));
2125     test(S("abcdefghij"), 0, 0, S("12345"), 1, 1, S("2abcdefghij"));
2126     test(S("abcdefghij"), 0, 0, S("12345"), 1, 2, S("23abcdefghij"));
2127     test(S("abcdefghij"), 0, 0, S("12345"), 1, 3, S("234abcdefghij"));
2128     test(S("abcdefghij"), 0, 0, S("12345"), 1, 4, S("2345abcdefghij"));
2129     test(S("abcdefghij"), 0, 0, S("12345"), 1, 5, S("2345abcdefghij"));
2130     test(S("abcdefghij"), 0, 0, S("12345"), 2, 0, S("abcdefghij"));
2131     test(S("abcdefghij"), 0, 0, S("12345"), 2, 1, S("3abcdefghij"));
2132     test(S("abcdefghij"), 0, 0, S("12345"), 2, 2, S("34abcdefghij"));
2133     test(S("abcdefghij"), 0, 0, S("12345"), 2, 3, S("345abcdefghij"));
2134     test(S("abcdefghij"), 0, 0, S("12345"), 2, 4, S("345abcdefghij"));
2135     test(S("abcdefghij"), 0, 0, S("12345"), 4, 0, S("abcdefghij"));
2136     test(S("abcdefghij"), 0, 0, S("12345"), 4, 1, S("5abcdefghij"));
2137     test(S("abcdefghij"), 0, 0, S("12345"), 4, 2, S("5abcdefghij"));
2138     test(S("abcdefghij"), 0, 0, S("12345"), 5, 0, S("abcdefghij"));
2139     test(S("abcdefghij"), 0, 0, S("12345"), 5, 1, S("abcdefghij"));
2140     test(S("abcdefghij"), 0, 0, S("12345"), 6, 0, S("can't happen"));
2141     test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 0, S("abcdefghij"));
2142     test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 1, S("1abcdefghij"));
2143     test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 5, S("12345abcdefghij"));
2144     test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 9, S("123456789abcdefghij"));
2145     test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 10, S("1234567890abcdefghij"));
2146     test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 11, S("1234567890abcdefghij"));
2147     test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 0, S("abcdefghij"));
2148     test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 1, S("2abcdefghij"));
2149     test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 4, S("2345abcdefghij"));
2150     test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 8, S("23456789abcdefghij"));
2151     test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 9, S("234567890abcdefghij"));
2152     test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 10, S("234567890abcdefghij"));
2153     test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 0, S("abcdefghij"));
2154     test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 1, S("6abcdefghij"));
2155     test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 2, S("67abcdefghij"));
2156     test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 4, S("6789abcdefghij"));
2157     test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 5, S("67890abcdefghij"));
2158     test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 6, S("67890abcdefghij"));
2159     test(S("abcdefghij"), 0, 0, S("1234567890"), 9, 0, S("abcdefghij"));
2160     test(S("abcdefghij"), 0, 0, S("1234567890"), 9, 1, S("0abcdefghij"));
2161     test(S("abcdefghij"), 0, 0, S("1234567890"), 9, 2, S("0abcdefghij"));
2162     test(S("abcdefghij"), 0, 0, S("1234567890"), 10, 0, S("abcdefghij"));
2163     test(S("abcdefghij"), 0, 0, S("1234567890"), 10, 1, S("abcdefghij"));
2164     test(S("abcdefghij"), 0, 0, S("1234567890"), 11, 0, S("can't happen"));
2165     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
2166     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 1, S("1abcdefghij"));
2167     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghij"));
2168     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghij"));
2169     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghij"));
2170     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghij"));
2171     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
2172     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 1, S("2abcdefghij"));
2173     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghij"));
2174     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghij"));
2175     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghij"));
2176     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghij"));
2177     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
2178     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 1, S("1abcdefghij"));
2179     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 5, S("12345abcdefghij"));
2180     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghij"));
2181     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghij"));
2182     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghij"));
2183     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
2184     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 19, 1, S("0abcdefghij"));
2185     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 19, 2, S("0abcdefghij"));
2186     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
2187     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
2188     test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
2189     test(S("abcdefghij"), 0, 1, S(""), 0, 0, S("bcdefghij"));
2190     test(S("abcdefghij"), 0, 1, S(""), 0, 1, S("bcdefghij"));
2191 }
2192 
2193 template <class S>
2194 void test20()
2195 {
2196     test(S("abcdefghij"), 0, 1, S(""), 1, 0, S("can't happen"));
2197     test(S("abcdefghij"), 0, 1, S("12345"), 0, 0, S("bcdefghij"));
2198     test(S("abcdefghij"), 0, 1, S("12345"), 0, 1, S("1bcdefghij"));
2199     test(S("abcdefghij"), 0, 1, S("12345"), 0, 2, S("12bcdefghij"));
2200     test(S("abcdefghij"), 0, 1, S("12345"), 0, 4, S("1234bcdefghij"));
2201     test(S("abcdefghij"), 0, 1, S("12345"), 0, 5, S("12345bcdefghij"));
2202     test(S("abcdefghij"), 0, 1, S("12345"), 0, 6, S("12345bcdefghij"));
2203     test(S("abcdefghij"), 0, 1, S("12345"), 1, 0, S("bcdefghij"));
2204     test(S("abcdefghij"), 0, 1, S("12345"), 1, 1, S("2bcdefghij"));
2205     test(S("abcdefghij"), 0, 1, S("12345"), 1, 2, S("23bcdefghij"));
2206     test(S("abcdefghij"), 0, 1, S("12345"), 1, 3, S("234bcdefghij"));
2207     test(S("abcdefghij"), 0, 1, S("12345"), 1, 4, S("2345bcdefghij"));
2208     test(S("abcdefghij"), 0, 1, S("12345"), 1, 5, S("2345bcdefghij"));
2209     test(S("abcdefghij"), 0, 1, S("12345"), 2, 0, S("bcdefghij"));
2210     test(S("abcdefghij"), 0, 1, S("12345"), 2, 1, S("3bcdefghij"));
2211     test(S("abcdefghij"), 0, 1, S("12345"), 2, 2, S("34bcdefghij"));
2212     test(S("abcdefghij"), 0, 1, S("12345"), 2, 3, S("345bcdefghij"));
2213     test(S("abcdefghij"), 0, 1, S("12345"), 2, 4, S("345bcdefghij"));
2214     test(S("abcdefghij"), 0, 1, S("12345"), 4, 0, S("bcdefghij"));
2215     test(S("abcdefghij"), 0, 1, S("12345"), 4, 1, S("5bcdefghij"));
2216     test(S("abcdefghij"), 0, 1, S("12345"), 4, 2, S("5bcdefghij"));
2217     test(S("abcdefghij"), 0, 1, S("12345"), 5, 0, S("bcdefghij"));
2218     test(S("abcdefghij"), 0, 1, S("12345"), 5, 1, S("bcdefghij"));
2219     test(S("abcdefghij"), 0, 1, S("12345"), 6, 0, S("can't happen"));
2220     test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 0, S("bcdefghij"));
2221     test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 1, S("1bcdefghij"));
2222     test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 5, S("12345bcdefghij"));
2223     test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 9, S("123456789bcdefghij"));
2224     test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 10, S("1234567890bcdefghij"));
2225     test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 11, S("1234567890bcdefghij"));
2226     test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 0, S("bcdefghij"));
2227     test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 1, S("2bcdefghij"));
2228     test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 4, S("2345bcdefghij"));
2229     test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 8, S("23456789bcdefghij"));
2230     test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 9, S("234567890bcdefghij"));
2231     test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 10, S("234567890bcdefghij"));
2232     test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 0, S("bcdefghij"));
2233     test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 1, S("6bcdefghij"));
2234     test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 2, S("67bcdefghij"));
2235     test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 4, S("6789bcdefghij"));
2236     test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 5, S("67890bcdefghij"));
2237     test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 6, S("67890bcdefghij"));
2238     test(S("abcdefghij"), 0, 1, S("1234567890"), 9, 0, S("bcdefghij"));
2239     test(S("abcdefghij"), 0, 1, S("1234567890"), 9, 1, S("0bcdefghij"));
2240     test(S("abcdefghij"), 0, 1, S("1234567890"), 9, 2, S("0bcdefghij"));
2241     test(S("abcdefghij"), 0, 1, S("1234567890"), 10, 0, S("bcdefghij"));
2242     test(S("abcdefghij"), 0, 1, S("1234567890"), 10, 1, S("bcdefghij"));
2243     test(S("abcdefghij"), 0, 1, S("1234567890"), 11, 0, S("can't happen"));
2244     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 0, S("bcdefghij"));
2245     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 1, S("1bcdefghij"));
2246     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890bcdefghij"));
2247     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789bcdefghij"));
2248     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890bcdefghij"));
2249     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890bcdefghij"));
2250     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 0, S("bcdefghij"));
2251     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 1, S("2bcdefghij"));
2252     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 9, S("234567890bcdefghij"));
2253     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789bcdefghij"));
2254     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890bcdefghij"));
2255     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890bcdefghij"));
2256     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 0, S("bcdefghij"));
2257     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 1, S("1bcdefghij"));
2258     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 5, S("12345bcdefghij"));
2259     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 9, S("123456789bcdefghij"));
2260     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890bcdefghij"));
2261     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890bcdefghij"));
2262     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 19, 0, S("bcdefghij"));
2263     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 19, 1, S("0bcdefghij"));
2264     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 19, 2, S("0bcdefghij"));
2265     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 20, 0, S("bcdefghij"));
2266     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 20, 1, S("bcdefghij"));
2267     test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
2268     test(S("abcdefghij"), 0, 5, S(""), 0, 0, S("fghij"));
2269     test(S("abcdefghij"), 0, 5, S(""), 0, 1, S("fghij"));
2270     test(S("abcdefghij"), 0, 5, S(""), 1, 0, S("can't happen"));
2271     test(S("abcdefghij"), 0, 5, S("12345"), 0, 0, S("fghij"));
2272     test(S("abcdefghij"), 0, 5, S("12345"), 0, 1, S("1fghij"));
2273     test(S("abcdefghij"), 0, 5, S("12345"), 0, 2, S("12fghij"));
2274     test(S("abcdefghij"), 0, 5, S("12345"), 0, 4, S("1234fghij"));
2275     test(S("abcdefghij"), 0, 5, S("12345"), 0, 5, S("12345fghij"));
2276     test(S("abcdefghij"), 0, 5, S("12345"), 0, 6, S("12345fghij"));
2277     test(S("abcdefghij"), 0, 5, S("12345"), 1, 0, S("fghij"));
2278     test(S("abcdefghij"), 0, 5, S("12345"), 1, 1, S("2fghij"));
2279     test(S("abcdefghij"), 0, 5, S("12345"), 1, 2, S("23fghij"));
2280     test(S("abcdefghij"), 0, 5, S("12345"), 1, 3, S("234fghij"));
2281     test(S("abcdefghij"), 0, 5, S("12345"), 1, 4, S("2345fghij"));
2282     test(S("abcdefghij"), 0, 5, S("12345"), 1, 5, S("2345fghij"));
2283     test(S("abcdefghij"), 0, 5, S("12345"), 2, 0, S("fghij"));
2284     test(S("abcdefghij"), 0, 5, S("12345"), 2, 1, S("3fghij"));
2285     test(S("abcdefghij"), 0, 5, S("12345"), 2, 2, S("34fghij"));
2286     test(S("abcdefghij"), 0, 5, S("12345"), 2, 3, S("345fghij"));
2287     test(S("abcdefghij"), 0, 5, S("12345"), 2, 4, S("345fghij"));
2288     test(S("abcdefghij"), 0, 5, S("12345"), 4, 0, S("fghij"));
2289     test(S("abcdefghij"), 0, 5, S("12345"), 4, 1, S("5fghij"));
2290     test(S("abcdefghij"), 0, 5, S("12345"), 4, 2, S("5fghij"));
2291     test(S("abcdefghij"), 0, 5, S("12345"), 5, 0, S("fghij"));
2292     test(S("abcdefghij"), 0, 5, S("12345"), 5, 1, S("fghij"));
2293     test(S("abcdefghij"), 0, 5, S("12345"), 6, 0, S("can't happen"));
2294     test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 0, S("fghij"));
2295     test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 1, S("1fghij"));
2296 }
2297 
2298 template <class S>
2299 void test21()
2300 {
2301     test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 5, S("12345fghij"));
2302     test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 9, S("123456789fghij"));
2303     test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 10, S("1234567890fghij"));
2304     test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 11, S("1234567890fghij"));
2305     test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 0, S("fghij"));
2306     test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 1, S("2fghij"));
2307     test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 4, S("2345fghij"));
2308     test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 8, S("23456789fghij"));
2309     test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 9, S("234567890fghij"));
2310     test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 10, S("234567890fghij"));
2311     test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 0, S("fghij"));
2312     test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 1, S("6fghij"));
2313     test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 2, S("67fghij"));
2314     test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 4, S("6789fghij"));
2315     test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 5, S("67890fghij"));
2316     test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 6, S("67890fghij"));
2317     test(S("abcdefghij"), 0, 5, S("1234567890"), 9, 0, S("fghij"));
2318     test(S("abcdefghij"), 0, 5, S("1234567890"), 9, 1, S("0fghij"));
2319     test(S("abcdefghij"), 0, 5, S("1234567890"), 9, 2, S("0fghij"));
2320     test(S("abcdefghij"), 0, 5, S("1234567890"), 10, 0, S("fghij"));
2321     test(S("abcdefghij"), 0, 5, S("1234567890"), 10, 1, S("fghij"));
2322     test(S("abcdefghij"), 0, 5, S("1234567890"), 11, 0, S("can't happen"));
2323     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 0, S("fghij"));
2324     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 1, S("1fghij"));
2325     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 10, S("1234567890fghij"));
2326     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 19, S("1234567890123456789fghij"));
2327     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 20, S("12345678901234567890fghij"));
2328     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 21, S("12345678901234567890fghij"));
2329     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 0, S("fghij"));
2330     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 1, S("2fghij"));
2331     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 9, S("234567890fghij"));
2332     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 18, S("234567890123456789fghij"));
2333     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 19, S("2345678901234567890fghij"));
2334     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 20, S("2345678901234567890fghij"));
2335     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 0, S("fghij"));
2336     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 1, S("1fghij"));
2337     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 5, S("12345fghij"));
2338     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 9, S("123456789fghij"));
2339     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 10, S("1234567890fghij"));
2340     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 11, S("1234567890fghij"));
2341     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 19, 0, S("fghij"));
2342     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 19, 1, S("0fghij"));
2343     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 19, 2, S("0fghij"));
2344     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 20, 0, S("fghij"));
2345     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 20, 1, S("fghij"));
2346     test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
2347     test(S("abcdefghij"), 0, 9, S(""), 0, 0, S("j"));
2348     test(S("abcdefghij"), 0, 9, S(""), 0, 1, S("j"));
2349     test(S("abcdefghij"), 0, 9, S(""), 1, 0, S("can't happen"));
2350     test(S("abcdefghij"), 0, 9, S("12345"), 0, 0, S("j"));
2351     test(S("abcdefghij"), 0, 9, S("12345"), 0, 1, S("1j"));
2352     test(S("abcdefghij"), 0, 9, S("12345"), 0, 2, S("12j"));
2353     test(S("abcdefghij"), 0, 9, S("12345"), 0, 4, S("1234j"));
2354     test(S("abcdefghij"), 0, 9, S("12345"), 0, 5, S("12345j"));
2355     test(S("abcdefghij"), 0, 9, S("12345"), 0, 6, S("12345j"));
2356     test(S("abcdefghij"), 0, 9, S("12345"), 1, 0, S("j"));
2357     test(S("abcdefghij"), 0, 9, S("12345"), 1, 1, S("2j"));
2358     test(S("abcdefghij"), 0, 9, S("12345"), 1, 2, S("23j"));
2359     test(S("abcdefghij"), 0, 9, S("12345"), 1, 3, S("234j"));
2360     test(S("abcdefghij"), 0, 9, S("12345"), 1, 4, S("2345j"));
2361     test(S("abcdefghij"), 0, 9, S("12345"), 1, 5, S("2345j"));
2362     test(S("abcdefghij"), 0, 9, S("12345"), 2, 0, S("j"));
2363     test(S("abcdefghij"), 0, 9, S("12345"), 2, 1, S("3j"));
2364     test(S("abcdefghij"), 0, 9, S("12345"), 2, 2, S("34j"));
2365     test(S("abcdefghij"), 0, 9, S("12345"), 2, 3, S("345j"));
2366     test(S("abcdefghij"), 0, 9, S("12345"), 2, 4, S("345j"));
2367     test(S("abcdefghij"), 0, 9, S("12345"), 4, 0, S("j"));
2368     test(S("abcdefghij"), 0, 9, S("12345"), 4, 1, S("5j"));
2369     test(S("abcdefghij"), 0, 9, S("12345"), 4, 2, S("5j"));
2370     test(S("abcdefghij"), 0, 9, S("12345"), 5, 0, S("j"));
2371     test(S("abcdefghij"), 0, 9, S("12345"), 5, 1, S("j"));
2372     test(S("abcdefghij"), 0, 9, S("12345"), 6, 0, S("can't happen"));
2373     test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 0, S("j"));
2374     test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 1, S("1j"));
2375     test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 5, S("12345j"));
2376     test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 9, S("123456789j"));
2377     test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 10, S("1234567890j"));
2378     test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 11, S("1234567890j"));
2379     test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 0, S("j"));
2380     test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 1, S("2j"));
2381     test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 4, S("2345j"));
2382     test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 8, S("23456789j"));
2383     test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 9, S("234567890j"));
2384     test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 10, S("234567890j"));
2385     test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 0, S("j"));
2386     test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 1, S("6j"));
2387     test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 2, S("67j"));
2388     test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 4, S("6789j"));
2389     test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 5, S("67890j"));
2390     test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 6, S("67890j"));
2391     test(S("abcdefghij"), 0, 9, S("1234567890"), 9, 0, S("j"));
2392     test(S("abcdefghij"), 0, 9, S("1234567890"), 9, 1, S("0j"));
2393     test(S("abcdefghij"), 0, 9, S("1234567890"), 9, 2, S("0j"));
2394     test(S("abcdefghij"), 0, 9, S("1234567890"), 10, 0, S("j"));
2395     test(S("abcdefghij"), 0, 9, S("1234567890"), 10, 1, S("j"));
2396     test(S("abcdefghij"), 0, 9, S("1234567890"), 11, 0, S("can't happen"));
2397     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 0, S("j"));
2398     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 1, S("1j"));
2399     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 10, S("1234567890j"));
2400     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 19, S("1234567890123456789j"));
2401 }
2402 
2403 template <class S>
2404 void test22()
2405 {
2406     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 20, S("12345678901234567890j"));
2407     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 21, S("12345678901234567890j"));
2408     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 0, S("j"));
2409     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 1, S("2j"));
2410     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 9, S("234567890j"));
2411     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 18, S("234567890123456789j"));
2412     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 19, S("2345678901234567890j"));
2413     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 20, S("2345678901234567890j"));
2414     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 0, S("j"));
2415     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 1, S("1j"));
2416     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 5, S("12345j"));
2417     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 9, S("123456789j"));
2418     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 10, S("1234567890j"));
2419     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 11, S("1234567890j"));
2420     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 19, 0, S("j"));
2421     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 19, 1, S("0j"));
2422     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 19, 2, S("0j"));
2423     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 20, 0, S("j"));
2424     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 20, 1, S("j"));
2425     test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 21, 0, S("can't happen"));
2426     test(S("abcdefghij"), 0, 10, S(""), 0, 0, S(""));
2427     test(S("abcdefghij"), 0, 10, S(""), 0, 1, S(""));
2428     test(S("abcdefghij"), 0, 10, S(""), 1, 0, S("can't happen"));
2429     test(S("abcdefghij"), 0, 10, S("12345"), 0, 0, S(""));
2430     test(S("abcdefghij"), 0, 10, S("12345"), 0, 1, S("1"));
2431     test(S("abcdefghij"), 0, 10, S("12345"), 0, 2, S("12"));
2432     test(S("abcdefghij"), 0, 10, S("12345"), 0, 4, S("1234"));
2433     test(S("abcdefghij"), 0, 10, S("12345"), 0, 5, S("12345"));
2434     test(S("abcdefghij"), 0, 10, S("12345"), 0, 6, S("12345"));
2435     test(S("abcdefghij"), 0, 10, S("12345"), 1, 0, S(""));
2436     test(S("abcdefghij"), 0, 10, S("12345"), 1, 1, S("2"));
2437     test(S("abcdefghij"), 0, 10, S("12345"), 1, 2, S("23"));
2438     test(S("abcdefghij"), 0, 10, S("12345"), 1, 3, S("234"));
2439     test(S("abcdefghij"), 0, 10, S("12345"), 1, 4, S("2345"));
2440     test(S("abcdefghij"), 0, 10, S("12345"), 1, 5, S("2345"));
2441     test(S("abcdefghij"), 0, 10, S("12345"), 2, 0, S(""));
2442     test(S("abcdefghij"), 0, 10, S("12345"), 2, 1, S("3"));
2443     test(S("abcdefghij"), 0, 10, S("12345"), 2, 2, S("34"));
2444     test(S("abcdefghij"), 0, 10, S("12345"), 2, 3, S("345"));
2445     test(S("abcdefghij"), 0, 10, S("12345"), 2, 4, S("345"));
2446     test(S("abcdefghij"), 0, 10, S("12345"), 4, 0, S(""));
2447     test(S("abcdefghij"), 0, 10, S("12345"), 4, 1, S("5"));
2448     test(S("abcdefghij"), 0, 10, S("12345"), 4, 2, S("5"));
2449     test(S("abcdefghij"), 0, 10, S("12345"), 5, 0, S(""));
2450     test(S("abcdefghij"), 0, 10, S("12345"), 5, 1, S(""));
2451     test(S("abcdefghij"), 0, 10, S("12345"), 6, 0, S("can't happen"));
2452     test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 0, S(""));
2453     test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 1, S("1"));
2454     test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 5, S("12345"));
2455     test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 9, S("123456789"));
2456     test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 10, S("1234567890"));
2457     test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 11, S("1234567890"));
2458     test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 0, S(""));
2459     test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 1, S("2"));
2460     test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 4, S("2345"));
2461     test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 8, S("23456789"));
2462     test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 9, S("234567890"));
2463     test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 10, S("234567890"));
2464     test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 0, S(""));
2465     test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 1, S("6"));
2466     test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 2, S("67"));
2467     test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 4, S("6789"));
2468     test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 5, S("67890"));
2469     test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 6, S("67890"));
2470     test(S("abcdefghij"), 0, 10, S("1234567890"), 9, 0, S(""));
2471     test(S("abcdefghij"), 0, 10, S("1234567890"), 9, 1, S("0"));
2472     test(S("abcdefghij"), 0, 10, S("1234567890"), 9, 2, S("0"));
2473     test(S("abcdefghij"), 0, 10, S("1234567890"), 10, 0, S(""));
2474     test(S("abcdefghij"), 0, 10, S("1234567890"), 10, 1, S(""));
2475     test(S("abcdefghij"), 0, 10, S("1234567890"), 11, 0, S("can't happen"));
2476     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 0, S(""));
2477     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 1, S("1"));
2478     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 10, S("1234567890"));
2479     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
2480     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
2481     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
2482     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 0, S(""));
2483     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 1, S("2"));
2484     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 9, S("234567890"));
2485     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 18, S("234567890123456789"));
2486     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
2487     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
2488     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 0, S(""));
2489     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 1, S("1"));
2490     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 5, S("12345"));
2491     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 9, S("123456789"));
2492     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 10, S("1234567890"));
2493     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 11, S("1234567890"));
2494     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 19, 0, S(""));
2495     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 19, 1, S("0"));
2496     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 19, 2, S("0"));
2497     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 20, 0, S(""));
2498     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 20, 1, S(""));
2499     test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 21, 0, S("can't happen"));
2500     test(S("abcdefghij"), 0, 11, S(""), 0, 0, S(""));
2501     test(S("abcdefghij"), 0, 11, S(""), 0, 1, S(""));
2502     test(S("abcdefghij"), 0, 11, S(""), 1, 0, S("can't happen"));
2503     test(S("abcdefghij"), 0, 11, S("12345"), 0, 0, S(""));
2504     test(S("abcdefghij"), 0, 11, S("12345"), 0, 1, S("1"));
2505     test(S("abcdefghij"), 0, 11, S("12345"), 0, 2, S("12"));
2506 }
2507 
2508 template <class S>
2509 void test23()
2510 {
2511     test(S("abcdefghij"), 0, 11, S("12345"), 0, 4, S("1234"));
2512     test(S("abcdefghij"), 0, 11, S("12345"), 0, 5, S("12345"));
2513     test(S("abcdefghij"), 0, 11, S("12345"), 0, 6, S("12345"));
2514     test(S("abcdefghij"), 0, 11, S("12345"), 1, 0, S(""));
2515     test(S("abcdefghij"), 0, 11, S("12345"), 1, 1, S("2"));
2516     test(S("abcdefghij"), 0, 11, S("12345"), 1, 2, S("23"));
2517     test(S("abcdefghij"), 0, 11, S("12345"), 1, 3, S("234"));
2518     test(S("abcdefghij"), 0, 11, S("12345"), 1, 4, S("2345"));
2519     test(S("abcdefghij"), 0, 11, S("12345"), 1, 5, S("2345"));
2520     test(S("abcdefghij"), 0, 11, S("12345"), 2, 0, S(""));
2521     test(S("abcdefghij"), 0, 11, S("12345"), 2, 1, S("3"));
2522     test(S("abcdefghij"), 0, 11, S("12345"), 2, 2, S("34"));
2523     test(S("abcdefghij"), 0, 11, S("12345"), 2, 3, S("345"));
2524     test(S("abcdefghij"), 0, 11, S("12345"), 2, 4, S("345"));
2525     test(S("abcdefghij"), 0, 11, S("12345"), 4, 0, S(""));
2526     test(S("abcdefghij"), 0, 11, S("12345"), 4, 1, S("5"));
2527     test(S("abcdefghij"), 0, 11, S("12345"), 4, 2, S("5"));
2528     test(S("abcdefghij"), 0, 11, S("12345"), 5, 0, S(""));
2529     test(S("abcdefghij"), 0, 11, S("12345"), 5, 1, S(""));
2530     test(S("abcdefghij"), 0, 11, S("12345"), 6, 0, S("can't happen"));
2531     test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 0, S(""));
2532     test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 1, S("1"));
2533     test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 5, S("12345"));
2534     test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 9, S("123456789"));
2535     test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 10, S("1234567890"));
2536     test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 11, S("1234567890"));
2537     test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 0, S(""));
2538     test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 1, S("2"));
2539     test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 4, S("2345"));
2540     test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 8, S("23456789"));
2541     test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 9, S("234567890"));
2542     test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 10, S("234567890"));
2543     test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 0, S(""));
2544     test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 1, S("6"));
2545     test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 2, S("67"));
2546     test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 4, S("6789"));
2547     test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 5, S("67890"));
2548     test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 6, S("67890"));
2549     test(S("abcdefghij"), 0, 11, S("1234567890"), 9, 0, S(""));
2550     test(S("abcdefghij"), 0, 11, S("1234567890"), 9, 1, S("0"));
2551     test(S("abcdefghij"), 0, 11, S("1234567890"), 9, 2, S("0"));
2552     test(S("abcdefghij"), 0, 11, S("1234567890"), 10, 0, S(""));
2553     test(S("abcdefghij"), 0, 11, S("1234567890"), 10, 1, S(""));
2554     test(S("abcdefghij"), 0, 11, S("1234567890"), 11, 0, S("can't happen"));
2555     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 0, S(""));
2556     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 1, S("1"));
2557     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 10, S("1234567890"));
2558     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
2559     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
2560     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
2561     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 0, S(""));
2562     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 1, S("2"));
2563     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 9, S("234567890"));
2564     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 18, S("234567890123456789"));
2565     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
2566     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
2567     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 0, S(""));
2568     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 1, S("1"));
2569     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 5, S("12345"));
2570     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 9, S("123456789"));
2571     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 10, S("1234567890"));
2572     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 11, S("1234567890"));
2573     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 19, 0, S(""));
2574     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 19, 1, S("0"));
2575     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 19, 2, S("0"));
2576     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 20, 0, S(""));
2577     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 20, 1, S(""));
2578     test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 21, 0, S("can't happen"));
2579     test(S("abcdefghij"), 1, 0, S(""), 0, 0, S("abcdefghij"));
2580     test(S("abcdefghij"), 1, 0, S(""), 0, 1, S("abcdefghij"));
2581     test(S("abcdefghij"), 1, 0, S(""), 1, 0, S("can't happen"));
2582     test(S("abcdefghij"), 1, 0, S("12345"), 0, 0, S("abcdefghij"));
2583     test(S("abcdefghij"), 1, 0, S("12345"), 0, 1, S("a1bcdefghij"));
2584     test(S("abcdefghij"), 1, 0, S("12345"), 0, 2, S("a12bcdefghij"));
2585     test(S("abcdefghij"), 1, 0, S("12345"), 0, 4, S("a1234bcdefghij"));
2586     test(S("abcdefghij"), 1, 0, S("12345"), 0, 5, S("a12345bcdefghij"));
2587     test(S("abcdefghij"), 1, 0, S("12345"), 0, 6, S("a12345bcdefghij"));
2588     test(S("abcdefghij"), 1, 0, S("12345"), 1, 0, S("abcdefghij"));
2589     test(S("abcdefghij"), 1, 0, S("12345"), 1, 1, S("a2bcdefghij"));
2590     test(S("abcdefghij"), 1, 0, S("12345"), 1, 2, S("a23bcdefghij"));
2591     test(S("abcdefghij"), 1, 0, S("12345"), 1, 3, S("a234bcdefghij"));
2592     test(S("abcdefghij"), 1, 0, S("12345"), 1, 4, S("a2345bcdefghij"));
2593     test(S("abcdefghij"), 1, 0, S("12345"), 1, 5, S("a2345bcdefghij"));
2594     test(S("abcdefghij"), 1, 0, S("12345"), 2, 0, S("abcdefghij"));
2595     test(S("abcdefghij"), 1, 0, S("12345"), 2, 1, S("a3bcdefghij"));
2596     test(S("abcdefghij"), 1, 0, S("12345"), 2, 2, S("a34bcdefghij"));
2597     test(S("abcdefghij"), 1, 0, S("12345"), 2, 3, S("a345bcdefghij"));
2598     test(S("abcdefghij"), 1, 0, S("12345"), 2, 4, S("a345bcdefghij"));
2599     test(S("abcdefghij"), 1, 0, S("12345"), 4, 0, S("abcdefghij"));
2600     test(S("abcdefghij"), 1, 0, S("12345"), 4, 1, S("a5bcdefghij"));
2601     test(S("abcdefghij"), 1, 0, S("12345"), 4, 2, S("a5bcdefghij"));
2602     test(S("abcdefghij"), 1, 0, S("12345"), 5, 0, S("abcdefghij"));
2603     test(S("abcdefghij"), 1, 0, S("12345"), 5, 1, S("abcdefghij"));
2604     test(S("abcdefghij"), 1, 0, S("12345"), 6, 0, S("can't happen"));
2605     test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 0, S("abcdefghij"));
2606     test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 1, S("a1bcdefghij"));
2607     test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 5, S("a12345bcdefghij"));
2608     test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 9, S("a123456789bcdefghij"));
2609     test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 10, S("a1234567890bcdefghij"));
2610     test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 11, S("a1234567890bcdefghij"));
2611 }
2612 
2613 template <class S>
2614 void test24()
2615 {
2616     test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 0, S("abcdefghij"));
2617     test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 1, S("a2bcdefghij"));
2618     test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 4, S("a2345bcdefghij"));
2619     test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 8, S("a23456789bcdefghij"));
2620     test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 9, S("a234567890bcdefghij"));
2621     test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 10, S("a234567890bcdefghij"));
2622     test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 0, S("abcdefghij"));
2623     test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 1, S("a6bcdefghij"));
2624     test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 2, S("a67bcdefghij"));
2625     test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 4, S("a6789bcdefghij"));
2626     test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 5, S("a67890bcdefghij"));
2627     test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 6, S("a67890bcdefghij"));
2628     test(S("abcdefghij"), 1, 0, S("1234567890"), 9, 0, S("abcdefghij"));
2629     test(S("abcdefghij"), 1, 0, S("1234567890"), 9, 1, S("a0bcdefghij"));
2630     test(S("abcdefghij"), 1, 0, S("1234567890"), 9, 2, S("a0bcdefghij"));
2631     test(S("abcdefghij"), 1, 0, S("1234567890"), 10, 0, S("abcdefghij"));
2632     test(S("abcdefghij"), 1, 0, S("1234567890"), 10, 1, S("abcdefghij"));
2633     test(S("abcdefghij"), 1, 0, S("1234567890"), 11, 0, S("can't happen"));
2634     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
2635     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 1, S("a1bcdefghij"));
2636     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghij"));
2637     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghij"));
2638     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghij"));
2639     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghij"));
2640     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
2641     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 1, S("a2bcdefghij"));
2642     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 9, S("a234567890bcdefghij"));
2643     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghij"));
2644     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghij"));
2645     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghij"));
2646     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
2647     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 1, S("a1bcdefghij"));
2648     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 5, S("a12345bcdefghij"));
2649     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 9, S("a123456789bcdefghij"));
2650     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghij"));
2651     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghij"));
2652     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
2653     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 19, 1, S("a0bcdefghij"));
2654     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 19, 2, S("a0bcdefghij"));
2655     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
2656     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
2657     test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
2658     test(S("abcdefghij"), 1, 1, S(""), 0, 0, S("acdefghij"));
2659     test(S("abcdefghij"), 1, 1, S(""), 0, 1, S("acdefghij"));
2660     test(S("abcdefghij"), 1, 1, S(""), 1, 0, S("can't happen"));
2661     test(S("abcdefghij"), 1, 1, S("12345"), 0, 0, S("acdefghij"));
2662     test(S("abcdefghij"), 1, 1, S("12345"), 0, 1, S("a1cdefghij"));
2663     test(S("abcdefghij"), 1, 1, S("12345"), 0, 2, S("a12cdefghij"));
2664     test(S("abcdefghij"), 1, 1, S("12345"), 0, 4, S("a1234cdefghij"));
2665     test(S("abcdefghij"), 1, 1, S("12345"), 0, 5, S("a12345cdefghij"));
2666     test(S("abcdefghij"), 1, 1, S("12345"), 0, 6, S("a12345cdefghij"));
2667     test(S("abcdefghij"), 1, 1, S("12345"), 1, 0, S("acdefghij"));
2668     test(S("abcdefghij"), 1, 1, S("12345"), 1, 1, S("a2cdefghij"));
2669     test(S("abcdefghij"), 1, 1, S("12345"), 1, 2, S("a23cdefghij"));
2670     test(S("abcdefghij"), 1, 1, S("12345"), 1, 3, S("a234cdefghij"));
2671     test(S("abcdefghij"), 1, 1, S("12345"), 1, 4, S("a2345cdefghij"));
2672     test(S("abcdefghij"), 1, 1, S("12345"), 1, 5, S("a2345cdefghij"));
2673     test(S("abcdefghij"), 1, 1, S("12345"), 2, 0, S("acdefghij"));
2674     test(S("abcdefghij"), 1, 1, S("12345"), 2, 1, S("a3cdefghij"));
2675     test(S("abcdefghij"), 1, 1, S("12345"), 2, 2, S("a34cdefghij"));
2676     test(S("abcdefghij"), 1, 1, S("12345"), 2, 3, S("a345cdefghij"));
2677     test(S("abcdefghij"), 1, 1, S("12345"), 2, 4, S("a345cdefghij"));
2678     test(S("abcdefghij"), 1, 1, S("12345"), 4, 0, S("acdefghij"));
2679     test(S("abcdefghij"), 1, 1, S("12345"), 4, 1, S("a5cdefghij"));
2680     test(S("abcdefghij"), 1, 1, S("12345"), 4, 2, S("a5cdefghij"));
2681     test(S("abcdefghij"), 1, 1, S("12345"), 5, 0, S("acdefghij"));
2682     test(S("abcdefghij"), 1, 1, S("12345"), 5, 1, S("acdefghij"));
2683     test(S("abcdefghij"), 1, 1, S("12345"), 6, 0, S("can't happen"));
2684     test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 0, S("acdefghij"));
2685     test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 1, S("a1cdefghij"));
2686     test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 5, S("a12345cdefghij"));
2687     test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 9, S("a123456789cdefghij"));
2688     test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 10, S("a1234567890cdefghij"));
2689     test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 11, S("a1234567890cdefghij"));
2690     test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 0, S("acdefghij"));
2691     test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 1, S("a2cdefghij"));
2692     test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 4, S("a2345cdefghij"));
2693     test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 8, S("a23456789cdefghij"));
2694     test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 9, S("a234567890cdefghij"));
2695     test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 10, S("a234567890cdefghij"));
2696     test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 0, S("acdefghij"));
2697     test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 1, S("a6cdefghij"));
2698     test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 2, S("a67cdefghij"));
2699     test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 4, S("a6789cdefghij"));
2700     test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 5, S("a67890cdefghij"));
2701     test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 6, S("a67890cdefghij"));
2702     test(S("abcdefghij"), 1, 1, S("1234567890"), 9, 0, S("acdefghij"));
2703     test(S("abcdefghij"), 1, 1, S("1234567890"), 9, 1, S("a0cdefghij"));
2704     test(S("abcdefghij"), 1, 1, S("1234567890"), 9, 2, S("a0cdefghij"));
2705     test(S("abcdefghij"), 1, 1, S("1234567890"), 10, 0, S("acdefghij"));
2706     test(S("abcdefghij"), 1, 1, S("1234567890"), 10, 1, S("acdefghij"));
2707     test(S("abcdefghij"), 1, 1, S("1234567890"), 11, 0, S("can't happen"));
2708     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 0, S("acdefghij"));
2709     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 1, S("a1cdefghij"));
2710     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 10, S("a1234567890cdefghij"));
2711     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789cdefghij"));
2712     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890cdefghij"));
2713     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890cdefghij"));
2714     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 0, S("acdefghij"));
2715     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 1, S("a2cdefghij"));
2716 }
2717 
2718 template <class S>
2719 void test25()
2720 {
2721     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 9, S("a234567890cdefghij"));
2722     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 18, S("a234567890123456789cdefghij"));
2723     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890cdefghij"));
2724     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890cdefghij"));
2725     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 0, S("acdefghij"));
2726     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 1, S("a1cdefghij"));
2727     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 5, S("a12345cdefghij"));
2728     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 9, S("a123456789cdefghij"));
2729     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 10, S("a1234567890cdefghij"));
2730     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 11, S("a1234567890cdefghij"));
2731     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 19, 0, S("acdefghij"));
2732     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 19, 1, S("a0cdefghij"));
2733     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 19, 2, S("a0cdefghij"));
2734     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 20, 0, S("acdefghij"));
2735     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 20, 1, S("acdefghij"));
2736     test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
2737     test(S("abcdefghij"), 1, 4, S(""), 0, 0, S("afghij"));
2738     test(S("abcdefghij"), 1, 4, S(""), 0, 1, S("afghij"));
2739     test(S("abcdefghij"), 1, 4, S(""), 1, 0, S("can't happen"));
2740     test(S("abcdefghij"), 1, 4, S("12345"), 0, 0, S("afghij"));
2741     test(S("abcdefghij"), 1, 4, S("12345"), 0, 1, S("a1fghij"));
2742     test(S("abcdefghij"), 1, 4, S("12345"), 0, 2, S("a12fghij"));
2743     test(S("abcdefghij"), 1, 4, S("12345"), 0, 4, S("a1234fghij"));
2744     test(S("abcdefghij"), 1, 4, S("12345"), 0, 5, S("a12345fghij"));
2745     test(S("abcdefghij"), 1, 4, S("12345"), 0, 6, S("a12345fghij"));
2746     test(S("abcdefghij"), 1, 4, S("12345"), 1, 0, S("afghij"));
2747     test(S("abcdefghij"), 1, 4, S("12345"), 1, 1, S("a2fghij"));
2748     test(S("abcdefghij"), 1, 4, S("12345"), 1, 2, S("a23fghij"));
2749     test(S("abcdefghij"), 1, 4, S("12345"), 1, 3, S("a234fghij"));
2750     test(S("abcdefghij"), 1, 4, S("12345"), 1, 4, S("a2345fghij"));
2751     test(S("abcdefghij"), 1, 4, S("12345"), 1, 5, S("a2345fghij"));
2752     test(S("abcdefghij"), 1, 4, S("12345"), 2, 0, S("afghij"));
2753     test(S("abcdefghij"), 1, 4, S("12345"), 2, 1, S("a3fghij"));
2754     test(S("abcdefghij"), 1, 4, S("12345"), 2, 2, S("a34fghij"));
2755     test(S("abcdefghij"), 1, 4, S("12345"), 2, 3, S("a345fghij"));
2756     test(S("abcdefghij"), 1, 4, S("12345"), 2, 4, S("a345fghij"));
2757     test(S("abcdefghij"), 1, 4, S("12345"), 4, 0, S("afghij"));
2758     test(S("abcdefghij"), 1, 4, S("12345"), 4, 1, S("a5fghij"));
2759     test(S("abcdefghij"), 1, 4, S("12345"), 4, 2, S("a5fghij"));
2760     test(S("abcdefghij"), 1, 4, S("12345"), 5, 0, S("afghij"));
2761     test(S("abcdefghij"), 1, 4, S("12345"), 5, 1, S("afghij"));
2762     test(S("abcdefghij"), 1, 4, S("12345"), 6, 0, S("can't happen"));
2763     test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 0, S("afghij"));
2764     test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 1, S("a1fghij"));
2765     test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 5, S("a12345fghij"));
2766     test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 9, S("a123456789fghij"));
2767     test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 10, S("a1234567890fghij"));
2768     test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 11, S("a1234567890fghij"));
2769     test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 0, S("afghij"));
2770     test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 1, S("a2fghij"));
2771     test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 4, S("a2345fghij"));
2772     test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 8, S("a23456789fghij"));
2773     test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 9, S("a234567890fghij"));
2774     test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 10, S("a234567890fghij"));
2775     test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 0, S("afghij"));
2776     test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 1, S("a6fghij"));
2777     test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 2, S("a67fghij"));
2778     test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 4, S("a6789fghij"));
2779     test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 5, S("a67890fghij"));
2780     test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 6, S("a67890fghij"));
2781     test(S("abcdefghij"), 1, 4, S("1234567890"), 9, 0, S("afghij"));
2782     test(S("abcdefghij"), 1, 4, S("1234567890"), 9, 1, S("a0fghij"));
2783     test(S("abcdefghij"), 1, 4, S("1234567890"), 9, 2, S("a0fghij"));
2784     test(S("abcdefghij"), 1, 4, S("1234567890"), 10, 0, S("afghij"));
2785     test(S("abcdefghij"), 1, 4, S("1234567890"), 10, 1, S("afghij"));
2786     test(S("abcdefghij"), 1, 4, S("1234567890"), 11, 0, S("can't happen"));
2787     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 0, S("afghij"));
2788     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 1, S("a1fghij"));
2789     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 10, S("a1234567890fghij"));
2790     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 19, S("a1234567890123456789fghij"));
2791     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 20, S("a12345678901234567890fghij"));
2792     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 21, S("a12345678901234567890fghij"));
2793     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 0, S("afghij"));
2794     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 1, S("a2fghij"));
2795     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 9, S("a234567890fghij"));
2796     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 18, S("a234567890123456789fghij"));
2797     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 19, S("a2345678901234567890fghij"));
2798     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 20, S("a2345678901234567890fghij"));
2799     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 0, S("afghij"));
2800     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 1, S("a1fghij"));
2801     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 5, S("a12345fghij"));
2802     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 9, S("a123456789fghij"));
2803     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 10, S("a1234567890fghij"));
2804     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 11, S("a1234567890fghij"));
2805     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 19, 0, S("afghij"));
2806     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 19, 1, S("a0fghij"));
2807     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 19, 2, S("a0fghij"));
2808     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 20, 0, S("afghij"));
2809     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 20, 1, S("afghij"));
2810     test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
2811     test(S("abcdefghij"), 1, 8, S(""), 0, 0, S("aj"));
2812     test(S("abcdefghij"), 1, 8, S(""), 0, 1, S("aj"));
2813     test(S("abcdefghij"), 1, 8, S(""), 1, 0, S("can't happen"));
2814     test(S("abcdefghij"), 1, 8, S("12345"), 0, 0, S("aj"));
2815     test(S("abcdefghij"), 1, 8, S("12345"), 0, 1, S("a1j"));
2816     test(S("abcdefghij"), 1, 8, S("12345"), 0, 2, S("a12j"));
2817     test(S("abcdefghij"), 1, 8, S("12345"), 0, 4, S("a1234j"));
2818     test(S("abcdefghij"), 1, 8, S("12345"), 0, 5, S("a12345j"));
2819     test(S("abcdefghij"), 1, 8, S("12345"), 0, 6, S("a12345j"));
2820     test(S("abcdefghij"), 1, 8, S("12345"), 1, 0, S("aj"));
2821 }
2822 
2823 template <class S>
2824 void test26()
2825 {
2826     test(S("abcdefghij"), 1, 8, S("12345"), 1, 1, S("a2j"));
2827     test(S("abcdefghij"), 1, 8, S("12345"), 1, 2, S("a23j"));
2828     test(S("abcdefghij"), 1, 8, S("12345"), 1, 3, S("a234j"));
2829     test(S("abcdefghij"), 1, 8, S("12345"), 1, 4, S("a2345j"));
2830     test(S("abcdefghij"), 1, 8, S("12345"), 1, 5, S("a2345j"));
2831     test(S("abcdefghij"), 1, 8, S("12345"), 2, 0, S("aj"));
2832     test(S("abcdefghij"), 1, 8, S("12345"), 2, 1, S("a3j"));
2833     test(S("abcdefghij"), 1, 8, S("12345"), 2, 2, S("a34j"));
2834     test(S("abcdefghij"), 1, 8, S("12345"), 2, 3, S("a345j"));
2835     test(S("abcdefghij"), 1, 8, S("12345"), 2, 4, S("a345j"));
2836     test(S("abcdefghij"), 1, 8, S("12345"), 4, 0, S("aj"));
2837     test(S("abcdefghij"), 1, 8, S("12345"), 4, 1, S("a5j"));
2838     test(S("abcdefghij"), 1, 8, S("12345"), 4, 2, S("a5j"));
2839     test(S("abcdefghij"), 1, 8, S("12345"), 5, 0, S("aj"));
2840     test(S("abcdefghij"), 1, 8, S("12345"), 5, 1, S("aj"));
2841     test(S("abcdefghij"), 1, 8, S("12345"), 6, 0, S("can't happen"));
2842     test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 0, S("aj"));
2843     test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 1, S("a1j"));
2844     test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 5, S("a12345j"));
2845     test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 9, S("a123456789j"));
2846     test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 10, S("a1234567890j"));
2847     test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 11, S("a1234567890j"));
2848     test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 0, S("aj"));
2849     test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 1, S("a2j"));
2850     test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 4, S("a2345j"));
2851     test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 8, S("a23456789j"));
2852     test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 9, S("a234567890j"));
2853     test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 10, S("a234567890j"));
2854     test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 0, S("aj"));
2855     test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 1, S("a6j"));
2856     test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 2, S("a67j"));
2857     test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 4, S("a6789j"));
2858     test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 5, S("a67890j"));
2859     test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 6, S("a67890j"));
2860     test(S("abcdefghij"), 1, 8, S("1234567890"), 9, 0, S("aj"));
2861     test(S("abcdefghij"), 1, 8, S("1234567890"), 9, 1, S("a0j"));
2862     test(S("abcdefghij"), 1, 8, S("1234567890"), 9, 2, S("a0j"));
2863     test(S("abcdefghij"), 1, 8, S("1234567890"), 10, 0, S("aj"));
2864     test(S("abcdefghij"), 1, 8, S("1234567890"), 10, 1, S("aj"));
2865     test(S("abcdefghij"), 1, 8, S("1234567890"), 11, 0, S("can't happen"));
2866     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 0, S("aj"));
2867     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 1, S("a1j"));
2868     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 10, S("a1234567890j"));
2869     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 19, S("a1234567890123456789j"));
2870     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 20, S("a12345678901234567890j"));
2871     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 21, S("a12345678901234567890j"));
2872     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 0, S("aj"));
2873     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 1, S("a2j"));
2874     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 9, S("a234567890j"));
2875     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 18, S("a234567890123456789j"));
2876     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 19, S("a2345678901234567890j"));
2877     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 20, S("a2345678901234567890j"));
2878     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 0, S("aj"));
2879     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 1, S("a1j"));
2880     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 5, S("a12345j"));
2881     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 9, S("a123456789j"));
2882     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 10, S("a1234567890j"));
2883     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 11, S("a1234567890j"));
2884     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 19, 0, S("aj"));
2885     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 19, 1, S("a0j"));
2886     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 19, 2, S("a0j"));
2887     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 20, 0, S("aj"));
2888     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 20, 1, S("aj"));
2889     test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 21, 0, S("can't happen"));
2890     test(S("abcdefghij"), 1, 9, S(""), 0, 0, S("a"));
2891     test(S("abcdefghij"), 1, 9, S(""), 0, 1, S("a"));
2892     test(S("abcdefghij"), 1, 9, S(""), 1, 0, S("can't happen"));
2893     test(S("abcdefghij"), 1, 9, S("12345"), 0, 0, S("a"));
2894     test(S("abcdefghij"), 1, 9, S("12345"), 0, 1, S("a1"));
2895     test(S("abcdefghij"), 1, 9, S("12345"), 0, 2, S("a12"));
2896     test(S("abcdefghij"), 1, 9, S("12345"), 0, 4, S("a1234"));
2897     test(S("abcdefghij"), 1, 9, S("12345"), 0, 5, S("a12345"));
2898     test(S("abcdefghij"), 1, 9, S("12345"), 0, 6, S("a12345"));
2899     test(S("abcdefghij"), 1, 9, S("12345"), 1, 0, S("a"));
2900     test(S("abcdefghij"), 1, 9, S("12345"), 1, 1, S("a2"));
2901     test(S("abcdefghij"), 1, 9, S("12345"), 1, 2, S("a23"));
2902     test(S("abcdefghij"), 1, 9, S("12345"), 1, 3, S("a234"));
2903     test(S("abcdefghij"), 1, 9, S("12345"), 1, 4, S("a2345"));
2904     test(S("abcdefghij"), 1, 9, S("12345"), 1, 5, S("a2345"));
2905     test(S("abcdefghij"), 1, 9, S("12345"), 2, 0, S("a"));
2906     test(S("abcdefghij"), 1, 9, S("12345"), 2, 1, S("a3"));
2907     test(S("abcdefghij"), 1, 9, S("12345"), 2, 2, S("a34"));
2908     test(S("abcdefghij"), 1, 9, S("12345"), 2, 3, S("a345"));
2909     test(S("abcdefghij"), 1, 9, S("12345"), 2, 4, S("a345"));
2910     test(S("abcdefghij"), 1, 9, S("12345"), 4, 0, S("a"));
2911     test(S("abcdefghij"), 1, 9, S("12345"), 4, 1, S("a5"));
2912     test(S("abcdefghij"), 1, 9, S("12345"), 4, 2, S("a5"));
2913     test(S("abcdefghij"), 1, 9, S("12345"), 5, 0, S("a"));
2914     test(S("abcdefghij"), 1, 9, S("12345"), 5, 1, S("a"));
2915     test(S("abcdefghij"), 1, 9, S("12345"), 6, 0, S("can't happen"));
2916     test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 0, S("a"));
2917     test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 1, S("a1"));
2918     test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 5, S("a12345"));
2919     test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 9, S("a123456789"));
2920     test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 10, S("a1234567890"));
2921     test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 11, S("a1234567890"));
2922     test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 0, S("a"));
2923     test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 1, S("a2"));
2924     test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 4, S("a2345"));
2925     test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 8, S("a23456789"));
2926 }
2927 
2928 template <class S>
2929 void test27()
2930 {
2931     test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 9, S("a234567890"));
2932     test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 10, S("a234567890"));
2933     test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 0, S("a"));
2934     test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 1, S("a6"));
2935     test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 2, S("a67"));
2936     test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 4, S("a6789"));
2937     test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 5, S("a67890"));
2938     test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 6, S("a67890"));
2939     test(S("abcdefghij"), 1, 9, S("1234567890"), 9, 0, S("a"));
2940     test(S("abcdefghij"), 1, 9, S("1234567890"), 9, 1, S("a0"));
2941     test(S("abcdefghij"), 1, 9, S("1234567890"), 9, 2, S("a0"));
2942     test(S("abcdefghij"), 1, 9, S("1234567890"), 10, 0, S("a"));
2943     test(S("abcdefghij"), 1, 9, S("1234567890"), 10, 1, S("a"));
2944     test(S("abcdefghij"), 1, 9, S("1234567890"), 11, 0, S("can't happen"));
2945     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 0, S("a"));
2946     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 1, S("a1"));
2947     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 10, S("a1234567890"));
2948     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
2949     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
2950     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
2951     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 0, S("a"));
2952     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 1, S("a2"));
2953     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 9, S("a234567890"));
2954     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
2955     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
2956     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
2957     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 0, S("a"));
2958     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 1, S("a1"));
2959     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 5, S("a12345"));
2960     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 9, S("a123456789"));
2961     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 10, S("a1234567890"));
2962     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 11, S("a1234567890"));
2963     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 19, 0, S("a"));
2964     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 19, 1, S("a0"));
2965     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 19, 2, S("a0"));
2966     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 20, 0, S("a"));
2967     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 20, 1, S("a"));
2968     test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 21, 0, S("can't happen"));
2969     test(S("abcdefghij"), 1, 10, S(""), 0, 0, S("a"));
2970     test(S("abcdefghij"), 1, 10, S(""), 0, 1, S("a"));
2971     test(S("abcdefghij"), 1, 10, S(""), 1, 0, S("can't happen"));
2972     test(S("abcdefghij"), 1, 10, S("12345"), 0, 0, S("a"));
2973     test(S("abcdefghij"), 1, 10, S("12345"), 0, 1, S("a1"));
2974     test(S("abcdefghij"), 1, 10, S("12345"), 0, 2, S("a12"));
2975     test(S("abcdefghij"), 1, 10, S("12345"), 0, 4, S("a1234"));
2976     test(S("abcdefghij"), 1, 10, S("12345"), 0, 5, S("a12345"));
2977     test(S("abcdefghij"), 1, 10, S("12345"), 0, 6, S("a12345"));
2978     test(S("abcdefghij"), 1, 10, S("12345"), 1, 0, S("a"));
2979     test(S("abcdefghij"), 1, 10, S("12345"), 1, 1, S("a2"));
2980     test(S("abcdefghij"), 1, 10, S("12345"), 1, 2, S("a23"));
2981     test(S("abcdefghij"), 1, 10, S("12345"), 1, 3, S("a234"));
2982     test(S("abcdefghij"), 1, 10, S("12345"), 1, 4, S("a2345"));
2983     test(S("abcdefghij"), 1, 10, S("12345"), 1, 5, S("a2345"));
2984     test(S("abcdefghij"), 1, 10, S("12345"), 2, 0, S("a"));
2985     test(S("abcdefghij"), 1, 10, S("12345"), 2, 1, S("a3"));
2986     test(S("abcdefghij"), 1, 10, S("12345"), 2, 2, S("a34"));
2987     test(S("abcdefghij"), 1, 10, S("12345"), 2, 3, S("a345"));
2988     test(S("abcdefghij"), 1, 10, S("12345"), 2, 4, S("a345"));
2989     test(S("abcdefghij"), 1, 10, S("12345"), 4, 0, S("a"));
2990     test(S("abcdefghij"), 1, 10, S("12345"), 4, 1, S("a5"));
2991     test(S("abcdefghij"), 1, 10, S("12345"), 4, 2, S("a5"));
2992     test(S("abcdefghij"), 1, 10, S("12345"), 5, 0, S("a"));
2993     test(S("abcdefghij"), 1, 10, S("12345"), 5, 1, S("a"));
2994     test(S("abcdefghij"), 1, 10, S("12345"), 6, 0, S("can't happen"));
2995     test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 0, S("a"));
2996     test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 1, S("a1"));
2997     test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 5, S("a12345"));
2998     test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 9, S("a123456789"));
2999     test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 10, S("a1234567890"));
3000     test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 11, S("a1234567890"));
3001     test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 0, S("a"));
3002     test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 1, S("a2"));
3003     test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 4, S("a2345"));
3004     test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 8, S("a23456789"));
3005     test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 9, S("a234567890"));
3006     test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 10, S("a234567890"));
3007     test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 0, S("a"));
3008     test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 1, S("a6"));
3009     test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 2, S("a67"));
3010     test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 4, S("a6789"));
3011     test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 5, S("a67890"));
3012     test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 6, S("a67890"));
3013     test(S("abcdefghij"), 1, 10, S("1234567890"), 9, 0, S("a"));
3014     test(S("abcdefghij"), 1, 10, S("1234567890"), 9, 1, S("a0"));
3015     test(S("abcdefghij"), 1, 10, S("1234567890"), 9, 2, S("a0"));
3016     test(S("abcdefghij"), 1, 10, S("1234567890"), 10, 0, S("a"));
3017     test(S("abcdefghij"), 1, 10, S("1234567890"), 10, 1, S("a"));
3018     test(S("abcdefghij"), 1, 10, S("1234567890"), 11, 0, S("can't happen"));
3019     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 0, S("a"));
3020     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 1, S("a1"));
3021     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 10, S("a1234567890"));
3022     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
3023     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
3024     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
3025     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 0, S("a"));
3026     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 1, S("a2"));
3027     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 9, S("a234567890"));
3028     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
3029     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
3030     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
3031 }
3032 
3033 template <class S>
3034 void test28()
3035 {
3036     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 0, S("a"));
3037     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 1, S("a1"));
3038     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 5, S("a12345"));
3039     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 9, S("a123456789"));
3040     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 10, S("a1234567890"));
3041     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 11, S("a1234567890"));
3042     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 19, 0, S("a"));
3043     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 19, 1, S("a0"));
3044     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 19, 2, S("a0"));
3045     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 20, 0, S("a"));
3046     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 20, 1, S("a"));
3047     test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 21, 0, S("can't happen"));
3048     test(S("abcdefghij"), 5, 0, S(""), 0, 0, S("abcdefghij"));
3049     test(S("abcdefghij"), 5, 0, S(""), 0, 1, S("abcdefghij"));
3050     test(S("abcdefghij"), 5, 0, S(""), 1, 0, S("can't happen"));
3051     test(S("abcdefghij"), 5, 0, S("12345"), 0, 0, S("abcdefghij"));
3052     test(S("abcdefghij"), 5, 0, S("12345"), 0, 1, S("abcde1fghij"));
3053     test(S("abcdefghij"), 5, 0, S("12345"), 0, 2, S("abcde12fghij"));
3054     test(S("abcdefghij"), 5, 0, S("12345"), 0, 4, S("abcde1234fghij"));
3055     test(S("abcdefghij"), 5, 0, S("12345"), 0, 5, S("abcde12345fghij"));
3056     test(S("abcdefghij"), 5, 0, S("12345"), 0, 6, S("abcde12345fghij"));
3057     test(S("abcdefghij"), 5, 0, S("12345"), 1, 0, S("abcdefghij"));
3058     test(S("abcdefghij"), 5, 0, S("12345"), 1, 1, S("abcde2fghij"));
3059     test(S("abcdefghij"), 5, 0, S("12345"), 1, 2, S("abcde23fghij"));
3060     test(S("abcdefghij"), 5, 0, S("12345"), 1, 3, S("abcde234fghij"));
3061     test(S("abcdefghij"), 5, 0, S("12345"), 1, 4, S("abcde2345fghij"));
3062     test(S("abcdefghij"), 5, 0, S("12345"), 1, 5, S("abcde2345fghij"));
3063     test(S("abcdefghij"), 5, 0, S("12345"), 2, 0, S("abcdefghij"));
3064     test(S("abcdefghij"), 5, 0, S("12345"), 2, 1, S("abcde3fghij"));
3065     test(S("abcdefghij"), 5, 0, S("12345"), 2, 2, S("abcde34fghij"));
3066     test(S("abcdefghij"), 5, 0, S("12345"), 2, 3, S("abcde345fghij"));
3067     test(S("abcdefghij"), 5, 0, S("12345"), 2, 4, S("abcde345fghij"));
3068     test(S("abcdefghij"), 5, 0, S("12345"), 4, 0, S("abcdefghij"));
3069     test(S("abcdefghij"), 5, 0, S("12345"), 4, 1, S("abcde5fghij"));
3070     test(S("abcdefghij"), 5, 0, S("12345"), 4, 2, S("abcde5fghij"));
3071     test(S("abcdefghij"), 5, 0, S("12345"), 5, 0, S("abcdefghij"));
3072     test(S("abcdefghij"), 5, 0, S("12345"), 5, 1, S("abcdefghij"));
3073     test(S("abcdefghij"), 5, 0, S("12345"), 6, 0, S("can't happen"));
3074     test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 0, S("abcdefghij"));
3075     test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 1, S("abcde1fghij"));
3076     test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 5, S("abcde12345fghij"));
3077     test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 9, S("abcde123456789fghij"));
3078     test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 10, S("abcde1234567890fghij"));
3079     test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 11, S("abcde1234567890fghij"));
3080     test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 0, S("abcdefghij"));
3081     test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 1, S("abcde2fghij"));
3082     test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 4, S("abcde2345fghij"));
3083     test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 8, S("abcde23456789fghij"));
3084     test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 9, S("abcde234567890fghij"));
3085     test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 10, S("abcde234567890fghij"));
3086     test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 0, S("abcdefghij"));
3087     test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 1, S("abcde6fghij"));
3088     test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 2, S("abcde67fghij"));
3089     test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 4, S("abcde6789fghij"));
3090     test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 5, S("abcde67890fghij"));
3091     test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 6, S("abcde67890fghij"));
3092     test(S("abcdefghij"), 5, 0, S("1234567890"), 9, 0, S("abcdefghij"));
3093     test(S("abcdefghij"), 5, 0, S("1234567890"), 9, 1, S("abcde0fghij"));
3094     test(S("abcdefghij"), 5, 0, S("1234567890"), 9, 2, S("abcde0fghij"));
3095     test(S("abcdefghij"), 5, 0, S("1234567890"), 10, 0, S("abcdefghij"));
3096     test(S("abcdefghij"), 5, 0, S("1234567890"), 10, 1, S("abcdefghij"));
3097     test(S("abcdefghij"), 5, 0, S("1234567890"), 11, 0, S("can't happen"));
3098     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
3099     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 1, S("abcde1fghij"));
3100     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 10, S("abcde1234567890fghij"));
3101     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789fghij"));
3102     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890fghij"));
3103     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890fghij"));
3104     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
3105     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 1, S("abcde2fghij"));
3106     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 9, S("abcde234567890fghij"));
3107     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 18, S("abcde234567890123456789fghij"));
3108     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890fghij"));
3109     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890fghij"));
3110     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
3111     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 1, S("abcde1fghij"));
3112     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 5, S("abcde12345fghij"));
3113     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 9, S("abcde123456789fghij"));
3114     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 10, S("abcde1234567890fghij"));
3115     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 11, S("abcde1234567890fghij"));
3116     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
3117     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 19, 1, S("abcde0fghij"));
3118     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 19, 2, S("abcde0fghij"));
3119     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
3120     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
3121     test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
3122     test(S("abcdefghij"), 5, 1, S(""), 0, 0, S("abcdeghij"));
3123     test(S("abcdefghij"), 5, 1, S(""), 0, 1, S("abcdeghij"));
3124     test(S("abcdefghij"), 5, 1, S(""), 1, 0, S("can't happen"));
3125     test(S("abcdefghij"), 5, 1, S("12345"), 0, 0, S("abcdeghij"));
3126     test(S("abcdefghij"), 5, 1, S("12345"), 0, 1, S("abcde1ghij"));
3127     test(S("abcdefghij"), 5, 1, S("12345"), 0, 2, S("abcde12ghij"));
3128     test(S("abcdefghij"), 5, 1, S("12345"), 0, 4, S("abcde1234ghij"));
3129     test(S("abcdefghij"), 5, 1, S("12345"), 0, 5, S("abcde12345ghij"));
3130     test(S("abcdefghij"), 5, 1, S("12345"), 0, 6, S("abcde12345ghij"));
3131     test(S("abcdefghij"), 5, 1, S("12345"), 1, 0, S("abcdeghij"));
3132     test(S("abcdefghij"), 5, 1, S("12345"), 1, 1, S("abcde2ghij"));
3133     test(S("abcdefghij"), 5, 1, S("12345"), 1, 2, S("abcde23ghij"));
3134     test(S("abcdefghij"), 5, 1, S("12345"), 1, 3, S("abcde234ghij"));
3135     test(S("abcdefghij"), 5, 1, S("12345"), 1, 4, S("abcde2345ghij"));
3136 }
3137 
3138 template <class S>
3139 void test29()
3140 {
3141     test(S("abcdefghij"), 5, 1, S("12345"), 1, 5, S("abcde2345ghij"));
3142     test(S("abcdefghij"), 5, 1, S("12345"), 2, 0, S("abcdeghij"));
3143     test(S("abcdefghij"), 5, 1, S("12345"), 2, 1, S("abcde3ghij"));
3144     test(S("abcdefghij"), 5, 1, S("12345"), 2, 2, S("abcde34ghij"));
3145     test(S("abcdefghij"), 5, 1, S("12345"), 2, 3, S("abcde345ghij"));
3146     test(S("abcdefghij"), 5, 1, S("12345"), 2, 4, S("abcde345ghij"));
3147     test(S("abcdefghij"), 5, 1, S("12345"), 4, 0, S("abcdeghij"));
3148     test(S("abcdefghij"), 5, 1, S("12345"), 4, 1, S("abcde5ghij"));
3149     test(S("abcdefghij"), 5, 1, S("12345"), 4, 2, S("abcde5ghij"));
3150     test(S("abcdefghij"), 5, 1, S("12345"), 5, 0, S("abcdeghij"));
3151     test(S("abcdefghij"), 5, 1, S("12345"), 5, 1, S("abcdeghij"));
3152     test(S("abcdefghij"), 5, 1, S("12345"), 6, 0, S("can't happen"));
3153     test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 0, S("abcdeghij"));
3154     test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 1, S("abcde1ghij"));
3155     test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 5, S("abcde12345ghij"));
3156     test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 9, S("abcde123456789ghij"));
3157     test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 10, S("abcde1234567890ghij"));
3158     test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 11, S("abcde1234567890ghij"));
3159     test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 0, S("abcdeghij"));
3160     test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 1, S("abcde2ghij"));
3161     test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 4, S("abcde2345ghij"));
3162     test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 8, S("abcde23456789ghij"));
3163     test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 9, S("abcde234567890ghij"));
3164     test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 10, S("abcde234567890ghij"));
3165     test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 0, S("abcdeghij"));
3166     test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 1, S("abcde6ghij"));
3167     test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 2, S("abcde67ghij"));
3168     test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 4, S("abcde6789ghij"));
3169     test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 5, S("abcde67890ghij"));
3170     test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 6, S("abcde67890ghij"));
3171     test(S("abcdefghij"), 5, 1, S("1234567890"), 9, 0, S("abcdeghij"));
3172     test(S("abcdefghij"), 5, 1, S("1234567890"), 9, 1, S("abcde0ghij"));
3173     test(S("abcdefghij"), 5, 1, S("1234567890"), 9, 2, S("abcde0ghij"));
3174     test(S("abcdefghij"), 5, 1, S("1234567890"), 10, 0, S("abcdeghij"));
3175     test(S("abcdefghij"), 5, 1, S("1234567890"), 10, 1, S("abcdeghij"));
3176     test(S("abcdefghij"), 5, 1, S("1234567890"), 11, 0, S("can't happen"));
3177     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 0, S("abcdeghij"));
3178     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 1, S("abcde1ghij"));
3179     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 10, S("abcde1234567890ghij"));
3180     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789ghij"));
3181     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890ghij"));
3182     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890ghij"));
3183     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 0, S("abcdeghij"));
3184     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 1, S("abcde2ghij"));
3185     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 9, S("abcde234567890ghij"));
3186     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 18, S("abcde234567890123456789ghij"));
3187     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890ghij"));
3188     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890ghij"));
3189     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 0, S("abcdeghij"));
3190     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 1, S("abcde1ghij"));
3191     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 5, S("abcde12345ghij"));
3192     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 9, S("abcde123456789ghij"));
3193     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 10, S("abcde1234567890ghij"));
3194     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 11, S("abcde1234567890ghij"));
3195     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 19, 0, S("abcdeghij"));
3196     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 19, 1, S("abcde0ghij"));
3197     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 19, 2, S("abcde0ghij"));
3198     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 20, 0, S("abcdeghij"));
3199     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 20, 1, S("abcdeghij"));
3200     test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
3201     test(S("abcdefghij"), 5, 2, S(""), 0, 0, S("abcdehij"));
3202     test(S("abcdefghij"), 5, 2, S(""), 0, 1, S("abcdehij"));
3203     test(S("abcdefghij"), 5, 2, S(""), 1, 0, S("can't happen"));
3204     test(S("abcdefghij"), 5, 2, S("12345"), 0, 0, S("abcdehij"));
3205     test(S("abcdefghij"), 5, 2, S("12345"), 0, 1, S("abcde1hij"));
3206     test(S("abcdefghij"), 5, 2, S("12345"), 0, 2, S("abcde12hij"));
3207     test(S("abcdefghij"), 5, 2, S("12345"), 0, 4, S("abcde1234hij"));
3208     test(S("abcdefghij"), 5, 2, S("12345"), 0, 5, S("abcde12345hij"));
3209     test(S("abcdefghij"), 5, 2, S("12345"), 0, 6, S("abcde12345hij"));
3210     test(S("abcdefghij"), 5, 2, S("12345"), 1, 0, S("abcdehij"));
3211     test(S("abcdefghij"), 5, 2, S("12345"), 1, 1, S("abcde2hij"));
3212     test(S("abcdefghij"), 5, 2, S("12345"), 1, 2, S("abcde23hij"));
3213     test(S("abcdefghij"), 5, 2, S("12345"), 1, 3, S("abcde234hij"));
3214     test(S("abcdefghij"), 5, 2, S("12345"), 1, 4, S("abcde2345hij"));
3215     test(S("abcdefghij"), 5, 2, S("12345"), 1, 5, S("abcde2345hij"));
3216     test(S("abcdefghij"), 5, 2, S("12345"), 2, 0, S("abcdehij"));
3217     test(S("abcdefghij"), 5, 2, S("12345"), 2, 1, S("abcde3hij"));
3218     test(S("abcdefghij"), 5, 2, S("12345"), 2, 2, S("abcde34hij"));
3219     test(S("abcdefghij"), 5, 2, S("12345"), 2, 3, S("abcde345hij"));
3220     test(S("abcdefghij"), 5, 2, S("12345"), 2, 4, S("abcde345hij"));
3221     test(S("abcdefghij"), 5, 2, S("12345"), 4, 0, S("abcdehij"));
3222     test(S("abcdefghij"), 5, 2, S("12345"), 4, 1, S("abcde5hij"));
3223     test(S("abcdefghij"), 5, 2, S("12345"), 4, 2, S("abcde5hij"));
3224     test(S("abcdefghij"), 5, 2, S("12345"), 5, 0, S("abcdehij"));
3225     test(S("abcdefghij"), 5, 2, S("12345"), 5, 1, S("abcdehij"));
3226     test(S("abcdefghij"), 5, 2, S("12345"), 6, 0, S("can't happen"));
3227     test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 0, S("abcdehij"));
3228     test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 1, S("abcde1hij"));
3229     test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 5, S("abcde12345hij"));
3230     test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 9, S("abcde123456789hij"));
3231     test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 10, S("abcde1234567890hij"));
3232     test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 11, S("abcde1234567890hij"));
3233     test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 0, S("abcdehij"));
3234     test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 1, S("abcde2hij"));
3235     test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 4, S("abcde2345hij"));
3236     test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 8, S("abcde23456789hij"));
3237     test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 9, S("abcde234567890hij"));
3238     test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 10, S("abcde234567890hij"));
3239     test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 0, S("abcdehij"));
3240     test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 1, S("abcde6hij"));
3241 }
3242 
3243 template <class S>
3244 void test30()
3245 {
3246     test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 2, S("abcde67hij"));
3247     test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 4, S("abcde6789hij"));
3248     test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 5, S("abcde67890hij"));
3249     test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 6, S("abcde67890hij"));
3250     test(S("abcdefghij"), 5, 2, S("1234567890"), 9, 0, S("abcdehij"));
3251     test(S("abcdefghij"), 5, 2, S("1234567890"), 9, 1, S("abcde0hij"));
3252     test(S("abcdefghij"), 5, 2, S("1234567890"), 9, 2, S("abcde0hij"));
3253     test(S("abcdefghij"), 5, 2, S("1234567890"), 10, 0, S("abcdehij"));
3254     test(S("abcdefghij"), 5, 2, S("1234567890"), 10, 1, S("abcdehij"));
3255     test(S("abcdefghij"), 5, 2, S("1234567890"), 11, 0, S("can't happen"));
3256     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 0, S("abcdehij"));
3257     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 1, S("abcde1hij"));
3258     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 10, S("abcde1234567890hij"));
3259     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789hij"));
3260     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890hij"));
3261     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890hij"));
3262     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 0, S("abcdehij"));
3263     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 1, S("abcde2hij"));
3264     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 9, S("abcde234567890hij"));
3265     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 18, S("abcde234567890123456789hij"));
3266     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890hij"));
3267     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890hij"));
3268     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 0, S("abcdehij"));
3269     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 1, S("abcde1hij"));
3270     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 5, S("abcde12345hij"));
3271     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 9, S("abcde123456789hij"));
3272     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 10, S("abcde1234567890hij"));
3273     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 11, S("abcde1234567890hij"));
3274     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 19, 0, S("abcdehij"));
3275     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 19, 1, S("abcde0hij"));
3276     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 19, 2, S("abcde0hij"));
3277     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 20, 0, S("abcdehij"));
3278     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 20, 1, S("abcdehij"));
3279     test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
3280     test(S("abcdefghij"), 5, 4, S(""), 0, 0, S("abcdej"));
3281     test(S("abcdefghij"), 5, 4, S(""), 0, 1, S("abcdej"));
3282     test(S("abcdefghij"), 5, 4, S(""), 1, 0, S("can't happen"));
3283     test(S("abcdefghij"), 5, 4, S("12345"), 0, 0, S("abcdej"));
3284     test(S("abcdefghij"), 5, 4, S("12345"), 0, 1, S("abcde1j"));
3285     test(S("abcdefghij"), 5, 4, S("12345"), 0, 2, S("abcde12j"));
3286     test(S("abcdefghij"), 5, 4, S("12345"), 0, 4, S("abcde1234j"));
3287     test(S("abcdefghij"), 5, 4, S("12345"), 0, 5, S("abcde12345j"));
3288     test(S("abcdefghij"), 5, 4, S("12345"), 0, 6, S("abcde12345j"));
3289     test(S("abcdefghij"), 5, 4, S("12345"), 1, 0, S("abcdej"));
3290     test(S("abcdefghij"), 5, 4, S("12345"), 1, 1, S("abcde2j"));
3291     test(S("abcdefghij"), 5, 4, S("12345"), 1, 2, S("abcde23j"));
3292     test(S("abcdefghij"), 5, 4, S("12345"), 1, 3, S("abcde234j"));
3293     test(S("abcdefghij"), 5, 4, S("12345"), 1, 4, S("abcde2345j"));
3294     test(S("abcdefghij"), 5, 4, S("12345"), 1, 5, S("abcde2345j"));
3295     test(S("abcdefghij"), 5, 4, S("12345"), 2, 0, S("abcdej"));
3296     test(S("abcdefghij"), 5, 4, S("12345"), 2, 1, S("abcde3j"));
3297     test(S("abcdefghij"), 5, 4, S("12345"), 2, 2, S("abcde34j"));
3298     test(S("abcdefghij"), 5, 4, S("12345"), 2, 3, S("abcde345j"));
3299     test(S("abcdefghij"), 5, 4, S("12345"), 2, 4, S("abcde345j"));
3300     test(S("abcdefghij"), 5, 4, S("12345"), 4, 0, S("abcdej"));
3301     test(S("abcdefghij"), 5, 4, S("12345"), 4, 1, S("abcde5j"));
3302     test(S("abcdefghij"), 5, 4, S("12345"), 4, 2, S("abcde5j"));
3303     test(S("abcdefghij"), 5, 4, S("12345"), 5, 0, S("abcdej"));
3304     test(S("abcdefghij"), 5, 4, S("12345"), 5, 1, S("abcdej"));
3305     test(S("abcdefghij"), 5, 4, S("12345"), 6, 0, S("can't happen"));
3306     test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 0, S("abcdej"));
3307     test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 1, S("abcde1j"));
3308     test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 5, S("abcde12345j"));
3309     test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 9, S("abcde123456789j"));
3310     test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 10, S("abcde1234567890j"));
3311     test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 11, S("abcde1234567890j"));
3312     test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 0, S("abcdej"));
3313     test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 1, S("abcde2j"));
3314     test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 4, S("abcde2345j"));
3315     test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 8, S("abcde23456789j"));
3316     test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 9, S("abcde234567890j"));
3317     test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 10, S("abcde234567890j"));
3318     test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 0, S("abcdej"));
3319     test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 1, S("abcde6j"));
3320     test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 2, S("abcde67j"));
3321     test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 4, S("abcde6789j"));
3322     test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 5, S("abcde67890j"));
3323     test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 6, S("abcde67890j"));
3324     test(S("abcdefghij"), 5, 4, S("1234567890"), 9, 0, S("abcdej"));
3325     test(S("abcdefghij"), 5, 4, S("1234567890"), 9, 1, S("abcde0j"));
3326     test(S("abcdefghij"), 5, 4, S("1234567890"), 9, 2, S("abcde0j"));
3327     test(S("abcdefghij"), 5, 4, S("1234567890"), 10, 0, S("abcdej"));
3328     test(S("abcdefghij"), 5, 4, S("1234567890"), 10, 1, S("abcdej"));
3329     test(S("abcdefghij"), 5, 4, S("1234567890"), 11, 0, S("can't happen"));
3330     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 0, S("abcdej"));
3331     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 1, S("abcde1j"));
3332     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 10, S("abcde1234567890j"));
3333     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789j"));
3334     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890j"));
3335     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890j"));
3336     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 0, S("abcdej"));
3337     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 1, S("abcde2j"));
3338     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 9, S("abcde234567890j"));
3339     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 18, S("abcde234567890123456789j"));
3340     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890j"));
3341     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890j"));
3342     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 0, S("abcdej"));
3343     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 1, S("abcde1j"));
3344     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 5, S("abcde12345j"));
3345     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 9, S("abcde123456789j"));
3346 }
3347 
3348 template <class S>
3349 void test31()
3350 {
3351     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 10, S("abcde1234567890j"));
3352     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 11, S("abcde1234567890j"));
3353     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 19, 0, S("abcdej"));
3354     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 19, 1, S("abcde0j"));
3355     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 19, 2, S("abcde0j"));
3356     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 20, 0, S("abcdej"));
3357     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 20, 1, S("abcdej"));
3358     test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
3359     test(S("abcdefghij"), 5, 5, S(""), 0, 0, S("abcde"));
3360     test(S("abcdefghij"), 5, 5, S(""), 0, 1, S("abcde"));
3361     test(S("abcdefghij"), 5, 5, S(""), 1, 0, S("can't happen"));
3362     test(S("abcdefghij"), 5, 5, S("12345"), 0, 0, S("abcde"));
3363     test(S("abcdefghij"), 5, 5, S("12345"), 0, 1, S("abcde1"));
3364     test(S("abcdefghij"), 5, 5, S("12345"), 0, 2, S("abcde12"));
3365     test(S("abcdefghij"), 5, 5, S("12345"), 0, 4, S("abcde1234"));
3366     test(S("abcdefghij"), 5, 5, S("12345"), 0, 5, S("abcde12345"));
3367     test(S("abcdefghij"), 5, 5, S("12345"), 0, 6, S("abcde12345"));
3368     test(S("abcdefghij"), 5, 5, S("12345"), 1, 0, S("abcde"));
3369     test(S("abcdefghij"), 5, 5, S("12345"), 1, 1, S("abcde2"));
3370     test(S("abcdefghij"), 5, 5, S("12345"), 1, 2, S("abcde23"));
3371     test(S("abcdefghij"), 5, 5, S("12345"), 1, 3, S("abcde234"));
3372     test(S("abcdefghij"), 5, 5, S("12345"), 1, 4, S("abcde2345"));
3373     test(S("abcdefghij"), 5, 5, S("12345"), 1, 5, S("abcde2345"));
3374     test(S("abcdefghij"), 5, 5, S("12345"), 2, 0, S("abcde"));
3375     test(S("abcdefghij"), 5, 5, S("12345"), 2, 1, S("abcde3"));
3376     test(S("abcdefghij"), 5, 5, S("12345"), 2, 2, S("abcde34"));
3377     test(S("abcdefghij"), 5, 5, S("12345"), 2, 3, S("abcde345"));
3378     test(S("abcdefghij"), 5, 5, S("12345"), 2, 4, S("abcde345"));
3379     test(S("abcdefghij"), 5, 5, S("12345"), 4, 0, S("abcde"));
3380     test(S("abcdefghij"), 5, 5, S("12345"), 4, 1, S("abcde5"));
3381     test(S("abcdefghij"), 5, 5, S("12345"), 4, 2, S("abcde5"));
3382     test(S("abcdefghij"), 5, 5, S("12345"), 5, 0, S("abcde"));
3383     test(S("abcdefghij"), 5, 5, S("12345"), 5, 1, S("abcde"));
3384     test(S("abcdefghij"), 5, 5, S("12345"), 6, 0, S("can't happen"));
3385     test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 0, S("abcde"));
3386     test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 1, S("abcde1"));
3387     test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 5, S("abcde12345"));
3388     test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 9, S("abcde123456789"));
3389     test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 10, S("abcde1234567890"));
3390     test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 11, S("abcde1234567890"));
3391     test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 0, S("abcde"));
3392     test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 1, S("abcde2"));
3393     test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 4, S("abcde2345"));
3394     test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 8, S("abcde23456789"));
3395     test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 9, S("abcde234567890"));
3396     test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 10, S("abcde234567890"));
3397     test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 0, S("abcde"));
3398     test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 1, S("abcde6"));
3399     test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 2, S("abcde67"));
3400     test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 4, S("abcde6789"));
3401     test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 5, S("abcde67890"));
3402     test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 6, S("abcde67890"));
3403     test(S("abcdefghij"), 5, 5, S("1234567890"), 9, 0, S("abcde"));
3404     test(S("abcdefghij"), 5, 5, S("1234567890"), 9, 1, S("abcde0"));
3405     test(S("abcdefghij"), 5, 5, S("1234567890"), 9, 2, S("abcde0"));
3406     test(S("abcdefghij"), 5, 5, S("1234567890"), 10, 0, S("abcde"));
3407     test(S("abcdefghij"), 5, 5, S("1234567890"), 10, 1, S("abcde"));
3408     test(S("abcdefghij"), 5, 5, S("1234567890"), 11, 0, S("can't happen"));
3409     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 0, S("abcde"));
3410     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 1, S("abcde1"));
3411     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
3412     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
3413     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
3414     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
3415     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 0, S("abcde"));
3416     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 1, S("abcde2"));
3417     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 9, S("abcde234567890"));
3418     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
3419     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
3420     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
3421     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 0, S("abcde"));
3422     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 1, S("abcde1"));
3423     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 5, S("abcde12345"));
3424     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 9, S("abcde123456789"));
3425     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
3426     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
3427     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 19, 0, S("abcde"));
3428     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 19, 1, S("abcde0"));
3429     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 19, 2, S("abcde0"));
3430     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 20, 0, S("abcde"));
3431     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 20, 1, S("abcde"));
3432     test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
3433     test(S("abcdefghij"), 5, 6, S(""), 0, 0, S("abcde"));
3434     test(S("abcdefghij"), 5, 6, S(""), 0, 1, S("abcde"));
3435     test(S("abcdefghij"), 5, 6, S(""), 1, 0, S("can't happen"));
3436     test(S("abcdefghij"), 5, 6, S("12345"), 0, 0, S("abcde"));
3437     test(S("abcdefghij"), 5, 6, S("12345"), 0, 1, S("abcde1"));
3438     test(S("abcdefghij"), 5, 6, S("12345"), 0, 2, S("abcde12"));
3439     test(S("abcdefghij"), 5, 6, S("12345"), 0, 4, S("abcde1234"));
3440     test(S("abcdefghij"), 5, 6, S("12345"), 0, 5, S("abcde12345"));
3441     test(S("abcdefghij"), 5, 6, S("12345"), 0, 6, S("abcde12345"));
3442     test(S("abcdefghij"), 5, 6, S("12345"), 1, 0, S("abcde"));
3443     test(S("abcdefghij"), 5, 6, S("12345"), 1, 1, S("abcde2"));
3444     test(S("abcdefghij"), 5, 6, S("12345"), 1, 2, S("abcde23"));
3445     test(S("abcdefghij"), 5, 6, S("12345"), 1, 3, S("abcde234"));
3446     test(S("abcdefghij"), 5, 6, S("12345"), 1, 4, S("abcde2345"));
3447     test(S("abcdefghij"), 5, 6, S("12345"), 1, 5, S("abcde2345"));
3448     test(S("abcdefghij"), 5, 6, S("12345"), 2, 0, S("abcde"));
3449     test(S("abcdefghij"), 5, 6, S("12345"), 2, 1, S("abcde3"));
3450     test(S("abcdefghij"), 5, 6, S("12345"), 2, 2, S("abcde34"));
3451 }
3452 
3453 template <class S>
3454 void test32()
3455 {
3456     test(S("abcdefghij"), 5, 6, S("12345"), 2, 3, S("abcde345"));
3457     test(S("abcdefghij"), 5, 6, S("12345"), 2, 4, S("abcde345"));
3458     test(S("abcdefghij"), 5, 6, S("12345"), 4, 0, S("abcde"));
3459     test(S("abcdefghij"), 5, 6, S("12345"), 4, 1, S("abcde5"));
3460     test(S("abcdefghij"), 5, 6, S("12345"), 4, 2, S("abcde5"));
3461     test(S("abcdefghij"), 5, 6, S("12345"), 5, 0, S("abcde"));
3462     test(S("abcdefghij"), 5, 6, S("12345"), 5, 1, S("abcde"));
3463     test(S("abcdefghij"), 5, 6, S("12345"), 6, 0, S("can't happen"));
3464     test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 0, S("abcde"));
3465     test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 1, S("abcde1"));
3466     test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 5, S("abcde12345"));
3467     test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 9, S("abcde123456789"));
3468     test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 10, S("abcde1234567890"));
3469     test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 11, S("abcde1234567890"));
3470     test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 0, S("abcde"));
3471     test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 1, S("abcde2"));
3472     test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 4, S("abcde2345"));
3473     test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 8, S("abcde23456789"));
3474     test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 9, S("abcde234567890"));
3475     test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 10, S("abcde234567890"));
3476     test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 0, S("abcde"));
3477     test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 1, S("abcde6"));
3478     test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 2, S("abcde67"));
3479     test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 4, S("abcde6789"));
3480     test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 5, S("abcde67890"));
3481     test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 6, S("abcde67890"));
3482     test(S("abcdefghij"), 5, 6, S("1234567890"), 9, 0, S("abcde"));
3483     test(S("abcdefghij"), 5, 6, S("1234567890"), 9, 1, S("abcde0"));
3484     test(S("abcdefghij"), 5, 6, S("1234567890"), 9, 2, S("abcde0"));
3485     test(S("abcdefghij"), 5, 6, S("1234567890"), 10, 0, S("abcde"));
3486     test(S("abcdefghij"), 5, 6, S("1234567890"), 10, 1, S("abcde"));
3487     test(S("abcdefghij"), 5, 6, S("1234567890"), 11, 0, S("can't happen"));
3488     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 0, S("abcde"));
3489     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 1, S("abcde1"));
3490     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
3491     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
3492     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
3493     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
3494     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 0, S("abcde"));
3495     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 1, S("abcde2"));
3496     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 9, S("abcde234567890"));
3497     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
3498     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
3499     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
3500     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 0, S("abcde"));
3501     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 1, S("abcde1"));
3502     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 5, S("abcde12345"));
3503     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 9, S("abcde123456789"));
3504     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
3505     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
3506     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 19, 0, S("abcde"));
3507     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 19, 1, S("abcde0"));
3508     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 19, 2, S("abcde0"));
3509     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 20, 0, S("abcde"));
3510     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 20, 1, S("abcde"));
3511     test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 21, 0, S("can't happen"));
3512     test(S("abcdefghij"), 9, 0, S(""), 0, 0, S("abcdefghij"));
3513     test(S("abcdefghij"), 9, 0, S(""), 0, 1, S("abcdefghij"));
3514     test(S("abcdefghij"), 9, 0, S(""), 1, 0, S("can't happen"));
3515     test(S("abcdefghij"), 9, 0, S("12345"), 0, 0, S("abcdefghij"));
3516     test(S("abcdefghij"), 9, 0, S("12345"), 0, 1, S("abcdefghi1j"));
3517     test(S("abcdefghij"), 9, 0, S("12345"), 0, 2, S("abcdefghi12j"));
3518     test(S("abcdefghij"), 9, 0, S("12345"), 0, 4, S("abcdefghi1234j"));
3519     test(S("abcdefghij"), 9, 0, S("12345"), 0, 5, S("abcdefghi12345j"));
3520     test(S("abcdefghij"), 9, 0, S("12345"), 0, 6, S("abcdefghi12345j"));
3521     test(S("abcdefghij"), 9, 0, S("12345"), 1, 0, S("abcdefghij"));
3522     test(S("abcdefghij"), 9, 0, S("12345"), 1, 1, S("abcdefghi2j"));
3523     test(S("abcdefghij"), 9, 0, S("12345"), 1, 2, S("abcdefghi23j"));
3524     test(S("abcdefghij"), 9, 0, S("12345"), 1, 3, S("abcdefghi234j"));
3525     test(S("abcdefghij"), 9, 0, S("12345"), 1, 4, S("abcdefghi2345j"));
3526     test(S("abcdefghij"), 9, 0, S("12345"), 1, 5, S("abcdefghi2345j"));
3527     test(S("abcdefghij"), 9, 0, S("12345"), 2, 0, S("abcdefghij"));
3528     test(S("abcdefghij"), 9, 0, S("12345"), 2, 1, S("abcdefghi3j"));
3529     test(S("abcdefghij"), 9, 0, S("12345"), 2, 2, S("abcdefghi34j"));
3530     test(S("abcdefghij"), 9, 0, S("12345"), 2, 3, S("abcdefghi345j"));
3531     test(S("abcdefghij"), 9, 0, S("12345"), 2, 4, S("abcdefghi345j"));
3532     test(S("abcdefghij"), 9, 0, S("12345"), 4, 0, S("abcdefghij"));
3533     test(S("abcdefghij"), 9, 0, S("12345"), 4, 1, S("abcdefghi5j"));
3534     test(S("abcdefghij"), 9, 0, S("12345"), 4, 2, S("abcdefghi5j"));
3535     test(S("abcdefghij"), 9, 0, S("12345"), 5, 0, S("abcdefghij"));
3536     test(S("abcdefghij"), 9, 0, S("12345"), 5, 1, S("abcdefghij"));
3537     test(S("abcdefghij"), 9, 0, S("12345"), 6, 0, S("can't happen"));
3538     test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 0, S("abcdefghij"));
3539     test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 1, S("abcdefghi1j"));
3540     test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 5, S("abcdefghi12345j"));
3541     test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 9, S("abcdefghi123456789j"));
3542     test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 10, S("abcdefghi1234567890j"));
3543     test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 11, S("abcdefghi1234567890j"));
3544     test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 0, S("abcdefghij"));
3545     test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 1, S("abcdefghi2j"));
3546     test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 4, S("abcdefghi2345j"));
3547     test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 8, S("abcdefghi23456789j"));
3548     test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 9, S("abcdefghi234567890j"));
3549     test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 10, S("abcdefghi234567890j"));
3550     test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 0, S("abcdefghij"));
3551     test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 1, S("abcdefghi6j"));
3552     test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 2, S("abcdefghi67j"));
3553     test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 4, S("abcdefghi6789j"));
3554     test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 5, S("abcdefghi67890j"));
3555     test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 6, S("abcdefghi67890j"));
3556 }
3557 
3558 template <class S>
3559 void test33()
3560 {
3561     test(S("abcdefghij"), 9, 0, S("1234567890"), 9, 0, S("abcdefghij"));
3562     test(S("abcdefghij"), 9, 0, S("1234567890"), 9, 1, S("abcdefghi0j"));
3563     test(S("abcdefghij"), 9, 0, S("1234567890"), 9, 2, S("abcdefghi0j"));
3564     test(S("abcdefghij"), 9, 0, S("1234567890"), 10, 0, S("abcdefghij"));
3565     test(S("abcdefghij"), 9, 0, S("1234567890"), 10, 1, S("abcdefghij"));
3566     test(S("abcdefghij"), 9, 0, S("1234567890"), 11, 0, S("can't happen"));
3567     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
3568     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 1, S("abcdefghi1j"));
3569     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890j"));
3570     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789j"));
3571     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890j"));
3572     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890j"));
3573     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
3574     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 1, S("abcdefghi2j"));
3575     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 9, S("abcdefghi234567890j"));
3576     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789j"));
3577     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890j"));
3578     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890j"));
3579     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
3580     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 1, S("abcdefghi1j"));
3581     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 5, S("abcdefghi12345j"));
3582     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 9, S("abcdefghi123456789j"));
3583     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890j"));
3584     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890j"));
3585     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
3586     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 19, 1, S("abcdefghi0j"));
3587     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 19, 2, S("abcdefghi0j"));
3588     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
3589     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
3590     test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
3591     test(S("abcdefghij"), 9, 1, S(""), 0, 0, S("abcdefghi"));
3592     test(S("abcdefghij"), 9, 1, S(""), 0, 1, S("abcdefghi"));
3593     test(S("abcdefghij"), 9, 1, S(""), 1, 0, S("can't happen"));
3594     test(S("abcdefghij"), 9, 1, S("12345"), 0, 0, S("abcdefghi"));
3595     test(S("abcdefghij"), 9, 1, S("12345"), 0, 1, S("abcdefghi1"));
3596     test(S("abcdefghij"), 9, 1, S("12345"), 0, 2, S("abcdefghi12"));
3597     test(S("abcdefghij"), 9, 1, S("12345"), 0, 4, S("abcdefghi1234"));
3598     test(S("abcdefghij"), 9, 1, S("12345"), 0, 5, S("abcdefghi12345"));
3599     test(S("abcdefghij"), 9, 1, S("12345"), 0, 6, S("abcdefghi12345"));
3600     test(S("abcdefghij"), 9, 1, S("12345"), 1, 0, S("abcdefghi"));
3601     test(S("abcdefghij"), 9, 1, S("12345"), 1, 1, S("abcdefghi2"));
3602     test(S("abcdefghij"), 9, 1, S("12345"), 1, 2, S("abcdefghi23"));
3603     test(S("abcdefghij"), 9, 1, S("12345"), 1, 3, S("abcdefghi234"));
3604     test(S("abcdefghij"), 9, 1, S("12345"), 1, 4, S("abcdefghi2345"));
3605     test(S("abcdefghij"), 9, 1, S("12345"), 1, 5, S("abcdefghi2345"));
3606     test(S("abcdefghij"), 9, 1, S("12345"), 2, 0, S("abcdefghi"));
3607     test(S("abcdefghij"), 9, 1, S("12345"), 2, 1, S("abcdefghi3"));
3608     test(S("abcdefghij"), 9, 1, S("12345"), 2, 2, S("abcdefghi34"));
3609     test(S("abcdefghij"), 9, 1, S("12345"), 2, 3, S("abcdefghi345"));
3610     test(S("abcdefghij"), 9, 1, S("12345"), 2, 4, S("abcdefghi345"));
3611     test(S("abcdefghij"), 9, 1, S("12345"), 4, 0, S("abcdefghi"));
3612     test(S("abcdefghij"), 9, 1, S("12345"), 4, 1, S("abcdefghi5"));
3613     test(S("abcdefghij"), 9, 1, S("12345"), 4, 2, S("abcdefghi5"));
3614     test(S("abcdefghij"), 9, 1, S("12345"), 5, 0, S("abcdefghi"));
3615     test(S("abcdefghij"), 9, 1, S("12345"), 5, 1, S("abcdefghi"));
3616     test(S("abcdefghij"), 9, 1, S("12345"), 6, 0, S("can't happen"));
3617     test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 0, S("abcdefghi"));
3618     test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 1, S("abcdefghi1"));
3619     test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 5, S("abcdefghi12345"));
3620     test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 9, S("abcdefghi123456789"));
3621     test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 10, S("abcdefghi1234567890"));
3622     test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 11, S("abcdefghi1234567890"));
3623     test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 0, S("abcdefghi"));
3624     test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 1, S("abcdefghi2"));
3625     test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 4, S("abcdefghi2345"));
3626     test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 8, S("abcdefghi23456789"));
3627     test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 9, S("abcdefghi234567890"));
3628     test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 10, S("abcdefghi234567890"));
3629     test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 0, S("abcdefghi"));
3630     test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 1, S("abcdefghi6"));
3631     test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 2, S("abcdefghi67"));
3632     test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 4, S("abcdefghi6789"));
3633     test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 5, S("abcdefghi67890"));
3634     test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 6, S("abcdefghi67890"));
3635     test(S("abcdefghij"), 9, 1, S("1234567890"), 9, 0, S("abcdefghi"));
3636     test(S("abcdefghij"), 9, 1, S("1234567890"), 9, 1, S("abcdefghi0"));
3637     test(S("abcdefghij"), 9, 1, S("1234567890"), 9, 2, S("abcdefghi0"));
3638     test(S("abcdefghij"), 9, 1, S("1234567890"), 10, 0, S("abcdefghi"));
3639     test(S("abcdefghij"), 9, 1, S("1234567890"), 10, 1, S("abcdefghi"));
3640     test(S("abcdefghij"), 9, 1, S("1234567890"), 11, 0, S("can't happen"));
3641     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 0, S("abcdefghi"));
3642     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 1, S("abcdefghi1"));
3643     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890"));
3644     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789"));
3645     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890"));
3646     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890"));
3647     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 0, S("abcdefghi"));
3648     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 1, S("abcdefghi2"));
3649     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 9, S("abcdefghi234567890"));
3650     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789"));
3651     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890"));
3652     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890"));
3653     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 0, S("abcdefghi"));
3654     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 1, S("abcdefghi1"));
3655     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 5, S("abcdefghi12345"));
3656     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 9, S("abcdefghi123456789"));
3657     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890"));
3658     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890"));
3659     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, 0, S("abcdefghi"));
3660     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, 1, S("abcdefghi0"));
3661 }
3662 
3663 template <class S>
3664 void test34()
3665 {
3666     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, 2, S("abcdefghi0"));
3667     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, 0, S("abcdefghi"));
3668     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, 1, S("abcdefghi"));
3669     test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
3670     test(S("abcdefghij"), 9, 2, S(""), 0, 0, S("abcdefghi"));
3671     test(S("abcdefghij"), 9, 2, S(""), 0, 1, S("abcdefghi"));
3672     test(S("abcdefghij"), 9, 2, S(""), 1, 0, S("can't happen"));
3673     test(S("abcdefghij"), 9, 2, S("12345"), 0, 0, S("abcdefghi"));
3674     test(S("abcdefghij"), 9, 2, S("12345"), 0, 1, S("abcdefghi1"));
3675     test(S("abcdefghij"), 9, 2, S("12345"), 0, 2, S("abcdefghi12"));
3676     test(S("abcdefghij"), 9, 2, S("12345"), 0, 4, S("abcdefghi1234"));
3677     test(S("abcdefghij"), 9, 2, S("12345"), 0, 5, S("abcdefghi12345"));
3678     test(S("abcdefghij"), 9, 2, S("12345"), 0, 6, S("abcdefghi12345"));
3679     test(S("abcdefghij"), 9, 2, S("12345"), 1, 0, S("abcdefghi"));
3680     test(S("abcdefghij"), 9, 2, S("12345"), 1, 1, S("abcdefghi2"));
3681     test(S("abcdefghij"), 9, 2, S("12345"), 1, 2, S("abcdefghi23"));
3682     test(S("abcdefghij"), 9, 2, S("12345"), 1, 3, S("abcdefghi234"));
3683     test(S("abcdefghij"), 9, 2, S("12345"), 1, 4, S("abcdefghi2345"));
3684     test(S("abcdefghij"), 9, 2, S("12345"), 1, 5, S("abcdefghi2345"));
3685     test(S("abcdefghij"), 9, 2, S("12345"), 2, 0, S("abcdefghi"));
3686     test(S("abcdefghij"), 9, 2, S("12345"), 2, 1, S("abcdefghi3"));
3687     test(S("abcdefghij"), 9, 2, S("12345"), 2, 2, S("abcdefghi34"));
3688     test(S("abcdefghij"), 9, 2, S("12345"), 2, 3, S("abcdefghi345"));
3689     test(S("abcdefghij"), 9, 2, S("12345"), 2, 4, S("abcdefghi345"));
3690     test(S("abcdefghij"), 9, 2, S("12345"), 4, 0, S("abcdefghi"));
3691     test(S("abcdefghij"), 9, 2, S("12345"), 4, 1, S("abcdefghi5"));
3692     test(S("abcdefghij"), 9, 2, S("12345"), 4, 2, S("abcdefghi5"));
3693     test(S("abcdefghij"), 9, 2, S("12345"), 5, 0, S("abcdefghi"));
3694     test(S("abcdefghij"), 9, 2, S("12345"), 5, 1, S("abcdefghi"));
3695     test(S("abcdefghij"), 9, 2, S("12345"), 6, 0, S("can't happen"));
3696     test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 0, S("abcdefghi"));
3697     test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 1, S("abcdefghi1"));
3698     test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 5, S("abcdefghi12345"));
3699     test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 9, S("abcdefghi123456789"));
3700     test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 10, S("abcdefghi1234567890"));
3701     test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 11, S("abcdefghi1234567890"));
3702     test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 0, S("abcdefghi"));
3703     test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 1, S("abcdefghi2"));
3704     test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 4, S("abcdefghi2345"));
3705     test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 8, S("abcdefghi23456789"));
3706     test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 9, S("abcdefghi234567890"));
3707     test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 10, S("abcdefghi234567890"));
3708     test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 0, S("abcdefghi"));
3709     test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 1, S("abcdefghi6"));
3710     test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 2, S("abcdefghi67"));
3711     test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 4, S("abcdefghi6789"));
3712     test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 5, S("abcdefghi67890"));
3713     test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 6, S("abcdefghi67890"));
3714     test(S("abcdefghij"), 9, 2, S("1234567890"), 9, 0, S("abcdefghi"));
3715     test(S("abcdefghij"), 9, 2, S("1234567890"), 9, 1, S("abcdefghi0"));
3716     test(S("abcdefghij"), 9, 2, S("1234567890"), 9, 2, S("abcdefghi0"));
3717     test(S("abcdefghij"), 9, 2, S("1234567890"), 10, 0, S("abcdefghi"));
3718     test(S("abcdefghij"), 9, 2, S("1234567890"), 10, 1, S("abcdefghi"));
3719     test(S("abcdefghij"), 9, 2, S("1234567890"), 11, 0, S("can't happen"));
3720     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 0, S("abcdefghi"));
3721     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 1, S("abcdefghi1"));
3722     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890"));
3723     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789"));
3724     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890"));
3725     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890"));
3726     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 0, S("abcdefghi"));
3727     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 1, S("abcdefghi2"));
3728     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 9, S("abcdefghi234567890"));
3729     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789"));
3730     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890"));
3731     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890"));
3732     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 0, S("abcdefghi"));
3733     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 1, S("abcdefghi1"));
3734     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 5, S("abcdefghi12345"));
3735     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 9, S("abcdefghi123456789"));
3736     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890"));
3737     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890"));
3738     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 19, 0, S("abcdefghi"));
3739     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 19, 1, S("abcdefghi0"));
3740     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 19, 2, S("abcdefghi0"));
3741     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 20, 0, S("abcdefghi"));
3742     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 20, 1, S("abcdefghi"));
3743     test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
3744     test(S("abcdefghij"), 10, 0, S(""), 0, 0, S("abcdefghij"));
3745     test(S("abcdefghij"), 10, 0, S(""), 0, 1, S("abcdefghij"));
3746     test(S("abcdefghij"), 10, 0, S(""), 1, 0, S("can't happen"));
3747     test(S("abcdefghij"), 10, 0, S("12345"), 0, 0, S("abcdefghij"));
3748     test(S("abcdefghij"), 10, 0, S("12345"), 0, 1, S("abcdefghij1"));
3749     test(S("abcdefghij"), 10, 0, S("12345"), 0, 2, S("abcdefghij12"));
3750     test(S("abcdefghij"), 10, 0, S("12345"), 0, 4, S("abcdefghij1234"));
3751     test(S("abcdefghij"), 10, 0, S("12345"), 0, 5, S("abcdefghij12345"));
3752     test(S("abcdefghij"), 10, 0, S("12345"), 0, 6, S("abcdefghij12345"));
3753     test(S("abcdefghij"), 10, 0, S("12345"), 1, 0, S("abcdefghij"));
3754     test(S("abcdefghij"), 10, 0, S("12345"), 1, 1, S("abcdefghij2"));
3755     test(S("abcdefghij"), 10, 0, S("12345"), 1, 2, S("abcdefghij23"));
3756     test(S("abcdefghij"), 10, 0, S("12345"), 1, 3, S("abcdefghij234"));
3757     test(S("abcdefghij"), 10, 0, S("12345"), 1, 4, S("abcdefghij2345"));
3758     test(S("abcdefghij"), 10, 0, S("12345"), 1, 5, S("abcdefghij2345"));
3759     test(S("abcdefghij"), 10, 0, S("12345"), 2, 0, S("abcdefghij"));
3760     test(S("abcdefghij"), 10, 0, S("12345"), 2, 1, S("abcdefghij3"));
3761     test(S("abcdefghij"), 10, 0, S("12345"), 2, 2, S("abcdefghij34"));
3762     test(S("abcdefghij"), 10, 0, S("12345"), 2, 3, S("abcdefghij345"));
3763     test(S("abcdefghij"), 10, 0, S("12345"), 2, 4, S("abcdefghij345"));
3764     test(S("abcdefghij"), 10, 0, S("12345"), 4, 0, S("abcdefghij"));
3765     test(S("abcdefghij"), 10, 0, S("12345"), 4, 1, S("abcdefghij5"));
3766 }
3767 
3768 template <class S>
3769 void test35()
3770 {
3771     test(S("abcdefghij"), 10, 0, S("12345"), 4, 2, S("abcdefghij5"));
3772     test(S("abcdefghij"), 10, 0, S("12345"), 5, 0, S("abcdefghij"));
3773     test(S("abcdefghij"), 10, 0, S("12345"), 5, 1, S("abcdefghij"));
3774     test(S("abcdefghij"), 10, 0, S("12345"), 6, 0, S("can't happen"));
3775     test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 0, S("abcdefghij"));
3776     test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 1, S("abcdefghij1"));
3777     test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 5, S("abcdefghij12345"));
3778     test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 9, S("abcdefghij123456789"));
3779     test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
3780     test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
3781     test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 0, S("abcdefghij"));
3782     test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 1, S("abcdefghij2"));
3783     test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 4, S("abcdefghij2345"));
3784     test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 8, S("abcdefghij23456789"));
3785     test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 9, S("abcdefghij234567890"));
3786     test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 10, S("abcdefghij234567890"));
3787     test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 0, S("abcdefghij"));
3788     test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 1, S("abcdefghij6"));
3789     test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 2, S("abcdefghij67"));
3790     test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 4, S("abcdefghij6789"));
3791     test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 5, S("abcdefghij67890"));
3792     test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 6, S("abcdefghij67890"));
3793     test(S("abcdefghij"), 10, 0, S("1234567890"), 9, 0, S("abcdefghij"));
3794     test(S("abcdefghij"), 10, 0, S("1234567890"), 9, 1, S("abcdefghij0"));
3795     test(S("abcdefghij"), 10, 0, S("1234567890"), 9, 2, S("abcdefghij0"));
3796     test(S("abcdefghij"), 10, 0, S("1234567890"), 10, 0, S("abcdefghij"));
3797     test(S("abcdefghij"), 10, 0, S("1234567890"), 10, 1, S("abcdefghij"));
3798     test(S("abcdefghij"), 10, 0, S("1234567890"), 11, 0, S("can't happen"));
3799     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
3800     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
3801     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
3802     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
3803     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
3804     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
3805     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
3806     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
3807     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
3808     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
3809     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
3810     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
3811     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
3812     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
3813     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
3814     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
3815     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
3816     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
3817     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
3818     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
3819     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
3820     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
3821     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
3822     test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
3823     test(S("abcdefghij"), 10, 1, S(""), 0, 0, S("abcdefghij"));
3824     test(S("abcdefghij"), 10, 1, S(""), 0, 1, S("abcdefghij"));
3825     test(S("abcdefghij"), 10, 1, S(""), 1, 0, S("can't happen"));
3826     test(S("abcdefghij"), 10, 1, S("12345"), 0, 0, S("abcdefghij"));
3827     test(S("abcdefghij"), 10, 1, S("12345"), 0, 1, S("abcdefghij1"));
3828     test(S("abcdefghij"), 10, 1, S("12345"), 0, 2, S("abcdefghij12"));
3829     test(S("abcdefghij"), 10, 1, S("12345"), 0, 4, S("abcdefghij1234"));
3830     test(S("abcdefghij"), 10, 1, S("12345"), 0, 5, S("abcdefghij12345"));
3831     test(S("abcdefghij"), 10, 1, S("12345"), 0, 6, S("abcdefghij12345"));
3832     test(S("abcdefghij"), 10, 1, S("12345"), 1, 0, S("abcdefghij"));
3833     test(S("abcdefghij"), 10, 1, S("12345"), 1, 1, S("abcdefghij2"));
3834     test(S("abcdefghij"), 10, 1, S("12345"), 1, 2, S("abcdefghij23"));
3835     test(S("abcdefghij"), 10, 1, S("12345"), 1, 3, S("abcdefghij234"));
3836     test(S("abcdefghij"), 10, 1, S("12345"), 1, 4, S("abcdefghij2345"));
3837     test(S("abcdefghij"), 10, 1, S("12345"), 1, 5, S("abcdefghij2345"));
3838     test(S("abcdefghij"), 10, 1, S("12345"), 2, 0, S("abcdefghij"));
3839     test(S("abcdefghij"), 10, 1, S("12345"), 2, 1, S("abcdefghij3"));
3840     test(S("abcdefghij"), 10, 1, S("12345"), 2, 2, S("abcdefghij34"));
3841     test(S("abcdefghij"), 10, 1, S("12345"), 2, 3, S("abcdefghij345"));
3842     test(S("abcdefghij"), 10, 1, S("12345"), 2, 4, S("abcdefghij345"));
3843     test(S("abcdefghij"), 10, 1, S("12345"), 4, 0, S("abcdefghij"));
3844     test(S("abcdefghij"), 10, 1, S("12345"), 4, 1, S("abcdefghij5"));
3845     test(S("abcdefghij"), 10, 1, S("12345"), 4, 2, S("abcdefghij5"));
3846     test(S("abcdefghij"), 10, 1, S("12345"), 5, 0, S("abcdefghij"));
3847     test(S("abcdefghij"), 10, 1, S("12345"), 5, 1, S("abcdefghij"));
3848     test(S("abcdefghij"), 10, 1, S("12345"), 6, 0, S("can't happen"));
3849     test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 0, S("abcdefghij"));
3850     test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 1, S("abcdefghij1"));
3851     test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 5, S("abcdefghij12345"));
3852     test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 9, S("abcdefghij123456789"));
3853     test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
3854     test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
3855     test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 0, S("abcdefghij"));
3856     test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 1, S("abcdefghij2"));
3857     test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 4, S("abcdefghij2345"));
3858     test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 8, S("abcdefghij23456789"));
3859     test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 9, S("abcdefghij234567890"));
3860     test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 10, S("abcdefghij234567890"));
3861     test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 0, S("abcdefghij"));
3862     test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 1, S("abcdefghij6"));
3863     test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 2, S("abcdefghij67"));
3864     test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 4, S("abcdefghij6789"));
3865     test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 5, S("abcdefghij67890"));
3866     test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 6, S("abcdefghij67890"));
3867     test(S("abcdefghij"), 10, 1, S("1234567890"), 9, 0, S("abcdefghij"));
3868     test(S("abcdefghij"), 10, 1, S("1234567890"), 9, 1, S("abcdefghij0"));
3869     test(S("abcdefghij"), 10, 1, S("1234567890"), 9, 2, S("abcdefghij0"));
3870     test(S("abcdefghij"), 10, 1, S("1234567890"), 10, 0, S("abcdefghij"));
3871 }
3872 
3873 template <class S>
3874 void test36()
3875 {
3876     test(S("abcdefghij"), 10, 1, S("1234567890"), 10, 1, S("abcdefghij"));
3877     test(S("abcdefghij"), 10, 1, S("1234567890"), 11, 0, S("can't happen"));
3878     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 0, S("abcdefghij"));
3879     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
3880     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
3881     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
3882     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
3883     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
3884     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 0, S("abcdefghij"));
3885     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
3886     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
3887     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
3888     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
3889     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
3890     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 0, S("abcdefghij"));
3891     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
3892     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
3893     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
3894     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
3895     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
3896     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 19, 0, S("abcdefghij"));
3897     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
3898     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
3899     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 20, 0, S("abcdefghij"));
3900     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 20, 1, S("abcdefghij"));
3901     test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
3902     test(S("abcdefghij"), 11, 0, S(""), 0, 0, S("can't happen"));
3903     test(S("abcdefghij"), 11, 0, S(""), 0, 1, S("can't happen"));
3904     test(S("abcdefghij"), 11, 0, S(""), 1, 0, S("can't happen"));
3905     test(S("abcdefghij"), 11, 0, S("12345"), 0, 0, S("can't happen"));
3906     test(S("abcdefghij"), 11, 0, S("12345"), 0, 1, S("can't happen"));
3907     test(S("abcdefghij"), 11, 0, S("12345"), 0, 2, S("can't happen"));
3908     test(S("abcdefghij"), 11, 0, S("12345"), 0, 4, S("can't happen"));
3909     test(S("abcdefghij"), 11, 0, S("12345"), 0, 5, S("can't happen"));
3910     test(S("abcdefghij"), 11, 0, S("12345"), 0, 6, S("can't happen"));
3911     test(S("abcdefghij"), 11, 0, S("12345"), 1, 0, S("can't happen"));
3912     test(S("abcdefghij"), 11, 0, S("12345"), 1, 1, S("can't happen"));
3913     test(S("abcdefghij"), 11, 0, S("12345"), 1, 2, S("can't happen"));
3914     test(S("abcdefghij"), 11, 0, S("12345"), 1, 3, S("can't happen"));
3915     test(S("abcdefghij"), 11, 0, S("12345"), 1, 4, S("can't happen"));
3916     test(S("abcdefghij"), 11, 0, S("12345"), 1, 5, S("can't happen"));
3917     test(S("abcdefghij"), 11, 0, S("12345"), 2, 0, S("can't happen"));
3918     test(S("abcdefghij"), 11, 0, S("12345"), 2, 1, S("can't happen"));
3919     test(S("abcdefghij"), 11, 0, S("12345"), 2, 2, S("can't happen"));
3920     test(S("abcdefghij"), 11, 0, S("12345"), 2, 3, S("can't happen"));
3921     test(S("abcdefghij"), 11, 0, S("12345"), 2, 4, S("can't happen"));
3922     test(S("abcdefghij"), 11, 0, S("12345"), 4, 0, S("can't happen"));
3923     test(S("abcdefghij"), 11, 0, S("12345"), 4, 1, S("can't happen"));
3924     test(S("abcdefghij"), 11, 0, S("12345"), 4, 2, S("can't happen"));
3925     test(S("abcdefghij"), 11, 0, S("12345"), 5, 0, S("can't happen"));
3926     test(S("abcdefghij"), 11, 0, S("12345"), 5, 1, S("can't happen"));
3927     test(S("abcdefghij"), 11, 0, S("12345"), 6, 0, S("can't happen"));
3928     test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 0, S("can't happen"));
3929     test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 1, S("can't happen"));
3930     test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 5, S("can't happen"));
3931     test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 9, S("can't happen"));
3932     test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 10, S("can't happen"));
3933     test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 11, S("can't happen"));
3934     test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 0, S("can't happen"));
3935     test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 1, S("can't happen"));
3936     test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 4, S("can't happen"));
3937     test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 8, S("can't happen"));
3938     test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 9, S("can't happen"));
3939     test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 10, S("can't happen"));
3940     test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 0, S("can't happen"));
3941     test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 1, S("can't happen"));
3942     test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 2, S("can't happen"));
3943     test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 4, S("can't happen"));
3944     test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 5, S("can't happen"));
3945     test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 6, S("can't happen"));
3946     test(S("abcdefghij"), 11, 0, S("1234567890"), 9, 0, S("can't happen"));
3947     test(S("abcdefghij"), 11, 0, S("1234567890"), 9, 1, S("can't happen"));
3948     test(S("abcdefghij"), 11, 0, S("1234567890"), 9, 2, S("can't happen"));
3949     test(S("abcdefghij"), 11, 0, S("1234567890"), 10, 0, S("can't happen"));
3950     test(S("abcdefghij"), 11, 0, S("1234567890"), 10, 1, S("can't happen"));
3951     test(S("abcdefghij"), 11, 0, S("1234567890"), 11, 0, S("can't happen"));
3952     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 0, S("can't happen"));
3953     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 1, S("can't happen"));
3954     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 10, S("can't happen"));
3955     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 19, S("can't happen"));
3956     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 20, S("can't happen"));
3957     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 21, S("can't happen"));
3958     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 0, S("can't happen"));
3959     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 1, S("can't happen"));
3960     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 9, S("can't happen"));
3961     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 18, S("can't happen"));
3962     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 19, S("can't happen"));
3963     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 20, S("can't happen"));
3964     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 0, S("can't happen"));
3965     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 1, S("can't happen"));
3966     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 5, S("can't happen"));
3967     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 9, S("can't happen"));
3968     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 10, S("can't happen"));
3969     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 11, S("can't happen"));
3970     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 19, 0, S("can't happen"));
3971     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 19, 1, S("can't happen"));
3972     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 19, 2, S("can't happen"));
3973     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 20, 0, S("can't happen"));
3974     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 20, 1, S("can't happen"));
3975     test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
3976 }
3977 
3978 template <class S>
3979 void test37()
3980 {
3981     test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
3982     test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
3983     test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 1, 0, S("can't happen"));
3984     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
3985     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 1, S("1abcdefghijklmnopqrst"));
3986     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 2, S("12abcdefghijklmnopqrst"));
3987     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 4, S("1234abcdefghijklmnopqrst"));
3988     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 5, S("12345abcdefghijklmnopqrst"));
3989     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 6, S("12345abcdefghijklmnopqrst"));
3990     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
3991     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 1, S("2abcdefghijklmnopqrst"));
3992     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 2, S("23abcdefghijklmnopqrst"));
3993     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 3, S("234abcdefghijklmnopqrst"));
3994     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 4, S("2345abcdefghijklmnopqrst"));
3995     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 5, S("2345abcdefghijklmnopqrst"));
3996     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
3997     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 1, S("3abcdefghijklmnopqrst"));
3998     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 2, S("34abcdefghijklmnopqrst"));
3999     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 3, S("345abcdefghijklmnopqrst"));
4000     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 4, S("345abcdefghijklmnopqrst"));
4001     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
4002     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 4, 1, S("5abcdefghijklmnopqrst"));
4003     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 4, 2, S("5abcdefghijklmnopqrst"));
4004     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
4005     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
4006     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 6, 0, S("can't happen"));
4007     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
4008     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 1, S("1abcdefghijklmnopqrst"));
4009     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 5, S("12345abcdefghijklmnopqrst"));
4010     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 9, S("123456789abcdefghijklmnopqrst"));
4011     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst"));
4012     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 11, S("1234567890abcdefghijklmnopqrst"));
4013     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
4014     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 1, S("2abcdefghijklmnopqrst"));
4015     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 4, S("2345abcdefghijklmnopqrst"));
4016     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 8, S("23456789abcdefghijklmnopqrst"));
4017     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 9, S("234567890abcdefghijklmnopqrst"));
4018     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 10, S("234567890abcdefghijklmnopqrst"));
4019     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
4020     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 1, S("6abcdefghijklmnopqrst"));
4021     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 2, S("67abcdefghijklmnopqrst"));
4022     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 4, S("6789abcdefghijklmnopqrst"));
4023     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 5, S("67890abcdefghijklmnopqrst"));
4024     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 6, S("67890abcdefghijklmnopqrst"));
4025     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
4026     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 9, 1, S("0abcdefghijklmnopqrst"));
4027     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 9, 2, S("0abcdefghijklmnopqrst"));
4028     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
4029     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
4030     test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 11, 0, S("can't happen"));
4031     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
4032     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 1, S("1abcdefghijklmnopqrst"));
4033     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst"));
4034     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghijklmnopqrst"));
4035     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghijklmnopqrst"));
4036     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghijklmnopqrst"));
4037     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
4038     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 1, S("2abcdefghijklmnopqrst"));
4039     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghijklmnopqrst"));
4040     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghijklmnopqrst"));
4041     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghijklmnopqrst"));
4042     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghijklmnopqrst"));
4043     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
4044     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 1, S("1abcdefghijklmnopqrst"));
4045     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 5, S("12345abcdefghijklmnopqrst"));
4046     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghijklmnopqrst"));
4047     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghijklmnopqrst"));
4048     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghijklmnopqrst"));
4049     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
4050     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 19, 1, S("0abcdefghijklmnopqrst"));
4051     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 19, 2, S("0abcdefghijklmnopqrst"));
4052     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
4053     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
4054     test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
4055     test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 0, S("bcdefghijklmnopqrst"));
4056     test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 1, S("bcdefghijklmnopqrst"));
4057     test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 1, 0, S("can't happen"));
4058     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 0, S("bcdefghijklmnopqrst"));
4059     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 1, S("1bcdefghijklmnopqrst"));
4060     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 2, S("12bcdefghijklmnopqrst"));
4061     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 4, S("1234bcdefghijklmnopqrst"));
4062     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 5, S("12345bcdefghijklmnopqrst"));
4063     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 6, S("12345bcdefghijklmnopqrst"));
4064     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 0, S("bcdefghijklmnopqrst"));
4065     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 1, S("2bcdefghijklmnopqrst"));
4066     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 2, S("23bcdefghijklmnopqrst"));
4067     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 3, S("234bcdefghijklmnopqrst"));
4068     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 4, S("2345bcdefghijklmnopqrst"));
4069     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 5, S("2345bcdefghijklmnopqrst"));
4070     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 0, S("bcdefghijklmnopqrst"));
4071     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 1, S("3bcdefghijklmnopqrst"));
4072     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 2, S("34bcdefghijklmnopqrst"));
4073     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 3, S("345bcdefghijklmnopqrst"));
4074     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 4, S("345bcdefghijklmnopqrst"));
4075     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 4, 0, S("bcdefghijklmnopqrst"));
4076     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 4, 1, S("5bcdefghijklmnopqrst"));
4077     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 4, 2, S("5bcdefghijklmnopqrst"));
4078     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 5, 0, S("bcdefghijklmnopqrst"));
4079     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 5, 1, S("bcdefghijklmnopqrst"));
4080     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 6, 0, S("can't happen"));
4081 }
4082 
4083 template <class S>
4084 void test38()
4085 {
4086     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 0, S("bcdefghijklmnopqrst"));
4087     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 1, S("1bcdefghijklmnopqrst"));
4088     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 5, S("12345bcdefghijklmnopqrst"));
4089     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 9, S("123456789bcdefghijklmnopqrst"));
4090     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 10, S("1234567890bcdefghijklmnopqrst"));
4091     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 11, S("1234567890bcdefghijklmnopqrst"));
4092     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 0, S("bcdefghijklmnopqrst"));
4093     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 1, S("2bcdefghijklmnopqrst"));
4094     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 4, S("2345bcdefghijklmnopqrst"));
4095     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 8, S("23456789bcdefghijklmnopqrst"));
4096     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 9, S("234567890bcdefghijklmnopqrst"));
4097     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 10, S("234567890bcdefghijklmnopqrst"));
4098     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 0, S("bcdefghijklmnopqrst"));
4099     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 1, S("6bcdefghijklmnopqrst"));
4100     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 2, S("67bcdefghijklmnopqrst"));
4101     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 4, S("6789bcdefghijklmnopqrst"));
4102     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 5, S("67890bcdefghijklmnopqrst"));
4103     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 6, S("67890bcdefghijklmnopqrst"));
4104     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 9, 0, S("bcdefghijklmnopqrst"));
4105     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 9, 1, S("0bcdefghijklmnopqrst"));
4106     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 9, 2, S("0bcdefghijklmnopqrst"));
4107     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 10, 0, S("bcdefghijklmnopqrst"));
4108     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 10, 1, S("bcdefghijklmnopqrst"));
4109     test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 11, 0, S("can't happen"));
4110     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 0, S("bcdefghijklmnopqrst"));
4111     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 1, S("1bcdefghijklmnopqrst"));
4112     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890bcdefghijklmnopqrst"));
4113     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789bcdefghijklmnopqrst"));
4114     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890bcdefghijklmnopqrst"));
4115     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890bcdefghijklmnopqrst"));
4116     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 0, S("bcdefghijklmnopqrst"));
4117     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 1, S("2bcdefghijklmnopqrst"));
4118     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 9, S("234567890bcdefghijklmnopqrst"));
4119     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789bcdefghijklmnopqrst"));
4120     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890bcdefghijklmnopqrst"));
4121     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890bcdefghijklmnopqrst"));
4122     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 0, S("bcdefghijklmnopqrst"));
4123     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 1, S("1bcdefghijklmnopqrst"));
4124     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 5, S("12345bcdefghijklmnopqrst"));
4125     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 9, S("123456789bcdefghijklmnopqrst"));
4126     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890bcdefghijklmnopqrst"));
4127     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890bcdefghijklmnopqrst"));
4128     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 19, 0, S("bcdefghijklmnopqrst"));
4129     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 19, 1, S("0bcdefghijklmnopqrst"));
4130     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 19, 2, S("0bcdefghijklmnopqrst"));
4131     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 20, 0, S("bcdefghijklmnopqrst"));
4132     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 20, 1, S("bcdefghijklmnopqrst"));
4133     test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
4134     test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 0, S("klmnopqrst"));
4135     test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 1, S("klmnopqrst"));
4136     test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 1, 0, S("can't happen"));
4137     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 0, S("klmnopqrst"));
4138     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 1, S("1klmnopqrst"));
4139     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 2, S("12klmnopqrst"));
4140     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 4, S("1234klmnopqrst"));
4141     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 5, S("12345klmnopqrst"));
4142     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 6, S("12345klmnopqrst"));
4143     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 0, S("klmnopqrst"));
4144     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 1, S("2klmnopqrst"));
4145     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 2, S("23klmnopqrst"));
4146     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 3, S("234klmnopqrst"));
4147     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 4, S("2345klmnopqrst"));
4148     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 5, S("2345klmnopqrst"));
4149     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 0, S("klmnopqrst"));
4150     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 1, S("3klmnopqrst"));
4151     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 2, S("34klmnopqrst"));
4152     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 3, S("345klmnopqrst"));
4153     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 4, S("345klmnopqrst"));
4154     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 4, 0, S("klmnopqrst"));
4155     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 4, 1, S("5klmnopqrst"));
4156     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 4, 2, S("5klmnopqrst"));
4157     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 5, 0, S("klmnopqrst"));
4158     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 5, 1, S("klmnopqrst"));
4159     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 6, 0, S("can't happen"));
4160     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 0, S("klmnopqrst"));
4161     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 1, S("1klmnopqrst"));
4162     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 5, S("12345klmnopqrst"));
4163     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 9, S("123456789klmnopqrst"));
4164     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 10, S("1234567890klmnopqrst"));
4165     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 11, S("1234567890klmnopqrst"));
4166     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 0, S("klmnopqrst"));
4167     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 1, S("2klmnopqrst"));
4168     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 4, S("2345klmnopqrst"));
4169     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 8, S("23456789klmnopqrst"));
4170     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 9, S("234567890klmnopqrst"));
4171     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 10, S("234567890klmnopqrst"));
4172     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 0, S("klmnopqrst"));
4173     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 1, S("6klmnopqrst"));
4174     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 2, S("67klmnopqrst"));
4175     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 4, S("6789klmnopqrst"));
4176     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 5, S("67890klmnopqrst"));
4177     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 6, S("67890klmnopqrst"));
4178     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 9, 0, S("klmnopqrst"));
4179     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 9, 1, S("0klmnopqrst"));
4180     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 9, 2, S("0klmnopqrst"));
4181     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 10, 0, S("klmnopqrst"));
4182     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 10, 1, S("klmnopqrst"));
4183     test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 11, 0, S("can't happen"));
4184     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 0, S("klmnopqrst"));
4185     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 1, S("1klmnopqrst"));
4186 }
4187 
4188 template <class S>
4189 void test39()
4190 {
4191     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 10, S("1234567890klmnopqrst"));
4192     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 19, S("1234567890123456789klmnopqrst"));
4193     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 20, S("12345678901234567890klmnopqrst"));
4194     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 21, S("12345678901234567890klmnopqrst"));
4195     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 0, S("klmnopqrst"));
4196     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 1, S("2klmnopqrst"));
4197     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 9, S("234567890klmnopqrst"));
4198     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 18, S("234567890123456789klmnopqrst"));
4199     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 19, S("2345678901234567890klmnopqrst"));
4200     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 20, S("2345678901234567890klmnopqrst"));
4201     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 0, S("klmnopqrst"));
4202     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 1, S("1klmnopqrst"));
4203     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 5, S("12345klmnopqrst"));
4204     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 9, S("123456789klmnopqrst"));
4205     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 10, S("1234567890klmnopqrst"));
4206     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 11, S("1234567890klmnopqrst"));
4207     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 19, 0, S("klmnopqrst"));
4208     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 19, 1, S("0klmnopqrst"));
4209     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 19, 2, S("0klmnopqrst"));
4210     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 20, 0, S("klmnopqrst"));
4211     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 20, 1, S("klmnopqrst"));
4212     test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 21, 0, S("can't happen"));
4213     test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 0, S("t"));
4214     test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 1, S("t"));
4215     test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 1, 0, S("can't happen"));
4216     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 0, S("t"));
4217     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 1, S("1t"));
4218     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 2, S("12t"));
4219     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 4, S("1234t"));
4220     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 5, S("12345t"));
4221     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 6, S("12345t"));
4222     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 0, S("t"));
4223     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 1, S("2t"));
4224     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 2, S("23t"));
4225     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 3, S("234t"));
4226     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 4, S("2345t"));
4227     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 5, S("2345t"));
4228     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 0, S("t"));
4229     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 1, S("3t"));
4230     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 2, S("34t"));
4231     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 3, S("345t"));
4232     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 4, S("345t"));
4233     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 4, 0, S("t"));
4234     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 4, 1, S("5t"));
4235     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 4, 2, S("5t"));
4236     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 5, 0, S("t"));
4237     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 5, 1, S("t"));
4238     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 6, 0, S("can't happen"));
4239     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 0, S("t"));
4240     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 1, S("1t"));
4241     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 5, S("12345t"));
4242     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 9, S("123456789t"));
4243     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 10, S("1234567890t"));
4244     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 11, S("1234567890t"));
4245     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 0, S("t"));
4246     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 1, S("2t"));
4247     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 4, S("2345t"));
4248     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 8, S("23456789t"));
4249     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 9, S("234567890t"));
4250     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 10, S("234567890t"));
4251     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 0, S("t"));
4252     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 1, S("6t"));
4253     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 2, S("67t"));
4254     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 4, S("6789t"));
4255     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 5, S("67890t"));
4256     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 6, S("67890t"));
4257     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 9, 0, S("t"));
4258     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 9, 1, S("0t"));
4259     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 9, 2, S("0t"));
4260     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 10, 0, S("t"));
4261     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 10, 1, S("t"));
4262     test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 11, 0, S("can't happen"));
4263     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 0, S("t"));
4264     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 1, S("1t"));
4265     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 10, S("1234567890t"));
4266     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 19, S("1234567890123456789t"));
4267     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 20, S("12345678901234567890t"));
4268     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 21, S("12345678901234567890t"));
4269     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 0, S("t"));
4270     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 1, S("2t"));
4271     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 9, S("234567890t"));
4272     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 18, S("234567890123456789t"));
4273     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 19, S("2345678901234567890t"));
4274     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 20, S("2345678901234567890t"));
4275     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 0, S("t"));
4276     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 1, S("1t"));
4277     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 5, S("12345t"));
4278     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 9, S("123456789t"));
4279     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 10, S("1234567890t"));
4280     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 11, S("1234567890t"));
4281     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 19, 0, S("t"));
4282     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 19, 1, S("0t"));
4283     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 19, 2, S("0t"));
4284     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 20, 0, S("t"));
4285     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 20, 1, S("t"));
4286     test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 21, 0, S("can't happen"));
4287     test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 0, S(""));
4288     test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 1, S(""));
4289     test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 1, 0, S("can't happen"));
4290     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 0, S(""));
4291 }
4292 
4293 template <class S>
4294 void test40()
4295 {
4296     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 1, S("1"));
4297     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 2, S("12"));
4298     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 4, S("1234"));
4299     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 5, S("12345"));
4300     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 6, S("12345"));
4301     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 0, S(""));
4302     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 1, S("2"));
4303     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 2, S("23"));
4304     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 3, S("234"));
4305     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 4, S("2345"));
4306     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 5, S("2345"));
4307     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 0, S(""));
4308     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 1, S("3"));
4309     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 2, S("34"));
4310     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 3, S("345"));
4311     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 4, S("345"));
4312     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 4, 0, S(""));
4313     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 4, 1, S("5"));
4314     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 4, 2, S("5"));
4315     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 5, 0, S(""));
4316     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 5, 1, S(""));
4317     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 6, 0, S("can't happen"));
4318     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 0, S(""));
4319     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 1, S("1"));
4320     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 5, S("12345"));
4321     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 9, S("123456789"));
4322     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 10, S("1234567890"));
4323     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 11, S("1234567890"));
4324     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 0, S(""));
4325     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 1, S("2"));
4326     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 4, S("2345"));
4327     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 8, S("23456789"));
4328     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 9, S("234567890"));
4329     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 10, S("234567890"));
4330     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 0, S(""));
4331     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 1, S("6"));
4332     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 2, S("67"));
4333     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 4, S("6789"));
4334     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 5, S("67890"));
4335     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 6, S("67890"));
4336     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 9, 0, S(""));
4337     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 9, 1, S("0"));
4338     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 9, 2, S("0"));
4339     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 10, 0, S(""));
4340     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 10, 1, S(""));
4341     test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 11, 0, S("can't happen"));
4342     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 0, S(""));
4343     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 1, S("1"));
4344     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 10, S("1234567890"));
4345     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
4346     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
4347     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
4348     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 0, S(""));
4349     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 1, S("2"));
4350     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 9, S("234567890"));
4351     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 18, S("234567890123456789"));
4352     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
4353     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
4354     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 0, S(""));
4355     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 1, S("1"));
4356     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 5, S("12345"));
4357     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 9, S("123456789"));
4358     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 10, S("1234567890"));
4359     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 11, S("1234567890"));
4360     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 19, 0, S(""));
4361     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 19, 1, S("0"));
4362     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 19, 2, S("0"));
4363     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 20, 0, S(""));
4364     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 20, 1, S(""));
4365     test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 21, 0, S("can't happen"));
4366     test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 0, S(""));
4367     test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 1, S(""));
4368     test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 1, 0, S("can't happen"));
4369     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 0, S(""));
4370     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 1, S("1"));
4371     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 2, S("12"));
4372     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 4, S("1234"));
4373     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 5, S("12345"));
4374     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 6, S("12345"));
4375     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 0, S(""));
4376     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 1, S("2"));
4377     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 2, S("23"));
4378     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 3, S("234"));
4379     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 4, S("2345"));
4380     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 5, S("2345"));
4381     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 0, S(""));
4382     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 1, S("3"));
4383     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 2, S("34"));
4384     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 3, S("345"));
4385     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 4, S("345"));
4386     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 4, 0, S(""));
4387     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 4, 1, S("5"));
4388     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 4, 2, S("5"));
4389     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 5, 0, S(""));
4390     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 5, 1, S(""));
4391     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 6, 0, S("can't happen"));
4392     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 0, S(""));
4393     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 1, S("1"));
4394     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 5, S("12345"));
4395     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 9, S("123456789"));
4396 }
4397 
4398 template <class S>
4399 void test41()
4400 {
4401     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 10, S("1234567890"));
4402     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 11, S("1234567890"));
4403     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 0, S(""));
4404     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 1, S("2"));
4405     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 4, S("2345"));
4406     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 8, S("23456789"));
4407     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 9, S("234567890"));
4408     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 10, S("234567890"));
4409     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 0, S(""));
4410     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 1, S("6"));
4411     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 2, S("67"));
4412     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 4, S("6789"));
4413     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 5, S("67890"));
4414     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 6, S("67890"));
4415     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 9, 0, S(""));
4416     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 9, 1, S("0"));
4417     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 9, 2, S("0"));
4418     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 10, 0, S(""));
4419     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 10, 1, S(""));
4420     test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 11, 0, S("can't happen"));
4421     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 0, S(""));
4422     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 1, S("1"));
4423     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 10, S("1234567890"));
4424     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
4425     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
4426     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
4427     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 0, S(""));
4428     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 1, S("2"));
4429     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 9, S("234567890"));
4430     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 18, S("234567890123456789"));
4431     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
4432     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
4433     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 0, S(""));
4434     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 1, S("1"));
4435     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 5, S("12345"));
4436     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 9, S("123456789"));
4437     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 10, S("1234567890"));
4438     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 11, S("1234567890"));
4439     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 19, 0, S(""));
4440     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 19, 1, S("0"));
4441     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 19, 2, S("0"));
4442     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 20, 0, S(""));
4443     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 20, 1, S(""));
4444     test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 21, 0, S("can't happen"));
4445     test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
4446     test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
4447     test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 1, 0, S("can't happen"));
4448     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
4449     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 1, S("a1bcdefghijklmnopqrst"));
4450     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 2, S("a12bcdefghijklmnopqrst"));
4451     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 4, S("a1234bcdefghijklmnopqrst"));
4452     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 5, S("a12345bcdefghijklmnopqrst"));
4453     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 6, S("a12345bcdefghijklmnopqrst"));
4454     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
4455     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 1, S("a2bcdefghijklmnopqrst"));
4456     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 2, S("a23bcdefghijklmnopqrst"));
4457     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 3, S("a234bcdefghijklmnopqrst"));
4458     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 4, S("a2345bcdefghijklmnopqrst"));
4459     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 5, S("a2345bcdefghijklmnopqrst"));
4460     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
4461     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 1, S("a3bcdefghijklmnopqrst"));
4462     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 2, S("a34bcdefghijklmnopqrst"));
4463     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 3, S("a345bcdefghijklmnopqrst"));
4464     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 4, S("a345bcdefghijklmnopqrst"));
4465     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
4466     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 4, 1, S("a5bcdefghijklmnopqrst"));
4467     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 4, 2, S("a5bcdefghijklmnopqrst"));
4468     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
4469     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
4470     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 6, 0, S("can't happen"));
4471     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
4472     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 1, S("a1bcdefghijklmnopqrst"));
4473     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 5, S("a12345bcdefghijklmnopqrst"));
4474     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 9, S("a123456789bcdefghijklmnopqrst"));
4475     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst"));
4476     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 11, S("a1234567890bcdefghijklmnopqrst"));
4477     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
4478     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 1, S("a2bcdefghijklmnopqrst"));
4479     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 4, S("a2345bcdefghijklmnopqrst"));
4480     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 8, S("a23456789bcdefghijklmnopqrst"));
4481     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst"));
4482     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 10, S("a234567890bcdefghijklmnopqrst"));
4483     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
4484     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 1, S("a6bcdefghijklmnopqrst"));
4485     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 2, S("a67bcdefghijklmnopqrst"));
4486     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 4, S("a6789bcdefghijklmnopqrst"));
4487     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 5, S("a67890bcdefghijklmnopqrst"));
4488     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 6, S("a67890bcdefghijklmnopqrst"));
4489     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
4490     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 9, 1, S("a0bcdefghijklmnopqrst"));
4491     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 9, 2, S("a0bcdefghijklmnopqrst"));
4492     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
4493     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
4494     test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 11, 0, S("can't happen"));
4495     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
4496     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 1, S("a1bcdefghijklmnopqrst"));
4497     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst"));
4498     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghijklmnopqrst"));
4499     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghijklmnopqrst"));
4500     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghijklmnopqrst"));
4501 }
4502 
4503 template <class S>
4504 void test42()
4505 {
4506     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
4507     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 1, S("a2bcdefghijklmnopqrst"));
4508     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst"));
4509     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghijklmnopqrst"));
4510     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghijklmnopqrst"));
4511     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghijklmnopqrst"));
4512     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
4513     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 1, S("a1bcdefghijklmnopqrst"));
4514     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 5, S("a12345bcdefghijklmnopqrst"));
4515     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 9, S("a123456789bcdefghijklmnopqrst"));
4516     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghijklmnopqrst"));
4517     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghijklmnopqrst"));
4518     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
4519     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 19, 1, S("a0bcdefghijklmnopqrst"));
4520     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 19, 2, S("a0bcdefghijklmnopqrst"));
4521     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
4522     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
4523     test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
4524     test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 0, S("acdefghijklmnopqrst"));
4525     test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 1, S("acdefghijklmnopqrst"));
4526     test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 1, 0, S("can't happen"));
4527     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 0, S("acdefghijklmnopqrst"));
4528     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 1, S("a1cdefghijklmnopqrst"));
4529     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 2, S("a12cdefghijklmnopqrst"));
4530     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 4, S("a1234cdefghijklmnopqrst"));
4531     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 5, S("a12345cdefghijklmnopqrst"));
4532     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 6, S("a12345cdefghijklmnopqrst"));
4533     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 0, S("acdefghijklmnopqrst"));
4534     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 1, S("a2cdefghijklmnopqrst"));
4535     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 2, S("a23cdefghijklmnopqrst"));
4536     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 3, S("a234cdefghijklmnopqrst"));
4537     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 4, S("a2345cdefghijklmnopqrst"));
4538     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 5, S("a2345cdefghijklmnopqrst"));
4539     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 0, S("acdefghijklmnopqrst"));
4540     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 1, S("a3cdefghijklmnopqrst"));
4541     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 2, S("a34cdefghijklmnopqrst"));
4542     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 3, S("a345cdefghijklmnopqrst"));
4543     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 4, S("a345cdefghijklmnopqrst"));
4544     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 4, 0, S("acdefghijklmnopqrst"));
4545     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 4, 1, S("a5cdefghijklmnopqrst"));
4546     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 4, 2, S("a5cdefghijklmnopqrst"));
4547     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 5, 0, S("acdefghijklmnopqrst"));
4548     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 5, 1, S("acdefghijklmnopqrst"));
4549     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 6, 0, S("can't happen"));
4550     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 0, S("acdefghijklmnopqrst"));
4551     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 1, S("a1cdefghijklmnopqrst"));
4552     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 5, S("a12345cdefghijklmnopqrst"));
4553     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 9, S("a123456789cdefghijklmnopqrst"));
4554     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 10, S("a1234567890cdefghijklmnopqrst"));
4555     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 11, S("a1234567890cdefghijklmnopqrst"));
4556     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 0, S("acdefghijklmnopqrst"));
4557     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 1, S("a2cdefghijklmnopqrst"));
4558     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 4, S("a2345cdefghijklmnopqrst"));
4559     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 8, S("a23456789cdefghijklmnopqrst"));
4560     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 9, S("a234567890cdefghijklmnopqrst"));
4561     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 10, S("a234567890cdefghijklmnopqrst"));
4562     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 0, S("acdefghijklmnopqrst"));
4563     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 1, S("a6cdefghijklmnopqrst"));
4564     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 2, S("a67cdefghijklmnopqrst"));
4565     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 4, S("a6789cdefghijklmnopqrst"));
4566     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 5, S("a67890cdefghijklmnopqrst"));
4567     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 6, S("a67890cdefghijklmnopqrst"));
4568     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 9, 0, S("acdefghijklmnopqrst"));
4569     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 9, 1, S("a0cdefghijklmnopqrst"));
4570     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 9, 2, S("a0cdefghijklmnopqrst"));
4571     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 10, 0, S("acdefghijklmnopqrst"));
4572     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 10, 1, S("acdefghijklmnopqrst"));
4573     test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 11, 0, S("can't happen"));
4574     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 0, S("acdefghijklmnopqrst"));
4575     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 1, S("a1cdefghijklmnopqrst"));
4576     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 10, S("a1234567890cdefghijklmnopqrst"));
4577     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789cdefghijklmnopqrst"));
4578     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890cdefghijklmnopqrst"));
4579     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890cdefghijklmnopqrst"));
4580     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 0, S("acdefghijklmnopqrst"));
4581     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 1, S("a2cdefghijklmnopqrst"));
4582     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 9, S("a234567890cdefghijklmnopqrst"));
4583     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 18, S("a234567890123456789cdefghijklmnopqrst"));
4584     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890cdefghijklmnopqrst"));
4585     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890cdefghijklmnopqrst"));
4586     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 0, S("acdefghijklmnopqrst"));
4587     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 1, S("a1cdefghijklmnopqrst"));
4588     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 5, S("a12345cdefghijklmnopqrst"));
4589     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 9, S("a123456789cdefghijklmnopqrst"));
4590     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 10, S("a1234567890cdefghijklmnopqrst"));
4591     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 11, S("a1234567890cdefghijklmnopqrst"));
4592     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 19, 0, S("acdefghijklmnopqrst"));
4593     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 19, 1, S("a0cdefghijklmnopqrst"));
4594     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 19, 2, S("a0cdefghijklmnopqrst"));
4595     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 20, 0, S("acdefghijklmnopqrst"));
4596     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 20, 1, S("acdefghijklmnopqrst"));
4597     test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
4598     test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 0, S("aklmnopqrst"));
4599     test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 1, S("aklmnopqrst"));
4600     test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 1, 0, S("can't happen"));
4601     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 0, S("aklmnopqrst"));
4602     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 1, S("a1klmnopqrst"));
4603     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 2, S("a12klmnopqrst"));
4604     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 4, S("a1234klmnopqrst"));
4605     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 5, S("a12345klmnopqrst"));
4606 }
4607 
4608 template <class S>
4609 void test43()
4610 {
4611     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 6, S("a12345klmnopqrst"));
4612     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 0, S("aklmnopqrst"));
4613     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 1, S("a2klmnopqrst"));
4614     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 2, S("a23klmnopqrst"));
4615     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 3, S("a234klmnopqrst"));
4616     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 4, S("a2345klmnopqrst"));
4617     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 5, S("a2345klmnopqrst"));
4618     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 0, S("aklmnopqrst"));
4619     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 1, S("a3klmnopqrst"));
4620     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 2, S("a34klmnopqrst"));
4621     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 3, S("a345klmnopqrst"));
4622     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 4, S("a345klmnopqrst"));
4623     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 4, 0, S("aklmnopqrst"));
4624     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 4, 1, S("a5klmnopqrst"));
4625     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 4, 2, S("a5klmnopqrst"));
4626     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 5, 0, S("aklmnopqrst"));
4627     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 5, 1, S("aklmnopqrst"));
4628     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 6, 0, S("can't happen"));
4629     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 0, S("aklmnopqrst"));
4630     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 1, S("a1klmnopqrst"));
4631     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 5, S("a12345klmnopqrst"));
4632     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 9, S("a123456789klmnopqrst"));
4633     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 10, S("a1234567890klmnopqrst"));
4634     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 11, S("a1234567890klmnopqrst"));
4635     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 0, S("aklmnopqrst"));
4636     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 1, S("a2klmnopqrst"));
4637     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 4, S("a2345klmnopqrst"));
4638     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 8, S("a23456789klmnopqrst"));
4639     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 9, S("a234567890klmnopqrst"));
4640     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 10, S("a234567890klmnopqrst"));
4641     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 0, S("aklmnopqrst"));
4642     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 1, S("a6klmnopqrst"));
4643     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 2, S("a67klmnopqrst"));
4644     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 4, S("a6789klmnopqrst"));
4645     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 5, S("a67890klmnopqrst"));
4646     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 6, S("a67890klmnopqrst"));
4647     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 9, 0, S("aklmnopqrst"));
4648     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 9, 1, S("a0klmnopqrst"));
4649     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 9, 2, S("a0klmnopqrst"));
4650     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 10, 0, S("aklmnopqrst"));
4651     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 10, 1, S("aklmnopqrst"));
4652     test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 11, 0, S("can't happen"));
4653     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 0, S("aklmnopqrst"));
4654     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 1, S("a1klmnopqrst"));
4655     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 10, S("a1234567890klmnopqrst"));
4656     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 19, S("a1234567890123456789klmnopqrst"));
4657     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 20, S("a12345678901234567890klmnopqrst"));
4658     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 21, S("a12345678901234567890klmnopqrst"));
4659     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 0, S("aklmnopqrst"));
4660     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 1, S("a2klmnopqrst"));
4661     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 9, S("a234567890klmnopqrst"));
4662     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 18, S("a234567890123456789klmnopqrst"));
4663     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 19, S("a2345678901234567890klmnopqrst"));
4664     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 20, S("a2345678901234567890klmnopqrst"));
4665     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 0, S("aklmnopqrst"));
4666     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 1, S("a1klmnopqrst"));
4667     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 5, S("a12345klmnopqrst"));
4668     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 9, S("a123456789klmnopqrst"));
4669     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 10, S("a1234567890klmnopqrst"));
4670     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 11, S("a1234567890klmnopqrst"));
4671     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 19, 0, S("aklmnopqrst"));
4672     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 19, 1, S("a0klmnopqrst"));
4673     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 19, 2, S("a0klmnopqrst"));
4674     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 20, 0, S("aklmnopqrst"));
4675     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 20, 1, S("aklmnopqrst"));
4676     test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 21, 0, S("can't happen"));
4677     test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 0, S("at"));
4678     test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 1, S("at"));
4679     test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 1, 0, S("can't happen"));
4680     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 0, S("at"));
4681     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 1, S("a1t"));
4682     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 2, S("a12t"));
4683     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 4, S("a1234t"));
4684     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 5, S("a12345t"));
4685     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 6, S("a12345t"));
4686     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 0, S("at"));
4687     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 1, S("a2t"));
4688     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 2, S("a23t"));
4689     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 3, S("a234t"));
4690     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 4, S("a2345t"));
4691     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 5, S("a2345t"));
4692     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 0, S("at"));
4693     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 1, S("a3t"));
4694     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 2, S("a34t"));
4695     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 3, S("a345t"));
4696     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 4, S("a345t"));
4697     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 4, 0, S("at"));
4698     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 4, 1, S("a5t"));
4699     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 4, 2, S("a5t"));
4700     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 5, 0, S("at"));
4701     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 5, 1, S("at"));
4702     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 6, 0, S("can't happen"));
4703     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 0, S("at"));
4704     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 1, S("a1t"));
4705     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 5, S("a12345t"));
4706     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 9, S("a123456789t"));
4707     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 10, S("a1234567890t"));
4708     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 11, S("a1234567890t"));
4709     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 0, S("at"));
4710     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 1, S("a2t"));
4711 }
4712 
4713 template <class S>
4714 void test44()
4715 {
4716     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 4, S("a2345t"));
4717     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 8, S("a23456789t"));
4718     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 9, S("a234567890t"));
4719     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 10, S("a234567890t"));
4720     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 0, S("at"));
4721     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 1, S("a6t"));
4722     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 2, S("a67t"));
4723     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 4, S("a6789t"));
4724     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 5, S("a67890t"));
4725     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 6, S("a67890t"));
4726     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 9, 0, S("at"));
4727     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 9, 1, S("a0t"));
4728     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 9, 2, S("a0t"));
4729     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 10, 0, S("at"));
4730     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 10, 1, S("at"));
4731     test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 11, 0, S("can't happen"));
4732     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 0, S("at"));
4733     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 1, S("a1t"));
4734     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 10, S("a1234567890t"));
4735     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 19, S("a1234567890123456789t"));
4736     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 20, S("a12345678901234567890t"));
4737     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 21, S("a12345678901234567890t"));
4738     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 0, S("at"));
4739     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 1, S("a2t"));
4740     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 9, S("a234567890t"));
4741     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 18, S("a234567890123456789t"));
4742     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 19, S("a2345678901234567890t"));
4743     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 20, S("a2345678901234567890t"));
4744     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 0, S("at"));
4745     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 1, S("a1t"));
4746     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 5, S("a12345t"));
4747     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 9, S("a123456789t"));
4748     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 10, S("a1234567890t"));
4749     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 11, S("a1234567890t"));
4750     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 19, 0, S("at"));
4751     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 19, 1, S("a0t"));
4752     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 19, 2, S("a0t"));
4753     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 20, 0, S("at"));
4754     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 20, 1, S("at"));
4755     test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 21, 0, S("can't happen"));
4756     test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 0, S("a"));
4757     test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 1, S("a"));
4758     test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 1, 0, S("can't happen"));
4759     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 0, S("a"));
4760     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 1, S("a1"));
4761     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 2, S("a12"));
4762     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 4, S("a1234"));
4763     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 5, S("a12345"));
4764     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 6, S("a12345"));
4765     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 0, S("a"));
4766     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 1, S("a2"));
4767     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 2, S("a23"));
4768     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 3, S("a234"));
4769     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 4, S("a2345"));
4770     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 5, S("a2345"));
4771     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 0, S("a"));
4772     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 1, S("a3"));
4773     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 2, S("a34"));
4774     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 3, S("a345"));
4775     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 4, S("a345"));
4776     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 4, 0, S("a"));
4777     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 4, 1, S("a5"));
4778     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 4, 2, S("a5"));
4779     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 5, 0, S("a"));
4780     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 5, 1, S("a"));
4781     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 6, 0, S("can't happen"));
4782     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 0, S("a"));
4783     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 1, S("a1"));
4784     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 5, S("a12345"));
4785     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 9, S("a123456789"));
4786     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 10, S("a1234567890"));
4787     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 11, S("a1234567890"));
4788     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 0, S("a"));
4789     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 1, S("a2"));
4790     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 4, S("a2345"));
4791     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 8, S("a23456789"));
4792     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 9, S("a234567890"));
4793     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 10, S("a234567890"));
4794     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 0, S("a"));
4795     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 1, S("a6"));
4796     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 2, S("a67"));
4797     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 4, S("a6789"));
4798     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 5, S("a67890"));
4799     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 6, S("a67890"));
4800     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 9, 0, S("a"));
4801     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 9, 1, S("a0"));
4802     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 9, 2, S("a0"));
4803     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 10, 0, S("a"));
4804     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 10, 1, S("a"));
4805     test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 11, 0, S("can't happen"));
4806     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 0, S("a"));
4807     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 1, S("a1"));
4808     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 10, S("a1234567890"));
4809     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
4810     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
4811     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
4812     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 0, S("a"));
4813     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 1, S("a2"));
4814     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 9, S("a234567890"));
4815     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
4816 }
4817 
4818 template <class S>
4819 void test45()
4820 {
4821     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
4822     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
4823     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 0, S("a"));
4824     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 1, S("a1"));
4825     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 5, S("a12345"));
4826     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 9, S("a123456789"));
4827     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 10, S("a1234567890"));
4828     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 11, S("a1234567890"));
4829     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 19, 0, S("a"));
4830     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 19, 1, S("a0"));
4831     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 19, 2, S("a0"));
4832     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 20, 0, S("a"));
4833     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 20, 1, S("a"));
4834     test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 21, 0, S("can't happen"));
4835     test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 0, S("a"));
4836     test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 1, S("a"));
4837     test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 1, 0, S("can't happen"));
4838     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 0, S("a"));
4839     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 1, S("a1"));
4840     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 2, S("a12"));
4841     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 4, S("a1234"));
4842     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 5, S("a12345"));
4843     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 6, S("a12345"));
4844     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 0, S("a"));
4845     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 1, S("a2"));
4846     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 2, S("a23"));
4847     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 3, S("a234"));
4848     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 4, S("a2345"));
4849     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 5, S("a2345"));
4850     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 0, S("a"));
4851     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 1, S("a3"));
4852     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 2, S("a34"));
4853     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 3, S("a345"));
4854     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 4, S("a345"));
4855     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 4, 0, S("a"));
4856     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 4, 1, S("a5"));
4857     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 4, 2, S("a5"));
4858     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 5, 0, S("a"));
4859     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 5, 1, S("a"));
4860     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 6, 0, S("can't happen"));
4861     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 0, S("a"));
4862     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 1, S("a1"));
4863     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 5, S("a12345"));
4864     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 9, S("a123456789"));
4865     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 10, S("a1234567890"));
4866     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 11, S("a1234567890"));
4867     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 0, S("a"));
4868     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 1, S("a2"));
4869     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 4, S("a2345"));
4870     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 8, S("a23456789"));
4871     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 9, S("a234567890"));
4872     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 10, S("a234567890"));
4873     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 0, S("a"));
4874     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 1, S("a6"));
4875     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 2, S("a67"));
4876     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 4, S("a6789"));
4877     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 5, S("a67890"));
4878     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 6, S("a67890"));
4879     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 9, 0, S("a"));
4880     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 9, 1, S("a0"));
4881     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 9, 2, S("a0"));
4882     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 10, 0, S("a"));
4883     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 10, 1, S("a"));
4884     test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 11, 0, S("can't happen"));
4885     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 0, S("a"));
4886     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 1, S("a1"));
4887     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 10, S("a1234567890"));
4888     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
4889     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
4890     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
4891     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 0, S("a"));
4892     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 1, S("a2"));
4893     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 9, S("a234567890"));
4894     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
4895     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
4896     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
4897     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 0, S("a"));
4898     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 1, S("a1"));
4899     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 5, S("a12345"));
4900     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 9, S("a123456789"));
4901     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 10, S("a1234567890"));
4902     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 11, S("a1234567890"));
4903     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 19, 0, S("a"));
4904     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 19, 1, S("a0"));
4905     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 19, 2, S("a0"));
4906     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 20, 0, S("a"));
4907     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 20, 1, S("a"));
4908     test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 21, 0, S("can't happen"));
4909     test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
4910     test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
4911     test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 1, 0, S("can't happen"));
4912     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
4913     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 1, S("abcdefghij1klmnopqrst"));
4914     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 2, S("abcdefghij12klmnopqrst"));
4915     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 4, S("abcdefghij1234klmnopqrst"));
4916     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 5, S("abcdefghij12345klmnopqrst"));
4917     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 6, S("abcdefghij12345klmnopqrst"));
4918     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
4919     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 1, S("abcdefghij2klmnopqrst"));
4920     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 2, S("abcdefghij23klmnopqrst"));
4921 }
4922 
4923 template <class S>
4924 void test46()
4925 {
4926     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 3, S("abcdefghij234klmnopqrst"));
4927     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 4, S("abcdefghij2345klmnopqrst"));
4928     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 5, S("abcdefghij2345klmnopqrst"));
4929     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
4930     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 1, S("abcdefghij3klmnopqrst"));
4931     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 2, S("abcdefghij34klmnopqrst"));
4932     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 3, S("abcdefghij345klmnopqrst"));
4933     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 4, S("abcdefghij345klmnopqrst"));
4934     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
4935     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 4, 1, S("abcdefghij5klmnopqrst"));
4936     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 4, 2, S("abcdefghij5klmnopqrst"));
4937     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
4938     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
4939     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 6, 0, S("can't happen"));
4940     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
4941     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 1, S("abcdefghij1klmnopqrst"));
4942     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 5, S("abcdefghij12345klmnopqrst"));
4943     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 9, S("abcdefghij123456789klmnopqrst"));
4944     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst"));
4945     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 11, S("abcdefghij1234567890klmnopqrst"));
4946     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
4947     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 1, S("abcdefghij2klmnopqrst"));
4948     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 4, S("abcdefghij2345klmnopqrst"));
4949     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 8, S("abcdefghij23456789klmnopqrst"));
4950     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 9, S("abcdefghij234567890klmnopqrst"));
4951     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 10, S("abcdefghij234567890klmnopqrst"));
4952     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
4953     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 1, S("abcdefghij6klmnopqrst"));
4954     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 2, S("abcdefghij67klmnopqrst"));
4955     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 4, S("abcdefghij6789klmnopqrst"));
4956     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 5, S("abcdefghij67890klmnopqrst"));
4957     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 6, S("abcdefghij67890klmnopqrst"));
4958     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
4959     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 9, 1, S("abcdefghij0klmnopqrst"));
4960     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 9, 2, S("abcdefghij0klmnopqrst"));
4961     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
4962     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
4963     test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 11, 0, S("can't happen"));
4964     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
4965     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 1, S("abcdefghij1klmnopqrst"));
4966     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst"));
4967     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789klmnopqrst"));
4968     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890klmnopqrst"));
4969     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890klmnopqrst"));
4970     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
4971     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 1, S("abcdefghij2klmnopqrst"));
4972     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 9, S("abcdefghij234567890klmnopqrst"));
4973     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789klmnopqrst"));
4974     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890klmnopqrst"));
4975     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890klmnopqrst"));
4976     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
4977     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 1, S("abcdefghij1klmnopqrst"));
4978     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 5, S("abcdefghij12345klmnopqrst"));
4979     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 9, S("abcdefghij123456789klmnopqrst"));
4980     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890klmnopqrst"));
4981     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890klmnopqrst"));
4982     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
4983     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 19, 1, S("abcdefghij0klmnopqrst"));
4984     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 19, 2, S("abcdefghij0klmnopqrst"));
4985     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
4986     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
4987     test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
4988     test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 0, S("abcdefghijlmnopqrst"));
4989     test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 1, S("abcdefghijlmnopqrst"));
4990     test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 1, 0, S("can't happen"));
4991     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 0, S("abcdefghijlmnopqrst"));
4992     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 1, S("abcdefghij1lmnopqrst"));
4993     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 2, S("abcdefghij12lmnopqrst"));
4994     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 4, S("abcdefghij1234lmnopqrst"));
4995     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 5, S("abcdefghij12345lmnopqrst"));
4996     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 6, S("abcdefghij12345lmnopqrst"));
4997     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 0, S("abcdefghijlmnopqrst"));
4998     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 1, S("abcdefghij2lmnopqrst"));
4999     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 2, S("abcdefghij23lmnopqrst"));
5000     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 3, S("abcdefghij234lmnopqrst"));
5001     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 4, S("abcdefghij2345lmnopqrst"));
5002     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 5, S("abcdefghij2345lmnopqrst"));
5003     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 0, S("abcdefghijlmnopqrst"));
5004     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 1, S("abcdefghij3lmnopqrst"));
5005     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 2, S("abcdefghij34lmnopqrst"));
5006     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 3, S("abcdefghij345lmnopqrst"));
5007     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 4, S("abcdefghij345lmnopqrst"));
5008     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 4, 0, S("abcdefghijlmnopqrst"));
5009     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 4, 1, S("abcdefghij5lmnopqrst"));
5010     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 4, 2, S("abcdefghij5lmnopqrst"));
5011     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 5, 0, S("abcdefghijlmnopqrst"));
5012     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 5, 1, S("abcdefghijlmnopqrst"));
5013     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 6, 0, S("can't happen"));
5014     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 0, S("abcdefghijlmnopqrst"));
5015     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 1, S("abcdefghij1lmnopqrst"));
5016     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 5, S("abcdefghij12345lmnopqrst"));
5017     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 9, S("abcdefghij123456789lmnopqrst"));
5018     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 10, S("abcdefghij1234567890lmnopqrst"));
5019     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 11, S("abcdefghij1234567890lmnopqrst"));
5020     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 0, S("abcdefghijlmnopqrst"));
5021     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 1, S("abcdefghij2lmnopqrst"));
5022     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 4, S("abcdefghij2345lmnopqrst"));
5023     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 8, S("abcdefghij23456789lmnopqrst"));
5024     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 9, S("abcdefghij234567890lmnopqrst"));
5025     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 10, S("abcdefghij234567890lmnopqrst"));
5026 }
5027 
5028 template <class S>
5029 void test47()
5030 {
5031     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 0, S("abcdefghijlmnopqrst"));
5032     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 1, S("abcdefghij6lmnopqrst"));
5033     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 2, S("abcdefghij67lmnopqrst"));
5034     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 4, S("abcdefghij6789lmnopqrst"));
5035     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 5, S("abcdefghij67890lmnopqrst"));
5036     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 6, S("abcdefghij67890lmnopqrst"));
5037     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 9, 0, S("abcdefghijlmnopqrst"));
5038     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 9, 1, S("abcdefghij0lmnopqrst"));
5039     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 9, 2, S("abcdefghij0lmnopqrst"));
5040     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 10, 0, S("abcdefghijlmnopqrst"));
5041     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 10, 1, S("abcdefghijlmnopqrst"));
5042     test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 11, 0, S("can't happen"));
5043     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 0, S("abcdefghijlmnopqrst"));
5044     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 1, S("abcdefghij1lmnopqrst"));
5045     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890lmnopqrst"));
5046     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789lmnopqrst"));
5047     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890lmnopqrst"));
5048     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890lmnopqrst"));
5049     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 0, S("abcdefghijlmnopqrst"));
5050     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 1, S("abcdefghij2lmnopqrst"));
5051     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 9, S("abcdefghij234567890lmnopqrst"));
5052     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789lmnopqrst"));
5053     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890lmnopqrst"));
5054     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890lmnopqrst"));
5055     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 0, S("abcdefghijlmnopqrst"));
5056     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 1, S("abcdefghij1lmnopqrst"));
5057     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 5, S("abcdefghij12345lmnopqrst"));
5058     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 9, S("abcdefghij123456789lmnopqrst"));
5059     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890lmnopqrst"));
5060     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890lmnopqrst"));
5061     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 19, 0, S("abcdefghijlmnopqrst"));
5062     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 19, 1, S("abcdefghij0lmnopqrst"));
5063     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 19, 2, S("abcdefghij0lmnopqrst"));
5064     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 20, 0, S("abcdefghijlmnopqrst"));
5065     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 20, 1, S("abcdefghijlmnopqrst"));
5066     test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
5067     test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 0, S("abcdefghijpqrst"));
5068     test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 1, S("abcdefghijpqrst"));
5069     test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 1, 0, S("can't happen"));
5070     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 0, S("abcdefghijpqrst"));
5071     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 1, S("abcdefghij1pqrst"));
5072     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 2, S("abcdefghij12pqrst"));
5073     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 4, S("abcdefghij1234pqrst"));
5074     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 5, S("abcdefghij12345pqrst"));
5075     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 6, S("abcdefghij12345pqrst"));
5076     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 0, S("abcdefghijpqrst"));
5077     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 1, S("abcdefghij2pqrst"));
5078     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 2, S("abcdefghij23pqrst"));
5079     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 3, S("abcdefghij234pqrst"));
5080     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 4, S("abcdefghij2345pqrst"));
5081     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 5, S("abcdefghij2345pqrst"));
5082     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 0, S("abcdefghijpqrst"));
5083     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 1, S("abcdefghij3pqrst"));
5084     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 2, S("abcdefghij34pqrst"));
5085     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 3, S("abcdefghij345pqrst"));
5086     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 4, S("abcdefghij345pqrst"));
5087     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 4, 0, S("abcdefghijpqrst"));
5088     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 4, 1, S("abcdefghij5pqrst"));
5089     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 4, 2, S("abcdefghij5pqrst"));
5090     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 5, 0, S("abcdefghijpqrst"));
5091     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 5, 1, S("abcdefghijpqrst"));
5092     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 6, 0, S("can't happen"));
5093     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 0, S("abcdefghijpqrst"));
5094     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 1, S("abcdefghij1pqrst"));
5095     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 5, S("abcdefghij12345pqrst"));
5096     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 9, S("abcdefghij123456789pqrst"));
5097     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 10, S("abcdefghij1234567890pqrst"));
5098     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 11, S("abcdefghij1234567890pqrst"));
5099     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 0, S("abcdefghijpqrst"));
5100     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 1, S("abcdefghij2pqrst"));
5101     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 4, S("abcdefghij2345pqrst"));
5102     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 8, S("abcdefghij23456789pqrst"));
5103     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 9, S("abcdefghij234567890pqrst"));
5104     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 10, S("abcdefghij234567890pqrst"));
5105     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 0, S("abcdefghijpqrst"));
5106     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 1, S("abcdefghij6pqrst"));
5107     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 2, S("abcdefghij67pqrst"));
5108     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 4, S("abcdefghij6789pqrst"));
5109     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 5, S("abcdefghij67890pqrst"));
5110     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 6, S("abcdefghij67890pqrst"));
5111     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 9, 0, S("abcdefghijpqrst"));
5112     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 9, 1, S("abcdefghij0pqrst"));
5113     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 9, 2, S("abcdefghij0pqrst"));
5114     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 10, 0, S("abcdefghijpqrst"));
5115     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 10, 1, S("abcdefghijpqrst"));
5116     test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 11, 0, S("can't happen"));
5117     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 0, S("abcdefghijpqrst"));
5118     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 1, S("abcdefghij1pqrst"));
5119     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890pqrst"));
5120     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789pqrst"));
5121     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890pqrst"));
5122     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890pqrst"));
5123     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 0, S("abcdefghijpqrst"));
5124     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 1, S("abcdefghij2pqrst"));
5125     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 9, S("abcdefghij234567890pqrst"));
5126     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789pqrst"));
5127     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890pqrst"));
5128     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890pqrst"));
5129     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 0, S("abcdefghijpqrst"));
5130     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 1, S("abcdefghij1pqrst"));
5131 }
5132 
5133 template <class S>
5134 void test48()
5135 {
5136     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 5, S("abcdefghij12345pqrst"));
5137     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 9, S("abcdefghij123456789pqrst"));
5138     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890pqrst"));
5139     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890pqrst"));
5140     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 19, 0, S("abcdefghijpqrst"));
5141     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 19, 1, S("abcdefghij0pqrst"));
5142     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 19, 2, S("abcdefghij0pqrst"));
5143     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 20, 0, S("abcdefghijpqrst"));
5144     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 20, 1, S("abcdefghijpqrst"));
5145     test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
5146     test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 0, S("abcdefghijt"));
5147     test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 1, S("abcdefghijt"));
5148     test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 1, 0, S("can't happen"));
5149     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 0, S("abcdefghijt"));
5150     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 1, S("abcdefghij1t"));
5151     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 2, S("abcdefghij12t"));
5152     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 4, S("abcdefghij1234t"));
5153     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 5, S("abcdefghij12345t"));
5154     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 6, S("abcdefghij12345t"));
5155     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 0, S("abcdefghijt"));
5156     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 1, S("abcdefghij2t"));
5157     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 2, S("abcdefghij23t"));
5158     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 3, S("abcdefghij234t"));
5159     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 4, S("abcdefghij2345t"));
5160     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 5, S("abcdefghij2345t"));
5161     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 0, S("abcdefghijt"));
5162     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 1, S("abcdefghij3t"));
5163     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 2, S("abcdefghij34t"));
5164     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 3, S("abcdefghij345t"));
5165     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 4, S("abcdefghij345t"));
5166     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 4, 0, S("abcdefghijt"));
5167     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 4, 1, S("abcdefghij5t"));
5168     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 4, 2, S("abcdefghij5t"));
5169     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 5, 0, S("abcdefghijt"));
5170     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 5, 1, S("abcdefghijt"));
5171     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 6, 0, S("can't happen"));
5172     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 0, S("abcdefghijt"));
5173     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 1, S("abcdefghij1t"));
5174     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 5, S("abcdefghij12345t"));
5175     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 9, S("abcdefghij123456789t"));
5176     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 10, S("abcdefghij1234567890t"));
5177     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 11, S("abcdefghij1234567890t"));
5178     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 0, S("abcdefghijt"));
5179     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 1, S("abcdefghij2t"));
5180     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 4, S("abcdefghij2345t"));
5181     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 8, S("abcdefghij23456789t"));
5182     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 9, S("abcdefghij234567890t"));
5183     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 10, S("abcdefghij234567890t"));
5184     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 0, S("abcdefghijt"));
5185     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 1, S("abcdefghij6t"));
5186     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 2, S("abcdefghij67t"));
5187     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 4, S("abcdefghij6789t"));
5188     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 5, S("abcdefghij67890t"));
5189     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 6, S("abcdefghij67890t"));
5190     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 9, 0, S("abcdefghijt"));
5191     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 9, 1, S("abcdefghij0t"));
5192     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 9, 2, S("abcdefghij0t"));
5193     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 10, 0, S("abcdefghijt"));
5194     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 10, 1, S("abcdefghijt"));
5195     test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 11, 0, S("can't happen"));
5196     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 0, S("abcdefghijt"));
5197     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 1, S("abcdefghij1t"));
5198     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890t"));
5199     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789t"));
5200     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890t"));
5201     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890t"));
5202     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 0, S("abcdefghijt"));
5203     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 1, S("abcdefghij2t"));
5204     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 9, S("abcdefghij234567890t"));
5205     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789t"));
5206     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890t"));
5207     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890t"));
5208     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 0, S("abcdefghijt"));
5209     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 1, S("abcdefghij1t"));
5210     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 5, S("abcdefghij12345t"));
5211     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 9, S("abcdefghij123456789t"));
5212     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890t"));
5213     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890t"));
5214     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 19, 0, S("abcdefghijt"));
5215     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 19, 1, S("abcdefghij0t"));
5216     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 19, 2, S("abcdefghij0t"));
5217     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 20, 0, S("abcdefghijt"));
5218     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 20, 1, S("abcdefghijt"));
5219     test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 21, 0, S("can't happen"));
5220     test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 0, S("abcdefghij"));
5221     test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 1, S("abcdefghij"));
5222     test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 1, 0, S("can't happen"));
5223     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 0, S("abcdefghij"));
5224     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 1, S("abcdefghij1"));
5225     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 2, S("abcdefghij12"));
5226     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 4, S("abcdefghij1234"));
5227     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 5, S("abcdefghij12345"));
5228     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 6, S("abcdefghij12345"));
5229     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 0, S("abcdefghij"));
5230     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 1, S("abcdefghij2"));
5231     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 2, S("abcdefghij23"));
5232     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 3, S("abcdefghij234"));
5233     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 4, S("abcdefghij2345"));
5234     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 5, S("abcdefghij2345"));
5235     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 0, S("abcdefghij"));
5236 }
5237 
5238 template <class S>
5239 void test49()
5240 {
5241     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 1, S("abcdefghij3"));
5242     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 2, S("abcdefghij34"));
5243     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 3, S("abcdefghij345"));
5244     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 4, S("abcdefghij345"));
5245     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 4, 0, S("abcdefghij"));
5246     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 4, 1, S("abcdefghij5"));
5247     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 4, 2, S("abcdefghij5"));
5248     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 5, 0, S("abcdefghij"));
5249     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 5, 1, S("abcdefghij"));
5250     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 6, 0, S("can't happen"));
5251     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 0, S("abcdefghij"));
5252     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 1, S("abcdefghij1"));
5253     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 5, S("abcdefghij12345"));
5254     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 9, S("abcdefghij123456789"));
5255     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
5256     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
5257     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 0, S("abcdefghij"));
5258     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 1, S("abcdefghij2"));
5259     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 4, S("abcdefghij2345"));
5260     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 8, S("abcdefghij23456789"));
5261     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 9, S("abcdefghij234567890"));
5262     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 10, S("abcdefghij234567890"));
5263     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 0, S("abcdefghij"));
5264     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 1, S("abcdefghij6"));
5265     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 2, S("abcdefghij67"));
5266     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 4, S("abcdefghij6789"));
5267     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 5, S("abcdefghij67890"));
5268     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 6, S("abcdefghij67890"));
5269     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 9, 0, S("abcdefghij"));
5270     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 9, 1, S("abcdefghij0"));
5271     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 9, 2, S("abcdefghij0"));
5272     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 10, 0, S("abcdefghij"));
5273     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 10, 1, S("abcdefghij"));
5274     test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 11, 0, S("can't happen"));
5275     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 0, S("abcdefghij"));
5276     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
5277     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
5278     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
5279     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
5280     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
5281     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 0, S("abcdefghij"));
5282     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
5283     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
5284     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
5285     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
5286     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
5287     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 0, S("abcdefghij"));
5288     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
5289     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
5290     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
5291     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
5292     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
5293     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 19, 0, S("abcdefghij"));
5294     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
5295     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
5296     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 20, 0, S("abcdefghij"));
5297     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 20, 1, S("abcdefghij"));
5298     test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 21, 0, S("can't happen"));
5299     test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 0, S("abcdefghij"));
5300     test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 1, S("abcdefghij"));
5301     test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 1, 0, S("can't happen"));
5302     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 0, S("abcdefghij"));
5303     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 1, S("abcdefghij1"));
5304     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 2, S("abcdefghij12"));
5305     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 4, S("abcdefghij1234"));
5306     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 5, S("abcdefghij12345"));
5307     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 6, S("abcdefghij12345"));
5308     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 0, S("abcdefghij"));
5309     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 1, S("abcdefghij2"));
5310     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 2, S("abcdefghij23"));
5311     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 3, S("abcdefghij234"));
5312     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 4, S("abcdefghij2345"));
5313     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 5, S("abcdefghij2345"));
5314     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 0, S("abcdefghij"));
5315     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 1, S("abcdefghij3"));
5316     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 2, S("abcdefghij34"));
5317     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 3, S("abcdefghij345"));
5318     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 4, S("abcdefghij345"));
5319     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 4, 0, S("abcdefghij"));
5320     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 4, 1, S("abcdefghij5"));
5321     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 4, 2, S("abcdefghij5"));
5322     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 5, 0, S("abcdefghij"));
5323     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 5, 1, S("abcdefghij"));
5324     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 6, 0, S("can't happen"));
5325     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 0, S("abcdefghij"));
5326     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 1, S("abcdefghij1"));
5327     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 5, S("abcdefghij12345"));
5328     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 9, S("abcdefghij123456789"));
5329     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
5330     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
5331     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 0, S("abcdefghij"));
5332     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 1, S("abcdefghij2"));
5333     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 4, S("abcdefghij2345"));
5334     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 8, S("abcdefghij23456789"));
5335     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 9, S("abcdefghij234567890"));
5336     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 10, S("abcdefghij234567890"));
5337     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 0, S("abcdefghij"));
5338     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 1, S("abcdefghij6"));
5339     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 2, S("abcdefghij67"));
5340     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 4, S("abcdefghij6789"));
5341 }
5342 
5343 template <class S>
5344 void test50()
5345 {
5346     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 5, S("abcdefghij67890"));
5347     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 6, S("abcdefghij67890"));
5348     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 9, 0, S("abcdefghij"));
5349     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 9, 1, S("abcdefghij0"));
5350     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 9, 2, S("abcdefghij0"));
5351     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 10, 0, S("abcdefghij"));
5352     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 10, 1, S("abcdefghij"));
5353     test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 11, 0, S("can't happen"));
5354     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 0, S("abcdefghij"));
5355     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
5356     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
5357     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
5358     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
5359     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
5360     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 0, S("abcdefghij"));
5361     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
5362     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
5363     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
5364     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
5365     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
5366     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 0, S("abcdefghij"));
5367     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
5368     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
5369     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
5370     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
5371     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
5372     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 19, 0, S("abcdefghij"));
5373     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
5374     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
5375     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 20, 0, S("abcdefghij"));
5376     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 20, 1, S("abcdefghij"));
5377     test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 21, 0, S("can't happen"));
5378     test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
5379     test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
5380     test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 1, 0, S("can't happen"));
5381     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
5382     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 1, S("abcdefghijklmnopqrs1t"));
5383     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 2, S("abcdefghijklmnopqrs12t"));
5384     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234t"));
5385     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345t"));
5386     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345t"));
5387     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
5388     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 1, S("abcdefghijklmnopqrs2t"));
5389     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 2, S("abcdefghijklmnopqrs23t"));
5390     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 3, S("abcdefghijklmnopqrs234t"));
5391     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345t"));
5392     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345t"));
5393     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
5394     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 1, S("abcdefghijklmnopqrs3t"));
5395     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 2, S("abcdefghijklmnopqrs34t"));
5396     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 3, S("abcdefghijklmnopqrs345t"));
5397     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 4, S("abcdefghijklmnopqrs345t"));
5398     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
5399     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 4, 1, S("abcdefghijklmnopqrs5t"));
5400     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 4, 2, S("abcdefghijklmnopqrs5t"));
5401     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
5402     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
5403     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 6, 0, S("can't happen"));
5404     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
5405     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1t"));
5406     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345t"));
5407     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789t"));
5408     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t"));
5409     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890t"));
5410     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
5411     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2t"));
5412     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345t"));
5413     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789t"));
5414     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t"));
5415     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890t"));
5416     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
5417     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6t"));
5418     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67t"));
5419     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789t"));
5420     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890t"));
5421     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890t"));
5422     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
5423     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0t"));
5424     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0t"));
5425     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
5426     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
5427     test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 11, 0, S("can't happen"));
5428     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
5429     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1t"));
5430     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t"));
5431     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789t"));
5432     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890t"));
5433     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890t"));
5434     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
5435     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2t"));
5436     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t"));
5437     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789t"));
5438     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890t"));
5439     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890t"));
5440     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
5441     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1t"));
5442     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345t"));
5443     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789t"));
5444     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890t"));
5445     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890t"));
5446 }
5447 
5448 template <class S>
5449 void test51()
5450 {
5451     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
5452     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0t"));
5453     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0t"));
5454     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
5455     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
5456     test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
5457     test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 0, S("abcdefghijklmnopqrs"));
5458     test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 1, S("abcdefghijklmnopqrs"));
5459     test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 1, 0, S("can't happen"));
5460     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 0, S("abcdefghijklmnopqrs"));
5461     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 1, S("abcdefghijklmnopqrs1"));
5462     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 2, S("abcdefghijklmnopqrs12"));
5463     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234"));
5464     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345"));
5465     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345"));
5466     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 0, S("abcdefghijklmnopqrs"));
5467     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 1, S("abcdefghijklmnopqrs2"));
5468     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 2, S("abcdefghijklmnopqrs23"));
5469     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 3, S("abcdefghijklmnopqrs234"));
5470     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345"));
5471     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345"));
5472     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 0, S("abcdefghijklmnopqrs"));
5473     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 1, S("abcdefghijklmnopqrs3"));
5474     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 2, S("abcdefghijklmnopqrs34"));
5475     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 3, S("abcdefghijklmnopqrs345"));
5476     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 4, S("abcdefghijklmnopqrs345"));
5477     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 4, 0, S("abcdefghijklmnopqrs"));
5478     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 4, 1, S("abcdefghijklmnopqrs5"));
5479     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 4, 2, S("abcdefghijklmnopqrs5"));
5480     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 5, 0, S("abcdefghijklmnopqrs"));
5481     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 5, 1, S("abcdefghijklmnopqrs"));
5482     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 6, 0, S("can't happen"));
5483     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 0, S("abcdefghijklmnopqrs"));
5484     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1"));
5485     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345"));
5486     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789"));
5487     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890"));
5488     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890"));
5489     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 0, S("abcdefghijklmnopqrs"));
5490     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2"));
5491     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345"));
5492     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789"));
5493     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890"));
5494     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890"));
5495     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 0, S("abcdefghijklmnopqrs"));
5496     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6"));
5497     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67"));
5498     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789"));
5499     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890"));
5500     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890"));
5501     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 9, 0, S("abcdefghijklmnopqrs"));
5502     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0"));
5503     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0"));
5504     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 10, 0, S("abcdefghijklmnopqrs"));
5505     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 10, 1, S("abcdefghijklmnopqrs"));
5506     test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 11, 0, S("can't happen"));
5507     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrs"));
5508     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1"));
5509     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890"));
5510     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789"));
5511     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890"));
5512     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890"));
5513     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrs"));
5514     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2"));
5515     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890"));
5516     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789"));
5517     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890"));
5518     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890"));
5519     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrs"));
5520     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1"));
5521     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345"));
5522     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789"));
5523     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890"));
5524     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890"));
5525     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrs"));
5526     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0"));
5527     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0"));
5528     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrs"));
5529     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrs"));
5530     test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
5531     test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 0, S("abcdefghijklmnopqrs"));
5532     test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 1, S("abcdefghijklmnopqrs"));
5533     test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 1, 0, S("can't happen"));
5534     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 0, S("abcdefghijklmnopqrs"));
5535     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 1, S("abcdefghijklmnopqrs1"));
5536     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 2, S("abcdefghijklmnopqrs12"));
5537     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234"));
5538     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345"));
5539     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345"));
5540     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 0, S("abcdefghijklmnopqrs"));
5541     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 1, S("abcdefghijklmnopqrs2"));
5542     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 2, S("abcdefghijklmnopqrs23"));
5543     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 3, S("abcdefghijklmnopqrs234"));
5544     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345"));
5545     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345"));
5546     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 0, S("abcdefghijklmnopqrs"));
5547     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 1, S("abcdefghijklmnopqrs3"));
5548     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 2, S("abcdefghijklmnopqrs34"));
5549     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 3, S("abcdefghijklmnopqrs345"));
5550     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 4, S("abcdefghijklmnopqrs345"));
5551 }
5552 
5553 template <class S>
5554 void test52()
5555 {
5556     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 4, 0, S("abcdefghijklmnopqrs"));
5557     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 4, 1, S("abcdefghijklmnopqrs5"));
5558     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 4, 2, S("abcdefghijklmnopqrs5"));
5559     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 5, 0, S("abcdefghijklmnopqrs"));
5560     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 5, 1, S("abcdefghijklmnopqrs"));
5561     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 6, 0, S("can't happen"));
5562     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 0, S("abcdefghijklmnopqrs"));
5563     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1"));
5564     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345"));
5565     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789"));
5566     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890"));
5567     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890"));
5568     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 0, S("abcdefghijklmnopqrs"));
5569     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2"));
5570     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345"));
5571     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789"));
5572     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890"));
5573     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890"));
5574     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 0, S("abcdefghijklmnopqrs"));
5575     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6"));
5576     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67"));
5577     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789"));
5578     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890"));
5579     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890"));
5580     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 9, 0, S("abcdefghijklmnopqrs"));
5581     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0"));
5582     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0"));
5583     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 10, 0, S("abcdefghijklmnopqrs"));
5584     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 10, 1, S("abcdefghijklmnopqrs"));
5585     test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 11, 0, S("can't happen"));
5586     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrs"));
5587     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1"));
5588     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890"));
5589     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789"));
5590     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890"));
5591     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890"));
5592     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrs"));
5593     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2"));
5594     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890"));
5595     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789"));
5596     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890"));
5597     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890"));
5598     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrs"));
5599     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1"));
5600     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345"));
5601     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789"));
5602     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890"));
5603     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890"));
5604     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrs"));
5605     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0"));
5606     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0"));
5607     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrs"));
5608     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrs"));
5609     test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
5610     test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
5611     test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
5612     test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 1, 0, S("can't happen"));
5613     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
5614     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 1, S("abcdefghijklmnopqrst1"));
5615     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 2, S("abcdefghijklmnopqrst12"));
5616     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 4, S("abcdefghijklmnopqrst1234"));
5617     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 5, S("abcdefghijklmnopqrst12345"));
5618     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 6, S("abcdefghijklmnopqrst12345"));
5619     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
5620     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 1, S("abcdefghijklmnopqrst2"));
5621     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 2, S("abcdefghijklmnopqrst23"));
5622     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 3, S("abcdefghijklmnopqrst234"));
5623     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 4, S("abcdefghijklmnopqrst2345"));
5624     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 5, S("abcdefghijklmnopqrst2345"));
5625     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
5626     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 1, S("abcdefghijklmnopqrst3"));
5627     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 2, S("abcdefghijklmnopqrst34"));
5628     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 3, S("abcdefghijklmnopqrst345"));
5629     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 4, S("abcdefghijklmnopqrst345"));
5630     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
5631     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 4, 1, S("abcdefghijklmnopqrst5"));
5632     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 4, 2, S("abcdefghijklmnopqrst5"));
5633     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
5634     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
5635     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 6, 0, S("can't happen"));
5636     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
5637     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
5638     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 5, S("abcdefghijklmnopqrst12345"));
5639     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 9, S("abcdefghijklmnopqrst123456789"));
5640     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
5641     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 11, S("abcdefghijklmnopqrst1234567890"));
5642     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
5643     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
5644     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 4, S("abcdefghijklmnopqrst2345"));
5645     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 8, S("abcdefghijklmnopqrst23456789"));
5646     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
5647     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 10, S("abcdefghijklmnopqrst234567890"));
5648     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
5649     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 1, S("abcdefghijklmnopqrst6"));
5650     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 2, S("abcdefghijklmnopqrst67"));
5651     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 4, S("abcdefghijklmnopqrst6789"));
5652     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 5, S("abcdefghijklmnopqrst67890"));
5653     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 6, S("abcdefghijklmnopqrst67890"));
5654     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
5655     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 9, 1, S("abcdefghijklmnopqrst0"));
5656 }
5657 
5658 template <class S>
5659 void test53()
5660 {
5661     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 9, 2, S("abcdefghijklmnopqrst0"));
5662     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
5663     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
5664     test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 11, 0, S("can't happen"));
5665     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
5666     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
5667     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
5668     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrst1234567890123456789"));
5669     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrst12345678901234567890"));
5670     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrst12345678901234567890"));
5671     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
5672     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
5673     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
5674     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrst234567890123456789"));
5675     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrst2345678901234567890"));
5676     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrst2345678901234567890"));
5677     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
5678     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrst1"));
5679     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrst12345"));
5680     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrst123456789"));
5681     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrst1234567890"));
5682     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrst1234567890"));
5683     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
5684     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrst0"));
5685     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrst0"));
5686     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
5687     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
5688     test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
5689     test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 0, S("abcdefghijklmnopqrst"));
5690     test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 1, S("abcdefghijklmnopqrst"));
5691     test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 1, 0, S("can't happen"));
5692     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
5693     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 1, S("abcdefghijklmnopqrst1"));
5694     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 2, S("abcdefghijklmnopqrst12"));
5695     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 4, S("abcdefghijklmnopqrst1234"));
5696     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 5, S("abcdefghijklmnopqrst12345"));
5697     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 6, S("abcdefghijklmnopqrst12345"));
5698     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
5699     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 1, S("abcdefghijklmnopqrst2"));
5700     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 2, S("abcdefghijklmnopqrst23"));
5701     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 3, S("abcdefghijklmnopqrst234"));
5702     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 4, S("abcdefghijklmnopqrst2345"));
5703     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 5, S("abcdefghijklmnopqrst2345"));
5704     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
5705     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 1, S("abcdefghijklmnopqrst3"));
5706     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 2, S("abcdefghijklmnopqrst34"));
5707     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 3, S("abcdefghijklmnopqrst345"));
5708     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 4, S("abcdefghijklmnopqrst345"));
5709     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
5710     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 4, 1, S("abcdefghijklmnopqrst5"));
5711     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 4, 2, S("abcdefghijklmnopqrst5"));
5712     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
5713     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
5714     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 6, 0, S("can't happen"));
5715     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
5716     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
5717     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 5, S("abcdefghijklmnopqrst12345"));
5718     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 9, S("abcdefghijklmnopqrst123456789"));
5719     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
5720     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 11, S("abcdefghijklmnopqrst1234567890"));
5721     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
5722     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
5723     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 4, S("abcdefghijklmnopqrst2345"));
5724     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 8, S("abcdefghijklmnopqrst23456789"));
5725     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
5726     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 10, S("abcdefghijklmnopqrst234567890"));
5727     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
5728     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 1, S("abcdefghijklmnopqrst6"));
5729     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 2, S("abcdefghijklmnopqrst67"));
5730     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 4, S("abcdefghijklmnopqrst6789"));
5731     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 5, S("abcdefghijklmnopqrst67890"));
5732     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 6, S("abcdefghijklmnopqrst67890"));
5733     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
5734     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 9, 1, S("abcdefghijklmnopqrst0"));
5735     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 9, 2, S("abcdefghijklmnopqrst0"));
5736     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
5737     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
5738     test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 11, 0, S("can't happen"));
5739     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
5740     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
5741     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
5742     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrst1234567890123456789"));
5743     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrst12345678901234567890"));
5744     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrst12345678901234567890"));
5745     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
5746     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
5747     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
5748     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrst234567890123456789"));
5749     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrst2345678901234567890"));
5750     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrst2345678901234567890"));
5751     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
5752     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrst1"));
5753     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrst12345"));
5754     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrst123456789"));
5755     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrst1234567890"));
5756     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrst1234567890"));
5757     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
5758     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrst0"));
5759     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrst0"));
5760     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
5761 }
5762 
5763 template <class S>
5764 void test54()
5765 {
5766     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
5767     test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
5768     test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 0, S("can't happen"));
5769     test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 1, S("can't happen"));
5770     test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 1, 0, S("can't happen"));
5771     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 0, S("can't happen"));
5772     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 1, S("can't happen"));
5773     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 2, S("can't happen"));
5774     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 4, S("can't happen"));
5775     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 5, S("can't happen"));
5776     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 6, S("can't happen"));
5777     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 0, S("can't happen"));
5778     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 1, S("can't happen"));
5779     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 2, S("can't happen"));
5780     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 3, S("can't happen"));
5781     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 4, S("can't happen"));
5782     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 5, S("can't happen"));
5783     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 0, S("can't happen"));
5784     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 1, S("can't happen"));
5785     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 2, S("can't happen"));
5786     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 3, S("can't happen"));
5787     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 4, S("can't happen"));
5788     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 4, 0, S("can't happen"));
5789     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 4, 1, S("can't happen"));
5790     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 4, 2, S("can't happen"));
5791     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 5, 0, S("can't happen"));
5792     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 5, 1, S("can't happen"));
5793     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 6, 0, S("can't happen"));
5794     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 0, S("can't happen"));
5795     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 1, S("can't happen"));
5796     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 5, S("can't happen"));
5797     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 9, S("can't happen"));
5798     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 10, S("can't happen"));
5799     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 11, S("can't happen"));
5800     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 0, S("can't happen"));
5801     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 1, S("can't happen"));
5802     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 4, S("can't happen"));
5803     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 8, S("can't happen"));
5804     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 9, S("can't happen"));
5805     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 10, S("can't happen"));
5806     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 0, S("can't happen"));
5807     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 1, S("can't happen"));
5808     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 2, S("can't happen"));
5809     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 4, S("can't happen"));
5810     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 5, S("can't happen"));
5811     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 6, S("can't happen"));
5812     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 9, 0, S("can't happen"));
5813     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 9, 1, S("can't happen"));
5814     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 9, 2, S("can't happen"));
5815     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 10, 0, S("can't happen"));
5816     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 10, 1, S("can't happen"));
5817     test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 11, 0, S("can't happen"));
5818     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 0, S("can't happen"));
5819     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 1, S("can't happen"));
5820     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 10, S("can't happen"));
5821     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 19, S("can't happen"));
5822     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 20, S("can't happen"));
5823     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 21, S("can't happen"));
5824     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 0, S("can't happen"));
5825     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 1, S("can't happen"));
5826     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 9, S("can't happen"));
5827     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 18, S("can't happen"));
5828     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 19, S("can't happen"));
5829     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 20, S("can't happen"));
5830     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 0, S("can't happen"));
5831     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 1, S("can't happen"));
5832     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 5, S("can't happen"));
5833     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 9, S("can't happen"));
5834     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 10, S("can't happen"));
5835     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 11, S("can't happen"));
5836     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 19, 0, S("can't happen"));
5837     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 19, 1, S("can't happen"));
5838     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 19, 2, S("can't happen"));
5839     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 20, 0, S("can't happen"));
5840     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 20, 1, S("can't happen"));
5841     test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
5842 }
5843 
5844 template <class S>
5845 void test55()
5846 {
5847     test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, S("abcdefghi1234567890"));
5848     test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, S("abcdefghi0"));
5849     test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, S("abcdefghi"));
5850     test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, S("abcdefghi"));
5851     test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 21, S("can't happen"));
5852     test_npos(S("abcdefghij"), 9, 2, S(""), 0, S("abcdefghi"));
5853     test_npos(S("abcdefghij"), 9, 2, S(""), 1, S("can't happen"));
5854     test_npos(S("abcdefghij"), 9, 2, S("12345"), 0, S("abcdefghi12345"));
5855     test_npos(S("abcdefghij"), 9, 2, S("12345"), 1, S("abcdefghi2345"));
5856     test_npos(S("abcdefghij"), 9, 2, S("12345"), 2, S("abcdefghi345"));
5857     test_npos(S("abcdefghij"), 9, 2, S("12345"), 4, S("abcdefghi5"));
5858     test_npos(S("abcdefghij"), 9, 2, S("12345"), 5, S("abcdefghi"));
5859     test_npos(S("abcdefghij"), 9, 2, S("12345"), 6, S("can't happen"));
5860 }
5861 
5862 int main(int, char**)
5863 {
5864     {
5865     typedef std::string S;
5866     test0<S>();
5867     test1<S>();
5868     test2<S>();
5869     test3<S>();
5870     test4<S>();
5871     test5<S>();
5872     test6<S>();
5873     test7<S>();
5874     test8<S>();
5875     test9<S>();
5876     test10<S>();
5877     test11<S>();
5878     test12<S>();
5879     test13<S>();
5880     test14<S>();
5881     test15<S>();
5882     test16<S>();
5883     test17<S>();
5884     test18<S>();
5885     test19<S>();
5886     test20<S>();
5887     test21<S>();
5888     test22<S>();
5889     test23<S>();
5890     test24<S>();
5891     test25<S>();
5892     test26<S>();
5893     test27<S>();
5894     test28<S>();
5895     test29<S>();
5896     test30<S>();
5897     test31<S>();
5898     test32<S>();
5899     test33<S>();
5900     test34<S>();
5901     test35<S>();
5902     test36<S>();
5903     test37<S>();
5904     test38<S>();
5905     test39<S>();
5906     test40<S>();
5907     test41<S>();
5908     test42<S>();
5909     test43<S>();
5910     test44<S>();
5911     test45<S>();
5912     test46<S>();
5913     test47<S>();
5914     test48<S>();
5915     test49<S>();
5916     test50<S>();
5917     test51<S>();
5918     test52<S>();
5919     test53<S>();
5920     test54<S>();
5921     test55<S>();
5922     }
5923 #if TEST_STD_VER >= 11
5924     {
5925     typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
5926     test0<S>();
5927     test1<S>();
5928     test2<S>();
5929     test3<S>();
5930     test4<S>();
5931     test5<S>();
5932     test6<S>();
5933     test7<S>();
5934     test8<S>();
5935     test9<S>();
5936     test10<S>();
5937     test11<S>();
5938     test12<S>();
5939     test13<S>();
5940     test14<S>();
5941     test15<S>();
5942     test16<S>();
5943     test17<S>();
5944     test18<S>();
5945     test19<S>();
5946     test20<S>();
5947     test21<S>();
5948     test22<S>();
5949     test23<S>();
5950     test24<S>();
5951     test25<S>();
5952     test26<S>();
5953     test27<S>();
5954     test28<S>();
5955     test29<S>();
5956     test30<S>();
5957     test31<S>();
5958     test32<S>();
5959     test33<S>();
5960     test34<S>();
5961     test35<S>();
5962     test36<S>();
5963     test37<S>();
5964     test38<S>();
5965     test39<S>();
5966     test40<S>();
5967     test41<S>();
5968     test42<S>();
5969     test43<S>();
5970     test44<S>();
5971     test45<S>();
5972     test46<S>();
5973     test47<S>();
5974     test48<S>();
5975     test49<S>();
5976     test50<S>();
5977     test51<S>();
5978     test52<S>();
5979     test53<S>();
5980     test54<S>();
5981     test55<S>();
5982     }
5983 #endif
5984 
5985   return 0;
5986 }
5987