refactor: start using void* with trie

This commit is contained in:
Jef Roosens 2022-12-07 23:20:39 +01:00
parent 01eb5ece55
commit c99bc83015
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
8 changed files with 83 additions and 57 deletions

View file

@ -2,5 +2,10 @@ add_compile_options(-Wno-incompatible-pointer-types)
add_executable(test_trie test_trie.c ../src/trie.c)
add_test(NAME test_trie COMMAND test_trie)
add_executable(test_trie_fuzzy test_trie_fuzzy.c ../src/trie.c)
add_test(NAME test_trie_fuzzy COMMAND test_trie_fuzzy)
add_test(NAME test_leaks COMMAND valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes --leak-check=full ./test_trie)
add_test(NAME test_fuzzy_leaks COMMAND valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes --leak-check=full ./test_trie_fuzzy)

View file

@ -28,6 +28,8 @@ void test_add_one() {
TEST_CHECK(trie_search(ct, &entry2, string) == Ok);
TEST_CHECK(entry == entry2);
TEST_SIZE(ct, 1);
entry_free(entry);
trie_free(ct);
}
@ -52,6 +54,8 @@ void test_add_prefix() {
TEST_CHECK(trie_search(ct, &entry3, s2) == Ok);
TEST_CHECK(entry3 == entry2);
entry_free(entry1);
entry_free(entry2);
trie_free(ct);
}
@ -104,6 +108,7 @@ void test_add_more() {
TEST_CHECK(trie_add(ct, twenty, NULL) == AlreadyPresent);
TEST_CHECK(trie_add(ct, twentytwo, NULL) == AlreadyPresent);
entry_free(entry);
trie_free(ct);
}

View file

@ -10,7 +10,7 @@ void test_fuzzy() {
int counter = 0;
int res;
for (int len = 1; len < 25; len += 5) {
for (int len = 2; len < 25; len += 5) {
for (int count = 10; count <= 500; count += 10) {
for (int i = 0; i < 50; i++) {
counter++;