198 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(m), cx_str(""))); |
198 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(m), cx_str(""))); |
199 } |
199 } |
200 } |
200 } |
201 |
201 |
202 CX_TEST(test_strrchr) { |
202 CX_TEST(test_strrchr) { |
203 cxstring str = CX_STR("I will find you - and I will kill you"); |
203 cxstring str = CX_STR("X will find you - and I will kill you"); |
204 |
204 |
205 CX_TEST_DO { |
205 CX_TEST_DO { |
206 cxstring notfound = cx_strrchr(str, 'x'); |
206 cxstring notfound = cx_strrchr(str, 'x'); |
207 CX_TEST_ASSERT(notfound.length == 0); |
207 CX_TEST_ASSERT(notfound.length == 0); |
208 |
208 |
209 cxstring result = cx_strrchr(str, 'w'); |
209 cxstring result = cx_strrchr(str, 'w'); |
210 CX_TEST_ASSERT(result.length == 13); |
210 CX_TEST_ASSERT(result.length == 13); |
211 CX_TEST_ASSERT(0 == strcmp(result.ptr, "will kill you")); |
211 CX_TEST_ASSERT(0 == strcmp(result.ptr, "will kill you")); |
|
212 |
|
213 result = cx_strrchr(str, 'u'); |
|
214 CX_TEST_ASSERT(result.length == 1); |
|
215 CX_TEST_ASSERT(0 == strcmp(result.ptr, "u")); |
|
216 |
|
217 result = cx_strrchr(str, 'X'); |
|
218 CX_TEST_ASSERT(0 == cx_strcmp(result, str)); |
212 |
219 |
213 // just for coverage, call the _m variant |
220 // just for coverage, call the _m variant |
214 cxmutstr m = cx_strrchr_m(cx_mutstrn(NULL, 0), 'a'); |
221 cxmutstr m = cx_strrchr_m(cx_mutstrn(NULL, 0), 'a'); |
215 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(m), cx_str(""))); |
222 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(m), cx_str(""))); |
216 } |
223 } |