aboutsummaryrefslogtreecommitdiffstats
path: root/libfonts_parse_aa__.c
blob: 8394a56ead85cbe7c4f90a59d7e37aea133e824a (plain) (blame)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifndef TEST


int
libfonts_parse_aa__(enum libfonts_antialiasing *outp, const char *value)
{
#define X(C, S)\
	if (!strcasecmp(value, S)) {\
		*outp = C;\
	} else
	LIST_ANTIALIASINGS(X,) {
		return 0;
	}
#undef X
	return 1;

}


#else


int
main(void)
{
	enum libfonts_antialiasing res;
	char buf[1024];
	size_t i;

#define X(C, S)\
		do {\
			res = 999;\
			ASSERT(libfonts_parse_aa__(&res, S) == 1);\
			ASSERT(res == C);\
			strcpy(buf, S);\
			for (i = 0; buf[i]; i++)\
				buf[i] = (char)toupper(buf[i]);\
			res = 999;\
			ASSERT(libfonts_parse_aa__(&res, buf) == 1);\
			ASSERT(res == C);\
		} while (0)
	LIST_ANTIALIASINGS(X, ;);
#undef X

	res = 999;
	ASSERT(libfonts_parse_aa__(&res, " something else ") == 0);
	ASSERT(res == 999);

	return 0;
}


#endif