diff options
author | JSDurand <mmemmew@gmail.com> | 2022-02-05 17:30:11 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2022-02-05 17:30:11 +0800 |
commit | 510b10b96b546fcc6c6b6be85050305ddd192a41 (patch) | |
tree | 997d6c3f2c0a1ad6e27127d54a94655527e57864 /src/test/check_splist.c | |
parent | 3fb5430080199a6d92a63f8259fe4a88df9b83ba (diff) |
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.
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; +} |