test/string_tests.c

changeset 364
5577d6c27a33
parent 306
90b6d69bb499
child 378
952c2df7e7ac
--- a/test/string_tests.c	Sun Nov 03 16:22:46 2019 +0100
+++ b/test/string_tests.c	Sun Nov 03 16:34:29 2019 +0100
@@ -452,3 +452,27 @@
     
     UCX_TEST_END
 }
+
+UCX_TEST(test_sstrcaseprefixsuffix) {
+    sstr_t str = ST("test my prefix and my suffix");
+    sstr_t empty = ST("");
+    
+    UCX_TEST_BEGIN
+    
+    UCX_TEST_ASSERT(!sstrcaseprefix(empty, S("pREf")), "prefix empty string fails");
+    UCX_TEST_ASSERT(!sstrcasesuffix(empty, S("sUf")), "suffix empty string fails");
+    
+    UCX_TEST_ASSERT(sstrcaseprefix(str, empty), "empty prefix fails");
+    UCX_TEST_ASSERT(sstrcasesuffix(str, empty), "empty suffix fails");
+    
+    UCX_TEST_ASSERT(sstrcaseprefix(empty, empty), "string and prefix empty fails");
+    UCX_TEST_ASSERT(sstrcasesuffix(empty, empty), "string and suffix empty fails");
+    
+    UCX_TEST_ASSERT(sstrcaseprefix(str, S("TEST ")), "prefix false negative");
+    UCX_TEST_ASSERT(!sstrcaseprefix(str, S("8-) fsck ")), "prefix false positive");
+    
+    UCX_TEST_ASSERT(sstrcasesuffix(str, S("FIX")), "suffix false negative");
+    UCX_TEST_ASSERT(!sstrcasesuffix(str, S("fox")), "suffix false positive");
+    
+    UCX_TEST_END
+}

mercurial