This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21 #include "unistr.h"
22
23 #include "macros.h"
24
25 int
26 main ()
27 {
28 ucs4_t uc;
29 int ret;
30
31
32 {
33 static const uint8_t input[] = "";
34 uc = 0xBADFACE;
35 ret = u8_mbtoucr (&uc, input, 1);
36 ASSERT (ret == 1);
37 ASSERT (uc == 0);
38 }
39
40
41 {
42 ucs4_t c;
43 uint8_t buf[1];
44
45 for (c = 0; c < 0x80; c++)
46 {
47 buf[0] = c;
48 uc = 0xBADFACE;
49 ret = u8_mbtoucr (&uc, buf, 1);
50 ASSERT (ret == 1);
51 ASSERT (uc == c);
52 }
53 }
54
55
56 {
57 static const uint8_t input[] = { 0xC3, 0x97 };
58 uc = 0xBADFACE;
59 ret = u8_mbtoucr (&uc, input, 2);
60 ASSERT (ret == 2);
61 ASSERT (uc == 0x00D7);
62 }
63
64
65 {
66 static const uint8_t input[] = { 0xE2, 0x82, 0xAC };
67 uc = 0xBADFACE;
68 ret = u8_mbtoucr (&uc, input, 3);
69 ASSERT (ret == 3);
70 ASSERT (uc == 0x20AC);
71 }
72
73
74 {
75 static const uint8_t input[] = { 0xF4, 0x8F, 0xBF, 0xBD };
76 uc = 0xBADFACE;
77 ret = u8_mbtoucr (&uc, input, 4);
78 ASSERT (ret == 4);
79 ASSERT (uc == 0x10FFFD);
80 }
81
82
83 {
84 static const uint8_t input[] = { 0xC1 };
85 uc = 0xBADFACE;
86 ret = u8_mbtoucr (&uc, input, 1);
87 ASSERT (ret == -1);
88 ASSERT (uc == 0xFFFD);
89 }
90 {
91 static const uint8_t input[] = { 0xC3 };
92 uc = 0xBADFACE;
93 ret = u8_mbtoucr (&uc, input, 1);
94 ASSERT (ret == -2);
95 ASSERT (uc == 0xFFFD);
96 }
97 {
98 static const uint8_t input[] = { 0xE2 };
99 uc = 0xBADFACE;
100 ret = u8_mbtoucr (&uc, input, 1);
101 ASSERT (ret == -2);
102 ASSERT (uc == 0xFFFD);
103 }
104 {
105 static const uint8_t input[] = { 0xF4 };
106 uc = 0xBADFACE;
107 ret = u8_mbtoucr (&uc, input, 1);
108 ASSERT (ret == -2);
109 ASSERT (uc == 0xFFFD);
110 }
111 {
112 static const uint8_t input[] = { 0xFE };
113 uc = 0xBADFACE;
114 ret = u8_mbtoucr (&uc, input, 1);
115 ASSERT (ret == -1);
116 ASSERT (uc == 0xFFFD);
117 }
118
119
120 {
121 static const uint8_t input[] = { 0xE0, 0x9F };
122 uc = 0xBADFACE;
123 ret = u8_mbtoucr (&uc, input, 2);
124 ASSERT (ret == -1);
125 ASSERT (uc == 0xFFFD);
126 }
127 {
128 static const uint8_t input[] = { 0xE2, 0x82 };
129 uc = 0xBADFACE;
130 ret = u8_mbtoucr (&uc, input, 2);
131 ASSERT (ret == -2);
132 ASSERT (uc == 0xFFFD);
133 }
134 {
135 static const uint8_t input[] = { 0xE2, 0xD0 };
136 uc = 0xBADFACE;
137 ret = u8_mbtoucr (&uc, input, 2);
138 ASSERT (ret == -1);
139 ASSERT (uc == 0xFFFD);
140 }
141 {
142 static const uint8_t input[] = { 0xF0, 0x8F };
143 uc = 0xBADFACE;
144 ret = u8_mbtoucr (&uc, input, 2);
145 ASSERT (ret == -1);
146 ASSERT (uc == 0xFFFD);
147 }
148 {
149 static const uint8_t input[] = { 0xF3, 0x8F };
150 uc = 0xBADFACE;
151 ret = u8_mbtoucr (&uc, input, 2);
152 ASSERT (ret == -2);
153 ASSERT (uc == 0xFFFD);
154 }
155 {
156 static const uint8_t input[] = { 0xF3, 0xD0 };
157 uc = 0xBADFACE;
158 ret = u8_mbtoucr (&uc, input, 2);
159 ASSERT (ret == -1);
160 ASSERT (uc == 0xFFFD);
161 }
162
163
164 {
165 static const uint8_t input[] = { 0xF3, 0x8F, 0xBF };
166 uc = 0xBADFACE;
167 ret = u8_mbtoucr (&uc, input, 3);
168 ASSERT (ret == -2);
169 ASSERT (uc == 0xFFFD);
170 }
171 {
172 static const uint8_t input[] = { 0xF3, 0xD0, 0xBF };
173 uc = 0xBADFACE;
174 ret = u8_mbtoucr (&uc, input, 3);
175 ASSERT (ret == -1);
176 ASSERT (uc == 0xFFFD);
177 }
178 {
179 static const uint8_t input[] = { 0xF3, 0x8F, 0xD0 };
180 uc = 0xBADFACE;
181 ret = u8_mbtoucr (&uc, input, 3);
182 ASSERT (ret == -1);
183 ASSERT (uc == 0xFFFD);
184 }
185
186 return 0;
187 }