57 for(i = 0; i <
sizeof(array)/
sizeof(*array); i++)
60 fail_if(
result > array_size,
"result == %zu > %zu == array_size",
result, array_size);
61 va_start(arg, array_size);
62 for(i = 0; i <
sizeof(array)/
sizeof(*array); i++) {
63 const char *expected_result;
65 expected_result = va_arg(arg,
const char *);
66 if (expected_result == NULL)
70 fail(
"internal error: too many arguments passed to check_split_string()");
72 fail_if(strcmp(array[i], expected_result) != 0,
"strcmp(array[%zu] == %s, %s) != 0", i, array[i], expected_result);
74 fail_if(array[i] != NULL,
"array[%zu] == NULL", i);
105 snprintf(
init,
sizeof(
init),
"first test");
106 replace(
init,
"first",
"other", replaced,
sizeof(replaced));
107 fail_if(strcmp(replaced,
"other test") != 0,
"%s != other test", replaced);
109 snprintf(
init,
sizeof(
init),
"second test");
110 replace(
init,
"e",
"a", replaced,
sizeof(replaced));
111 fail_if(strcmp(replaced,
"sacond tast") != 0,
"%s != sacond tast", replaced);
114 snprintf(
init,
sizeof(
init),
"long test");
116 fail_if(strcmp(replaced,
"really lo") != 0,
"%s != really lo", replaced);
121 Suite *s = suite_create(
"utils");
122 TCase *tc_core = tcase_create(
"Core");
127 suite_add_tcase(s, tc_core);
128 tcase_add_test(tc_core, test_split_string);
129 tcase_add_test(tc_core, test_replace);
137 SRunner *sr = srunner_create(s);
139 srunner_set_fork_status(sr, CK_NOFORK);
140 srunner_set_xml(sr, LOGDIR
"/unit/common/utils.xml");
141 srunner_set_log(sr, LOGDIR
"/unit/common/utils.out");
142 srunner_run_all(sr, CK_ENV);
143 nf = srunner_ntests_failed(sr);
145 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;