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