tests/test_string.c

changeset 1003
455afb252878
parent 926
8fdd8d78c14b
equal deleted inserted replaced
1002:1483c47063a8 1003:455afb252878
314 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t6), CX_STR("Hello, World!"))); 314 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t6), CX_STR("Hello, World!")));
315 ASSERT_ZERO_TERMINATED(t6); 315 ASSERT_ZERO_TERMINATED(t6);
316 cx_strfree(&t6); 316 cx_strfree(&t6);
317 } 317 }
318 cx_testing_allocator_destroy(&talloc); 318 cx_testing_allocator_destroy(&talloc);
319 }
320
321 CX_TEST(test_strcat_more_than_eight) {
322 cxstring s1 = CX_STR("12");
323 cxstring s2 = CX_STR("34");
324 cxstring s3 = CX_STR("56");
325 cxstring s4 = CX_STR("78");
326 cxstring s5 = CX_STR("9a");
327 cxstring s6 = CX_STR("bc");
328 cxstring s7 = CX_STR("de");
329 cxstring s8 = CX_STR("f0");
330 cxstring s9 = CX_STR("xy");
331
332 CX_TEST_DO {
333 cxmutstr r = cx_strcat(9, s1, s2, s3, s4, s5, s6, s7, s8, s9);
334 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(r), CX_STR("123456789abcdef0xy")));
335 ASSERT_ZERO_TERMINATED(r);
336 cx_strfree(&r);
337 }
319 } 338 }
320 339
321 CX_TEST(test_strsplit) { 340 CX_TEST(test_strsplit) {
322 cxstring test = CX_STR("this,is,a,csv,string"); 341 cxstring test = CX_STR("this,is,a,csv,string");
323 size_t capa = 8; 342 size_t capa = 8;
965 cx_test_register(suite, test_strrchr); 984 cx_test_register(suite, test_strrchr);
966 cx_test_register(suite, test_strstr); 985 cx_test_register(suite, test_strstr);
967 cx_test_register(suite, test_strcmp); 986 cx_test_register(suite, test_strcmp);
968 cx_test_register(suite, test_strcasecmp); 987 cx_test_register(suite, test_strcasecmp);
969 cx_test_register(suite, test_strcat); 988 cx_test_register(suite, test_strcat);
989 cx_test_register(suite, test_strcat_more_than_eight);
970 cx_test_register(suite, test_strsplit); 990 cx_test_register(suite, test_strsplit);
971 cx_test_register(suite, test_strsplit_a); 991 cx_test_register(suite, test_strsplit_a);
972 cx_test_register(suite, test_strtrim); 992 cx_test_register(suite, test_strtrim);
973 cx_test_register(suite, test_strprefix); 993 cx_test_register(suite, test_strprefix);
974 cx_test_register(suite, test_strsuffix); 994 cx_test_register(suite, test_strsuffix);

mercurial