tests/test_string.c

changeset 1126
20c9212b3a47
parent 1071
028cb6d22197
child 1127
1fd31909a3f8
equal deleted inserted replaced
1125:6090c455b8df 1126:20c9212b3a47
118 CX_TEST_DO { 118 CX_TEST_DO {
119 cxstring sub = cx_strsubs(str, 0); 119 cxstring sub = cx_strsubs(str, 0);
120 CX_TEST_ASSERT(0 == cx_strcmp(sub, str)); 120 CX_TEST_ASSERT(0 == cx_strcmp(sub, str));
121 121
122 sub = cx_strsubs(str, 2); 122 sub = cx_strsubs(str, 2);
123 CX_TEST_ASSERT(0 == cx_strcmp(sub, CX_STR("test string"))); 123 CX_TEST_ASSERT(0 == cx_strcmp(sub, cx_str("test string")));
124 124
125 sub = cx_strsubs(str, 7); 125 sub = cx_strsubs(str, 7);
126 CX_TEST_ASSERT(0 == cx_strcmp(sub, CX_STR("string"))); 126 CX_TEST_ASSERT(0 == cx_strcmp(sub, cx_str("string")));
127 127
128 sub = cx_strsubs(str, 15); 128 sub = cx_strsubs(str, 15);
129 CX_TEST_ASSERT(0 == cx_strcmp(sub, CX_STR(""))); 129 CX_TEST_ASSERT(0 == cx_strcmp(sub, cx_str("")));
130 130
131 sub = cx_strsubsl(str, 2, 4); 131 sub = cx_strsubsl(str, 2, 4);
132 CX_TEST_ASSERT(0 == cx_strcmp(sub, CX_STR("test"))); 132 CX_TEST_ASSERT(0 == cx_strcmp(sub, cx_str("test")));
133 133
134 sub = cx_strsubsl(str, 7, 3); 134 sub = cx_strsubsl(str, 7, 3);
135 CX_TEST_ASSERT(0 == cx_strcmp(sub, CX_STR("str"))); 135 CX_TEST_ASSERT(0 == cx_strcmp(sub, cx_str("str")));
136 136
137 sub = cx_strsubsl(str, 7, 20); 137 sub = cx_strsubsl(str, 7, 20);
138 CX_TEST_ASSERT(0 == cx_strcmp(sub, CX_STR("string"))); 138 CX_TEST_ASSERT(0 == cx_strcmp(sub, cx_str("string")));
139 139
140 // just for coverage, call the _m variant 140 // just for coverage, call the _m variant
141 cxmutstr m = cx_strsubs_m(cx_mutstrn(NULL, 0), 0); 141 cxmutstr m = cx_strsubs_m(cx_mutstrn(NULL, 0), 0);
142 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(m), CX_STR(""))); 142 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(m), cx_str("")));
143 } 143 }
144 } 144 }
145 145
146 CX_TEST(test_strchr) { 146 CX_TEST(test_strchr) {
147 cxstring str = CX_STR("I will find you - and I will kill you"); 147 cxstring str = CX_STR("I will find you - and I will kill you");
154 CX_TEST_ASSERT(result.length == 35); 154 CX_TEST_ASSERT(result.length == 35);
155 CX_TEST_ASSERT(0 == strcmp(result.ptr, "will find you - and I will kill you")); 155 CX_TEST_ASSERT(0 == strcmp(result.ptr, "will find you - and I will kill you"));
156 156
157 // just for coverage, call the _m variant 157 // just for coverage, call the _m variant
158 cxmutstr m = cx_strchr_m(cx_mutstrn(NULL, 0), 'a'); 158 cxmutstr m = cx_strchr_m(cx_mutstrn(NULL, 0), 'a');
159 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(m), CX_STR(""))); 159 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(m), cx_str("")));
160 } 160 }
161 } 161 }
162 162
163 CX_TEST(test_strrchr) { 163 CX_TEST(test_strrchr) {
164 cxstring str = CX_STR("I will find you - and I will kill you"); 164 cxstring str = CX_STR("I will find you - and I will kill you");
171 CX_TEST_ASSERT(result.length == 13); 171 CX_TEST_ASSERT(result.length == 13);
172 CX_TEST_ASSERT(0 == strcmp(result.ptr, "will kill you")); 172 CX_TEST_ASSERT(0 == strcmp(result.ptr, "will kill you"));
173 173
174 // just for coverage, call the _m variant 174 // just for coverage, call the _m variant
175 cxmutstr m = cx_strrchr_m(cx_mutstrn(NULL, 0), 'a'); 175 cxmutstr m = cx_strrchr_m(cx_mutstrn(NULL, 0), 'a');
176 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(m), CX_STR(""))); 176 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(m), cx_str("")));
177 } 177 }
178 } 178 }
179 179
180 CX_TEST(test_strstr) { 180 CX_TEST(test_strstr) {
181 cxstring str = CX_STR("find the match in this string"); 181 cxstring str = CX_STR("find the match in this string");
213 cxmutstr longstr = cx_mutstrn(longstrc, longstrlen); 213 cxmutstr longstr = cx_mutstrn(longstrc, longstrlen);
214 cxstring longstrpattern = cx_strn(longstrpatternc, longstrpatternlen); 214 cxstring longstrpattern = cx_strn(longstrpatternc, longstrpatternlen);
215 cxmutstr longstrresult = cx_mutstrn(longstrc+256, longstrlen-256); 215 cxmutstr longstrresult = cx_mutstrn(longstrc+256, longstrlen-256);
216 216
217 CX_TEST_DO { 217 CX_TEST_DO {
218 cxstring notfound = cx_strstr(str, CX_STR("no match")); 218 cxstring notfound = cx_strstr(str, cx_str("no match"));
219 CX_TEST_ASSERT(notfound.length == 0); 219 CX_TEST_ASSERT(notfound.length == 0);
220 220
221 cxstring result = cx_strstr(str, CX_STR("match")); 221 cxstring result = cx_strstr(str, cx_str("match"));
222 CX_TEST_ASSERT(result.length == 20); 222 CX_TEST_ASSERT(result.length == 20);
223 CX_TEST_ASSERT(0 == strcmp(result.ptr, "match in this string")); 223 CX_TEST_ASSERT(0 == strcmp(result.ptr, "match in this string"));
224 224
225 result = cx_strstr(str, CX_STR("")); 225 result = cx_strstr(str, cx_str(""));
226 CX_TEST_ASSERT(result.length == str.length); 226 CX_TEST_ASSERT(result.length == str.length);
227 CX_TEST_ASSERT(0 == strcmp(result.ptr, str.ptr)); 227 CX_TEST_ASSERT(0 == strcmp(result.ptr, str.ptr));
228 228
229 cxmutstr resultm = cx_strstr_m(longstr, longstrpattern); 229 cxmutstr resultm = cx_strstr_m(longstr, longstrpattern);
230 CX_TEST_ASSERT(resultm.length == longstrresult.length); 230 CX_TEST_ASSERT(resultm.length == longstrresult.length);
236 } 236 }
237 237
238 CX_TEST(test_strcmp) { 238 CX_TEST(test_strcmp) {
239 cxstring str = CX_STR("compare this"); 239 cxstring str = CX_STR("compare this");
240 CX_TEST_DO { 240 CX_TEST_DO {
241 CX_TEST_ASSERT(0 == cx_strcmp(CX_STR(""), CX_STR(""))); 241 CX_TEST_ASSERT(0 == cx_strcmp(cx_str(""), cx_str("")));
242 CX_TEST_ASSERT(0 < cx_strcmp(str, CX_STR(""))); 242 CX_TEST_ASSERT(0 < cx_strcmp(str, cx_str("")));
243 CX_TEST_ASSERT(0 == cx_strcmp(str, CX_STR("compare this"))); 243 CX_TEST_ASSERT(0 == cx_strcmp(str, cx_str("compare this")));
244 CX_TEST_ASSERT(0 != cx_strcmp(str, CX_STR("Compare This"))); 244 CX_TEST_ASSERT(0 != cx_strcmp(str, cx_str("Compare This")));
245 CX_TEST_ASSERT(0 > cx_strcmp(str, CX_STR("compare tool"))); 245 CX_TEST_ASSERT(0 > cx_strcmp(str, cx_str("compare tool")));
246 CX_TEST_ASSERT(0 < cx_strcmp(str, CX_STR("compare shit"))); 246 CX_TEST_ASSERT(0 < cx_strcmp(str, cx_str("compare shit")));
247 CX_TEST_ASSERT(0 > cx_strcmp(str, CX_STR("compare this not"))); 247 CX_TEST_ASSERT(0 > cx_strcmp(str, cx_str("compare this not")));
248 CX_TEST_ASSERT(0 < cx_strcmp(str, CX_STR("compare"))); 248 CX_TEST_ASSERT(0 < cx_strcmp(str, cx_str("compare")));
249 CX_TEST_ASSERT(0 > cx_strcmp(str, CX_STR("lex"))); 249 CX_TEST_ASSERT(0 > cx_strcmp(str, cx_str("lex")));
250 CX_TEST_ASSERT(0 < cx_strcmp(str, CX_STR("another lex test"))); 250 CX_TEST_ASSERT(0 < cx_strcmp(str, cx_str("another lex test")));
251 CX_TEST_ASSERT(0 < cx_strcmp(str, CX_STR("Lex"))); 251 CX_TEST_ASSERT(0 < cx_strcmp(str, cx_str("Lex")));
252 CX_TEST_ASSERT(0 < cx_strcmp(str, CX_STR("Another lex test"))); 252 CX_TEST_ASSERT(0 < cx_strcmp(str, cx_str("Another lex test")));
253 253
254 cxstring str2 = CX_STR("Compare This"); 254 cxstring str2 = CX_STR("Compare This");
255 CX_TEST_ASSERT(0 != cx_strcmp_p(&str, &str2)); 255 CX_TEST_ASSERT(0 != cx_strcmp_p(&str, &str2));
256 str2 = CX_STR("compare this"); 256 str2 = CX_STR("compare this");
257 CX_TEST_ASSERT(0 == cx_strcmp_p(&str, &str2)); 257 CX_TEST_ASSERT(0 == cx_strcmp_p(&str, &str2));
259 } 259 }
260 260
261 CX_TEST(test_strcasecmp) { 261 CX_TEST(test_strcasecmp) {
262 cxstring str = CX_STR("compare this"); 262 cxstring str = CX_STR("compare this");
263 CX_TEST_DO { 263 CX_TEST_DO {
264 CX_TEST_ASSERT(0 == cx_strcasecmp(CX_STR(""), CX_STR(""))); 264 CX_TEST_ASSERT(0 == cx_strcasecmp(cx_str(""), cx_str("")));
265 CX_TEST_ASSERT(0 < cx_strcasecmp(str, CX_STR(""))); 265 CX_TEST_ASSERT(0 < cx_strcasecmp(str, cx_str("")));
266 CX_TEST_ASSERT(0 == cx_strcasecmp(str, CX_STR("compare this"))); 266 CX_TEST_ASSERT(0 == cx_strcasecmp(str, cx_str("compare this")));
267 CX_TEST_ASSERT(0 == cx_strcasecmp(str, CX_STR("Compare This"))); 267 CX_TEST_ASSERT(0 == cx_strcasecmp(str, cx_str("Compare This")));
268 CX_TEST_ASSERT(0 > cx_strcasecmp(str, CX_STR("compare tool"))); 268 CX_TEST_ASSERT(0 > cx_strcasecmp(str, cx_str("compare tool")));
269 CX_TEST_ASSERT(0 < cx_strcasecmp(str, CX_STR("compare shit"))); 269 CX_TEST_ASSERT(0 < cx_strcasecmp(str, cx_str("compare shit")));
270 CX_TEST_ASSERT(0 > cx_strcasecmp(str, CX_STR("compare this not"))); 270 CX_TEST_ASSERT(0 > cx_strcasecmp(str, cx_str("compare this not")));
271 CX_TEST_ASSERT(0 < cx_strcasecmp(str, CX_STR("compare"))); 271 CX_TEST_ASSERT(0 < cx_strcasecmp(str, cx_str("compare")));
272 CX_TEST_ASSERT(0 > cx_strcasecmp(str, CX_STR("lex"))); 272 CX_TEST_ASSERT(0 > cx_strcasecmp(str, cx_str("lex")));
273 CX_TEST_ASSERT(0 < cx_strcasecmp(str, CX_STR("another lex test"))); 273 CX_TEST_ASSERT(0 < cx_strcasecmp(str, cx_str("another lex test")));
274 CX_TEST_ASSERT(0 > cx_strcasecmp(str, CX_STR("Lex"))); 274 CX_TEST_ASSERT(0 > cx_strcasecmp(str, cx_str("Lex")));
275 CX_TEST_ASSERT(0 < cx_strcasecmp(str, CX_STR("Another lex test"))); 275 CX_TEST_ASSERT(0 < cx_strcasecmp(str, cx_str("Another lex test")));
276 276
277 cxstring str2 = CX_STR("Compare This"); 277 cxstring str2 = CX_STR("Compare This");
278 CX_TEST_ASSERT(0 == cx_strcasecmp_p(&str, &str2)); 278 CX_TEST_ASSERT(0 == cx_strcasecmp_p(&str, &str2));
279 str2 = CX_STR("Compare Tool"); 279 str2 = CX_STR("Compare Tool");
280 CX_TEST_ASSERT(0 > cx_strcasecmp_p(&str, &str2)); 280 CX_TEST_ASSERT(0 > cx_strcasecmp_p(&str, &str2));
291 cx_testing_allocator_init(&talloc); 291 cx_testing_allocator_init(&talloc);
292 CxAllocator *alloc = &talloc.base; 292 CxAllocator *alloc = &talloc.base;
293 293
294 CX_TEST_DO { 294 CX_TEST_DO {
295 cxmutstr t1 = cx_strcat_a(alloc, 2, s1, s2); 295 cxmutstr t1 = cx_strcat_a(alloc, 2, s1, s2);
296 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t1), CX_STR("1234"))); 296 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t1), cx_str("1234")));
297 ASSERT_ZERO_TERMINATED(t1); 297 ASSERT_ZERO_TERMINATED(t1);
298 cx_strfree_a(alloc, &t1); 298 cx_strfree_a(alloc, &t1);
299 299
300 cxmutstr t2 = cx_strcat_a(alloc, 3, s1, s2, s3); 300 cxmutstr t2 = cx_strcat_a(alloc, 3, s1, s2, s3);
301 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t2), CX_STR("123456"))); 301 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t2), cx_str("123456")));
302 ASSERT_ZERO_TERMINATED(t2); 302 ASSERT_ZERO_TERMINATED(t2);
303 cx_strfree_a(alloc, &t2); 303 cx_strfree_a(alloc, &t2);
304 304
305 cxmutstr t3 = cx_strcat_a(alloc, 6, s1, sn, s2, sn, s3, sn); 305 cxmutstr t3 = cx_strcat_a(alloc, 6, s1, sn, s2, sn, s3, sn);
306 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t3), CX_STR("123456"))); 306 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t3), cx_str("123456")));
307 ASSERT_ZERO_TERMINATED(t3); 307 ASSERT_ZERO_TERMINATED(t3);
308 cx_strfree_a(alloc, &t3); 308 cx_strfree_a(alloc, &t3);
309 309
310 cxmutstr t4 = cx_strcat_a(alloc, 2, sn, sn); 310 cxmutstr t4 = cx_strcat_a(alloc, 2, sn, sn);
311 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t4), CX_STR(""))); 311 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t4), cx_str("")));
312 ASSERT_ZERO_TERMINATED(t4); 312 ASSERT_ZERO_TERMINATED(t4);
313 cx_strfree_a(alloc, &t4); 313 cx_strfree_a(alloc, &t4);
314 314
315 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); 315 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));
316 316
317 // use the macro 317 // use the macro
318 cxmutstr t5 = cx_strcat(3, s3, s1, s2); 318 cxmutstr t5 = cx_strcat(3, s3, s1, s2);
319 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t5), CX_STR("561234"))); 319 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t5), cx_str("561234")));
320 ASSERT_ZERO_TERMINATED(t5); 320 ASSERT_ZERO_TERMINATED(t5);
321 cx_strfree(&t5); 321 cx_strfree(&t5);
322 322
323 // use an initial string 323 // use an initial string
324 cxmutstr t6 = cx_strdup(CX_STR("Hello")); 324 cxmutstr t6 = cx_strdup(cx_str("Hello"));
325 t6 = cx_strcat_m(t6, 2, CX_STR(", "), CX_STR("World!")); 325 t6 = cx_strcat_m(t6, 2, cx_str(", "), cx_str("World!"));
326 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t6), CX_STR("Hello, World!"))); 326 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t6), cx_str("Hello, World!")));
327 ASSERT_ZERO_TERMINATED(t6); 327 ASSERT_ZERO_TERMINATED(t6);
328 cx_strfree(&t6); 328 cx_strfree(&t6);
329 } 329 }
330 cx_testing_allocator_destroy(&talloc); 330 cx_testing_allocator_destroy(&talloc);
331 } 331 }
341 cxstring s8 = CX_STR("f0"); 341 cxstring s8 = CX_STR("f0");
342 cxstring s9 = CX_STR("xy"); 342 cxstring s9 = CX_STR("xy");
343 343
344 CX_TEST_DO { 344 CX_TEST_DO {
345 cxmutstr r = cx_strcat(9, s1, s2, s3, s4, s5, s6, s7, s8, s9); 345 cxmutstr r = cx_strcat(9, s1, s2, s3, s4, s5, s6, s7, s8, s9);
346 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(r), CX_STR("123456789abcdef0xy"))); 346 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(r), cx_str("123456789abcdef0xy")));
347 ASSERT_ZERO_TERMINATED(r); 347 ASSERT_ZERO_TERMINATED(r);
348 cx_strfree(&r); 348 cx_strfree(&r);
349 } 349 }
350 } 350 }
351 351
354 size_t capa = 8; 354 size_t capa = 8;
355 cxstring list[8]; 355 cxstring list[8];
356 size_t n; 356 size_t n;
357 CX_TEST_DO { 357 CX_TEST_DO {
358 // special case: empty string 358 // special case: empty string
359 n = cx_strsplit(test, CX_STR(""), capa, list); 359 n = cx_strsplit(test, cx_str(""), capa, list);
360 CX_TEST_ASSERT(n == 1); 360 CX_TEST_ASSERT(n == 1);
361 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test)); 361 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test));
362 362
363 // no delimiter occurrence 363 // no delimiter occurrence
364 n = cx_strsplit(test, CX_STR("z"), capa, list); 364 n = cx_strsplit(test, cx_str("z"), capa, list);
365 CX_TEST_ASSERT(n == 1); 365 CX_TEST_ASSERT(n == 1);
366 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test)); 366 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test));
367 367
368 // partially matching delimiter 368 // partially matching delimiter
369 n = cx_strsplit(test, CX_STR("is,not"), capa, list); 369 n = cx_strsplit(test, cx_str("is,not"), capa, list);
370 CX_TEST_ASSERT(n == 1); 370 CX_TEST_ASSERT(n == 1);
371 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test)); 371 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test));
372 372
373 // matching single-char delimiter 373 // matching single-char delimiter
374 n = cx_strsplit(test, CX_STR(","), capa, list); 374 n = cx_strsplit(test, cx_str(","), capa, list);
375 CX_TEST_ASSERT(n == 5); 375 CX_TEST_ASSERT(n == 5);
376 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("this"))); 376 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("this")));
377 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("is"))); 377 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str("is")));
378 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR("a"))); 378 CX_TEST_ASSERT(0 == cx_strcmp(list[2], cx_str("a")));
379 CX_TEST_ASSERT(0 == cx_strcmp(list[3], CX_STR("csv"))); 379 CX_TEST_ASSERT(0 == cx_strcmp(list[3], cx_str("csv")));
380 CX_TEST_ASSERT(0 == cx_strcmp(list[4], CX_STR("string"))); 380 CX_TEST_ASSERT(0 == cx_strcmp(list[4], cx_str("string")));
381 381
382 // matching multi-char delimiter 382 // matching multi-char delimiter
383 n = cx_strsplit(test, CX_STR("is"), capa, list); 383 n = cx_strsplit(test, cx_str("is"), capa, list);
384 CX_TEST_ASSERT(n == 3); 384 CX_TEST_ASSERT(n == 3);
385 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("th"))); 385 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("th")));
386 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(","))); 386 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str(",")));
387 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR(",a,csv,string"))); 387 CX_TEST_ASSERT(0 == cx_strcmp(list[2], cx_str(",a,csv,string")));
388 388
389 // bounded list using single-char delimiter 389 // bounded list using single-char delimiter
390 n = cx_strsplit(test, CX_STR(","), 3, list); 390 n = cx_strsplit(test, cx_str(","), 3, list);
391 CX_TEST_ASSERT(n == 3); 391 CX_TEST_ASSERT(n == 3);
392 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("this"))); 392 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("this")));
393 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("is"))); 393 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str("is")));
394 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR("a,csv,string"))); 394 CX_TEST_ASSERT(0 == cx_strcmp(list[2], cx_str("a,csv,string")));
395 395
396 // bounded list using multi-char delimiter 396 // bounded list using multi-char delimiter
397 n = cx_strsplit(test, CX_STR("is"), 2, list); 397 n = cx_strsplit(test, cx_str("is"), 2, list);
398 CX_TEST_ASSERT(n == 2); 398 CX_TEST_ASSERT(n == 2);
399 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("th"))); 399 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("th")));
400 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(",is,a,csv,string"))); 400 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str(",is,a,csv,string")));
401 401
402 // start with delimiter 402 // start with delimiter
403 n = cx_strsplit(test, CX_STR("this"), capa, list); 403 n = cx_strsplit(test, cx_str("this"), capa, list);
404 CX_TEST_ASSERT(n == 2); 404 CX_TEST_ASSERT(n == 2);
405 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR(""))); 405 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("")));
406 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(",is,a,csv,string"))); 406 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str(",is,a,csv,string")));
407 407
408 // end with delimiter 408 // end with delimiter
409 n = cx_strsplit(test, CX_STR("string"), capa, list); 409 n = cx_strsplit(test, cx_str("string"), capa, list);
410 CX_TEST_ASSERT(n == 2); 410 CX_TEST_ASSERT(n == 2);
411 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("this,is,a,csv,"))); 411 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("this,is,a,csv,")));
412 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(""))); 412 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str("")));
413 413
414 414
415 // end with delimiter exceed bound 415 // end with delimiter exceed bound
416 n = cx_strsplit(CX_STR("a,b,c,"), CX_STR(","), 3, list); 416 n = cx_strsplit(cx_str("a,b,c,"), cx_str(","), 3, list);
417 CX_TEST_ASSERT(n == 3); 417 CX_TEST_ASSERT(n == 3);
418 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("a"))); 418 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("a")));
419 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("b"))); 419 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str("b")));
420 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR("c,"))); 420 CX_TEST_ASSERT(0 == cx_strcmp(list[2], cx_str("c,")));
421 421
422 // exact match 422 // exact match
423 n = cx_strsplit(test, CX_STR("this,is,a,csv,string"), capa, list); 423 n = cx_strsplit(test, cx_str("this,is,a,csv,string"), capa, list);
424 CX_TEST_ASSERT(n == 2); 424 CX_TEST_ASSERT(n == 2);
425 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR(""))); 425 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("")));
426 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(""))); 426 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str("")));
427 427
428 // string to be split is only substring 428 // string to be split is only substring
429 n = cx_strsplit(test, CX_STR("this,is,a,csv,string,with,extension"), capa, list); 429 n = cx_strsplit(test, cx_str("this,is,a,csv,string,with,extension"), capa, list);
430 CX_TEST_ASSERT(n == 1); 430 CX_TEST_ASSERT(n == 1);
431 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test)); 431 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test));
432 432
433 // subsequent encounter of delimiter (the string between is empty) 433 // subsequent encounter of delimiter (the string between is empty)
434 n = cx_strsplit(test, CX_STR("is,"), capa, list); 434 n = cx_strsplit(test, cx_str("is,"), capa, list);
435 CX_TEST_ASSERT(n == 3); 435 CX_TEST_ASSERT(n == 3);
436 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("th"))); 436 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("th")));
437 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(""))); 437 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str("")));
438 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR("a,csv,string"))); 438 CX_TEST_ASSERT(0 == cx_strcmp(list[2], cx_str("a,csv,string")));
439 439
440 // call the _m variant just for coverage 440 // call the _m variant just for coverage
441 cxmutstr mtest = cx_strdup(test); 441 cxmutstr mtest = cx_strdup(test);
442 cxmutstr mlist[4]; 442 cxmutstr mlist[4];
443 n = cx_strsplit_m(mtest, CX_STR("is,"), 4, mlist); 443 n = cx_strsplit_m(mtest, cx_str("is,"), 4, mlist);
444 CX_TEST_ASSERT(n == 3); 444 CX_TEST_ASSERT(n == 3);
445 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[0]), CX_STR("th"))); 445 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[0]), cx_str("th")));
446 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[1]), CX_STR(""))); 446 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[1]), cx_str("")));
447 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[2]), CX_STR("a,csv,string"))); 447 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[2]), cx_str("a,csv,string")));
448 cx_strfree(&mtest); 448 cx_strfree(&mtest);
449 } 449 }
450 } 450 }
451 451
452 CX_TEST(test_strsplit_a) { 452 CX_TEST(test_strsplit_a) {
458 size_t capa = 8; 458 size_t capa = 8;
459 cxstring *list; 459 cxstring *list;
460 size_t n; 460 size_t n;
461 CX_TEST_DO { 461 CX_TEST_DO {
462 // special case: empty string 462 // special case: empty string
463 n = cx_strsplit_a(alloc, test, CX_STR(""), capa, &list); 463 n = cx_strsplit_a(alloc, test, cx_str(""), capa, &list);
464 CX_TEST_ASSERT(n == 1); 464 CX_TEST_ASSERT(n == 1);
465 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test)); 465 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test));
466 cxFree(alloc, list); 466 cxFree(alloc, list);
467 467
468 // no delimiter occurrence 468 // no delimiter occurrence
469 n = cx_strsplit_a(alloc, test, CX_STR("z"), capa, &list); 469 n = cx_strsplit_a(alloc, test, cx_str("z"), capa, &list);
470 CX_TEST_ASSERT(n == 1); 470 CX_TEST_ASSERT(n == 1);
471 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test)); 471 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test));
472 cxFree(alloc, list); 472 cxFree(alloc, list);
473 473
474 // partially matching delimiter 474 // partially matching delimiter
475 n = cx_strsplit_a(alloc, test, CX_STR("is,not"), capa, &list); 475 n = cx_strsplit_a(alloc, test, cx_str("is,not"), capa, &list);
476 CX_TEST_ASSERT(n == 1); 476 CX_TEST_ASSERT(n == 1);
477 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test)); 477 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test));
478 cxFree(alloc, list); 478 cxFree(alloc, list);
479 479
480 // matching single-char delimiter 480 // matching single-char delimiter
481 n = cx_strsplit_a(alloc, test, CX_STR(","), capa, &list); 481 n = cx_strsplit_a(alloc, test, cx_str(","), capa, &list);
482 CX_TEST_ASSERT(n == 5); 482 CX_TEST_ASSERT(n == 5);
483 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("this"))); 483 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("this")));
484 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("is"))); 484 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str("is")));
485 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR("a"))); 485 CX_TEST_ASSERT(0 == cx_strcmp(list[2], cx_str("a")));
486 CX_TEST_ASSERT(0 == cx_strcmp(list[3], CX_STR("csv"))); 486 CX_TEST_ASSERT(0 == cx_strcmp(list[3], cx_str("csv")));
487 CX_TEST_ASSERT(0 == cx_strcmp(list[4], CX_STR("string"))); 487 CX_TEST_ASSERT(0 == cx_strcmp(list[4], cx_str("string")));
488 cxFree(alloc, list); 488 cxFree(alloc, list);
489 489
490 // matching multi-char delimiter 490 // matching multi-char delimiter
491 n = cx_strsplit_a(alloc, test, CX_STR("is"), capa, &list); 491 n = cx_strsplit_a(alloc, test, cx_str("is"), capa, &list);
492 CX_TEST_ASSERT(n == 3); 492 CX_TEST_ASSERT(n == 3);
493 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("th"))); 493 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("th")));
494 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(","))); 494 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str(",")));
495 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR(",a,csv,string"))); 495 CX_TEST_ASSERT(0 == cx_strcmp(list[2], cx_str(",a,csv,string")));
496 cxFree(alloc, list); 496 cxFree(alloc, list);
497 497
498 // bounded list using single-char delimiter 498 // bounded list using single-char delimiter
499 n = cx_strsplit_a(alloc, test, CX_STR(","), 3, &list); 499 n = cx_strsplit_a(alloc, test, cx_str(","), 3, &list);
500 CX_TEST_ASSERT(n == 3); 500 CX_TEST_ASSERT(n == 3);
501 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("this"))); 501 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("this")));
502 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("is"))); 502 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str("is")));
503 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR("a,csv,string"))); 503 CX_TEST_ASSERT(0 == cx_strcmp(list[2], cx_str("a,csv,string")));
504 cxFree(alloc, list); 504 cxFree(alloc, list);
505 505
506 // bounded list using multi-char delimiter 506 // bounded list using multi-char delimiter
507 n = cx_strsplit_a(alloc, test, CX_STR("is"), 2, &list); 507 n = cx_strsplit_a(alloc, test, cx_str("is"), 2, &list);
508 CX_TEST_ASSERT(n == 2); 508 CX_TEST_ASSERT(n == 2);
509 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("th"))); 509 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("th")));
510 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(",is,a,csv,string"))); 510 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str(",is,a,csv,string")));
511 cxFree(alloc, list); 511 cxFree(alloc, list);
512 512
513 // start with delimiter 513 // start with delimiter
514 n = cx_strsplit_a(alloc, test, CX_STR("this"), capa, &list); 514 n = cx_strsplit_a(alloc, test, cx_str("this"), capa, &list);
515 CX_TEST_ASSERT(n == 2); 515 CX_TEST_ASSERT(n == 2);
516 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR(""))); 516 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("")));
517 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(",is,a,csv,string"))); 517 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str(",is,a,csv,string")));
518 cxFree(alloc, list); 518 cxFree(alloc, list);
519 519
520 // end with delimiter 520 // end with delimiter
521 n = cx_strsplit_a(alloc, test, CX_STR("string"), capa, &list); 521 n = cx_strsplit_a(alloc, test, cx_str("string"), capa, &list);
522 CX_TEST_ASSERT(n == 2); 522 CX_TEST_ASSERT(n == 2);
523 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("this,is,a,csv,"))); 523 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("this,is,a,csv,")));
524 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(""))); 524 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str("")));
525 cxFree(alloc, list); 525 cxFree(alloc, list);
526 526
527 // end with delimiter exceed bound 527 // end with delimiter exceed bound
528 n = cx_strsplit_a(alloc, CX_STR("a,b,c,"), CX_STR(","), 3, &list); 528 n = cx_strsplit_a(alloc, cx_str("a,b,c,"), cx_str(","), 3, &list);
529 CX_TEST_ASSERT(n == 3); 529 CX_TEST_ASSERT(n == 3);
530 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("a"))); 530 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("a")));
531 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("b"))); 531 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str("b")));
532 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR("c,"))); 532 CX_TEST_ASSERT(0 == cx_strcmp(list[2], cx_str("c,")));
533 cxFree(alloc, list); 533 cxFree(alloc, list);
534 534
535 // exact match 535 // exact match
536 n = cx_strsplit_a(alloc, test, CX_STR("this,is,a,csv,string"), capa, &list); 536 n = cx_strsplit_a(alloc, test, cx_str("this,is,a,csv,string"), capa, &list);
537 CX_TEST_ASSERT(n == 2); 537 CX_TEST_ASSERT(n == 2);
538 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR(""))); 538 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("")));
539 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(""))); 539 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str("")));
540 cxFree(alloc, list); 540 cxFree(alloc, list);
541 541
542 // string to be split is only substring 542 // string to be split is only substring
543 n = cx_strsplit_a(alloc, test, CX_STR("this,is,a,csv,string,with,extension"), capa, &list); 543 n = cx_strsplit_a(alloc, test, cx_str("this,is,a,csv,string,with,extension"), capa, &list);
544 CX_TEST_ASSERT(n == 1); 544 CX_TEST_ASSERT(n == 1);
545 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test)); 545 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test));
546 cxFree(alloc, list); 546 cxFree(alloc, list);
547 547
548 // subsequent encounter of delimiter (the string between is empty) 548 // subsequent encounter of delimiter (the string between is empty)
549 n = cx_strsplit_a(alloc, test, CX_STR("is,"), capa, &list); 549 n = cx_strsplit_a(alloc, test, cx_str("is,"), capa, &list);
550 CX_TEST_ASSERT(n == 3); 550 CX_TEST_ASSERT(n == 3);
551 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("th"))); 551 CX_TEST_ASSERT(0 == cx_strcmp(list[0], cx_str("th")));
552 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(""))); 552 CX_TEST_ASSERT(0 == cx_strcmp(list[1], cx_str("")));
553 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR("a,csv,string"))); 553 CX_TEST_ASSERT(0 == cx_strcmp(list[2], cx_str("a,csv,string")));
554 cxFree(alloc, list); 554 cxFree(alloc, list);
555 555
556 // call the _m variant just for coverage 556 // call the _m variant just for coverage
557 cxmutstr mtest = cx_strdup(test); 557 cxmutstr mtest = cx_strdup(test);
558 cxmutstr *mlist; 558 cxmutstr *mlist;
559 n = cx_strsplit_ma(alloc, mtest, CX_STR("is,"), 4, &mlist); 559 n = cx_strsplit_ma(alloc, mtest, cx_str("is,"), 4, &mlist);
560 CX_TEST_ASSERT(n == 3); 560 CX_TEST_ASSERT(n == 3);
561 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[0]), CX_STR("th"))); 561 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[0]), cx_str("th")));
562 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[1]), CX_STR(""))); 562 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[1]), cx_str("")));
563 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[2]), CX_STR("a,csv,string"))); 563 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[2]), cx_str("a,csv,string")));
564 cxFree(alloc, mlist); 564 cxFree(alloc, mlist);
565 cx_strfree(&mtest); 565 cx_strfree(&mtest);
566 566
567 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); 567 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));
568 } 568 }
569 cx_testing_allocator_destroy(&talloc); 569 cx_testing_allocator_destroy(&talloc);
570 } 570 }
571 571
572 CX_TEST(test_strtrim) { 572 CX_TEST(test_strtrim) {
573 cxstring t1 = cx_strtrim(CX_STR(" ein test \t ")); 573 cxstring t1 = cx_strtrim(cx_str(" ein test \t "));
574 cxstring t2 = cx_strtrim(CX_STR("abc")); 574 cxstring t2 = cx_strtrim(cx_str("abc"));
575 cxstring t3 = cx_strtrim(CX_STR(" 123")); 575 cxstring t3 = cx_strtrim(cx_str(" 123"));
576 cxstring t4 = cx_strtrim(CX_STR("xyz ")); 576 cxstring t4 = cx_strtrim(cx_str("xyz "));
577 cxstring t5 = cx_strtrim(CX_STR(" ")); 577 cxstring t5 = cx_strtrim(cx_str(" "));
578 cxstring empty = cx_strtrim(CX_STR("")); 578 cxstring empty = cx_strtrim(cx_str(""));
579 579
580 CX_TEST_DO { 580 CX_TEST_DO {
581 CX_TEST_ASSERT(0 == cx_strcmp(t1, CX_STR("ein test"))); 581 CX_TEST_ASSERT(0 == cx_strcmp(t1, cx_str("ein test")));
582 CX_TEST_ASSERT(0 == cx_strcmp(t2, CX_STR("abc"))); 582 CX_TEST_ASSERT(0 == cx_strcmp(t2, cx_str("abc")));
583 CX_TEST_ASSERT(0 == cx_strcmp(t3, CX_STR("123"))); 583 CX_TEST_ASSERT(0 == cx_strcmp(t3, cx_str("123")));
584 CX_TEST_ASSERT(0 == cx_strcmp(t4, CX_STR("xyz"))); 584 CX_TEST_ASSERT(0 == cx_strcmp(t4, cx_str("xyz")));
585 CX_TEST_ASSERT(0 == cx_strcmp(t5, CX_STR(""))); 585 CX_TEST_ASSERT(0 == cx_strcmp(t5, cx_str("")));
586 CX_TEST_ASSERT(0 == cx_strcmp(empty, CX_STR(""))); 586 CX_TEST_ASSERT(0 == cx_strcmp(empty, cx_str("")));
587 587
588 // call the _m variant just for coverage 588 // call the _m variant just for coverage
589 cxmutstr m1 = cx_strtrim_m(cx_mutstr((char *) " ein test \t ")); 589 cxmutstr m1 = cx_strtrim_m(cx_mutstr((char *) " ein test \t "));
590 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(m1), CX_STR("ein test"))); 590 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(m1), cx_str("ein test")));
591 } 591 }
592 } 592 }
593 593
594 CX_TEST(test_strprefix) { 594 CX_TEST(test_strprefix) {
595 cxstring str = CX_STR("test my prefix and my suffix"); 595 cxstring str = CX_STR("test my prefix and my suffix");
596 cxstring empty = CX_STR(""); 596 cxstring empty = CX_STR("");
597 CX_TEST_DO { 597 CX_TEST_DO {
598 CX_TEST_ASSERT(!cx_strprefix(empty, CX_STR("pref"))); 598 CX_TEST_ASSERT(!cx_strprefix(empty, cx_str("pref")));
599 CX_TEST_ASSERT(cx_strprefix(str, empty)); 599 CX_TEST_ASSERT(cx_strprefix(str, empty));
600 CX_TEST_ASSERT(cx_strprefix(empty, empty)); 600 CX_TEST_ASSERT(cx_strprefix(empty, empty));
601 CX_TEST_ASSERT(cx_strprefix(str, CX_STR("test "))); 601 CX_TEST_ASSERT(cx_strprefix(str, cx_str("test ")));
602 CX_TEST_ASSERT(!cx_strprefix(str, CX_STR("8-) fsck "))); 602 CX_TEST_ASSERT(!cx_strprefix(str, cx_str("8-) fsck ")));
603 } 603 }
604 } 604 }
605 605
606 CX_TEST(test_strsuffix) { 606 CX_TEST(test_strsuffix) {
607 cxstring str = CX_STR("test my prefix and my suffix"); 607 cxstring str = CX_STR("test my prefix and my suffix");
608 cxstring empty = CX_STR(""); 608 cxstring empty = CX_STR("");
609 CX_TEST_DO { 609 CX_TEST_DO {
610 CX_TEST_ASSERT(!cx_strsuffix(empty, CX_STR("suf"))); 610 CX_TEST_ASSERT(!cx_strsuffix(empty, cx_str("suf")));
611 CX_TEST_ASSERT(cx_strsuffix(str, empty)); 611 CX_TEST_ASSERT(cx_strsuffix(str, empty));
612 CX_TEST_ASSERT(cx_strsuffix(empty, empty)); 612 CX_TEST_ASSERT(cx_strsuffix(empty, empty));
613 CX_TEST_ASSERT(cx_strsuffix(str, CX_STR("fix"))); 613 CX_TEST_ASSERT(cx_strsuffix(str, cx_str("fix")));
614 CX_TEST_ASSERT(!cx_strsuffix(str, CX_STR("fox"))); 614 CX_TEST_ASSERT(!cx_strsuffix(str, cx_str("fox")));
615 } 615 }
616 } 616 }
617 617
618 CX_TEST(test_strcaseprefix) { 618 CX_TEST(test_strcaseprefix) {
619 cxstring str = CX_STR("test my prefix and my suffix"); 619 cxstring str = CX_STR("test my prefix and my suffix");
620 cxstring empty = CX_STR(""); 620 cxstring empty = CX_STR("");
621 CX_TEST_DO { 621 CX_TEST_DO {
622 CX_TEST_ASSERT(!cx_strcaseprefix(empty, CX_STR("pREf"))); 622 CX_TEST_ASSERT(!cx_strcaseprefix(empty, cx_str("pREf")));
623 CX_TEST_ASSERT(cx_strcaseprefix(str, empty)); 623 CX_TEST_ASSERT(cx_strcaseprefix(str, empty));
624 CX_TEST_ASSERT(cx_strcaseprefix(empty, empty)); 624 CX_TEST_ASSERT(cx_strcaseprefix(empty, empty));
625 CX_TEST_ASSERT(cx_strcaseprefix(str, CX_STR("TEST "))); 625 CX_TEST_ASSERT(cx_strcaseprefix(str, cx_str("TEST ")));
626 CX_TEST_ASSERT(!cx_strcaseprefix(str, CX_STR("8-) fsck "))); 626 CX_TEST_ASSERT(!cx_strcaseprefix(str, cx_str("8-) fsck ")));
627 } 627 }
628 } 628 }
629 629
630 CX_TEST(test_strcasesuffix) { 630 CX_TEST(test_strcasesuffix) {
631 cxstring str = CX_STR("test my prefix and my suffix"); 631 cxstring str = CX_STR("test my prefix and my suffix");
632 cxstring empty = CX_STR(""); 632 cxstring empty = CX_STR("");
633 CX_TEST_DO { 633 CX_TEST_DO {
634 CX_TEST_ASSERT(!cx_strcasesuffix(empty, CX_STR("sUf"))); 634 CX_TEST_ASSERT(!cx_strcasesuffix(empty, cx_str("sUf")));
635 CX_TEST_ASSERT(cx_strcasesuffix(str, empty)); 635 CX_TEST_ASSERT(cx_strcasesuffix(str, empty));
636 CX_TEST_ASSERT(cx_strcasesuffix(empty, empty)); 636 CX_TEST_ASSERT(cx_strcasesuffix(empty, empty));
637 CX_TEST_ASSERT(cx_strcasesuffix(str, CX_STR("FIX"))); 637 CX_TEST_ASSERT(cx_strcasesuffix(str, cx_str("FIX")));
638 CX_TEST_ASSERT(!cx_strcasesuffix(str, CX_STR("fox"))); 638 CX_TEST_ASSERT(!cx_strcasesuffix(str, cx_str("fox")));
639 } 639 }
640 } 640 }
641 641
642 CX_TEST(test_strreplace) { 642 CX_TEST(test_strreplace) {
643 CxTestingAllocator talloc; 643 CxTestingAllocator talloc;
650 cxstring notrail = CX_STR("test abab"); 650 cxstring notrail = CX_STR("test abab");
651 cxstring empty = CX_STR(""); 651 cxstring empty = CX_STR("");
652 cxstring astr = CX_STR("aaaaaaaaaa"); 652 cxstring astr = CX_STR("aaaaaaaaaa");
653 cxstring csstr = CX_STR("test AB ab TEST xyz"); 653 cxstring csstr = CX_STR("test AB ab TEST xyz");
654 654
655 cxmutstr repl = cx_strreplace(str, CX_STR("abab"), CX_STR("muchlonger")); 655 cxmutstr repl = cx_strreplace(str, cx_str("abab"), cx_str("muchlonger"));
656 const char *expected = "test muchlongerab string aba"; 656 const char *expected = "test muchlongerab string aba";
657 657
658 cxmutstr repln = cx_strreplacen(str, CX_STR("ab"), CX_STR("c"), 2); 658 cxmutstr repln = cx_strreplacen(str, cx_str("ab"), cx_str("c"), 2);
659 const char *expectedn = "test ccab string aba"; 659 const char *expectedn = "test ccab string aba";
660 660
661 cxmutstr longrepl = cx_strreplace(longstr, CX_STR("a"), CX_STR("z")); 661 cxmutstr longrepl = cx_strreplace(longstr, cx_str("a"), cx_str("z"));
662 const char *longexpect = "xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzcd"; 662 const char *longexpect = "xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzcd";
663 663
664 cxmutstr replnotrail = cx_strreplace(notrail, CX_STR("ab"), CX_STR("z")); 664 cxmutstr replnotrail = cx_strreplace(notrail, cx_str("ab"), cx_str("z"));
665 const char *notrailexpect = "test zz"; 665 const char *notrailexpect = "test zz";
666 666
667 cxmutstr repleq = cx_strreplace(str, str, CX_STR("hello")); 667 cxmutstr repleq = cx_strreplace(str, str, cx_str("hello"));
668 const char *eqexpect = "hello"; 668 const char *eqexpect = "hello";
669 669
670 cxmutstr replempty1 = cx_strreplace(empty, CX_STR("ab"), CX_STR("c")); // expect: empty 670 cxmutstr replempty1 = cx_strreplace(empty, cx_str("ab"), cx_str("c")); // expect: empty
671 cxmutstr replempty2 = cx_strreplace(str, CX_STR("abab"), empty); 671 cxmutstr replempty2 = cx_strreplace(str, cx_str("abab"), empty);
672 const char *emptyexpect2 = "test ab string aba"; 672 const char *emptyexpect2 = "test ab string aba";
673 673
674 cxmutstr replpre = cx_strreplace(str, CX_STR("test "), CX_STR("TEST ")); 674 cxmutstr replpre = cx_strreplace(str, cx_str("test "), cx_str("TEST "));
675 const char *preexpected = "TEST ababab string aba"; 675 const char *preexpected = "TEST ababab string aba";
676 676
677 cxmutstr replan1 = cx_strreplacen(astr, CX_STR("a"), CX_STR("x"), 1); 677 cxmutstr replan1 = cx_strreplacen(astr, cx_str("a"), cx_str("x"), 1);
678 const char *an1expected = "xaaaaaaaaa"; 678 const char *an1expected = "xaaaaaaaaa";
679 679
680 cxmutstr replan4 = cx_strreplacen(astr, CX_STR("a"), CX_STR("x"), 4); 680 cxmutstr replan4 = cx_strreplacen(astr, cx_str("a"), cx_str("x"), 4);
681 const char *an4expected = "xxxxaaaaaa"; 681 const char *an4expected = "xxxxaaaaaa";
682 682
683 cxmutstr replan9 = cx_strreplacen(astr, CX_STR("a"), CX_STR("x"), 9); 683 cxmutstr replan9 = cx_strreplacen(astr, cx_str("a"), cx_str("x"), 9);
684 const char *an9expected = "xxxxxxxxxa"; 684 const char *an9expected = "xxxxxxxxxa";
685 685
686 cxmutstr replan10 = cx_strreplacen(astr, CX_STR("a"), CX_STR("x"), 10); 686 cxmutstr replan10 = cx_strreplacen(astr, cx_str("a"), cx_str("x"), 10);
687 const char *an10expected = "xxxxxxxxxx"; 687 const char *an10expected = "xxxxxxxxxx";
688 688
689 CX_TEST_DO { 689 CX_TEST_DO {
690 cxmutstr repl1_a = cx_strreplace_a(alloc, csstr, CX_STR("AB"), CX_STR("*")); 690 cxmutstr repl1_a = cx_strreplace_a(alloc, csstr, cx_str("AB"), cx_str("*"));
691 const char *expeced1_a = "test * ab TEST xyz"; 691 const char *expeced1_a = "test * ab TEST xyz";
692 692
693 cxmutstr repl2_a = cx_strreplace_a(alloc, csstr, CX_STR("test"), CX_STR("TEST")); 693 cxmutstr repl2_a = cx_strreplace_a(alloc, csstr, cx_str("test"), cx_str("TEST"));
694 const char *expected2_a = "TEST AB ab TEST xyz"; 694 const char *expected2_a = "TEST AB ab TEST xyz";
695 695
696 CX_TEST_ASSERT(repl.ptr != str.ptr); 696 CX_TEST_ASSERT(repl.ptr != str.ptr);
697 ASSERT_ZERO_TERMINATED(repl); 697 ASSERT_ZERO_TERMINATED(repl);
698 CX_TEST_ASSERT(0 == strcmp(repl.ptr, expected)); 698 CX_TEST_ASSERT(0 == strcmp(repl.ptr, expected));
742 cx_strfree(&replan10); 742 cx_strfree(&replan10);
743 cx_testing_allocator_destroy(&talloc); 743 cx_testing_allocator_destroy(&talloc);
744 } 744 }
745 745
746 CX_TEST(test_strupper) { 746 CX_TEST(test_strupper) {
747 cxmutstr str = cx_strdup(CX_STR("thIs 1s @ Te$t")); 747 cxmutstr str = cx_strdup(cx_str("thIs 1s @ Te$t"));
748 CX_TEST_DO { 748 CX_TEST_DO {
749 cx_strupper(str); 749 cx_strupper(str);
750 CX_TEST_ASSERT(0 == strcmp(str.ptr, "THIS 1S @ TE$T")); 750 CX_TEST_ASSERT(0 == strcmp(str.ptr, "THIS 1S @ TE$T"));
751 } 751 }
752 cx_strfree(&str); 752 cx_strfree(&str);
753 } 753 }
754 754
755 CX_TEST(test_strlower) { 755 CX_TEST(test_strlower) {
756 cxmutstr str = cx_strdup(CX_STR("thIs 1s @ Te$t")); 756 cxmutstr str = cx_strdup(cx_str("thIs 1s @ Te$t"));
757 CX_TEST_DO { 757 CX_TEST_DO {
758 cx_strlower(str); 758 cx_strlower(str);
759 CX_TEST_ASSERT(0 == strcmp(str.ptr, "this 1s @ te$t")); 759 CX_TEST_ASSERT(0 == strcmp(str.ptr, "this 1s @ te$t"));
760 } 760 }
761 cx_strfree(&str); 761 cx_strfree(&str);
778 CX_TEST_ASSERT(ctx.delim_more_count == 0); 778 CX_TEST_ASSERT(ctx.delim_more_count == 0);
779 } 779 }
780 } 780 }
781 781
782 CX_TEST(test_strtok_m) { 782 CX_TEST(test_strtok_m) {
783 cxmutstr str = cx_strdup(CX_STR("a,comma,separated,string")); 783 cxmutstr str = cx_strdup(cx_str("a,comma,separated,string"));
784 cxstring delim = CX_STR(","); 784 cxstring delim = CX_STR(",");
785 CX_TEST_DO { 785 CX_TEST_DO {
786 CxStrtokCtx ctx = cx_strtok_m(str, delim, 3); 786 CxStrtokCtx ctx = cx_strtok_m(str, delim, 3);
787 CX_TEST_ASSERT(ctx.str.ptr == str.ptr); 787 CX_TEST_ASSERT(ctx.str.ptr == str.ptr);
788 CX_TEST_ASSERT(ctx.str.length == str.length); 788 CX_TEST_ASSERT(ctx.str.length == str.length);
826 bool ret; 826 bool ret;
827 cxstring tok; 827 cxstring tok;
828 828
829 ret = cx_strtok_next(&ctx, &tok); 829 ret = cx_strtok_next(&ctx, &tok);
830 CX_TEST_ASSERT(ret); 830 CX_TEST_ASSERT(ret);
831 CX_TEST_ASSERT(0 == cx_strcmp(tok, CX_STR("a"))); 831 CX_TEST_ASSERT(0 == cx_strcmp(tok, cx_str("a")));
832 CX_TEST_ASSERT(ctx.pos == 0); 832 CX_TEST_ASSERT(ctx.pos == 0);
833 CX_TEST_ASSERT(ctx.next_pos == 2); 833 CX_TEST_ASSERT(ctx.next_pos == 2);
834 CX_TEST_ASSERT(ctx.delim_pos == 1); 834 CX_TEST_ASSERT(ctx.delim_pos == 1);
835 CX_TEST_ASSERT(ctx.found == 1); 835 CX_TEST_ASSERT(ctx.found == 1);
836 836
837 ret = cx_strtok_next(&ctx, &tok); 837 ret = cx_strtok_next(&ctx, &tok);
838 CX_TEST_ASSERT(ret); 838 CX_TEST_ASSERT(ret);
839 CX_TEST_ASSERT(0 == cx_strcmp(tok, CX_STR("comma"))); 839 CX_TEST_ASSERT(0 == cx_strcmp(tok, cx_str("comma")));
840 CX_TEST_ASSERT(ctx.pos == 2); 840 CX_TEST_ASSERT(ctx.pos == 2);
841 CX_TEST_ASSERT(ctx.next_pos == 8); 841 CX_TEST_ASSERT(ctx.next_pos == 8);
842 CX_TEST_ASSERT(ctx.delim_pos == 7); 842 CX_TEST_ASSERT(ctx.delim_pos == 7);
843 CX_TEST_ASSERT(ctx.found == 2); 843 CX_TEST_ASSERT(ctx.found == 2);
844 844
845 ret = cx_strtok_next(&ctx, &tok); 845 ret = cx_strtok_next(&ctx, &tok);
846 CX_TEST_ASSERT(ret); 846 CX_TEST_ASSERT(ret);
847 CX_TEST_ASSERT(0 == cx_strcmp(tok, CX_STR("separated"))); 847 CX_TEST_ASSERT(0 == cx_strcmp(tok, cx_str("separated")));
848 CX_TEST_ASSERT(ctx.pos == 8); 848 CX_TEST_ASSERT(ctx.pos == 8);
849 CX_TEST_ASSERT(ctx.next_pos == 18); 849 CX_TEST_ASSERT(ctx.next_pos == 18);
850 CX_TEST_ASSERT(ctx.delim_pos == 17); 850 CX_TEST_ASSERT(ctx.delim_pos == 17);
851 CX_TEST_ASSERT(ctx.found == 3); 851 CX_TEST_ASSERT(ctx.found == 3);
852 852
867 bool ret; 867 bool ret;
868 cxstring tok; 868 cxstring tok;
869 869
870 ret = cx_strtok_next(&ctx, &tok); 870 ret = cx_strtok_next(&ctx, &tok);
871 CX_TEST_ASSERT(ret); 871 CX_TEST_ASSERT(ret);
872 CX_TEST_ASSERT(0 == cx_strcmp(tok, CX_STR("some"))); 872 CX_TEST_ASSERT(0 == cx_strcmp(tok, cx_str("some")));
873 CX_TEST_ASSERT(ctx.pos == 0); 873 CX_TEST_ASSERT(ctx.pos == 0);
874 CX_TEST_ASSERT(ctx.next_pos == 7); 874 CX_TEST_ASSERT(ctx.next_pos == 7);
875 CX_TEST_ASSERT(ctx.delim_pos == 4); 875 CX_TEST_ASSERT(ctx.delim_pos == 4);
876 CX_TEST_ASSERT(ctx.found == 1); 876 CX_TEST_ASSERT(ctx.found == 1);
877 877
878 ret = cx_strtok_next(&ctx, &tok); 878 ret = cx_strtok_next(&ctx, &tok);
879 CX_TEST_ASSERT(ret); 879 CX_TEST_ASSERT(ret);
880 CX_TEST_ASSERT(0 == cx_strcmp(tok, CX_STR("otherwise"))); 880 CX_TEST_ASSERT(0 == cx_strcmp(tok, cx_str("otherwise")));
881 CX_TEST_ASSERT(ctx.pos == 7); 881 CX_TEST_ASSERT(ctx.pos == 7);
882 CX_TEST_ASSERT(ctx.next_pos == 19); 882 CX_TEST_ASSERT(ctx.next_pos == 19);
883 CX_TEST_ASSERT(ctx.delim_pos == 16); 883 CX_TEST_ASSERT(ctx.delim_pos == 16);
884 CX_TEST_ASSERT(ctx.found == 2); 884 CX_TEST_ASSERT(ctx.found == 2);
885 885
886 ret = cx_strtok_next(&ctx, &tok); 886 ret = cx_strtok_next(&ctx, &tok);
887 CX_TEST_ASSERT(ret); 887 CX_TEST_ASSERT(ret);
888 CX_TEST_ASSERT(0 == cx_strcmp(tok, CX_STR("separated"))); 888 CX_TEST_ASSERT(0 == cx_strcmp(tok, cx_str("separated")));
889 CX_TEST_ASSERT(ctx.pos == 19); 889 CX_TEST_ASSERT(ctx.pos == 19);
890 CX_TEST_ASSERT(ctx.next_pos == 31); 890 CX_TEST_ASSERT(ctx.next_pos == 31);
891 CX_TEST_ASSERT(ctx.delim_pos == 28); 891 CX_TEST_ASSERT(ctx.delim_pos == 28);
892 CX_TEST_ASSERT(ctx.found == 3); 892 CX_TEST_ASSERT(ctx.found == 3);
893 893
894 ret = cx_strtok_next(&ctx, &tok); 894 ret = cx_strtok_next(&ctx, &tok);
895 CX_TEST_ASSERT(ret); 895 CX_TEST_ASSERT(ret);
896 CX_TEST_ASSERT(0 == cx_strcmp(tok, CX_STR("string"))); 896 CX_TEST_ASSERT(0 == cx_strcmp(tok, cx_str("string")));
897 CX_TEST_ASSERT(ctx.pos == 31); 897 CX_TEST_ASSERT(ctx.pos == 31);
898 CX_TEST_ASSERT(ctx.next_pos == 40); 898 CX_TEST_ASSERT(ctx.next_pos == 40);
899 CX_TEST_ASSERT(ctx.delim_pos == 37); 899 CX_TEST_ASSERT(ctx.delim_pos == 37);
900 CX_TEST_ASSERT(ctx.found == 4); 900 CX_TEST_ASSERT(ctx.found == 4);
901 901
902 ret = cx_strtok_next(&ctx, &tok); 902 ret = cx_strtok_next(&ctx, &tok);
903 CX_TEST_ASSERT(ret); 903 CX_TEST_ASSERT(ret);
904 CX_TEST_ASSERT(0 == cx_strcmp(tok, CX_STR(""))); 904 CX_TEST_ASSERT(0 == cx_strcmp(tok, cx_str("")));
905 CX_TEST_ASSERT(ctx.pos == 40); 905 CX_TEST_ASSERT(ctx.pos == 40);
906 CX_TEST_ASSERT(ctx.next_pos == 40); 906 CX_TEST_ASSERT(ctx.next_pos == 40);
907 CX_TEST_ASSERT(ctx.delim_pos == 40); 907 CX_TEST_ASSERT(ctx.delim_pos == 40);
908 CX_TEST_ASSERT(ctx.found == 5); 908 CX_TEST_ASSERT(ctx.found == 5);
909 909
914 CX_TEST_ASSERT(ctx.found == 5); 914 CX_TEST_ASSERT(ctx.found == 5);
915 } 915 }
916 } 916 }
917 917
918 CX_TEST(test_strtok_next_advanced) { 918 CX_TEST(test_strtok_next_advanced) {
919 cxmutstr str = cx_strdup(CX_STR("an,arbitrarily;||separated;string")); 919 cxmutstr str = cx_strdup(cx_str("an,arbitrarily;||separated;string"));
920 cxstring delim = CX_STR(","); 920 cxstring delim = CX_STR(",");
921 cxstring delim_more[2] = {CX_STR("||"), CX_STR(";")}; 921 cxstring delim_more[2] = {CX_STR("||"), CX_STR(";")};
922 CX_TEST_DO { 922 CX_TEST_DO {
923 CxStrtokCtx ctx = cx_strtok_m(str, delim, 10); 923 CxStrtokCtx ctx = cx_strtok_m(str, delim, 10);
924 cx_strtok_delim(&ctx, delim_more, 2); 924 cx_strtok_delim(&ctx, delim_more, 2);
925 bool ret; 925 bool ret;
926 cxmutstr tok; 926 cxmutstr tok;
927 927
928 ret = cx_strtok_next_m(&ctx, &tok); 928 ret = cx_strtok_next_m(&ctx, &tok);
929 CX_TEST_ASSERT(ret); 929 CX_TEST_ASSERT(ret);
930 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(tok), CX_STR("an"))); 930 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(tok), cx_str("an")));
931 CX_TEST_ASSERT(ctx.pos == 0); 931 CX_TEST_ASSERT(ctx.pos == 0);
932 CX_TEST_ASSERT(ctx.next_pos == 3); 932 CX_TEST_ASSERT(ctx.next_pos == 3);
933 CX_TEST_ASSERT(ctx.delim_pos == 2); 933 CX_TEST_ASSERT(ctx.delim_pos == 2);
934 CX_TEST_ASSERT(ctx.found == 1); 934 CX_TEST_ASSERT(ctx.found == 1);
935 cx_strupper(tok); 935 cx_strupper(tok);
936 936
937 ret = cx_strtok_next_m(&ctx, &tok); 937 ret = cx_strtok_next_m(&ctx, &tok);
938 CX_TEST_ASSERT(ret); 938 CX_TEST_ASSERT(ret);
939 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(tok), CX_STR("arbitrarily"))); 939 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(tok), cx_str("arbitrarily")));
940 CX_TEST_ASSERT(ctx.pos == 3); 940 CX_TEST_ASSERT(ctx.pos == 3);
941 CX_TEST_ASSERT(ctx.next_pos == 15); 941 CX_TEST_ASSERT(ctx.next_pos == 15);
942 CX_TEST_ASSERT(ctx.delim_pos == 14); 942 CX_TEST_ASSERT(ctx.delim_pos == 14);
943 CX_TEST_ASSERT(ctx.found == 2); 943 CX_TEST_ASSERT(ctx.found == 2);
944 cx_strupper(tok); 944 cx_strupper(tok);
945 945
946 ret = cx_strtok_next_m(&ctx, &tok); 946 ret = cx_strtok_next_m(&ctx, &tok);
947 CX_TEST_ASSERT(ret); 947 CX_TEST_ASSERT(ret);
948 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(tok), CX_STR(""))); 948 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(tok), cx_str("")));
949 CX_TEST_ASSERT(ctx.pos == 15); 949 CX_TEST_ASSERT(ctx.pos == 15);
950 CX_TEST_ASSERT(ctx.next_pos == 17); 950 CX_TEST_ASSERT(ctx.next_pos == 17);
951 CX_TEST_ASSERT(ctx.delim_pos == 15); 951 CX_TEST_ASSERT(ctx.delim_pos == 15);
952 CX_TEST_ASSERT(ctx.found == 3); 952 CX_TEST_ASSERT(ctx.found == 3);
953 cx_strupper(tok); 953 cx_strupper(tok);
954 954
955 ret = cx_strtok_next_m(&ctx, &tok); 955 ret = cx_strtok_next_m(&ctx, &tok);
956 CX_TEST_ASSERT(ret); 956 CX_TEST_ASSERT(ret);
957 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(tok), CX_STR("separated"))); 957 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(tok), cx_str("separated")));
958 CX_TEST_ASSERT(ctx.pos == 17); 958 CX_TEST_ASSERT(ctx.pos == 17);
959 CX_TEST_ASSERT(ctx.next_pos == 27); 959 CX_TEST_ASSERT(ctx.next_pos == 27);
960 CX_TEST_ASSERT(ctx.delim_pos == 26); 960 CX_TEST_ASSERT(ctx.delim_pos == 26);
961 CX_TEST_ASSERT(ctx.found == 4); 961 CX_TEST_ASSERT(ctx.found == 4);
962 cx_strupper(tok); 962 cx_strupper(tok);
963 963
964 ret = cx_strtok_next_m(&ctx, &tok); 964 ret = cx_strtok_next_m(&ctx, &tok);
965 CX_TEST_ASSERT(ret); 965 CX_TEST_ASSERT(ret);
966 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(tok), CX_STR("string"))); 966 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(tok), cx_str("string")));
967 CX_TEST_ASSERT(ctx.pos == 27); 967 CX_TEST_ASSERT(ctx.pos == 27);
968 CX_TEST_ASSERT(ctx.next_pos == 33); 968 CX_TEST_ASSERT(ctx.next_pos == 33);
969 CX_TEST_ASSERT(ctx.delim_pos == 33); 969 CX_TEST_ASSERT(ctx.delim_pos == 33);
970 CX_TEST_ASSERT(ctx.found == 5); 970 CX_TEST_ASSERT(ctx.found == 5);
971 cx_strupper(tok); 971 cx_strupper(tok);
975 CX_TEST_ASSERT(ctx.pos == 27); 975 CX_TEST_ASSERT(ctx.pos == 27);
976 CX_TEST_ASSERT(ctx.next_pos == 33); 976 CX_TEST_ASSERT(ctx.next_pos == 33);
977 CX_TEST_ASSERT(ctx.delim_pos == 33); 977 CX_TEST_ASSERT(ctx.delim_pos == 33);
978 CX_TEST_ASSERT(ctx.found == 5); 978 CX_TEST_ASSERT(ctx.found == 5);
979 979
980 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(str), CX_STR("AN,ARBITRARILY;||SEPARATED;STRING"))); 980 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(str), cx_str("AN,ARBITRARILY;||SEPARATED;STRING")));
981 } 981 }
982 cx_strfree(&str); 982 cx_strfree(&str);
983 } 983 }
984 984
985 #define test_strtoint_impl(suffix, num, base, var, min, max) \ 985 #define test_strtoint_impl(suffix, num, base, var, min, max) \

mercurial