lander/lsm/test/trie/trie.c

33 lines
713 B
C

#include "test.h"
#include "lsm.h"
#include "lsm/trie_internal.h"
#define TRIE_INIT() \
lsm_trie *trie; \
TEST_CHECK(lsm_trie_init(&trie) == lsm_error_ok); \
TEST_CHECK(trie != NULL)
void test_init() {
TRIE_INIT();
/* lsm_trie_free(trie); */
}
void test_insert_one() {
TRIE_INIT();
lsm_str *s;
lsm_str_init_copy(&s, "hello");
TEST_CHECK(lsm_trie_insert(trie, s, (void *)1) == lsm_error_ok);
TEST_CHECK(lsm_trie_insert(trie, s, (void *)1) == lsm_error_already_present);
void *data;
TEST_CHECK(lsm_trie_search(&data, trie, s) == lsm_error_ok);
TEST_CHECK(data == (void *)1);
}
TEST_LIST = {
{ "trie init", test_init },
{ "trie insert one", test_insert_one },
{ NULL, NULL }
};