test/string_tests.c

changeset 148
c27c2425c0b1
parent 147
1aa598f36872
child 149
3bf87676d42d
equal deleted inserted replaced
147:1aa598f36872 148:c27c2425c0b1
67 UCX_TEST_END 67 UCX_TEST_END
68 68
69 free(cat.ptr); 69 free(cat.ptr);
70 } 70 }
71 71
72 UCX_TEST(test_sstrchr) {
73 sstr_t str = ST("I will find you - and I will kill you");
74 UCX_TEST_BEGIN
75
76 sstr_t result = sstrchr(str, 'w');
77 UCX_TEST_ASSERT(result.length == 35, "sstrchr returned wrong length");
78 UCX_TEST_ASSERT(strcmp("will find you - and I will kill you", result.ptr)
79 == 0, "sstrchr did not return the expected string");
80
81 result = sstrrchr(str, 'w');
82 UCX_TEST_ASSERT(result.length == 13, "sstrrchr returned wrong length");
83 UCX_TEST_ASSERT(strcmp("will kill you", result.ptr)
84 == 0, "sstrrchr did not return the expected string");
85
86 UCX_TEST_END
87 }
88
72 UCX_TEST(test_sstrsplit) { 89 UCX_TEST(test_sstrsplit) {
73 90
74 const char *original = "this,is,a,csv,string"; 91 const char *original = "this,is,a,csv,string";
75 sstr_t test = ST("this,is,a,csv,string"); /* use copy of original here */ 92 sstr_t test = ST("this,is,a,csv,string"); /* use copy of original here */
76 size_t n; 93 size_t n;

mercurial