52 UCX_TEST_ASSERT(len == 10, "sstrnlen returned wrong size"); |
52 UCX_TEST_ASSERT(len == 10, "sstrnlen returned wrong size"); |
53 |
53 |
54 UCX_TEST_END |
54 UCX_TEST_END |
55 } |
55 } |
56 |
56 |
|
57 |
57 UCX_TEST(test_sstrchr_sstrrchr) { |
58 UCX_TEST(test_sstrchr_sstrrchr) { |
58 sstr_t str = ST("I will find you - and I will kill you"); |
59 sstr_t str = ST("I will find you - and I will kill you"); |
59 UCX_TEST_BEGIN |
60 UCX_TEST_BEGIN |
60 |
61 |
61 sstr_t result = sstrchr(str, 'w'); |
62 sstr_t result = sstrchr(str, 'w'); |
98 "len < 0 failed"); |
99 "len < 0 failed"); |
99 UCX_TEST_ASSERT(sstrcasecmp(str, S("compare")) > 0, "len > 0 failed"); |
100 UCX_TEST_ASSERT(sstrcasecmp(str, S("compare")) > 0, "len > 0 failed"); |
100 UCX_TEST_END |
101 UCX_TEST_END |
101 } |
102 } |
102 |
103 |
|
104 |
|
105 UCX_TEST(test_sstrcat) { |
|
106 sstr_t s1 = S("12"); |
|
107 sstr_t s2 = S("34"); |
|
108 sstr_t s3 = S("56"); |
|
109 sstr_t sn = { NULL, 0 }; |
|
110 |
|
111 UCX_TEST_BEGIN |
|
112 |
|
113 sstr_t t1 = sstrcat(2, s1, s2); |
|
114 UCX_TEST_ASSERT(!sstrcmp(t1, S("1234")), "t1: wrong content"); |
|
115 free(t1.ptr); |
|
116 |
|
117 sstr_t t2 = sstrcat(3, s1, s2, s3); |
|
118 UCX_TEST_ASSERT(!sstrcmp(t2, S("123456")), "t2: wrong content"); |
|
119 free(t2.ptr); |
|
120 |
|
121 sstr_t t3 = sstrcat(6, s1, sn, s2, sn, s3, sn); |
|
122 UCX_TEST_ASSERT(!sstrcmp(t3, S("123456")), "t3: wrong content"); |
|
123 free(t3.ptr); |
|
124 |
|
125 sstr_t t4 = sstrcat(2, sn, sn); |
|
126 UCX_TEST_ASSERT(t4.ptr, "t4.ptr is NULL"); |
|
127 UCX_TEST_ASSERT(t4.length == 0, "t4 has wrong length"); |
|
128 free(t4.ptr); |
|
129 |
|
130 |
|
131 UCX_TEST_END |
|
132 |
|
133 } |
|
134 |
103 UCX_TEST(test_sstrsplit) { |
135 UCX_TEST(test_sstrsplit) { |
104 |
136 |
105 const char *original = "this,is,a,csv,string"; |
137 const char *original = "this,is,a,csv,string"; |
106 sstr_t test = ST("this,is,a,csv,string"); /* use copy of original here */ |
138 sstr_t test = ST("this,is,a,csv,string"); /* use copy of original here */ |
107 ssize_t n; |
139 ssize_t n; |