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