Blob Blame Raw

#include "private.h"

//#define HELI_DO_TESTS

#ifndef HELI_DO_TESTS
void heliDoTests() { }
#else


static void printStringset(HeliArray *a) {
	for(int i = 0; i < a->count; ++i)
		printf("  %s\n", (const char*)a->items[i].key);
}

static void testStringSet() {
	printf("-- testStringSet\n");
	
	static char *strings[] = {
		"hello",
		"apple",
		"orange",
		"pineapple",
		"potato",
		"carrot",
		"grape",
		"cucumber"
	};
	
	HeliArray a = {};
	for(int i = 0; i < (int)(sizeof(strings)/sizeof(*strings)); ++i)
		heliStringmapAdd(&a, strings[i], NULL, NULL);
	
	printf("  fill:\n");
	printStringset(&a);
	
	printf("\n -remove %s:\n", "hello");
	heliStringmapRemove(&a, "hello");
	printStringset(&a);

	printf("\n -remove %s:\n", "apple");
	heliStringmapRemove(&a, "apple");
	printStringset(&a);
	
	printf("\n -remove %s:\n", "potato");
	heliStringmapRemove(&a, "potato");
	printStringset(&a);
	
	heliArrayDestroy(&a);

	printf("-- end\n");
}

void heliDoTests() {
	printf("---- doTests\n");
	testStringSet();
	printf("---- end\n");
}

#endif