1/*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24/*
25 * @test
26 * @library /java/text/testlib
27 * @summary test English Collation
28 */
29
30import java.util.Locale;
31import java.text.Collator;
32
33/*
34(C) Copyright Taligent, Inc. 1996 - All Rights Reserved
35(C) Copyright IBM Corp. 1996 - All Rights Reserved
36
37  The original version of this source code and documentation is copyrighted and
38owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These materials are
39provided under terms of a License Agreement between Taligent and Sun. This
40technology is protected by multiple US and International patents. This notice and
41attribution to Taligent may not be removed.
42  Taligent is a registered trademark of Taligent, Inc.
43*/
44
45public class EnglishTest extends CollatorTest {
46
47    public static void main(String[] args) throws Exception {
48        new EnglishTest().run(args);
49    }
50
51    /*
52     * Data for TestPrimary()
53     */
54    private static final String[] primarySourceData = {
55        "p\u00EAche",
56        "abc",
57        "abc",
58        "abc",
59        "a\u00E6c"
60    };
61
62    private static final String[] primaryTargetData = {
63        "p\u00E9ch\u00E9",
64        "aBC",
65        "abd",
66        "\u00E4bc",
67        "a\u00C6c"
68    };
69
70    private static final int[] primaryResults = {
71         0,  0, -1,  0,  0,
72    };
73
74    /*
75     * Data for TestSecondary()
76     */
77    private static final String[] secondarySourceData = {
78        "abc",
79        "abc",
80        "a\u00E6c",
81        "abc",
82        "abc",
83        "p\u00e9ch\u00e9"
84    };
85
86    private static final String[] secondaryTargetData = {
87        "aBd",
88        "\u00E4bc",
89        "a\u00C6c",
90        "aBd",
91        "\u00E4bc",
92        "p\u00eache"
93    };
94
95    private static final int[] secondaryResults = {
96        -1, -1,  0, -1, -1, -1
97    };
98
99    /*
100     * Data for TestTertiary() {
101     */
102    private static final String[] tertiarySourceData = {
103        "ab",
104        "black-bird",
105        "black bird",
106        "black-bird",
107        "Hello",
108        "ABC",
109        "abc",
110        "blackbird",
111        "black-bird",
112        "black-bird",
113        "p\u00EAche",
114        "p\u00E9ch\u00E9",
115        "\u00C4B\u0308C\u0308",
116        "a\u0308bc",
117        "p\u00E9cher",
118        "roles",
119        "abc",
120        "A",
121        "A",
122        "ab",
123        "tcompareplain",
124        "ab",
125        "a#b",
126        "a#b",
127        "abc",
128        "Abcda",
129        "abcda",
130        "abcda",
131        "\u00E6bcda",
132        "\u00E4bcda",
133        "abc",
134        "abc",
135        "abc",
136        "abc",
137        "abc",
138        "acHc",
139        "a\u0308bc",
140        "thi\u0302s"
141    };
142
143    private static final String[] tertiaryTargetData = {
144        "abc",
145        "blackbird",
146        "black-bird",
147        "black",
148        "hello",
149        "ABC",
150        "ABC",
151        "blackbirds",
152        "blackbirds",
153        "blackbird",
154        "p\u00E9ch\u00E9",
155        "p\u00E9cher",
156        "\u00C4B\u0308C\u0308",
157        "A\u0308bc",
158        "p\u00E9che",
159        "ro\u0302le",
160        "A\u00E1cd",
161        "A\u00E1cd",
162        "abc",
163        "abc",
164        "TComparePlain",
165        "aBc",
166        "a#B",
167        "a&b",
168        "a#c",
169        "abcda",
170        "\u00C4bcda",
171        "\u00E4bcda",
172        "\u00C4bcda",
173        "\u00C4bcda",
174        "ab#c",
175        "abc",
176        "ab=c",
177        "abd",
178        "\u00E4bc",
179        "aCHc",
180        "\u00E4bc",
181        "th\u00EEs"
182    };
183
184    private static final int[] tertiaryResults = {
185        -1,  1, -1,  1,  1,  0, -1, -1, -1,  1,
186         1, -1,  0, -1,  1,  1,  1, -1, -1, -1,
187        -1, -1, -1,  1,  1,  1, -1, -1,  1, -1,
188         1,  0,  1, -1, -1, -1,  0,  0
189    };
190
191    private static final String testData[] = {
192        "a",
193        "A",
194        "e",
195        "E",
196        "\u00e9",
197        "\u00e8",
198        "\u00ea",
199        "\u00eb",
200        "ea",
201        "x"
202    };
203
204    public void TestPrimary() {
205        doTest(myCollation, Collator.PRIMARY,
206               primarySourceData, primaryTargetData, primaryResults);
207    }
208
209    public void TestSecondary() {
210        doTest(myCollation, Collator.SECONDARY,
211               secondarySourceData, secondaryTargetData, secondaryResults);
212    }
213
214    public void TestTertiary() {
215        doTest(myCollation, Collator.TERTIARY,
216               tertiarySourceData, tertiaryTargetData, tertiaryResults);
217
218        for (int i = 0; i < testData.length-1; i++) {
219            for (int j = i+1; j < testData.length; j++) {
220                doTest(myCollation, testData[i], testData[j], -1);
221            }
222        }
223    }
224
225    private final Collator myCollation = Collator.getInstance(Locale.ENGLISH);
226}
227