~ubuntu-branches/ubuntu/vivid/icu4j-4.4/vivid

« back to all changes in this revision

Viewing changes to main/tests/core/src/com/ibm/icu/dev/test/bidi/TestData.java

  • Committer: Bazaar Package Importer
  • Author(s): Niels Thykier
  • Date: 2011-08-02 15:50:33 UTC
  • Revision ID: james.westby@ubuntu.com-20110802155033-itjzsl21y2lqdonn
Tags: upstream-4.4.2
ImportĀ upstreamĀ versionĀ 4.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
*******************************************************************************
 
3
*   Copyright (C) 2001-2007, 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 DEF = Bidi.CLASS_DEFAULT;
 
41
 
 
42
    protected static final String[] dirPropNames = {
 
43
        "L", "R", "EN", "ES", "ET", "AN", "CS", "B", "S", "WS", "ON",
 
44
        "LRE", "LRO", "AL", "RLE", "RLO", "PDF", "NSM", "BN"
 
45
    };
 
46
    protected static final short[][] testDirProps = {
 
47
        { L, L, WS, L, WS, EN, L, B },                                          // 0
 
48
        { R, AL, WS, R, AL, WS, R },                                            // 1
 
49
        { L, L, WS, EN, CS, WS, EN, CS, EN, WS, L, L },                         // 2
 
50
        { L, AL, AL, AL, L, AL, AL, L, WS, EN, CS, WS, EN, CS, EN, WS, L, L },  // 3
 
51
        { AL, R, AL, WS, EN, CS, WS, EN, CS, EN, WS, R, R, WS, L, L },          // 4
 
52
        { R, EN, NSM, ET },                                                     // 5
 
53
        { RLE, WS, R, R, R, WS, PDF, WS, B },                                   // 6
 
54
        { LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,
 
55
            LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,
 
56
            LRE, LRE, LRE, AN, RLO, NSM, LRE, PDF, RLE, ES, EN, ON },           // 7
 
57
        { LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,
 
58
            LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,
 
59
            LRE, LRE, LRE, LRE, BN, CS, RLO, S, PDF, EN, LRO, AN, ES },         // 8
 
60
        { S, WS, NSM, RLE, WS, L, L, L, WS, LRO, WS, R, R, R, WS, RLO, WS, L, L,
 
61
            L, WS, LRE, WS, R, R, R, WS, PDF, WS, L, L, L, WS, PDF, WS, AL, AL,
 
62
            AL, WS, PDF, WS, L, L, L, WS, PDF, WS, L, L, L, WS, PDF, ON, PDF,
 
63
            BN, BN, ON, PDF },                                                  // 9
 
64
        { NSM, WS, L, L, L, L, L, L, L, WS, L, L, L, L, WS, R, R, R, R, R, WS,
 
65
            L, L, L, L, L, L, L, WS, WS, AL, AL, AL, AL, WS, EN, EN, ES, EN,
 
66
            EN, CS, S, EN, EN, CS, WS, EN, EN, WS, AL, AL, AL, AL, AL, B, L, L,
 
67
            L, L, L, L, L, L, WS, AN, AN, CS, AN, AN, WS },                     // 10
 
68
        { NSM, WS, L, L, L, L, L, L, L, WS, L, L, L, L, WS, R, R, R, R, R, WS,
 
69
            L, L, L, L, L, L, L, WS, WS, AL, AL, AL, AL, WS, EN, EN, ES, EN,
 
70
            EN, CS, S, EN, EN, CS, WS, EN, EN, WS, AL, AL, AL, AL, AL, B, L, L,
 
71
            L, L, L, L, L, L, WS, AN, AN, CS, AN, AN, WS },                     // 11
 
72
        { NSM, WS, L, L, L, L, L, L, L, WS, L, L, L, L, WS, R, R, R, R, R, WS,
 
73
            L, L, L, L, L, L, L, WS, WS, AL, AL, AL, AL, WS, EN, EN, ES, EN,
 
74
            EN, CS, S, EN, EN, CS, WS, EN, EN, WS, AL, AL, AL, AL, AL, B, L, L,
 
75
            L, L, L, L, L, L, WS, AN, AN, CS, AN, AN, WS },                     // 12
 
76
        { NSM, WS, L, L, L, L, L, L, L, WS, L, L, L, L, WS, R, R, R, R, R, WS,
 
77
            L, L, L, L, L, L, L, WS, WS, AL, AL, AL, AL, WS, EN, EN, ES, EN,
 
78
            EN, CS, S, EN, EN, CS, WS, EN, EN, WS, AL, AL, AL, AL, AL, B, L, L,
 
79
            L, L, L, L, L, L, WS, AN, AN, CS, AN, AN, WS },                     // 13
 
80
        { NSM, WS, L, L, L, L, L, L, L, WS, L, L, L, L, WS, R, R, R, R, R, WS,
 
81
            L, L, L, L, L, L, L, WS, WS, AL, AL, AL, AL, WS, EN, EN, ES, EN,
 
82
            EN, CS, S, EN, EN, CS, WS, EN, EN, WS, AL, AL, AL, AL, AL, B, L, L,
 
83
            L, L, L, L, L, L, WS, AN, AN, CS, AN, AN, WS },                     // 14
 
84
        { ON, L, RLO, CS, R, WS, AN, AN, PDF, LRE, R, L, LRO, WS, BN, ON, S,
 
85
            LRE, LRO, B },                                                      // 15
 
86
        { ON, L, RLO, CS, R, WS, AN, AN, PDF, LRE, R, L, LRO, WS, BN, ON, S,
 
87
            LRE, LRO, B },                                                      // 16
 
88
        { RLO, RLO, AL, AL, WS, EN, ES, ON, WS, S, S, PDF, LRO, WS, AL, ET, RLE,
 
89
            ON, EN, B },                                                        // 17
 
90
        { R, L, CS, L },                                                        // 18
 
91
        { L, L, L, WS, L, L, L, WS, L, L, L },                                  // 19
 
92
        { R, R, R, WS, R, R, R, WS, R, R, R },                                  // 20
 
93
        { L },                                                                  // 21
 
94
        null                                                                    // 22
 
95
    };
 
