summaryrefslogtreecommitdiff
path: root/tests/test_engine.c
blob: f772c36f4f82486777733a9f15476b69c1fd98c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdio.h>
#include <stdlib.h>

#include "../unity/unity.h"
#include "../src/include/engine/engine.h"

extern tablist_t *list;

void test_readdb(void) {
	tablist_t *db = readdb("dbs/test.xdb");
	TEST_ASSERT_NOT_NULL(db);
	delkeys(db, -1, NULL, 0);
	free(db);
}

void test_getkeys(void) {
	tablist_t *tmp = getkeys(list, -1, NULL, 0);
	TEST_ASSERT_NOT_NULL(tmp);
	for (int i = 0; i < tmp[0].len; ++i) {
		printf("id: %d\t", i);
		for (int j = 0; tmp[i].tab[j].flag; ++j)
			printf("%s\t", tmp[i].tab[j].key);
		printf("\n");
	}
	free(tmp);
}