PageRenderTime 29ms CodeModel.GetById 18ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/src/test/list_model_default_test.c

http://ftk.googlecode.com/
C | 30 lines | 25 code | 5 blank | 0 comment | 8 complexity | 2b2b0b9846a257e0a627089139dacc48 MD5 | raw file
 1#include "ftk.h"
 2
 3int main(int argc, char* argv[])
 4{
 5	int i = 0;
 6	FtkListItemInfo info ={0};
 7	FtkListItemInfo* pinfo = NULL;
 8	ftk_set_allocator(ftk_allocator_default_create());
 9	FtkListModel* thiz = ftk_list_model_default_create(0);
10	
11	for(i = 0; i < 1000; i++)
12	{
13		info.text ="12346578";
14		info.state = i;
15		assert(ftk_list_model_get_total(thiz) == i);
16		assert(ftk_list_model_add(thiz, &info) == RET_OK);
17		assert(ftk_list_model_get_data(thiz, i, (void**)&pinfo) == RET_OK);
18		assert(pinfo->state == i);
19	}
20	
21	for(i = 0; i < 1000; i++)
22	{
23		assert(ftk_list_model_get_total(thiz) == 1000-i);
24		assert(ftk_list_model_remove(thiz, 0) == RET_OK);
25	}
26
27	ftk_list_model_destroy(thiz);
28
29	return 0;
30}