summaryrefslogtreecommitdiff
path: root/eglib/test/unicode.c
blob: c1c3402ba8ecc219b65e0829eb4a8f6cbb9b5893 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "test.h"

/*
 * g_unichar_type
 */
RESULT
test_g_unichar_type ()
{
	if (g_unichar_type ('A') != G_UNICODE_UPPERCASE_LETTER)
		return FAILED ("#1");
	if (g_unichar_type ('a') != G_UNICODE_LOWERCASE_LETTER)
		return FAILED ("#2");
	if (g_unichar_type ('1') != G_UNICODE_DECIMAL_NUMBER)
		return FAILED ("#3");
	if (g_unichar_type (0xA3) != G_UNICODE_CURRENCY_SYMBOL)
		return FAILED ("#4");
	return NULL;
}

/*
 * g_unichar_toupper
 */
RESULT
test_g_unichar_toupper ()
{
	if (g_unichar_toupper (0) != 0)
		return FAILED ("#0");
	if (g_unichar_toupper ('a') != 'A')
		return FAILED ("#1");
	if (g_unichar_toupper ('1') != '1')
		return FAILED ("#2");
	if (g_unichar_toupper (0x1C4) != 0x1C4)
		return FAILED ("#3");
	if (g_unichar_toupper (0x1F2) != 0x1F1)
		return FAILED ("#4");
	if (g_unichar_toupper (0x1F3) != 0x1F1)
		return FAILED ("#5");
	if (g_unichar_toupper (0xFFFF) != 0xFFFF)
		return FAILED ("#6");
	if (g_unichar_toupper (0x10428) != 0x10400)
		return FAILED ("#7");
	return NULL;
}

/*
 * g_unichar_tolower
 */
RESULT
test_g_unichar_tolower ()
{
	if (g_unichar_tolower (0) != 0)
		return FAILED ("#0");
	if (g_unichar_tolower ('A') != 'a')
		return FAILED ("#1");
	if (g_unichar_tolower ('1') != '1')
		return FAILED ("#2");
	if (g_unichar_tolower (0x1C5) != 0x1C6)
		return FAILED ("#3");
	if (g_unichar_tolower (0x1F1) != 0x1F3)
		return FAILED ("#4");
	if (g_unichar_tolower (0x1F2) != 0x1F3)
		return FAILED ("#5");
	if (g_unichar_tolower (0xFFFF) != 0xFFFF)
		return FAILED ("#6");
	return NULL;
}

/*
 * g_unichar_totitle
 */
RESULT
test_g_unichar_totitle ()
{
	if (g_unichar_toupper (0) != 0)
		return FAILED ("#0");
	if (g_unichar_totitle ('a') != 'A')
		return FAILED ("#1");
	if (g_unichar_totitle ('1') != '1')
		return FAILED ("#2");
	if (g_unichar_totitle (0x1C4) != 0x1C5)
		return FAILED ("#3");
	if (g_unichar_totitle (0x1F2) != 0x1F2)
		return FAILED ("#4");
	if (g_unichar_totitle (0x1F3) != 0x1F2)
		return FAILED ("#5");
	if (g_unichar_toupper (0xFFFF) != 0xFFFF)
		return FAILED ("#6");
	return NULL;
}

static Test unicode_tests [] = {
	{"g_unichar_type", test_g_unichar_type},
	{"g_unichar_toupper", test_g_unichar_toupper},
	{"g_unichar_tolower", test_g_unichar_tolower},
	{"g_unichar_totitle", test_g_unichar_totitle},
	{NULL, NULL}
};

DEFINE_TEST_GROUP_INIT(unicode_tests_init, unicode_tests)