96
 
 
97
    protected static final byte[][] testLevels = {
 
98
        { 0, 0, 0, 0, 0, 0, 0, 0 },                                             // 0
 
99
        { 1, 1, 1, 1, 1, 1, 1 },                                                // 1
 
100
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },                                 // 2
 
101
        { 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },               // 3
 
102
        { 1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 2, 2 },                     // 4
 
103
        { 1, 2, 2, 2 },                                                         // 5
 
104
        { 1, 1, 1, 1, 1, 1, 1, 1, 1 },                                          // 6
 
105
        { 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
 
106
            62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 61, 61,
 
107
            61, 61, 61, 61, 61, 61 },                                           // 7
 
108
        { 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
 
109
            60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 0,
 
110
            0, 62, 62, 62, 62, 60 },                                            // 8
 
111
        { 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4,
 
112
            5, 5, 5, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0,
 
113
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },                               // 9
 
114
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0,
 
115
            0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 0, 2, 2, 1, 1,
 
116
            2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2,
 
117
            0 },                                                                // 10
 
118
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0,
 
119
            0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 0, 2, 2, 1, 1,
 
120
            2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2,
 
121
            0 },                                                                // 11
 
122
        { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2,
 
123
            2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 3, 4, 4, 3, 2, 4, 4, 3, 3,
 
124
            4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4,
 
125
            2 },                                                                // 12
 
126
        { 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 6, 6,
 
127
            6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 6, 6, 5, 6, 6, 5, 5, 6, 6, 5, 5,
 
128
            6, 6, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6,
 
129
            5 },                                                                // 13
 
130
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0,
 
131
            0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 0, 2, 2, 1, 1,
 
132
            2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2,
 
