58 for(i = 0; i <
sizeof(array)/
sizeof(*array); i++)
62 va_start(arg, array_size);
63 for(i = 0; i <
sizeof(array)/
sizeof(*array); i++) {
64 const char *expected_result;
66 expected_result = va_arg(arg,
const char *);
67 if (expected_result == NULL)
71 FAIL(
"internal error: too many arguments passed to check_split_string()");
73 FAIL_IF(strcmp(array[i], expected_result) != 0,
"strcmp(array[%zu] == %s, %s) != 0", i, array[i], expected_result);
75 FAIL_IF(array[i] != NULL,
"array[%zu] == NULL", i);
106 snprintf(
init,
sizeof(
init),
"first test");
107 replace(
init,
"first",
"other", replaced,
sizeof(replaced));
108 FAIL_IF(strcmp(replaced,
"other test") != 0,
"%s != other test", replaced);
110 snprintf(
init,
sizeof(
init),
"second test");
111 replace(
init,
"e",
"a", replaced,
sizeof(replaced));
112 FAIL_IF(strcmp(replaced,
"sacond tast") != 0,
"%s != sacond tast", replaced);
115 snprintf(
init,
sizeof(
init),
"long test");
117 FAIL_IF(strcmp(replaced,
"really lo") != 0,
"%s != really lo", replaced);
122 Suite *s = suite_create(
"utils");
123 TCase *tc_core = tcase_create(
"Core");
128 suite_add_tcase(s, tc_core);
129 tcase_add_test(tc_core, test_split_string);
130 tcase_add_test(tc_core, test_replace);
138 SRunner *sr = srunner_create(s);
140 srunner_set_fork_status(sr, CK_NOFORK);
141 srunner_set_xml(sr, LOGDIR
"/unit/common/utils.xml");
142 srunner_set_log(sr, LOGDIR
"/unit/common/utils.out");
143 srunner_run_all(sr, CK_ENV);
144 nf = srunner_ntests_failed(sr);
146 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;