PageRenderTime 20ms CodeModel.GetById 14ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/pairs_test.c

http://ftk.googlecode.com/
C | 34 lines | 28 code | 6 blank | 0 comment | 6 complexity | 9cdd66d766b521dbecffd4447c2aaafc MD5 | raw file
 1#include "ftk.h"
 2#include "ftk_pairs.h"
 3
 4int main(int argc, char* argv[])
 5{
 6	int i = 0;
 7	int nr = 100;
 8	char key[FTK_KEY_LEN+1];
 9	char value[FTK_VALUE_LEN+1];
10	FtkPairs* thiz = NULL;
11	ftk_set_allocator(ftk_allocator_default_create());
12	
13	thiz = ftk_pairs_create(nr, (FtkCompare)strcmp);
14
15	for(i = 0; i < nr; i++)
16	{
17		snprintf(key, FTK_KEY_LEN, "key%d", i);
18		snprintf(value, FTK_VALUE_LEN, "value%d", i);
19		assert(ftk_pairs_set(thiz, key, value) == RET_OK);
20		assert(strcmp(ftk_pairs_find(thiz, key), value) == 0);
21	}
22	
23	ftk_pairs_dump(thiz);
24	for(i = 0; i < nr; i++)
25	{
26		snprintf(key, FTK_KEY_LEN, "key%d", i);
27		assert(ftk_pairs_remove(thiz, key) == RET_OK);
28		assert(ftk_pairs_find(thiz, key) == NULL);
29	}
30
31	ftk_pairs_destroy(thiz);
32
33	return 0;
34}