2022-11-29 16:25:24 +01:00
|
|
|
#include "test.h"
|
|
|
|
#include "trie.h"
|
|
|
|
#include "fuzzy.h"
|
|
|
|
|
|
|
|
void test_fuzzy() {
|
|
|
|
// Randomize seed
|
|
|
|
srand(time(NULL));
|
|
|
|
|
|
|
|
FuzzyConfig config;
|
|
|
|
int counter = 0;
|
|
|
|
int res;
|
|
|
|
|
|
|
|
for (int len = 1; len < 25; len += 5) {
|
|
|
|
for (int count = 10; count <= 500; count += 10) {
|
|
|
|
for (int i = 0; i < 50; i++) {
|
|
|
|
counter++;
|
|
|
|
|
|
|
|
config.seed = rand();
|
|
|
|
config.word_length = len;
|
|
|
|
config.word_count = count;
|
|
|
|
|
|
|
|
res = fuzzy_test_trie_seed(config, trie_init,
|
|
|
|
trie_free, trie_add,
|
2022-11-29 17:37:22 +01:00
|
|
|
NULL, trie_size);
|
2022-11-29 16:25:24 +01:00
|
|
|
TEST_CHECK_(res == 0,
|
|
|
|
"Failed config, seed = %i, len = %i, count = %i, code = %i", config.seed, config.word_length, config.word_count, res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TEST_MSG("fuzzy tests done = %i", counter);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_LIST = {
|
|
|
|
{ "customtrie fuzzy", test_fuzzy },
|
|
|
|
{ NULL, NULL}
|
|
|
|
};
|