Check of count or size is 0 in heapsort
This commit is contained in:
+29
-1
@@ -81,16 +81,44 @@ START_TEST (test_heapsort_even)
|
||||
|
||||
uc_heapsort(unordered, ARRAY_SIZE(unordered), sizeof(struct Stuff),
|
||||
cmp_stuff, swap_stuff, NULL);
|
||||
print_stuff(unordered, ARRAY_SIZE(unordered));
|
||||
fail_if(memcmp(unordered, ordered, sizeof unordered) != 0);
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_heapsort_zero)
|
||||
struct Stuff unordered[] = {
|
||||
{"1", 1},
|
||||
{"7", 7},
|
||||
{"3", 3},
|
||||
{"4", 4},
|
||||
{"6", 6},
|
||||
{"2", 2},
|
||||
};
|
||||
|
||||
struct Stuff same[] = {
|
||||
{"1", 1},
|
||||
{"7", 7},
|
||||
{"3", 3},
|
||||
{"4", 4},
|
||||
{"6", 6},
|
||||
{"2", 2},
|
||||
};
|
||||
|
||||
uc_heapsort(unordered, 0, sizeof(struct Stuff),
|
||||
cmp_stuff, swap_stuff, NULL);
|
||||
fail_if(memcmp(unordered, same, sizeof unordered) != 0);
|
||||
|
||||
uc_heapsort(unordered, ARRAY_SIZE(unordered), 0,
|
||||
cmp_stuff, swap_stuff, NULL);
|
||||
fail_if(memcmp(unordered, same, sizeof unordered) != 0);
|
||||
END_TEST
|
||||
|
||||
Suite *heapsort_suite(void)
|
||||
{
|
||||
Suite *s = suite_create("heapsort");
|
||||
TCase *tc = tcase_create("heapsort tests");
|
||||
tcase_add_test(tc, test_heapsort_odd);
|
||||
tcase_add_test(tc, test_heapsort_even);
|
||||
tcase_add_test(tc, test_heapsort_zero);
|
||||
|
||||
suite_add_tcase(s, tc);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user