133
            0 },                                                                // 14
 
134
        { 0, 0, 1, 1, 1, 1, 1, 1, 3, 3, 3, 2, 4, 4, 4, 4, 0, 0, 0, 0 },         // 15
 
135
        { 0, 0, 1, 1, 1, 0 },                                                   // 16
 
136
        { 1 },                                                                  // 17
 
137
        { 2 },                                                                  // 18
 
138
        { 2, 2, 2, 2, 2, 2, 2, 1 },                                             // 19
 
139
        { 1, 1, 1, 1, 1, 1, 1, 0 },                                             // 20
 
140
        { 2 },                                                                  // 21
 
141
        null                                                                    // 22
 
142
    };
 
143
 
 
144
    protected static final int[][] testVisualMaps = {
 
145
        { 0, 1, 2, 3, 4, 5, 6, 7 },                                             // 0
 
146
        { 6, 5, 4, 3, 2, 1, 0 },                                                // 1
 
147
        { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 },                               // 2
 
148
        { 0, 3, 2, 1, 4, 6, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 },       // 3
 
149
        { 15, 14, 13, 12, 11, 10, 9, 6, 7, 8, 5, 4, 3, 2, 0, 1 },               // 4
 
150
        { 3, 0, 1, 2 },                                                         // 5
 
151
        { 8, 7, 6, 5, 4, 3, 2, 1, 0 },                                          // 6
 
152
        { 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
 
153
            26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 7, 6, 5, 4, 3,
 
154
            2, 1, 0 },                                                          // 7
 
155
        { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
 
156
            20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
 
157
            37, 38, 39 },                                                       // 8
 
158
        { 0, 1, 2, 44, 43, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 31, 30, 29, 28, 27,
 
159
            26, 20, 21, 24, 23, 22, 25, 19, 18, 17, 16, 15, 14, 32, 33, 34, 35,
 
160
            36, 37, 38, 39, 40, 41, 42, 3, 45, 46, 47, 48, 49, 50, 51, 52, 53,
 
161
            54, 55, 56, 57 },                                                   // 9
 
162
        { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 18, 17, 16, 15,
 
163
            20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40, 39, 38, 37, 36, 34, 35,
 
164
            33, 31, 32, 30, 41, 52, 53, 51, 50, 48, 49, 47, 46, 45, 44, 43, 42,
 
165
            54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69 },   // 10
 
166
        { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 18, 17, 16, 15,
 
167
            20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40, 39, 38, 37, 36, 34, 35,
 
168
            33, 31, 32, 30, 41, 52, 53, 51, 50, 48, 49, 47, 46, 45, 44, 43, 42,
 
169
            54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69 },   // 11
 
170
        { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 18, 17, 16, 15,
 
171
            20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40, 39, 38, 37, 36, 34, 35,
 
172
            33, 31, 32, 30, 41, 52, 53, 51, 50, 48, 49, 47, 46, 45, 44, 43, 42,
 
173
            54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69 },   // 12
 
174
        { 69, 68, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 55, 54, 53,
 
175
            52, 51, 50, 49, 42, 43, 44, 45, 46, 47, 48, 41, 40, 39, 38, 37, 36,
 
176
            35, 33, 34, 32, 30, 31, 29, 28, 26, 27, 25, 24, 22, 23, 21, 20, 19,
 
177
            18, 17, 16, 15, 7, 8, 9, 10, 11, 12, 13, 14, 6, 1, 2, 3, 4, 5, 0 }, // 13
 
178
        { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 18, 17, 16, 15,
 
179
            20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40, 39, 38, 37, 36, 34, 35,
 
180
            33, 31, 32, 30, 41, 52, 53, 51, 50, 48, 49, 47, 46, 45, 44, 43, 42,
 
181
            54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69 },   // 14
 
182
        { 0, 1, 15, 14, 13, 12, 11, 10, 4, 3, 2, 5, 6, 7, 8, 9, 16, 17, 18, 19 }, // 15
 
183
        { 0, 1, 4, 3, 2, 5 },                                                   // 16
 
184
        { 0 },                                                                  // 17
 
185
        { 0 },                                                                  // 18
 
186
        { 1, 2, 3, 4, 5, 6, 7, 0 },                                             // 19
 
187
        { 6, 5, 4, 3, 2, 1, 0, 7 },                                             // 20
 
188
        { 0 },                                                                  // 21
 
189
        null                                                                    // 22
 
190
    };
 
