feat(lsm): added trie search
This commit is contained in:
parent
622d644f25
commit
87000e8f73
5 changed files with 124 additions and 6 deletions
|
|
@ -99,11 +99,11 @@ void test_remove_multiple() {
|
|||
}
|
||||
|
||||
TEST_LIST = {
|
||||
{ "test init", test_init },
|
||||
{ "test insert first", test_insert_first },
|
||||
{ "test insert two", test_insert_two },
|
||||
{ "test insert multiple", test_insert_multiple },
|
||||
{ "test remove root", test_remove_root },
|
||||
{ "test remove multiple", test_remove_multiple },
|
||||
{ "bt init", test_init },
|
||||
{ "bt insert first", test_insert_first },
|
||||
{ "bt insert two", test_insert_two },
|
||||
{ "bt insert multiple", test_insert_multiple },
|
||||
{ "bt remove root", test_remove_root },
|
||||
{ "bt remove multiple", test_remove_multiple },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
|
|
|||
32
lsm/test/trie/trie.c
Normal file
32
lsm/test/trie/trie.c
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#include "lsm.h"
|
||||
#include "test.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 }
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue