--- a/test/string_tests.c Mon Oct 26 14:09:45 2015 +0100 +++ b/test/string_tests.c Tue Oct 27 15:29:34 2015 +0100 @@ -79,6 +79,27 @@ UCX_TEST_END } +UCX_TEST(test_sstrstr) { + sstr_t str = ST("find the match in this string"); + UCX_TEST_BEGIN + + sstr_t notfound = sstrstr(str, S("no match")); + UCX_TEST_ASSERT(notfound.length == 0, "no match must return empty string"); + + sstr_t result = sstrstr(str, S("match")); + UCX_TEST_ASSERT(result.length == 20, "sstrstr returned wrong length"); + UCX_TEST_ASSERT(!strcmp("match in this string", result.ptr), + "sstrstr did not return the expected string"); + + result = sstrstr(str, S("")); + UCX_TEST_ASSERT(result.length == str.length, + "sstrstr with empty match string returned wrong length"); + UCX_TEST_ASSERT(!strcmp(str.ptr, result.ptr), + "sstrstr with empty match string did not return the original string"); + + UCX_TEST_END +} + UCX_TEST(test_sstrcmp) { sstr_t str = ST("compare this");