--- a/test/string_tests.c Mon Aug 19 10:44:11 2013 +0200 +++ b/test/string_tests.c Mon Aug 19 11:54:54 2013 +0200 @@ -69,7 +69,7 @@ free(cat.ptr); } -UCX_TEST(test_sstrchr) { +UCX_TEST(test_sstrchr_sstrrchr) { sstr_t str = ST("I will find you - and I will kill you"); UCX_TEST_BEGIN @@ -86,6 +86,35 @@ UCX_TEST_END } +UCX_TEST(test_sstrcmp) { + sstr_t str = ST("compare this"); + + UCX_TEST_BEGIN + UCX_TEST_ASSERT(sstrcmp(str, S("compare this")) == 0, "false negative"); + UCX_TEST_ASSERT(sstrcmp(str, S("Compare This")) != 0, "false positive"); + UCX_TEST_ASSERT(sstrcmp(str, S("compare tool")) < 0, "memcmp < 0 failed"); + UCX_TEST_ASSERT(sstrcmp(str, S("compare shit")) > 0, "memcmp > 0 failed"); + UCX_TEST_ASSERT(sstrcmp(str, S("compare this not")) < 0, "len < 0 failed"); + UCX_TEST_ASSERT(sstrcmp(str, S("compare")) > 0, "len > 0 failed"); + UCX_TEST_END +} + +UCX_TEST(test_sstrcasecmp) { + + sstr_t str = ST("compare this"); + + UCX_TEST_BEGIN + UCX_TEST_ASSERT(sstrcasecmp(str, S("compare this")) == 0, "false negative"); + UCX_TEST_ASSERT(sstrcasecmp(str, S("Compare This")) == 0, + "not ignoring case"); + UCX_TEST_ASSERT(sstrcasecmp(str, S("compare tool")) < 0, "< 0 failed"); + UCX_TEST_ASSERT(sstrcasecmp(str, S("compare shit")) > 0, "> 0 failed"); + UCX_TEST_ASSERT(sstrcasecmp(str, S("compare this not")) < 0, + "len < 0 failed"); + UCX_TEST_ASSERT(sstrcasecmp(str, S("compare")) > 0, "len > 0 failed"); + UCX_TEST_END +} + UCX_TEST(test_sstrsplit) { const char *original = "this,is,a,csv,string";