Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / icu / source / test / cintltst / cbididat.c
1 /********************************************************************
2  * COPYRIGHT:
3  * Copyright (c) 1997-2013, International Business Machines Corporation and
4  * others. All Rights Reserved.
5  ********************************************************************/
6 /*   file name:  cbididat.c
7 *   encoding:   US-ASCII
8 *   tab size:   8 (not used)
9 *   indentation:4
10 *
11 *   created on: 1999sep22
12 *   created by: Markus W. Scherer
13 */
14
15 #include "unicode/utypes.h"
16 #include "unicode/uchar.h"
17 #include "unicode/ubidi.h"
18 #include "cbiditst.h"
19
20 const char * const
21 dirPropNames[U_CHAR_DIRECTION_COUNT]={
22     "L", "R", "EN", "ES", "ET", "AN", "CS", "B", "S", "WS", "ON",
23     "LRE", "LRO", "AL", "RLE", "RLO", "PDF", "NSM", "BN",
24     "FSI", "LRI", "RLI", "PDI"  /* new in Unicode 6.3/ICU 52 */
25 };
26
27 UChar
28 charFromDirProp[U_CHAR_DIRECTION_COUNT]={
29  /* L     R      EN    ES    ET    AN     CS    B    S    WS    ON */
30     0x61, 0x5d0, 0x30, 0x2f, 0x25, 0x660, 0x2c, 0xa, 0x9, 0x20, 0x26,
31  /* LRE     LRO     AL     RLE     RLO     PDF     NSM    BN */
32     0x202a, 0x202d, 0x627, 0x202b, 0x202e, 0x202c, 0x308, 0x200c,
33  /* FSI     LRI     RLI     PDI */
34     0x2068, 0x2066, 0x2067, 0x2069  /* new in Unicode 6.3/ICU 52 */
35 };
36
37 static const uint8_t
38 testText1[]={
39     L, L, WS, L, WS, EN, L, B
40 };
41
42 static const UBiDiLevel
43 testLevels1[]={
44     0, 0, 0, 0, 0, 0, 0, 0
45 };
46
47 static const uint8_t
48 testVisualMap1[]={
49     0, 1, 2, 3, 4, 5, 6, 7
50 };
51
52 static const uint8_t
53 testText2[]={
54     R, AL, WS, R, AL, WS, R
55 };
56
57 static const UBiDiLevel
58 testLevels2[]={
59     1, 1, 1, 1, 1, 1, 1
60 };
61
62 static const uint8_t
63 testVisualMap2[]={
64     6, 5, 4, 3, 2, 1, 0
65 };
66
67 static const uint8_t
68 testText3[]={
69     L, L, WS, EN, CS, WS, EN, CS, EN, WS, L, L
70 };
71
72 static const UBiDiLevel
73 testLevels3[]={
74     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
75 };
76
77 static const uint8_t
78 testVisualMap3[]={
79     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
80 };
81
82 static const uint8_t
83 testText4[]={
84     L, AL, AL, AL, L, AL, AL, L, WS, EN, CS, WS, EN, CS, EN, WS, L, L
85 };
86
87 static const UBiDiLevel
88 testLevels4[]={
89     0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
90 };
91
92 static const uint8_t
93 testVisualMap4[]={
94     0, 3, 2, 1, 4, 6, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
95 };
96
97 static const uint8_t
98 testText5[]={
99     AL, R, AL, WS, EN, CS, WS, EN, CS, EN, WS, R, R, WS, L, L
100 };
101
102 static const UBiDiLevel
103 testLevels5[]={
104     1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 2, 2
105 };
106
107 static const uint8_t
108 testVisualMap5[]={
109     15, 14, 13, 12, 11, 10, 9, 6, 7, 8, 5, 4, 3, 2, 0, 1
110 };
111
112 static const uint8_t
113 testText6[]={
114     R, EN, NSM, ET
115 };
116
117 static const UBiDiLevel
118 testLevels6[]={
119     1, 2, 2, 2
120 };
121
122 static const uint8_t
123 testVisualMap6[]={
124     3, 0, 1, 2
125 };
126
127 #if 0
128 static const uint8_t
129 testText7[]={
130     /* empty */
131 };
132
133 static const UBiDiLevel
134 testLevels7[]={
135 };
136
137 static const uint8_t
138 testVisualMap7[]={
139 };
140
141 #endif
142
143 static const uint8_t
144 testText8[]={
145     RLE, WS, R, R, R, WS, PDF, WS, B
146 };
147
148 static const UBiDiLevel
149 testLevels8[]={
150     1, 1, 1, 1, 1, 1, 1, 1, 1
151 };
152
153 static const uint8_t
154 testVisualMap8[]={
155     8, 7, 6, 5, 4, 3, 2, 1, 0
156 };
157
158 static const uint8_t
159 testText9[]={
160     LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,      /* 15 entries */
161     LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,      /* 15 entries */
162     AN, RLO, NSM, LRE, PDF, RLE, ES, EN, ON                                         /*  9 entries */
163 };
164
165 static const UBiDiLevel
166 testLevels9[]={
167     126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126,      /* 15 entries */
168     126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126,      /* 15 entries */
169     126, 125, 125, 125, 125, 125, 125, 125, 125                                     /*  9 entries */
170 };
171
172 static const uint8_t
173 testVisualMap9[]={
174     8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,                       /* 15 entries */
175     23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,                     /* 15 entries */
176     38, 7, 6, 5, 4, 3, 2, 1, 0                                                      /*  9 entries */
177 };
178
179 static const uint8_t
180 testText10[]={
181     LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,      /* 15 entries */
182     LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,      /* 15 entries */
183     LRE, BN, CS, RLO, S, PDF, EN, LRO, AN, ES                                       /* 10 entries */
184 };
185
186 static const UBiDiLevel
187 testLevels10[]={
188     124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,      /* 15 entries */
189     124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,      /* 15 entries */
190     124, 124, 124, 64, 64, 124, 124, 126, 126, 124                                  /* 10 entries */
191 };
192
193 static const uint8_t
194 testVisualMap10[]={
195     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,                               /* 15 entries */
196     15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,                     /* 15 entries */
197     30, 31, 32, 33, 34, 35, 36, 37, 38, 39                                          /* 10 entries */
198 };
199
200 static const uint8_t
201 testText11[]={
202     S, WS, NSM, RLE, WS, L, L, L, WS, LRO, WS, R, R, R, WS, RLO, WS, L, L, L,       /* 20 entries */
203     WS, LRE, WS, R, R, R, WS, PDF, WS, L, L, L, WS, PDF, WS, AL, AL, AL, WS, PDF,   /* 20 entries */
204     WS, L, L, L, WS, PDF, WS, L, L, L, WS, PDF, ON, PDF, BN, BN, ON, PDF            /* 18 entries */
205 };
206
207 static const UBiDiLevel
208 testLevels11[]={
209     0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,                     /* 20 entries */
210     3, 4, 4, 5, 5, 5, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2,                     /* 20 entries */
211     2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0                            /* 18 entries */
212 };
213
214 static const uint8_t
215 testVisualMap11[]={
216     0, 1, 2, 44, 43, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 31, 30, 29, 28, 27,          /* 20 entries */
217     26, 20, 21, 24, 23, 22, 25, 19, 18, 17, 16, 15, 14, 32, 33, 34, 35, 36, 37, 38, /* 20 entries */
218     39, 40, 41, 42, 3, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57           /* 18 entries */
219 };
220
221 static const uint8_t
222 testText12[]={
223     NSM, WS, L, L, L, L, L, L, L, WS, L, L, L, L, WS,
224     R, R, R, R, R, WS, L, L, L, L, L, L, L, WS, WS, AL,
225     AL, AL, AL, WS, EN, EN, ES, EN, EN, CS, S, EN, EN, CS, WS,
226     EN, EN, WS, AL, AL, AL, AL, AL, B, L, L, L, L, L, L,
227     L, L, WS, AN, AN, CS, AN, AN, WS
228 };
229
230 static const UBiDiLevel
231 testLevels12[]={
232     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 0, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0
233 };
234
235 static const uint8_t
236 testVisualMap12[]={
237     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 18, 17, 16, 15, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40, 39, 38, 37, 36, 34, 35, 33, 31, 32, 30, 41, 52, 53, 51, 50, 48, 49, 47, 46, 45, 44, 43, 42, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69
238 };
239
240 static const UBiDiLevel
241 testLevels13[]={
242     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 0, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0
243 };
244
245 static const uint8_t
246 testVisualMap13[]={
247     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 18, 17, 16, 15, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40, 39, 38, 37, 36, 34, 35, 33, 31, 32, 30, 41, 52, 53, 51, 50, 48, 49, 47, 46, 45, 44, 43, 42, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69
248 };
249
250 static const UBiDiLevel
251 testLevels14[]={
252     2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 3, 4, 4, 3, 2, 4, 4, 3, 3, 4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 2
253 };
254
255 static const uint8_t
256 testVisualMap14[]={
257     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 18, 17, 16, 15, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40, 39, 38, 37, 36, 34, 35, 33, 31, 32, 30, 41, 52, 53, 51, 50, 48, 49, 47, 46, 45, 44, 43, 42, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69
258 };
259
260 static const UBiDiLevel
261 testLevels15[]={
262     5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 6, 6, 5, 6, 6, 5, 5, 6, 6, 5, 5, 6, 6, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 5
263 };
264
265 static const uint8_t
266 testVisualMap15[]={
267     69, 68, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 55, 54, 53, 52, 51, 50, 49, 42, 43, 44, 45, 46, 47, 48, 41, 40, 39, 38, 37, 36, 35, 33, 34, 32, 30, 31, 29, 28, 26, 27, 25, 24, 22, 23, 21, 20, 19, 18, 17, 16, 15, 7, 8, 9, 10, 11, 12, 13, 14, 6, 1, 2, 3, 4, 5, 0
268 };
269
270 static const UBiDiLevel
271 testLevels16[]={
272     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 0, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0
273 };
274
275 static const uint8_t
276 testVisualMap16[]={
277     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 18, 17, 16, 15, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40, 39, 38, 37, 36, 34, 35, 33, 31, 32, 30, 41, 52, 53, 51, 50, 48, 49, 47, 46, 45, 44, 43, 42, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69
278 };
279
280 static const uint8_t
281 testText13[]={
282     ON, L, RLO, CS, R, WS, AN, AN, PDF, LRE, R, L, LRO, WS, BN, ON, S, LRE, LRO, B
283 };
284
285 static const UBiDiLevel
286 testLevels17[]={
287     0, 0, 1, 1, 1, 1, 1, 1, 3, 3, 3, 2, 4, 4, 4, 4, 0, 0, 0, 0
288 };
289
290 static const uint8_t
291 testVisualMap17[]={
292     0, 1, 15, 14, 13, 12, 11, 10, 4, 3, 2, 5, 6, 7, 8, 9, 16, 17, 18, 19
293 };
294
295 static const UBiDiLevel
296 testLevels18[]={
297     0, 0, 1, 1, 1, 0
298 };
299
300 static const uint8_t
301 testVisualMap18[]={
302     0, 1, 4, 3, 2, 5
303 };
304
305 static const uint8_t
306 testText14[]={
307     RLO, RLO, AL, AL, WS, EN, ES, ON, WS, S, S, PDF, LRO, WS, AL, ET, RLE, ON, EN, B
308 };
309
310 static const UBiDiLevel
311 testLevels19[]={
312     1
313 };
314
315 static const uint8_t
316 testVisualMap19[]={
317     0
318 };
319
320 static const uint8_t
321 testText15[]={
322     R, L, CS, L
323 };
324
325 static const UBiDiLevel
326 testLevels20[]={
327     2
328 };
329
330 static const uint8_t
331 testText16[]={
332     L, L, L, WS, L, L, L, WS, L, L, L
333 };
334
335 static const UBiDiLevel
336 testLevels21[]={
337     2, 2, 2, 2, 2, 2, 2, 1
338 };
339
340 static const uint8_t
341 testVisualMap20[]={
342     1, 2, 3, 4, 5, 6, 7, 0
343 };
344
345 static const uint8_t
346 testText17[]={
347     R, R, R, WS, R, R, R, WS, R, R, R
348 };
349
350 static const UBiDiLevel
351 testLevels22[]={
352     1, 1, 1, 1, 1, 1, 1, 0
353 };
354
355 static const uint8_t
356 testVisualMap21[]={
357     6, 5, 4, 3, 2, 1, 0, 7
358 };
359
360 static const uint8_t
361 testTextXX[]={
362     L
363 };
364
365 static const UBiDiLevel
366 testLevelsXX[]={
367     2
368 };
369
370 static const uint8_t
371 testVisualMapXX[]={
372     0
373 };
374
375 const BiDiTestData
376 tests[]={
377     {testText1,  ARRAY_LENGTH(testText1),  UBIDI_DEFAULT_LTR, -1, -1,
378         UBIDI_LTR, 0,
379         testLevels1, testVisualMap1},
380     {testText2,  ARRAY_LENGTH(testText2),  UBIDI_DEFAULT_LTR, -1, -1,
381         UBIDI_RTL, 1,
382         testLevels2, testVisualMap2},
383     {testText3,  ARRAY_LENGTH(testText3),  UBIDI_DEFAULT_LTR, -1, -1,
384         UBIDI_LTR, 0,
385         testLevels3, testVisualMap3},
386     {testText4,  ARRAY_LENGTH(testText4),  UBIDI_DEFAULT_LTR, -1, -1,
387         UBIDI_MIXED, 0,
388         testLevels4, testVisualMap4},
389     {testText5,  ARRAY_LENGTH(testText5),  UBIDI_DEFAULT_LTR, -1, -1,
390         UBIDI_MIXED, 1,
391         testLevels5, testVisualMap5},
392     {testText6,  ARRAY_LENGTH(testText6),  UBIDI_DEFAULT_LTR, -1, -1,
393         UBIDI_MIXED, 1,
394         testLevels6, testVisualMap6},
395     {NULL,       0,                        UBIDI_DEFAULT_LTR, -1, -1,
396         UBIDI_LTR, 0,
397         NULL, NULL},
398     {testText8,  ARRAY_LENGTH(testText8),  UBIDI_DEFAULT_LTR, -1, -1,
399         UBIDI_RTL, 1,
400         testLevels8, testVisualMap8},
401     {testText9,  ARRAY_LENGTH(testText9),  64, -1, -1,
402         UBIDI_MIXED, 64,
403         testLevels9, testVisualMap9},
404     {testText10, ARRAY_LENGTH(testText10), 64, -1, -1,
405         UBIDI_MIXED, 64,
406         testLevels10, testVisualMap10},
407     {testText11, ARRAY_LENGTH(testText11), UBIDI_DEFAULT_LTR, -1, -1,
408         UBIDI_MIXED, 0,
409         testLevels11, testVisualMap11},
410     {testText12, ARRAY_LENGTH(testText12), UBIDI_DEFAULT_LTR, -1, -1,
411         UBIDI_MIXED, 0,
412         testLevels12, testVisualMap12},
413     {testText12, ARRAY_LENGTH(testText12), UBIDI_DEFAULT_RTL, -1, -1,
414         UBIDI_MIXED, 0,
415         testLevels13, testVisualMap13},
416     {testText12, ARRAY_LENGTH(testText12), 2, -1, -1,
417         UBIDI_MIXED, 2,
418         testLevels14, testVisualMap14},
419     {testText12, ARRAY_LENGTH(testText12), 5, -1, -1,
420         UBIDI_MIXED, 5,
421         testLevels15, testVisualMap15},
422     {testText12, ARRAY_LENGTH(testText12), UBIDI_DEFAULT_LTR, -1, -1,
423         UBIDI_MIXED, 0,
424         testLevels16, testVisualMap16},
425     {testText13, ARRAY_LENGTH(testText13), UBIDI_DEFAULT_LTR, -1, -1,
426         UBIDI_MIXED, 0,
427         testLevels17, testVisualMap17},
428     {testText13, ARRAY_LENGTH(testText13), UBIDI_DEFAULT_LTR, 0, 6,
429         UBIDI_MIXED, 0,
430         testLevels18, testVisualMap18},
431     {testText14, ARRAY_LENGTH(testText14), UBIDI_DEFAULT_LTR, 13, 14,
432         UBIDI_RTL, 1,
433         testLevels19, testVisualMap19},
434     {testText15, ARRAY_LENGTH(testText15), UBIDI_DEFAULT_LTR, 2, 3,
435         UBIDI_LTR, 2,
436         testLevels20, testVisualMap19},
437     {testText16, ARRAY_LENGTH(testText16), UBIDI_RTL, 0, 8,
438         UBIDI_MIXED, 1,
439         testLevels21, testVisualMap20},
440     {testText17, ARRAY_LENGTH(testText17), UBIDI_LTR, 0, 8,
441         UBIDI_MIXED, 0,
442         testLevels22, testVisualMap21},
443     {testTextXX, ARRAY_LENGTH(testTextXX), UBIDI_RTL, -1, -1,
444         UBIDI_MIXED, 1, testLevelsXX, testVisualMapXX}
445 };
446
447 const int
448 bidiTestCount=ARRAY_LENGTH(tests);