test/string_tests.c

changeset 148
c27c2425c0b1
parent 147
1aa598f36872
child 149
3bf87676d42d
--- a/test/string_tests.c	Fri Aug 16 14:48:58 2013 +0200
+++ b/test/string_tests.c	Mon Aug 19 10:44:11 2013 +0200
@@ -69,6 +69,23 @@
     free(cat.ptr);
 }
 
+UCX_TEST(test_sstrchr) {
+    sstr_t str = ST("I will find you - and I will kill you");
+    UCX_TEST_BEGIN
+    
+    sstr_t result = sstrchr(str, 'w');
+    UCX_TEST_ASSERT(result.length == 35, "sstrchr returned wrong length");
+    UCX_TEST_ASSERT(strcmp("will find you - and I will kill you", result.ptr)
+        == 0, "sstrchr did not return the expected string");
+    
+    result = sstrrchr(str, 'w');
+    UCX_TEST_ASSERT(result.length == 13, "sstrrchr returned wrong length");
+    UCX_TEST_ASSERT(strcmp("will kill you", result.ptr)
+        == 0, "sstrrchr did not return the expected string");
+    
+    UCX_TEST_END
+}
+
 UCX_TEST(test_sstrsplit) {
 
     const char *original = "this,is,a,csv,string";

mercurial