| 371 CX_TEST_ASSERT(notfound.length == 0); |
371 CX_TEST_ASSERT(notfound.length == 0); |
| 372 |
372 |
| 373 cxstring result = cx_strchr(str, 'w'); |
373 cxstring result = cx_strchr(str, 'w'); |
| 374 CX_TEST_ASSERT(result.length == 35); |
374 CX_TEST_ASSERT(result.length == 35); |
| 375 CX_TEST_ASSERT(0 == strcmp(result.ptr, "will find you - and I will kill you")); |
375 CX_TEST_ASSERT(0 == strcmp(result.ptr, "will find you - and I will kill you")); |
| 376 |
376 } |
| 377 // just for coverage, call the _m variant |
377 } |
| 378 cxmutstr m = cx_strchr_m(cx_mutstrn(NULL, 0), 'a'); |
378 |
| 379 CX_TEST_ASSERT(0 == cx_strcmp(m, "")); |
379 CX_TEST(test_strchr_m) { |
| |
380 cxmutstr str = cx_mutstr((char*)"I will find you - and I will kill you"); |
| |
381 |
| |
382 CX_TEST_DO { |
| |
383 cxmutstr notfound = cx_strchr(str, 'x'); |
| |
384 CX_TEST_ASSERT(notfound.length == 0); |
| |
385 |
| |
386 cxmutstr result = cx_strchr(str, 'w'); |
| |
387 CX_TEST_ASSERT(result.length == 35); |
| |
388 CX_TEST_ASSERT(0 == strcmp(result.ptr, "will find you - and I will kill you")); |
| 380 } |
389 } |
| 381 } |
390 } |
| 382 |
391 |
| 383 CX_TEST(test_strrchr) { |
392 CX_TEST(test_strrchr) { |
| 384 cxstring str = cx_str("X will find you - and I will kill you"); |
393 cxstring str = cx_str("X will find you - and I will kill you"); |
| 395 CX_TEST_ASSERT(result.length == 1); |
404 CX_TEST_ASSERT(result.length == 1); |
| 396 CX_TEST_ASSERT(0 == strcmp(result.ptr, "u")); |
405 CX_TEST_ASSERT(0 == strcmp(result.ptr, "u")); |
| 397 |
406 |
| 398 result = cx_strrchr(str, 'X'); |
407 result = cx_strrchr(str, 'X'); |
| 399 CX_TEST_ASSERT(0 == cx_strcmp(result, str)); |
408 CX_TEST_ASSERT(0 == cx_strcmp(result, str)); |
| 400 |
409 } |
| 401 // just for coverage, call the _m variant |
410 } |
| 402 cxmutstr m = cx_strrchr_m(cx_mutstrn(NULL, 0), 'a'); |
411 |
| 403 CX_TEST_ASSERT(0 == cx_strcmp(m, "")); |
412 CX_TEST(test_strrchr_m) { |
| |
413 cxmutstr str = cx_mutstr((char*)"X will find you - and I will kill you"); |
| |
414 |
| |
415 CX_TEST_DO { |
| |
416 cxmutstr notfound = cx_strrchr(str, 'x'); |
| |
417 CX_TEST_ASSERT(notfound.length == 0); |
| |
418 |
| |
419 cxmutstr result = cx_strrchr(str, 'w'); |
| |
420 CX_TEST_ASSERT(result.length == 13); |
| |
421 CX_TEST_ASSERT(0 == strcmp(result.ptr, "will kill you")); |
| |
422 |
| |
423 result = cx_strrchr(str, 'u'); |
| |
424 CX_TEST_ASSERT(result.length == 1); |
| |
425 CX_TEST_ASSERT(0 == strcmp(result.ptr, "u")); |
| |
426 |
| |
427 result = cx_strrchr(str, 'X'); |
| |
428 CX_TEST_ASSERT(0 == cx_strcmp(result, str)); |
| 404 } |
429 } |
| 405 } |
430 } |
| 406 |
431 |
| 407 CX_TEST(test_strstr) { |
432 CX_TEST(test_strstr) { |
| 408 cxstring str = cx_str("find the match in this string"); |
433 cxstring str = cx_str("find the match in this string"); |
| 1651 cx_test_register(suite, test_strsubs_cxms); |
1676 cx_test_register(suite, test_strsubs_cxms); |
| 1652 cx_test_register(suite, test_strsubs_cc); |
1677 cx_test_register(suite, test_strsubs_cc); |
| 1653 cx_test_register(suite, test_strsubs_c); |
1678 cx_test_register(suite, test_strsubs_c); |
| 1654 cx_test_register(suite, test_strat); |
1679 cx_test_register(suite, test_strat); |
| 1655 cx_test_register(suite, test_strchr); |
1680 cx_test_register(suite, test_strchr); |
| |
1681 cx_test_register(suite, test_strchr_m); |
| 1656 cx_test_register(suite, test_strrchr); |
1682 cx_test_register(suite, test_strrchr); |
| |
1683 cx_test_register(suite, test_strrchr_m); |
| 1657 cx_test_register(suite, test_strstr); |
1684 cx_test_register(suite, test_strstr); |
| 1658 cx_test_register(suite, test_strcmp); |
1685 cx_test_register(suite, test_strcmp); |
| 1659 cx_test_register(suite, test_strcasecmp); |
1686 cx_test_register(suite, test_strcasecmp); |
| 1660 cx_test_register(suite, test_strcat); |
1687 cx_test_register(suite, test_strcat); |
| 1661 cx_test_register(suite, test_strcat_more_than_eight); |
1688 cx_test_register(suite, test_strcat_more_than_eight); |