summaryrefslogtreecommitdiff
path: root/tests.c
blob: 43d3e50aa2e1de181b27fcc5fe19f4a8ac1f5f00 (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
27
28
29
30
31

static void allocr_test(void) {
	Allocator a;
	allocr_create(&a);
	for (int x = 1000; x <= 8000; x += 1000) {
		int nfoos = x;
		int *foos = allocr_malloc(&a, (size_t)nfoos * sizeof(int));

		for (int i = 0; i < nfoos; i++)
			foos[i] = i;
		for (int i = 0; i < nfoos; i++)
			assert(foos[i] == i);
		int nbars = x;
		int *bars = allocr_calloc(&a, (size_t)nbars, sizeof(int));
		for (int i = 0; i < nbars; i++)
			assert(bars[i] == 0);
		for (int i = 0; i < nbars; i++)
			bars[i] = i;
		for (int i = 0; i < nbars; i++)
			assert(bars[i] == i);
	}
	allocr_free_all(&a);
}

static void test_all(void) {
	allocr_test();
	arr_test();
	block_arr_test();
	idents_test();
	hash_table_test();
}