From 510b10b96b546fcc6c6b6be85050305ddd192a41 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Sat, 5 Feb 2022 17:30:11 +0800 Subject: replace some hash table usage by tuples Previously I used hash tables, which consume too much memory. Now the critical parts are replaced by a new hand-written library called "tuple.h". Now we can easily parse larger inputs. I haven't tested its limits, though. --- src/test/check_splist.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/test/check_splist.c (limited to 'src/test/check_splist.c') 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 + +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; +} -- cgit v1.2.3-18-g5258