Test heapsorting 1 element

This commit is contained in:
Nils O. Selåsdal
2014-06-23 22:58:27 +02:00
parent 157dca7997
commit 6c8e403a38
+8 -4
View File
@@ -83,7 +83,7 @@ START_TEST (test_heapsort_even)
{"2", 2},
};
struct Stuff ordered[] = {
const struct Stuff ordered[] = {
{"1", 1},
{"2", 2},
{"3", 3},
@@ -97,7 +97,7 @@ START_TEST (test_heapsort_even)
fail_if(cmp_stuff_array(unordered, ordered, ARRAY_SIZE(unordered)) != 0);
END_TEST
START_TEST (test_heapsort_zero)
START_TEST (test_heapsort_zero_one)
struct Stuff unordered[] = {
{"1", 1},
{"7", 7},
@@ -107,7 +107,7 @@ START_TEST (test_heapsort_zero)
{"2", 2},
};
struct Stuff same[] = {
const struct Stuff same[] = {
{"1", 1},
{"7", 7},
{"3", 3},
@@ -123,6 +123,10 @@ START_TEST (test_heapsort_zero)
uc_heapsort(unordered, ARRAY_SIZE(unordered), 0,
cmp_stuff, swap_stuff, NULL);
fail_if(cmp_stuff_array(unordered, same, ARRAY_SIZE(unordered)) != 0);
uc_heapsort(unordered, 1, sizeof(struct Stuff),
cmp_stuff, swap_stuff, NULL);
fail_if(cmp_stuff_array(unordered, same, ARRAY_SIZE(unordered)) != 0);
END_TEST
Suite *heapsort_suite(void)
@@ -131,7 +135,7 @@ Suite *heapsort_suite(void)
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);
tcase_add_test(tc, test_heapsort_zero_one);
suite_add_tcase(s, tc);