diff -r 36c0fb2b60b2 -r f889ffd07c86 tests/test_string.c --- a/tests/test_string.c Sun Dec 28 17:31:20 2025 +0100 +++ b/tests/test_string.c Sun Dec 28 18:30:25 2025 +0100 @@ -373,10 +373,19 @@ cxstring result = cx_strchr(str, 'w'); CX_TEST_ASSERT(result.length == 35); CX_TEST_ASSERT(0 == strcmp(result.ptr, "will find you - and I will kill you")); + } +} - // just for coverage, call the _m variant - cxmutstr m = cx_strchr_m(cx_mutstrn(NULL, 0), 'a'); - CX_TEST_ASSERT(0 == cx_strcmp(m, "")); +CX_TEST(test_strchr_m) { + cxmutstr str = cx_mutstr((char*)"I will find you - and I will kill you"); + + CX_TEST_DO { + cxmutstr notfound = cx_strchr(str, 'x'); + CX_TEST_ASSERT(notfound.length == 0); + + cxmutstr result = cx_strchr(str, 'w'); + CX_TEST_ASSERT(result.length == 35); + CX_TEST_ASSERT(0 == strcmp(result.ptr, "will find you - and I will kill you")); } } @@ -397,10 +406,26 @@ result = cx_strrchr(str, 'X'); CX_TEST_ASSERT(0 == cx_strcmp(result, str)); + } +} - // just for coverage, call the _m variant - cxmutstr m = cx_strrchr_m(cx_mutstrn(NULL, 0), 'a'); - CX_TEST_ASSERT(0 == cx_strcmp(m, "")); +CX_TEST(test_strrchr_m) { + cxmutstr str = cx_mutstr((char*)"X will find you - and I will kill you"); + + CX_TEST_DO { + cxmutstr notfound = cx_strrchr(str, 'x'); + CX_TEST_ASSERT(notfound.length == 0); + + cxmutstr result = cx_strrchr(str, 'w'); + CX_TEST_ASSERT(result.length == 13); + CX_TEST_ASSERT(0 == strcmp(result.ptr, "will kill you")); + + result = cx_strrchr(str, 'u'); + CX_TEST_ASSERT(result.length == 1); + CX_TEST_ASSERT(0 == strcmp(result.ptr, "u")); + + result = cx_strrchr(str, 'X'); + CX_TEST_ASSERT(0 == cx_strcmp(result, str)); } } @@ -1653,7 +1678,9 @@ cx_test_register(suite, test_strsubs_c); cx_test_register(suite, test_strat); cx_test_register(suite, test_strchr); + cx_test_register(suite, test_strchr_m); cx_test_register(suite, test_strrchr); + cx_test_register(suite, test_strrchr_m); cx_test_register(suite, test_strstr); cx_test_register(suite, test_strcmp); cx_test_register(suite, test_strcasecmp);