191 sstr_t t4 = sstrcat(2, sn, sn); |
191 sstr_t t4 = sstrcat(2, sn, sn); |
192 UCX_TEST_ASSERT(t4.ptr, "t4.ptr is NULL"); |
192 UCX_TEST_ASSERT(t4.ptr, "t4.ptr is NULL"); |
193 UCX_TEST_ASSERT(t4.length == 0, "t4 has wrong length"); |
193 UCX_TEST_ASSERT(t4.length == 0, "t4 has wrong length"); |
194 free(t4.ptr); |
194 free(t4.ptr); |
195 |
195 |
|
196 // overflow test |
|
197 sstr_t o0; |
|
198 o0.ptr = ""; |
|
199 o0.length = ((size_t)-1) - 50; |
|
200 sstr_t o1; |
|
201 o1.ptr = ""; |
|
202 o1.length = 100; |
|
203 sstr_t o2; |
|
204 o2.ptr = ""; |
|
205 o2.length = 10; |
|
206 |
|
207 sstr_t n = sstrcat(2, o0, o1); |
|
208 UCX_TEST_ASSERT(n.ptr == NULL && n.length == 0, "overflow not detected"); |
|
209 sstr_t n2 = sstrcat(3, o0, o2, o1); |
|
210 UCX_TEST_ASSERT(n2.ptr == NULL && n2.length == 0, "n2: overflow not detected"); |
196 |
211 |
197 UCX_TEST_END |
212 UCX_TEST_END |
198 |
213 |
199 } |
214 } |
200 |
215 |