summaryrefslogtreecommitdiff
path: root/test/entities.c
blob: e99e6b07014529cf35dd6463e1d4b8eca8c7670f (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
32
33
34
35
36
37
38
39
40
41
42
#include "tokeniser/entities.h"

#include "testutils.h"

static void *myrealloc(void *ptr, size_t len, void *pw)
{
	UNUSED(pw);

	return realloc(ptr, len);
}

int main(int argc, char **argv)
{
	uint32_t result;
	void *context = NULL;

	UNUSED(argc);
	UNUSED(argv);

	assert(hubbub_entities_create(myrealloc, NULL) == HUBBUB_OK);

	assert(hubbub_entities_search_step('o', &result, &context) ==
			HUBBUB_NEEDDATA);

	assert(hubbub_entities_search_step('r', &result, &context) ==
			HUBBUB_OK);

	assert(hubbub_entities_search_step('d', &result, &context) ==
			HUBBUB_NEEDDATA);

	assert(hubbub_entities_search_step('f', &result, &context) ==
			HUBBUB_OK);

	assert(hubbub_entities_search_step('z', &result, &context) ==
			HUBBUB_INVALID);

	hubbub_entities_destroy(myrealloc, NULL);

	printf("PASS\n");

	return 0;
}