41#define Insert(sig) StringIds::insert_ ## sig
43static const char*
const exceptions[] = {
44 "unknown exception",
"out_of_range",
"length_error",
45 "bad_alloc",
"exception"
53size_cptr_test_cases [] = {
56#define TEST(str, off, arg, res, bthrow) { \
57 __LINE__, off, -1, -1, -1, -1, str, sizeof str - 1, \
58 arg, sizeof arg - 1, res, sizeof res - 1, bthrow \
73 TEST (
"ab", 0,
"c",
"cab", 0),
75 TEST (
"", 0,
"",
"", 0),
76 TEST (
"", 0,
"abc",
"abc", 0),
78 TEST (
"<U0>", 0,
"",
"<U0>", 0),
79 TEST (
"", 0,
"<U0>",
"", 0),
81 TEST (
"abc", 0,
"",
"abc", 0),
82 TEST (
"abc", 1,
"",
"abc", 0),
83 TEST (
"abc", 3,
"",
"abc", 0),
85 TEST (
"<U0>", 0,
"a",
"a<U0>", 0),
86 TEST (
"<U0>", 1,
"a",
"<U0>a", 0),
87 TEST (
"<U0>", 0,
"<U0>",
"<U0>", 0),
88 TEST (
"<U0>", 1,
"<U0>@2",
"<U0>", 0),
90 TEST (
"cde", 0,
"ab",
"abcde", 0),
91 TEST (
"cde", 1,
"ab",
"cabde", 0),
92 TEST (
"cde", 2,
"ab",
"cdabe", 0),
93 TEST (
"cde", 3,
"ab",
"cdeab", 0),
95 TEST (
"<U0>ab<U0>@2c", 0,
"<U0>e<U0>",
"<U0>ab<U0>@2c", 0),
96 TEST (
"a<U0>b<U0>@2c", 2,
"e<U0>e",
"a<U0>eb<U0>@2c", 0),
97 TEST (
"a<U0>bc<U0>@2", 6,
"e<U0>e",
"a<U0>bc<U0>@2e", 0),
99 TEST (
"", 0, 0,
"", 0),
100 TEST (
"abc", 0, 0,
"abcabc", 0),
101 TEST (
"abc", 2, 0,
"ababcc", 0),
102 TEST (
"a<U0>bc<U0>@2", 0, 0,
"aa<U0>bc<U0>@2", 0),
103 TEST (
"a<U0>bc<U0>@2", 6, 0,
"a<U0>bc<U0>@2a", 0),
104 TEST (
"x@4096", 5, 0,
"x@8192", 0),
106 TEST (
"", 0,
"x@4096",
"x@4096", 0),
107 TEST (
"x@4096", 0,
"",
"x@4096", 0),
108 TEST (
"x@4096", 2,
"a@100",
"xxa@100x@4094", 0),
109 TEST (
"a@102", 2,
"x@4096",
"aax@4096a@100", 0),
111 TEST (
"x@10", 1,
"x@118",
"x@128", 0),
112 TEST (
"x@128", 128,
"x@79",
"x@207", 0),
113 TEST (
"x@207", 0,
"x@127",
"x@334", 0),
114 TEST (
"x@334", 1,
"x@206",
"x@540", 0),
115 TEST (
"x@540", 539,
"x@333",
"x@873", 0),
116 TEST (
"x@539", 539,
"x@873",
"x@1412", 0),
117 TEST (
"x@872", 0,
"x@1412",
"x@2284", 0),
118 TEST (
"x@1411", 207,
"x@2284",
"x@3695", 0),
119 TEST (
"x@1412", 0,
"x@2284",
"x@3696", 0),
121 TEST (
"<U0>", 2,
"",
"", 1),
122 TEST (
"a", 2,
"",
"", 1),
123 TEST (
"x@4096", 4106,
"",
"", 1),
125 TEST (
"last", 4,
"test",
"lasttest", 0)
133size_cstr_test_cases [] = {
136#define TEST(str, off, arg, res, bthrow) { \
137 __LINE__, off, -1, -1, -1, -1, str, sizeof str - 1, \
138 arg, sizeof arg - 1, res, sizeof res - 1, bthrow \
153 TEST (
"ab", 0,
"c",
"cab", 0),
155 TEST (
"", 0,
"",
"", 0),
156 TEST (
"", 0,
"abc",
"abc", 0),
158 TEST (
"<U0>", 0,
"",
"<U0>", 0),
159 TEST (
"", 0,
"<U0>",
"<U0>", 0),
161 TEST (
"abc", 0,
"",
"abc", 0),
162 TEST (
"abc", 1,
"",
"abc", 0),
163 TEST (
"abc", 3,
"",
"abc", 0),
165 TEST (
"<U0>", 0,
"a",
"a<U0>", 0),
166 TEST (
"<U0>", 1,
"a",
"<U0>a", 0),
167 TEST (
"<U0>", 0,
"<U0>",
"<U0>@2", 0),
168 TEST (
"<U0>", 1,
"<U0>@2",
"<U0>@3", 0),
170 TEST (
"cde", 0,
"ab",
"abcde", 0),
171 TEST (
"cde", 1,
"ab",
"cabde", 0),
172 TEST (
"cde", 2,
"ab",
"cdabe", 0),
173 TEST (
"cde", 3,
"ab",
"cdeab", 0),
175 TEST (
"<U0>ab<U0>@2c", 0,
"<U0>e<U0>",
"<U0>e<U0>@2ab<U0>@2c", 0),
176 TEST (
"a<U0>b<U0>@2c", 2,
"e<U0>e",
"a<U0>e<U0>eb<U0>@2c", 0),
177 TEST (
"a<U0>bc<U0>@2", 6,
"e<U0>@2e<U0>",
"a<U0>bc<U0>@2e<U0>@2e<U0>", 0),
179 TEST (
"abc", 0, 0,
"abcabc", 0),
180 TEST (
"abc", 2, 0,
"ababcc", 0),
181 TEST (
"a<U0>bc<U0>@2", 0, 0,
"a<U0>bc<U0>@2a<U0>bc<U0>@2", 0),
182 TEST (
"a<U0>bc<U0>@2", 6, 0,
"a<U0>bc<U0>@2a<U0>bc<U0>@2", 0),
183 TEST (
"x@4096", 5, 0,
"x@8192", 0),
185 TEST (
"", 0,
"x@4096",
"x@4096", 0),
186 TEST (
"x@4096", 0,
"",
"x@4096", 0),
187 TEST (
"x@4096", 2,
"a@100",
"xxa@100x@4094", 0),
188 TEST (
"a@102", 2,
"x@4096",
"aax@4096a@100", 0),
190 TEST (
"x@10", 1,
"x@118",
"x@128", 0),
191 TEST (
"x@128", 128,
"x@79",
"x@207", 0),
192 TEST (
"x@207", 0,
"x@127",
"x@334", 0),
193 TEST (
"x@334", 1,
"x@206",
"x@540", 0),
194 TEST (
"x@540", 539,
"x@333",
"x@873", 0),
195 TEST (
"x@539", 539,
"x@873",
"x@1412", 0),
196 TEST (
"x@872", 0,
"x@1412",
"x@2284", 0),
197 TEST (
"x@1411", 207,
"x@2284",
"x@3695", 0),
198 TEST (
"x@1412", 0,
"x@2284",
"x@3696", 0),
200 TEST (
"<U0>", 2,
"",
"", 1),
201 TEST (
"a", 2,
"",
"", 1),
202 TEST (
"x@4096", 4106,
"",
"", 1),
204 TEST (
"last", 4,
"test",
"lasttest", 0)
213iter_range_test_cases [] = {
216#define size_cstr_size_size_test_cases iter_range_test_cases
219#define TEST(str, off, arg, off2, size2, res, bthrow) { \
220 __LINE__, off, -1, off2, size2, -1, str, sizeof str - 1, \
221 arg, sizeof arg - 1, res, sizeof res - 1, bthrow \
238 TEST (
"ab", 0,
"c", 0, 1,
"cab", 0),
240 TEST (
"", 0,
"", 0, 0,
"", 0),
241 TEST (
"", 0,
"abc", 1, 1,
"b", 0),
242 TEST (
"", 0,
"<U0>", 0, 1,
"<U0>", 0),
244 TEST (
"<U0>", 0,
"", 0, 0,
"<U0>", 0),
245 TEST (
"<U0>", 1,
"", 0, 0,
"<U0>", 0),
247 TEST (
"abc", 0,
"", 0, 0,
"abc", 0),
248 TEST (
"abc", 1,
"", 0, 0,
"abc", 0),
249 TEST (
"abc", 3,
"", 0, 0,
"abc", 0),
251 TEST (
"<U0>", 0,
"a", 0, 1,
"a<U0>", 0),
252 TEST (
"<U0>", 1,
"a", 0, 1,
"<U0>a", 0),
253 TEST (
"<U0>", 0,
"<U0>@2", 1, 1,
"<U0>@2", 0),
254 TEST (
"<U0>", 1,
"<U0>@2", 0, 2,
"<U0>@3", 0),
255 TEST (
"<U0>", 1,
"<U0>@2", 1, 5,
"<U0>@2", 0),
257 TEST (
"cde", 0,
"ab", 0, 2,
"abcde", 0),
258 TEST (
"cde", 1,
"ab", 0, 1,
"cade", 0),
259 TEST (
"cde", 2,
"ab", 1, 5,
"cdbe", 0),
260 TEST (
"cde", 3,
"ab", 1, 1,
"cdeb", 0),
262 TEST (
"ab", 0,
"c<U0>e", 0, 3,
"c<U0>eab", 0),
263 TEST (
"ab", 1,
"c<U0>e", 1, 2,
"a<U0>eb", 0),
264 TEST (
"ab", 2,
"c<U0>e", 0, 2,
"abc<U0>", 0),
266 TEST (
"<U0>e<U0>", 1,
"<U0>ab<U0>@2c", 0, 9,
"<U0>@2ab<U0>@2ce<U0>",0),
267 TEST (
"<U0>e<U0>", 1,
"<U0>ab<U0>@2c", 0, 3,
"<U0>@2abe<U0>", 0),
268 TEST (
"a<U0>b<U0>@2c", 3,
"<U0>e<U0>", 0, 3,
"a<U0>b<U0>e<U0>@3c", 0),
269 TEST (
"a<U0>b<U0>@2c", 2,
"<U0>@2e<U0>", 0, 2,
"a<U0>@3b<U0>@2c", 0),
270 TEST (
"<U0>ab<U0>@2c", 0,
"<U0>e<U0>", 2, 1,
"<U0>@2ab<U0>@2c", 0),
271 TEST (
"a<U0>bc<U0>@2", 6,
"<U0>e", 0, 2,
"a<U0>bc<U0>@3e", 0),
273 TEST (
"abc", 0, 0, 1, 1,
"babc", 0),
274 TEST (
"abc", 2, 0, 0, 2,
"ababc", 0),
275 TEST (
"a<U0>bc<U0>@2", 0, 0, 4, 2,
"<U0>@2a<U0>bc<U0>@2", 0),
276 TEST (
"a<U0>bc<U0>@2", 6, 0, 1, 3,
"a<U0>bc<U0>@3bc", 0),
277 TEST (
"abcdef", 0, 0, 1, 2,
"bcabcdef", 0),
279 TEST (
"", 0,
"x@4096", 0, 4096,
"x@4096", 0),
280 TEST (
"x@4096", 0,
"", 0, 0,
"x@4096", 0),
281 TEST (
"a@1000", 0,
"b@1000", 0, 999,
"b@999a@1000", 0),
282 TEST (
"a@1000", 1,
"b@1001", 0, 1000,
"ab@1000a@999", 0),
283 TEST (
"a@1000", 2,
"b@1002", 0, 1001,
"aab@1001a@998", 0),
284 TEST (
"a@1000", 998,
"b@1000", 1, 999,
"a@998b@999aa", 0),
285 TEST (
"a@1000", 999,
"b@1001", 2, 1000,
"a@999b@999a", 0),
286 TEST (
"a@1000", 2,
"b@1002", 999, 1001,
"aabbba@998", 0),
288 TEST (
"x@10", 1,
"x@118", 0, 118,
"x@128", 0),
289 TEST (
"x@128", 0,
"x@129", 50, 79,
"x@207", 0),
290 TEST (
"x@207", 207,
"x@127", 0, 127,
"x@334", 0),
291 TEST (
"x@207", 128,
"x@207", 10, 127,
"x@334", 0),
292 TEST (
"x@334", 334,
"x@208", 2, 206,
"x@540", 0),
293 TEST (
"x@540", 0,
"x@336", 3, 333,
"x@873", 0),
294 TEST (
"x@539", 538,
"x@873", 0, 873,
"x@1412", 0),
295 TEST (
"x@873", 540,
"x@540", 1, 539,
"x@1412", 0),
296 TEST (
"x@872", 0,
"x@1412", 0, 1412,
"x@2284", 0),
297 TEST (
"x@1411", 1411,
"x@2288", 4, 2284,
"x@3695", 0),
298 TEST (
"x@1411", 872,
"x@3695", 128, 2284,
"x@3695", 0),
299 TEST (
"x@1412", 0,
"x@2284", 0, 2284,
"x@3696", 0),
301 TEST (
"<U0>", 2,
"", 0, 0,
"<U0>", 1),
302 TEST (
"", 0,
"<U0>", 2, 0,
"", 2),
304 TEST (
"a", 2,
"", 0, 0,
"a", 1),
305 TEST (
"", 0,
"a", 2, 0,
"", 2),
307 TEST (
"x@4096", 4106,
"", 0, 0,
"x@4096", 1),
308 TEST (
"", 0,
"x@4096", 4106, 0,
"", 2),
310 TEST (
"last", 4,
"test", 0, 4,
"lasttest", 0)
318size_cptr_size_test_cases [] = {
321#define TEST(str, off, arg, size2, res, bthrow) { \
322 __LINE__, off, -1, -1, size2, -1, str, sizeof str - 1, \
323 arg, sizeof arg - 1, res, sizeof res - 1, bthrow }
338 TEST (
"ab", 0,
"c", 1,
"cab", 0),
340 TEST (
"", 0,
"", 0,
"", 0),
341 TEST (
"", 0,
"abc", 1,
"a", 0),
343 TEST (
"<U0>", 0,
"", 0,
"<U0>", 0),
344 TEST (
"<U0>", 1,
"", 0,
"<U0>", 0),
345 TEST (
"", 0,
"<U0>", 1,
"<U0>", 0),
347 TEST (
"<U0>", 0,
"a", 0,
"<U0>", 0),
348 TEST (
"<U0>", 1,
"a", 1,
"<U0>a", 0),
349 TEST (
"<U0>", 0,
"<U0>@2", 1,
"<U0>@2", 0),
350 TEST (
"<U0>", 1,
"<U0>@2", 2,
"<U0>@3", 0),
352 TEST (
"cde", 0,
"ab", 2,
"abcde", 0),
353 TEST (
"cde", 1,
"ab", 1,
"cade", 0),
354 TEST (
"cde", 3,
"ab", 1,
"cdea", 0),
355 TEST (
"cde", 2,
"ab", 2,
"cdabe", 0),
357 TEST (
"<U0>e<U0>", 3,
"a<U0>b<U0>@2c", 0,
"<U0>e<U0>", 0),
358 TEST (
"<U0>e<U0>", 3,
"<U0>ab<U0>@2c", 3,
"<U0>e<U0>@2ab", 0),
360 TEST (
"a<U0>b<U0>@2c", 3,
"<U0>e<U0>", 3,
"a<U0>b<U0>e<U0>@3c", 0),
361 TEST (
"a<U0>b<U0>@2c", 2,
"<U0>@2e<U0>", 2,
"a<U0>@3b<U0>@2c", 0),
362 TEST (
"<U0>ab<U0>@2c", 0,
"<U0>e<U0>", 1,
"<U0>@2ab<U0>@2c", 0),
363 TEST (
"a<U0>bc<U0>@2", 6,
"<U0>e", 2,
"a<U0>bc<U0>@3e", 0),
365 TEST (
"abc", 0, 0, 1,
"aabc", 0),
366 TEST (
"abc", 2, 0, 2,
"ababc", 0),
367 TEST (
"<U0>abc<U0>@2", 0, 0, 1,
"<U0>@2abc<U0>@2", 0),
368 TEST (
"a<U0>bc<U0>@2", 6, 0, 3,
"a<U0>bc<U0>@2a<U0>b", 0),
369 TEST (
"a@4096", 0, 0, 1111,
"a@5207", 0),
370 TEST (
"b@4096", 1, 0, 2222,
"b@6318", 0),
372 TEST (
"x@4096", 1,
"<U0>", 1,
"x<U0>x@4095", 0),
373 TEST (
"x@4096", 0,
"<U0>", 1,
"<U0>x@4096", 0),
374 TEST (
"x@4096", 4096,
"<U0>", 1,
"x@4096<U0>", 0),
375 TEST (
"x@4096", 0,
"ab", 2,
"abx@4096", 0),
376 TEST (
"x@4096", 4095,
"ab", 1,
"x@4095ax", 0),
377 TEST (
"x@4096", 4094,
"<U0>@2", 2,
"x@4094<U0>@2xx", 0),
379 TEST (
"", 0,
"x@4096", 4096,
"x@4096", 0),
380 TEST (
"x@4096", 0,
"", 0,
"x@4096", 0),
382 TEST (
"", 0,
"x@873", 540,
"x@540", 0),
383 TEST (
"x@10", 1,
"x@118", 118,
"x@128", 0),
384 TEST (
"x@128", 128,
"x@79", 79,
"x@207", 0),
385 TEST (
"x@207", 0,
"x@127", 127,
"x@334", 0),
386 TEST (
"x@207", 207,
"x@207", 127,
"x@334", 0),
387 TEST (
"x@334", 128,
"x@206", 206,
"x@540", 0),
388 TEST (
"x@540", 540,
"x@333", 333,
"x@873", 0),
389 TEST (
"x@539", 0,
"x@873", 873,
"x@1412", 0),
390 TEST (
"x@873", 5,
"x@540", 539,
"x@1412", 0),
391 TEST (
"x@872", 0,
"x@1412", 1412,
"x@2284", 0),
392 TEST (
"x@1411", 1411,
"x@2284", 2284,
"x@3695", 0),
393 TEST (
"x@1411", 873,
"x@3695", 2284,
"x@3695", 0),
394 TEST (
"x@1412", 0,
"x@2284", 2284,
"x@3696", 0),
395 TEST (
"", 0,
"x@3696", 3696,
"x@3696", 0),
397 TEST (
"<U0>", 2,
"", 0,
"", 1),
398 TEST (
"a", 2,
"", 0,
"", 1),
399 TEST (
"x@4096", 4106,
"", 0,
"", 1),
401 TEST (
"last", 4,
"test", 4,
"lasttest", 0)
410iter_size_val_test_cases [] = {
413#define size_size_val_test_cases iter_size_val_test_cases
416#define TEST(str, off, size2, val, res, bthrow) { \
417 __LINE__, off, -1, -1, size2, val, str, sizeof str - 1, \
418 0, 0, res, sizeof res - 1, bthrow \
434 TEST (
"ab", 0, 1,
'c',
"cab", 0),
436 TEST (
"", 0, 0,
' ',
"", 0),
437 TEST (
"", 0, 1,
'b',
"b", 0),
439 TEST (
"<U0>", 0, 0,
' ',
"<U0>", 0),
440 TEST (
"<U0>", 1, 0,
' ',
"<U0>", 0),
441 TEST (
"", 0, 2,
'\0',
"<U0>@2", 0),
443 TEST (
"<U0>", 0, 1,
'a',
"a<U0>", 0),
444 TEST (
"<U0>", 1, 1,
'a',
"<U0>a", 0),
445 TEST (
"<U0>", 0, 1,
'\0',
"<U0>@2", 0),
446 TEST (
"<U0>", 1, 2,
'\0',
"<U0>@3", 0),
447 TEST (
"<U0>", 1, 0,
'\0',
"<U0>", 0),
449 TEST (
"cde", 0, 2,
'a',
"aacde", 0),
450 TEST (
"cde", 1, 1,
'a',
"cade", 0),
451 TEST (
"cde", 3, 3,
'a',
"cdeaaa", 0),
452 TEST (
"cde", 2, 3,
'a',
"cdaaae", 0),
454 TEST (
"ab", 0, 2,
'\0',
"<U0>@2ab", 0),
455 TEST (
"ab", 1, 1,
'\0',
"a<U0>b", 0),
456 TEST (
"ab", 2, 2,
'\0',
"ab<U0>@2", 0),
458 TEST (
"a<U0>b<U0>@2c", 3, 2,
'\0',
"a<U0>b<U0>@3<U0>c", 0),
459 TEST (
"a<U0>b<U0>@2c", 2, 1,
'\0',
"a<U0>@2b<U0>@2c", 0),
460 TEST (
"<U0>ab<U0>@2c", 0, 3,
'\0',
"<U0>@3<U0>ab<U0>@2c", 0),
461 TEST (
"a<U0>bc<U0>@2", 6, 2,
'a',
"a<U0>bc<U0>@2aa", 0),
463 TEST (
"", 0, 4106,
'x',
"x@4106", 0),
464 TEST (
"x@4096", 0, 2,
'a',
"aax@4096", 0),
466 TEST (
"x@4096", 0, 2,
'a',
"aax@4096", 0),
467 TEST (
"x@4096", 1, 2,
'a',
"xaax@4095", 0),
468 TEST (
"x@4096", 1, 1,
'\0',
"x<U0>x@4095", 0),
470 TEST (
"x@127", 0, 1,
'x',
"x@128", 0),
471 TEST (
"x@200", 128, 7,
'x',
"x@207", 0),
472 TEST (
"x@331", 331, 3,
'x',
"x@334", 0),
473 TEST (
"x@539", 0, 1,
'x',
"x@540", 0),
474 TEST (
"x@539", 0, 873,
'x',
"x@1412", 0),
475 TEST (
"x@873", 873, 1411,
'x',
"x@2284", 0),
476 TEST (
"x@3694", 128, 1,
'x',
"x@3695", 0),
477 TEST (
"x@540", 0, 1,
'x',
"x@541", 0),
478 TEST (
"", 0, 3695,
'x',
"x@3695", 0),
480 TEST (
"a", 0, 4095,
'x',
"x@4095a", 0),
481 TEST (
"x@4096", 0, 2047,
'b',
"b@2047x@4096", 0),
482 TEST (
"x@4096", 2047, 2048,
'x',
"x@6144", 0),
484 TEST (
"last", 4, 4,
't',
"lasttttt", 0)
492iter_val_test_cases [] = {
495#define TEST(str, off, val, res, bthrow) \
496 { __LINE__, off, -1, -1, -1, val, str, sizeof str - 1, 0, \
497 0, res, sizeof res - 1, bthrow }
511 TEST (
"ab", 0,
'c',
"cab", 0),
513 TEST (
"", 0,
'b',
"b", 0),
514 TEST (
"", 0,
'\0',
"<U0>", 0),
516 TEST (
"<U0>", 0,
'a',
"a<U0>", 0),
517 TEST (
"<U0>", 1,
'a',
"<U0>a", 0),
518 TEST (
"<U0>", 0,
'\0',
"<U0>@2", 0),
519 TEST (
"<U0>", 1,
'\0',
"<U0>@2", 0),
521 TEST (
"cde", 0,
'a',
"acde", 0),
522 TEST (
"cde", 1,
'a',
"cade", 0),
523 TEST (
"cde", 2,
'a',
"cdae", 0),
524 TEST (
"cde", 3,
'a',
"cdea", 0),
526 TEST (
"a<U0>b<U0>@2c", 3,
'\0',
"a<U0>b<U0>@3c", 0),
527 TEST (
"<U0>ab<U0>@2c", 0,
'\0',
"<U0>@2ab<U0>@2c", 0),
528 TEST (
"a<U0>bc<U0>@2", 6,
'a',
"a<U0>bc<U0>@2a", 0),
530 TEST (
"x@4096", 0,
'a',
"ax@4096", 0),
531 TEST (
"x@4096", 1,
'a',
"xax@4095", 0),
532 TEST (
"x@4096", 1,
'\0',
"x<U0>x@4095", 0),
534 TEST (
"x@127", 0,
'x',
"x@128", 0),
535 TEST (
"x@206", 1,
'x',
"x@207", 0),
536 TEST (
"x@333", 333,
'x',
"x@334", 0),
537 TEST (
"x@539", 128,
'x',
"x@540", 0),
538 TEST (
"x@1411", 0,
'x',
"x@1412", 0),
539 TEST (
"x@2283", 10,
'x',
"x@2284", 0),
540 TEST (
"x@3694", 3694,
'x',
"x@3695", 0),
541 TEST (
"x@540", 538,
'x',
"x@541", 0),
543 TEST (
"last", 4,
't',
"lastt", 0)
550template <
class String,
class Iterator>
580 str.insert (first1, first2, last2);
588template <
class String,
class Iterator>
608 const std::size_t srclen_ = tcase.
arg ? tdata.
arglen_ :
str.size ();
610 const std::size_t
off =
612 const std::size_t ext = tdata.
ext2_;
614 if (0 == tcase.
arg) {
619 const Iterator last2 (first2 + ext);
621 str.insert (first1, first2, last2);
628 const Iterator last2 (first2 + ext);
630 str.insert (first1, first2, last2);
637template <
class charT,
class Traits,
class Allocator>
639 std::basic_string <charT, Traits, Allocator> > &rng,
642 typedef std::basic_string <charT, Traits, Allocator>
String;
643 typedef typename String::iterator StringIter;
659 std::ptrdiff_t exp_off =
Insert (iter_val) ==
func.which_ ? tcase.
off : 0;
663 const std::size_t size1 = tdata.
strlen_;
664 const std::size_t off1 =
665 std::size_t (tcase.
off) < size1 ? std::size_t (tcase.
off) : size1;
667 const charT*
const arg_ptr = tcase.
arg ?
arg.c_str () :
str.c_str ();
671 std::size_t total_length_calls = 0;
672 std::size_t n_length_calls = 0;
676 total_length_calls = rg_calls [TraitsFunc::length];
684 std::size_t throw_count;
685 for (throw_count = 0; ; ++throw_count) {
688 const char* expected = 0;
691#ifndef _RWSTD_NO_EXCEPTIONS
693 const bool use_iters =
696 if (1 == tcase.
bthrow && !use_iters)
697 expected = exceptions [1];
698 else if ( 2 == tcase.
bthrow
699 &&
Insert (size_cstr_size_size) ==
func.which_)
700 expected = exceptions [1];
701 else if (3 == tcase.
bthrow && !use_iters)
702 expected = exceptions [2];
703 else if (0 == tcase.
bthrow) {
707 expected = exceptions [3];
724 const String* ret_ptr = 0;
730 switch (
func.which_) {
733 ret_ptr = &
str.insert (tcase.
off, arg_ptr);
735 n_length_calls = rg_calls [TraitsFunc::length];
739 ret_ptr = &
str.insert (tcase.
off, arg_str);
742 case Insert (size_cptr_size):
743 ret_ptr = &
str.insert (tcase.
off, arg_ptr, tcase.
size2);
746 case Insert (size_cstr_size_size):
751 case Insert (size_size_val):
752 ret_ptr = &
str.insert (tcase.
off, tcase.
size2, arg_val);
755 case Insert (iter_size_val): {
756 const StringIter it (
str.begin () + off1);
757 str.insert (it, tcase.
size2, arg_val);
763 StringIter it (
str.begin () + off1);
764 it =
str.insert (it, arg_val);
765 ret_ptr = &
str + (it -
str.begin ());
769 case Insert (iter_range): {
770 ret_ptr = &rng (
str, tdata);
775 RW_ASSERT (!
"logic error: unknown insert overload");
782 const std::ptrdiff_t ret_off = ret_ptr - &
str;
786 "line %d. %{$FUNCALL} %{?}== begin() + %td, got %td%{;}"
787 "%{?}returned invalid reference, offset is %td%{;}",
793 static const int cwidth =
sizeof (
charT);
797 "line %d. %{$FUNCALL} expected %{/*.*Gs} with length "
798 "%zu, got %{/*.*Gs} with length %zu", __LINE__,
800 cwidth, int (
str.size ()),
str.c_str (),
str.size ());
806 const std::size_t match =
810 "line %d. %{$FUNCALL} expected %{/*.*Gs}, "
811 "got %{/*.*Gs}, difference at offset %zu",
813 cwidth, int (
str.size ()),
str.c_str (), match);
817 if (
Insert (size_cptr) ==
func.which_ && rg_calls) {
818 rw_assert (n_length_calls - total_length_calls > 0,
819 0, tcase.
line,
"line %d. %{$FUNCALL} doesn't "
820 "use traits::length()", __LINE__);
824#ifndef _RWSTD_NO_EXCEPTIONS
826 catch (
const std::out_of_range &ex) {
829 "line %d. %{$FUNCALL} %{?}expected %s,%{:}"
830 "unexpectedly%{;} caught std::%s(%#s)",
831 __LINE__, 0 != expected, expected,
caught, ex.what ());
833 catch (
const std::length_error &ex) {
836 "line %d. %{$FUNCALL} %{?}expected %s,%{:}"
837 "unexpectedly%{;} caught std::%s(%#s)",
838 __LINE__, 0 != expected, expected,
caught, ex.what ());
843 "line %d. %{$FUNCALL} %{?}expected %s,%{:}"
844 "unexpectedly%{;} caught std::%s(%#s)",
845 __LINE__, 0 != expected, expected,
caught, ex.what ());
850 "line %d. %{$FUNCALL} %{?}expected %s,%{:}"
851 "unexpectedly%{;} caught std::%s(%#s)",
852 __LINE__, 0 != expected, expected,
caught, ex.what ());
857 "line %d. %{$FUNCALL} %{?}expected %s,%{:}"
858 "unexpectedly%{;} caught %s",
859 __LINE__, 0 != expected, expected,
caught);
867 std::size_t (-1), std::size_t (-1));
882 else if (0 < tcase.
bthrow) {
884 "line %d. %{$FUNCALL} %{?}expected %s, caught %s"
885 "%{:}unexpectedly caught %s%{;}",
892#ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
896 const std::size_t expect_throws = str_state.
capacity_ <
str.capacity ();
900 const std::size_t expect_throws =
910 "line %d: %{$FUNCALL}: expected exactly 1 %s exception "
911 "while changing capacity from %zu to %zu, got %zu",
912 __LINE__, exceptions [3],
916 "line %d: %{$FUNCALL}: expected at least 1 %s exception "
917 "while changing capacity from %zu to %zu, got %zu",
918 __LINE__, exceptions [3],
928template <
class charT,
class Traits,
class Allocator>
932 typedef std::basic_string<charT, Traits, Allocator>
String;
941#define TEST(Iterator) do { \
942 typedef typename String::Iterator Iter; \
944 InsertRangeOverload<String, Iter> rng; \
945 test_insert ((charT*)0, (Traits*)0, (Allocator*)0, rng, tdata); \
960#define TEST(Iterator) do { \
961 typedef Iterator<charT> Iter; \
963 InsertRange<String, Iter> rng; \
964 test_insert ((charT*)0, (Traits*)0, (Allocator*)0, rng, tdata); \
973 rw_error (0, 0, __LINE__,
"bad iterator id");
987int main (
int argc,
char** argv)
994 Insert (sig), sig ## _test_cases, \
995 sizeof sig ## _test_cases / sizeof *sig ## _test_cases \
1000 TEST (size_cptr_size),
1001 TEST (size_cstr_size_size),
1002 TEST (size_size_val),
1004 TEST (iter_size_val),
1008 const std::size_t test_count =
sizeof tests /
sizeof *tests;
1012 "lib.string.insert",
1013 test_insert_func_array, tests, test_count);
#define TEST(str, off, arg, res, bthrow)
std::char_traits< S > Traits
const StringTestCase & tcase_
_TEST_EXPORT void rw_check_leaks(const SharedAlloc *=0, int=0, _RWSTD_SIZE_T=0, _RWSTD_SIZE_T=_RWSTD_SIZE_MAX)
UserChar make_char(char c, UserChar *)
_RWSTD_SIZE_T * rw_get_call_counters(std::char_traits< charT > *, charT *)
_TEST_EXPORT _RWSTD_SIZE_T rw_match(const char *, const char *, _RWSTD_SIZE_T=_RWSTD_SIZE_MAX)
_TEST_EXPORT int rw_assert(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_error(int, const char *, int, const char *,...)
_TEST_EXPORT rwt_free_store * rwt_get_free_store(rwt_free_store *)
StringState rw_get_string_state(const String &str)
_TEST_EXPORT int rw_run_string_test(int, char **, const char *, const char *, StringTestFunc *, const StringTest *, _RWSTD_SIZE_T)
#define DEFINE_STRING_TEST_FUNCTIONS(fname)
static ContIter begin(List &cont, ContIter *)
String::value_type StringChar
virtual List & operator()(List &lst, const ContainerTestCaseData< ListVal > &tdata) const
String::iterator StringIter
virtual List & operator()(List &lst, const ContainerTestCaseData< ListVal > &tdata) const
String::value_type StringChar
String::iterator StringIter
static SharedAlloc * instance(SharedAlloc *=0)
_RWSTD_SIZE_T throw_at_calls_[n_funs]
StringIds::OverloadId which_
StringIds::IteratorId iter_id_
static ArgId arg_type(OverloadId id, int argno)
int assert_equal(const StringState &, int, int, const char *) const
_RWSTD_SIZE_T * throw_at_calls_[2]
_RWSTD_SIZE_T new_calls_[2]