Ejemplo n.º 1
0
static int test_clear(c_pmap thiz)
{
	c_iterator begin, end;
	c_reverse_iterator rbegin, rend;
	c_map_clear(thiz);
	begin = c_map_begin(thiz);
	end = c_map_end(thiz);
	rbegin = c_map_rbegin(thiz);
	rend = c_map_rend(thiz);
	
	if(c_map_size(thiz) == 0)
		printf("ok, size is 0\n");
	else
		printf("error, size is not 0\n");
	
	if(ITER_EQUAL(begin, end))
		printf("ok, begin == end\n");
	else
		printf("error, begin != end\n");
	
	if(ITER_EQUAL(rbegin, rend))
		printf("ok, rbegin == rend\n");
	else
		printf("error, rbegin != rend\n");
	return 0;
}
Ejemplo n.º 2
0
static int test_size_empty(c_pmap thiz)
{
	int i = 0;
	printf("max size is %d\n", c_map_max_size(thiz));
	printf("size is %d\n", c_map_size(thiz));
	printf("is empty? %s\n", c_map_empty(thiz) ? "yes" : "no");
	
	for(; i < sizeof(values) / sizeof(int); ++ i)
	{
		printf("now insert %d\n", i + 1);
		c_map_insert(thiz, &pairs[i]);
		printf("size is %d\n", c_map_size(thiz));
		printf("is empty? %s\n", c_map_empty(thiz) ? "yes" : "no");
	}
	printf("now clear\n");
	c_map_clear(thiz);
	printf("size is %d\n", c_map_size(thiz));
	printf("is empty? %s\n", c_map_empty(thiz) ? "yes" : "no");

	return 0;
}
Ejemplo n.º 3
0
static int __map_size(Map *map){
	return c_map_size(&map->values);
}