Improve coverage of the test suite

This commit is contained in:
Patrick Pelissier committed 2023-04-13 23:27:01 +02:00
1 parent b5df21f9c5
commit ad023bb09d
3 files changed
+49 -1

No files matched your search

+22
View File
@@ -374,6 +374,27 @@ static void test_io(void)
string_clear(str);
}
// Test of internal functions, used only for reaching 100% coverage
static void test_coverage(void)
{
int_pqueue_array_t a, b;
int_pqueue_array_init(a);
int_pqueue_array_init(b);
int_pqueue_array_push_back(a, 12);
int_pqueue_array_push_back(b, 12);
int_pqueue_array_push_back(b, 12);
int_pqueue_array_set(a,b);
int_pqueue_array_clear(a);
int_pqueue_array_clear(b);
int_pqueue_array_init(a);
int_pqueue_array_init(b);
int_pqueue_array_push_back(a, 12);
int_pqueue_array_set(a,b);
int_pqueue_array_clear(a);
int_pqueue_array_clear(b);
}
int main(void)
{
test1();
@@ -382,6 +403,7 @@ int main(void)
test_double();
test_it();
test_io();
test_coverage();
testobj_final_check();
exit(0);
}
+10
View File
@@ -276,6 +276,16 @@ static void test0(void)
string_replace_all(s1, s1, s2);
assert( string_equal_str_p(s1, "WORLD"));
string_set_str(s1, "HE");
string_set_str(s2, "SHE");
string_replace_all(s1, s1, s2);
assert( string_equal_str_p(s1, "SHE"));
string_set_str(s1, "SHE");
string_set_str(s2, "HE");
string_replace_all(s1, s1, s2);
assert( string_equal_str_p(s1, "HE"));
string_printf (s1, "");
assert (string_cmp_str (s1, "") == 0);
assert (string_size (s1) == 0);
+17 -1
View File
@@ -490,13 +490,29 @@ static void test_io(void)
assert(b);
assert(*sp == 0);
assert(tree_equal_p(t1, t2));
string_set_str(s, "[{1,[{0,[{1,[{3},{5,[{2}]},{4,[{9},{7,[{8}]},{0},{6}]}]}]}]}]");
for(size_t i = 0; i < string_size(s); i++) {
string_set_str(s, "[{1,[{0,[{1,[{3},{5,[{2}]},{4,[{9},{7,[{8}]},{0},{6}]}]}]}]}]");
string_replace_at(s, i, 1, "");
b = tree_parse_str(t2, string_get_cstr(s), &sp);
assert(!b);
f = m_core_fopen ("a-mtree.dat", "wt");
if (!f) abort();
fprintf(f, "%s", string_get_cstr(s));
fclose (f);
f = m_core_fopen ("a-mtree.dat", "rt");
if (!f) abort();
b = tree_in_str (t2, f);
assert(!b);
fclose(f);
}
}
f = m_core_fopen ("a-mtree.dat", "wt");
if (!f) abort();
tree_out_str(f, t1);
fclose (f);
f = m_core_fopen ("a-mtree.dat", "rt");
if (!f) abort();
b = tree_in_str (t2, f);