diff options
Diffstat (limited to 'src/test/check_splist.c')
-rw-r--r-- | src/test/check_splist.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/test/check_splist.c b/src/test/check_splist.c new file mode 100644 index 0000000..335b383 --- /dev/null +++ b/src/test/check_splist.c @@ -0,0 +1,62 @@ +#include "../splist.h" +#include <stdio.h> + +int +main(U_ATTR int argc, U_ATTR char **argv) +{ + splist *s = new_splist(); + + if (!s) { + eprintf("failed to create a splist!\n"); + exit(1); + } + + unsigned char result = 0; + + result = init_splist(s, 10); + + if (result) { + eprintf("failed to init splist\n"); + exit(1); + } + + if (add_to_splist(s, 2) || + add_to_splist(s, 4) || + add_to_splist(s, 8)) { + eprintf("failed to add to splist!\n"); + exit(1); + } + + print_splist(s); + + /* eprintf("Successfully printed splist\n"); */ + + if (splist_is_member(s, 8)) + eprintf("8 is indeed a member\n"); + else { + eprintf("8 should be a member!\n"); + exit(1); + } + + if (splist_is_member(s, 1)) { + eprintf("1 should not be a member\n"); + exit(1); + } else { + eprintf("1 indeed is not a member!\n"); + } + + reset_splist(s); + + if (splist_is_member(s, 8)) { + eprintf("8 should not be a member now!\n"); + exit(1); + } else { + eprintf("8 is indeed not anymore a member!\n"); + } + + destroy_splist(s); + + eprintf("Successfully destroyed splist\n"); + + return 0; +} |