65 FAIL_UNLESS(str1 != NULL,
"add_string should not return null when receiving content.");
66 temp =
static_cast<char *
>(malloc(strlen(str1)+1));
69 FAIL_UNLESS(str2 == str1,
"add_string should return same pointer for 2 same strings but str1 (%p -> '%s') != str2 (%p -> '%s').", str1, str1, str2, str2);
71 FAIL_UNLESS(str3 != NULL,
"add_string should handle gracefully empty non null strings.");
82 FAIL_UNLESS(str1 == str2,
"result of add_refcount (%p) should be the same as original pointer (%p).", str2, str1);
117 FAIL_UNLESS(
result == NULL,
"add_string + free_string should mean i can't find the string anymore but find string returned %p(%s)",
result,
result);
128 FAIL_UNLESS(str2 == NULL,
"find_String should return null after a free_string but it returned %p (%s)", str2, str2);
133 FAIL_UNLESS(str2 == str1,
"find_string should return the string(%p) after a add_string, add_string, free_string but returned %p", str1, str2);
136 FAIL_UNLESS(str2 == NULL,
"find_string should return null after add_string, add_string, free_string, free_string but returned %p", str2);
144 FAIL_UNLESS(i,
"'1' +'22' can't fit in a 3 char buffer but buf_overflow told us there won't be any overflow");
146 FAIL_UNLESS(i,
"'1' +NULL can't fit in a 1 char buffer but buf_overflow told us there won't be any overflow");
148 FAIL_UNLESS(!i,
"'1' +NULL can fit in a 2 char buffer but buf_overflow told us it won't");
150 FAIL_UNLESS(!i,
"EMPTY +NULL can fit in a 1 char buffer but buf_overflow told us it won't");
152 FAIL_UNLESS(i,
"EMPTY +NULL can't fit in a 0 char buffer but buf_overflow told us there won't be any overflow");
157 Suite *s = suite_create(
"shstr");
158 TCase *tc_core = tcase_create(
"Core");
163 suite_add_tcase(s, tc_core);
164 tcase_add_test(tc_core, test_add_string);
165 tcase_add_test(tc_core, test_add_refcount);
166 tcase_add_test(tc_core, test_query_refcount);
167 tcase_add_test(tc_core, test_find_string);
168 tcase_add_test(tc_core, test_free_string);
169 tcase_add_test(tc_core, test_buf_overflow);
177 SRunner *sr = srunner_create(s);
179 srunner_set_xml(sr, LOGDIR
"/unit/common/shstr.xml");
180 srunner_set_log(sr, LOGDIR
"/unit/common/shstr.out");
181 srunner_run_all(sr, CK_ENV);
182 nf = srunner_ntests_failed(sr);
184 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;