test/string_tests.c

changeset 306
90b6d69bb499
parent 283
c3b6ff227481
child 364
5577d6c27a33
equal deleted inserted replaced
305:353d71349e61 306:90b6d69bb499
75 UCX_TEST(test_sstrchr_sstrrchr) { 75 UCX_TEST(test_sstrchr_sstrrchr) {
76 sstr_t str = ST("I will find you - and I will kill you"); 76 sstr_t str = ST("I will find you - and I will kill you");
77 UCX_TEST_BEGIN 77 UCX_TEST_BEGIN
78 78
79 sstr_t notfound = sstrchr(str, 'x'); 79 sstr_t notfound = sstrchr(str, 'x');
80 UCX_TEST_ASSERT(notfound.length == 0, "string length not 0"); 80 UCX_TEST_ASSERT(notfound.length == 0,
81 "string length not 0 after forward search w/o result");
82
83 notfound = sstrrchr(str, 'x');
84 UCX_TEST_ASSERT(notfound.length == 0,
85 "string length not 0 after reverse search w/o result");
81 86
82 sstr_t result = sstrchr(str, 'w'); 87 sstr_t result = sstrchr(str, 'w');
83 UCX_TEST_ASSERT(result.length == 35, "sstrchr returned wrong length"); 88 UCX_TEST_ASSERT(result.length == 35, "sstrchr returned wrong length");
84 UCX_TEST_ASSERT(strcmp("will find you - and I will kill you", result.ptr) 89 UCX_TEST_ASSERT(strcmp("will find you - and I will kill you", result.ptr)
85 == 0, "sstrchr did not return the expected string"); 90 == 0, "sstrchr did not return the expected string");

mercurial