3
#include "../src/slist.h"
5
START_TEST(test_slist_append)
8
char *testdata[] = { "foo", "bar", "baz" };
10
list = slist_append(list, (void *) testdata[0]);
11
fail_unless(list->data == testdata[0], "element's data attribute not correctly set");
12
fail_unless(list->next == NULL, "element's next attribute not set to NULL");
13
list = slist_append(list, (void *) testdata[1]);
14
fail_unless(list->data == testdata[0], "element's data attribute not correctly set");
15
fail_unless(list->next != NULL, "element's next attribute set to NULL");
16
fail_unless(list->next->data == testdata[1], "element's data attribute not correctly set");
17
fail_unless(list->next->next == NULL, "element's next attribute not set to NULL");
18
list = slist_append(list, (void *) testdata[2]);
19
fail_unless(list->data == testdata[0], "element's data attribute not correctly set");
20
fail_unless(list->next != NULL, "element's next attribute set to NULL");
21
fail_unless(list->next->data == testdata[1], "element's data attribute not correctly set");
22
fail_unless(list->next->next != NULL, "element's next attribute set to NULL");
23
fail_unless(list->next->next->data == testdata[2], "element's data attribute not correctly set");
24
fail_unless(list->next->next->next == NULL, "element's next attribute not set to NULL");
28
Suite *slist_suite(void)
30
Suite *s = suite_create("SList");
32
TCase *tc_slist = tcase_create("slist");
33
tcase_add_test(tc_slist, test_slist_append);
34
suite_add_tcase(s, tc_slist);
43
Suite *s = slist_suite();
44
SRunner *sr = srunner_create(s);
45
srunner_run_all(sr, CK_NORMAL);
46
number_failed = srunner_ntests_failed(sr);
48
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;