]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-52_1/main/tests/core/src/com/ibm/icu/dev/test/bidi/TestData.java
Upgrade ICU4J.
[Dictionary.git] / jars / icu4j-52_1 / main / tests / core / src / com / ibm / icu / dev / test / bidi / TestData.java
1 /*
2 *******************************************************************************
3 *   Copyright (C) 2001-2013, International Business Machines
4 *   Corporation and others.  All Rights Reserved.
5 *******************************************************************************
6 */
7
8 package com.ibm.icu.dev.test.bidi;
9
10 import com.ibm.icu.lang.UCharacterDirection;
11 import com.ibm.icu.text.Bidi;
12
13
14 /**
15  * Data and helper methods for Bidi regression tests
16  *
17  * Ported from C by Lina Kemmel, Matitiahu Allouche
18  *
19  */
20 public class TestData {
21     protected static final int L   = UCharacterDirection.LEFT_TO_RIGHT;
22     protected static final int R   = UCharacterDirection.RIGHT_TO_LEFT;
23     protected static final int EN  = UCharacterDirection.EUROPEAN_NUMBER;
24     protected static final int ES  = UCharacterDirection.EUROPEAN_NUMBER_SEPARATOR;
25     protected static final int ET  = UCharacterDirection.EUROPEAN_NUMBER_TERMINATOR;
26     protected static final int AN  = UCharacterDirection.ARABIC_NUMBER;
27     protected static final int CS  = UCharacterDirection.COMMON_NUMBER_SEPARATOR;
28     protected static final int B   = UCharacterDirection.BLOCK_SEPARATOR;
29     protected static final int S   = UCharacterDirection.SEGMENT_SEPARATOR;
30     protected static final int WS  = UCharacterDirection.WHITE_SPACE_NEUTRAL;
31     protected static final int ON  = UCharacterDirection.OTHER_NEUTRAL;
32     protected static final int LRE = UCharacterDirection.LEFT_TO_RIGHT_EMBEDDING;
33     protected static final int LRO = UCharacterDirection.LEFT_TO_RIGHT_OVERRIDE;
34     protected static final int AL  = UCharacterDirection.RIGHT_TO_LEFT_ARABIC;
35     protected static final int RLE = UCharacterDirection.RIGHT_TO_LEFT_EMBEDDING;
36     protected static final int RLO = UCharacterDirection.RIGHT_TO_LEFT_OVERRIDE;
37     protected static final int PDF = UCharacterDirection.POP_DIRECTIONAL_FORMAT;
38     protected static final int NSM = UCharacterDirection.DIR_NON_SPACING_MARK;
39     protected static final int BN  = UCharacterDirection.BOUNDARY_NEUTRAL;
40     protected static final int FSI = UCharacterDirection.FIRST_STRONG_ISOLATE;
41     protected static final int LRI = UCharacterDirection.LEFT_TO_RIGHT_ISOLATE;
42     protected static final int RLI = UCharacterDirection.RIGHT_TO_LEFT_ISOLATE;
43     protected static final int PDI = UCharacterDirection.POP_DIRECTIONAL_ISOLATE;
44     protected static final int DEF = Bidi.CLASS_DEFAULT;
45
46     protected static final String[] dirPropNames = {
47         "L", "R", "EN", "ES", "ET", "AN", "CS", "B", "S", "WS", "ON",
48         "LRE", "LRO", "AL", "RLE", "RLO", "PDF", "NSM", "BN",
49         "FSI", "LRI", "RLI", "PDI"  /* new in Unicode 6.3/ICU 52 */
50     };
51     protected static final short[][] testDirProps = {
52         { L, L, WS, L, WS, EN, L, B },                                          // 0
53         { R, AL, WS, R, AL, WS, R },                                            // 1
54         { L, L, WS, EN, CS, WS, EN, CS, EN, WS, L, L },                         // 2
55         { L, AL, AL, AL, L, AL, AL, L, WS, EN, CS, WS, EN, CS, EN, WS, L, L },  // 3
56         { AL, R, AL, WS, EN, CS, WS, EN, CS, EN, WS, R, R, WS, L, L },          // 4
57         { R, EN, NSM, ET },                                                     // 5
58         { RLE, WS, R, R, R, WS, PDF, WS, B },                                   // 6
59         {
60     LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,      /* 15 entries */
61     LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,      /* 15 entries */
62     AN, RLO, NSM, LRE, PDF, RLE, ES, EN, ON                                         /*  9 entries */
63         },                                                                      //7
64         {
65     LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,      /* 15 entries */
66     LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,      /* 15 entries */
67     LRE, BN, CS, RLO, S, PDF, EN, LRO, AN, ES                                       /* 10 entries */
68         },                                                                      // 8
69         { S, WS, NSM, RLE, WS, L, L, L, WS, LRO, WS, R, R, R, WS, RLO, WS, L, L,
70             L, WS, LRE, WS, R, R, R, WS, PDF, WS, L, L, L, WS, PDF, WS, AL, AL,
71             AL, WS, PDF, WS, L, L, L, WS, PDF, WS, L, L, L, WS, PDF, ON, PDF,
72             BN, BN, ON, PDF },                                                  // 9
73         { NSM, WS, L, L, L, L, L, L, L, WS, L, L, L, L, WS, R, R, R, R, R, WS,
74             L, L, L, L, L, L, L, WS, WS, AL, AL, AL, AL, WS, EN, EN, ES, EN,
75             EN, CS, S, EN, EN, CS, WS, EN, EN, WS, AL, AL, AL, AL, AL, B, L, L,
76             L, L, L, L, L, L, WS, AN, AN, CS, AN, AN, WS },                     // 10
77         { NSM, WS, L, L, L, L, L, L, L, WS, L, L, L, L, WS, R, R, R, R, R, WS,
78             L, L, L, L, L, L, L, WS, WS, AL, AL, AL, AL, WS, EN, EN, ES, EN,
79             EN, CS, S, EN, EN, CS, WS, EN, EN, WS, AL, AL, AL, AL, AL, B, L, L,
80             L, L, L, L, L, L, WS, AN, AN, CS, AN, AN, WS },                     // 11
81         { NSM, WS, L, L, L, L, L, L, L, WS, L, L, L, L, WS, R, R, R, R, R, WS,
82             L, L, L, L, L, L, L, WS, WS, AL, AL, AL, AL, WS, EN, EN, ES, EN,
83             EN, CS, S, EN, EN, CS, WS, EN, EN, WS, AL, AL, AL, AL, AL, B, L, L,
84             L, L, L, L, L, L, WS, AN, AN, CS, AN, AN, WS },                     // 12
85         { NSM, WS, L, L, L, L, L, L, L, WS, L, L, L, L, WS, R, R, R, R, R, WS,
86             L, L, L, L, L, L, L, WS, WS, AL, AL, AL, AL, WS, EN, EN, ES, EN,
87             EN, CS, S, EN, EN, CS, WS, EN, EN, WS, AL, AL, AL, AL, AL, B, L, L,
88             L, L, L, L, L, L, WS, AN, AN, CS, AN, AN, WS },                     // 13
89         { NSM, WS, L, L, L, L, L, L, L, WS, L, L, L, L, WS, R, R, R, R, R, WS,
90             L, L, L, L, L, L, L, WS, WS, AL, AL, AL, AL, WS, EN, EN, ES, EN,
91             EN, CS, S, EN, EN, CS, WS, EN, EN, WS, AL, AL, AL, AL, AL, B, L, L,
92             L, L, L, L, L, L, WS, AN, AN, CS, AN, AN, WS },                     // 14
93         { ON, L, RLO, CS, R, WS, AN, AN, PDF, LRE, R, L, LRO, WS, BN, ON, S,
94             LRE, LRO, B },                                                      // 15
95         { ON, L, RLO, CS, R, WS, AN, AN, PDF, LRE, R, L, LRO, WS, BN, ON, S,
96             LRE, LRO, B },                                                      // 16
97         { RLO, RLO, AL, AL, WS, EN, ES, ON, WS, S, S, PDF, LRO, WS, AL, ET, RLE,
98             ON, EN, B },                                                        // 17
99         { R, L, CS, L },                                                        // 18
100         { L, L, L, WS, L, L, L, WS, L, L, L },                                  // 19
101         { R, R, R, WS, R, R, R, WS, R, R, R },                                  // 20
102         { L },                                                                  // 21
103         null                                                                    // 22
104     };
105
106     protected static final byte[][] testLevels = {
107         { 0, 0, 0, 0, 0, 0, 0, 0 },                                             // 0
108         { 1, 1, 1, 1, 1, 1, 1 },                                                // 1
109         { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },                                 // 2
110         { 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },               // 3
111         { 1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 2, 2 },                     // 4
112         { 1, 2, 2, 2 },                                                         // 5
113         { 1, 1, 1, 1, 1, 1, 1, 1, 1 },                                          // 6
114         {
115     126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126,      /* 15 entries */
116     126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126,      /* 15 entries */
117     126, 125, 125, 125, 125, 125, 125, 125, 125                                     /*  9 entries */
118         },                                                                      // 7
119         {
120     124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,      /* 15 entries */
121     124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,      /* 15 entries */
122     124, 124, 124, 64, 64, 124, 124, 126, 126, 124                                  /* 10 entries */
123         },                                                                      // 8
124         { 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4,
125             5, 5, 5, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0,
126             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },                               // 9
127         { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0,
128             0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 0, 2, 2, 1, 1,
129             2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2,
130             0 },                                                                // 10
131         { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0,
132             0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 0, 2, 2, 1, 1,
133             2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2,
134             0 },                                                                // 11
135         { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2,
136             2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 3, 4, 4, 3, 2, 4, 4, 3, 3,
137             4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4,
138             2 },                                                                // 12
139         { 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 6, 6,
140             6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 6, 6, 5, 6, 6, 5, 5, 6, 6, 5, 5,
141             6, 6, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6,
142             5 },                                                                // 13
143         { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0,
144             0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 0, 2, 2, 1, 1,
145             2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2,
146             0 },                                                                // 14
147         { 0, 0, 1, 1, 1, 1, 1, 1, 3, 3, 3, 2, 4, 4, 4, 4, 0, 0, 0, 0 },         // 15
148         { 0, 0, 1, 1, 1, 0 },                                                   // 16
149         { 1 },                                                                  // 17
150         { 2 },                                                                  // 18
151         { 2, 2, 2, 2, 2, 2, 2, 1 },                                             // 19
152         { 1, 1, 1, 1, 1, 1, 1, 0 },                                             // 20
153         { 2 },                                                                  // 21
154         null                                                                    // 22
155     };
156
157     protected static final int[][] testVisualMaps = {
158         { 0, 1, 2, 3, 4, 5, 6, 7 },                                             // 0
159         { 6, 5, 4, 3, 2, 1, 0 },                                                // 1
160         { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 },                               // 2
161         { 0, 3, 2, 1, 4, 6, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 },       // 3
162         { 15, 14, 13, 12, 11, 10, 9, 6, 7, 8, 5, 4, 3, 2, 0, 1 },               // 4
163         { 3, 0, 1, 2 },                                                         // 5
164         { 8, 7, 6, 5, 4, 3, 2, 1, 0 },                                          // 6
165         {
166     8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,                       /* 15 entries */
167     23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,                     /* 15 entries */
168     38, 7, 6, 5, 4, 3, 2, 1, 0                                                      /*  9 entries */
169         },                                                                      // 7
170         { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
171             20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
172             37, 38, 39 },                                                       // 8
173         { 0, 1, 2, 44, 43, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 31, 30, 29, 28, 27,
174             26, 20, 21, 24, 23, 22, 25, 19, 18, 17, 16, 15, 14, 32, 33, 34, 35,
175             36, 37, 38, 39, 40, 41, 42, 3, 45, 46, 47, 48, 49, 50, 51, 52, 53,
176             54, 55, 56, 57 },                                                   // 9
177         { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 18, 17, 16, 15,
178             20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40, 39, 38, 37, 36, 34, 35,
179             33, 31, 32, 30, 41, 52, 53, 51, 50, 48, 49, 47, 46, 45, 44, 43, 42,
180             54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69 },   // 10
181         { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 18, 17, 16, 15,
182             20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40, 39, 38, 37, 36, 34, 35,
183             33, 31, 32, 30, 41, 52, 53, 51, 50, 48, 49, 47, 46, 45, 44, 43, 42,
184             54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69 },   // 11
185         { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 18, 17, 16, 15,
186             20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40, 39, 38, 37, 36, 34, 35,
187             33, 31, 32, 30, 41, 52, 53, 51, 50, 48, 49, 47, 46, 45, 44, 43, 42,
188             54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69 },   // 12
189         { 69, 68, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 55, 54, 53,
190             52, 51, 50, 49, 42, 43, 44, 45, 46, 47, 48, 41, 40, 39, 38, 37, 36,
191             35, 33, 34, 32, 30, 31, 29, 28, 26, 27, 25, 24, 22, 23, 21, 20, 19,
192             18, 17, 16, 15, 7, 8, 9, 10, 11, 12, 13, 14, 6, 1, 2, 3, 4, 5, 0 }, // 13
193         { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 18, 17, 16, 15,
194             20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40, 39, 38, 37, 36, 34, 35,
195             33, 31, 32, 30, 41, 52, 53, 51, 50, 48, 49, 47, 46, 45, 44, 43, 42,
196             54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69 },   // 14
197         { 0, 1, 15, 14, 13, 12, 11, 10, 4, 3, 2, 5, 6, 7, 8, 9, 16, 17, 18, 19 }, // 15
198         { 0, 1, 4, 3, 2, 5 },                                                   // 16
199         { 0 },                                                                  // 17
200         { 0 },                                                                  // 18
201         { 1, 2, 3, 4, 5, 6, 7, 0 },                                             // 19
202         { 6, 5, 4, 3, 2, 1, 0, 7 },                                             // 20
203         { 0 },                                                                  // 21
204         null                                                                    // 22
205     };
206
207     protected static final byte[] testParaLevels = {
208         Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR,
209         Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR,
210         Bidi.LEVEL_DEFAULT_LTR, 64,                     64,
211         Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_RTL,
212         2, 5, Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR,
213         Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR, Bidi.RTL, Bidi.LTR, Bidi.RTL,
214         Bidi.LEVEL_DEFAULT_LTR
215     };
216
217     protected static final byte[] testDirections = {
218         Bidi.LTR, Bidi.RTL, Bidi.LTR, Bidi.MIXED, Bidi.MIXED, Bidi.MIXED,
219         Bidi.RTL, Bidi.MIXED, Bidi.MIXED, Bidi.MIXED, Bidi.MIXED, Bidi.MIXED,
220         Bidi.MIXED, Bidi.MIXED, Bidi.MIXED, Bidi.MIXED, Bidi.MIXED, Bidi.RTL,
221         Bidi.LTR, Bidi.MIXED, Bidi.MIXED, Bidi.MIXED, Bidi.LTR
222     };
223
224     protected static final byte[] testResultLevels = new byte[] {
225         Bidi.LTR, Bidi.RTL, Bidi.LTR, Bidi.LTR, Bidi.RTL, Bidi.RTL, Bidi.RTL,
226         64,       64      , Bidi.LTR, Bidi.LTR, Bidi.LTR, 2, 5, Bidi.LTR,
227         Bidi.LTR, Bidi.LTR, Bidi.RTL, 2, Bidi.RTL, Bidi.LTR, Bidi.RTL, Bidi.LTR
228     };
229
230     protected static final byte[] testLineStarts = {
231         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 13,
232         2, 0, 0, -1, -1
233     };
234
235     protected static final byte[] testLineLimits = {
236         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6, 14,
237         3, 8, 8, -1, -1
238     };
239
240     protected short[] dirProps;
241     protected int lineStart;
242     protected int lineLimit;
243     protected byte direction;
244     protected byte paraLevel;
245     protected byte resultLevel;
246     protected byte[] levels;
247     protected int[] visualMap;
248
249     private TestData(short[] dirProps, int lineStart, int lineLimit,
250             byte direction, byte paraLevel, byte resultLevel, byte[] levels,
251             int[] visualMap) {
252         this.dirProps = dirProps;
253         this.lineStart = lineStart;
254         this.lineLimit = lineLimit;
255         this.direction = direction;
256         this.paraLevel = paraLevel;
257         this.resultLevel = resultLevel;
258         this.levels = levels;
259         this.visualMap = visualMap;
260     }
261
262     protected static TestData getTestData(int testNumber) {
263         return new TestData(testDirProps[testNumber],
264                 testLineStarts[testNumber], testLineLimits[testNumber],
265                 testDirections[testNumber], testParaLevels[testNumber],
266                 testResultLevels[testNumber], testLevels[testNumber],
267                 testVisualMaps[testNumber]);
268     }
269
270     protected static int testCount() {
271         return testDirProps.length;
272     }
273 }