191
 
 
192
    protected static final byte[] testParaLevels = {
 
193
        Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR,
 
194
        Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR,
 
195
        Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR,
 
196
        Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_RTL,
 
197
        2, 5, Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR,
 
198
        Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR, Bidi.RTL, Bidi.LTR, Bidi.RTL,
 
199
        Bidi.LEVEL_DEFAULT_LTR
 
200
    };
 
201
 
 
202
    protected static final byte[] testDirections = {
 
203
        Bidi.LTR, Bidi.RTL, Bidi.LTR, Bidi.MIXED, Bidi.MIXED, Bidi.MIXED,
 
204
        Bidi.RTL, Bidi.MIXED, Bidi.MIXED, Bidi.MIXED, Bidi.MIXED, Bidi.MIXED,
 
205
        Bidi.MIXED, Bidi.MIXED, Bidi.MIXED, Bidi.MIXED, Bidi.MIXED, Bidi.RTL,
 
206
        Bidi.LTR, Bidi.MIXED, Bidi.MIXED, Bidi.MIXED, Bidi.LTR
 
207
    };
 
208
 
 
209
    protected static final byte[] testResultLevels = new byte[] {
 
210
        Bidi.LTR, Bidi.RTL, Bidi.LTR, Bidi.LTR, Bidi.RTL, Bidi.RTL, Bidi.RTL,
 
211
        Bidi.LTR, Bidi.LTR, Bidi.LTR, Bidi.LTR, Bidi.LTR, 2, 5, Bidi.LTR,
 
212
        Bidi.LTR, Bidi.LTR, Bidi.RTL, 2, Bidi.RTL, Bidi.LTR, Bidi.RTL, Bidi.LTR
 
213
    };
 
214
 
 
215
    protected static final byte[] testLineStarts = {
 
216
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 13,
 
217
        2, 0, 0, -1, -1
 
218
    };
 
219
 
 
220
    protected static final byte[] testLineLimits = {
 
221
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6, 14,
 
222
        3, 8, 8, -1, -1
 
223
    };
 
224
 
 
225
    protected short[] dirProps;
 
226
    protected int lineStart;
 
227
    protected int lineLimit;
 
228
    protected byte direction;
 
229
    protected byte paraLevel;
 
230
    protected byte resultLevel;
 
231
    protected byte[] levels;
 
232
    protected int[] visualMap;
 
233
 
 
234
    private TestData(short[] dirProps, int lineStart, int lineLimit,
 
235
            byte direction, byte paraLevel, byte resultLevel, byte[] levels,
 
236
            int[] visualMap) {
 
237
        this.dirProps = dirProps;
 
238
        this.lineStart = lineStart;
 
239
        this.lineLimit = lineLimit;
 
240
        this.direction = direction;
 
241
        this.paraLevel = paraLevel;
 
242
        this.resultLevel = resultLevel;
 
243
        this.levels = levels;
 
244
        this.visualMap = visualMap;
 
245
    }
 
246
 
 
247
    protected static TestData getTestData(int testNumber) {
 
248
        return new TestData(testDirProps[testNumber],
 
249
                testLineStarts[testNumber], testLineLimits[testNumber],
 
250
                testDirections[testNumber], testParaLevels[testNumber],
 
251
                testResultLevels[testNumber], testLevels[testNumber],
 
252
                testVisualMaps[testNumber]);
 
253
    }
 
254
 
 
255
    protected static int testCount() {
 
256
        return testDirProps.length;
 
257
    }
 
258
}