< prev index next >

test/jdk/java/text/Collator/EnglishTest.java

Print this page

  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 
 30 import java.util.Locale;
 31 import 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
 38 owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These materials are
 39 provided under terms of a License Agreement between Taligent and Sun. This
 40 technology is protected by multiple US and International patents. This notice and
 41 attribution to Taligent may not be removed.
 42   Taligent is a registered trademark of Taligent, Inc.
 43 */
 44 
 45 public 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 

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 }

  1 /*
  2  * Copyright (c) 1997, 2023, 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  * @run junit EnglishTest
 29  */
 30 
 31 import java.util.Locale;
 32 import java.text.Collator;
 33 
 34 import org.junit.jupiter.api.Test;
 35 
 36 import static org.junit.jupiter.api.Assertions.fail;
 37 
 38 /*
 39 (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
 40 (C) Copyright IBM Corp. 1996 - All Rights Reserved
 41 
 42   The original version of this source code and documentation is copyrighted and
 43 owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These materials are
 44 provided under terms of a License Agreement between Taligent and Sun. This
 45 technology is protected by multiple US and International patents. This notice and
 46 attribution to Taligent may not be removed.
 47   Taligent is a registered trademark of Taligent, Inc.
 48 */
 49 
 50 public class EnglishTest {




 51 
 52     /*
 53      * Data for TestPrimary()
 54      */
 55     private static final String[] primarySourceData = {
 56         "p\u00EAche",
 57         "abc",
 58         "abc",
 59         "abc",
 60         "a\u00E6c"
 61     };
 62 
 63     private static final String[] primaryTargetData = {
 64         "p\u00E9ch\u00E9",
 65         "aBC",
 66         "abd",
 67         "\u00E4bc",
 68         "a\u00C6c"
 69     };
 70 

185     private static final int[] tertiaryResults = {
186         -1,  1, -1,  1,  1,  0, -1, -1, -1,  1,
187          1, -1,  0, -1,  1,  1,  1, -1, -1, -1,
188         -1, -1, -1,  1,  1,  1, -1, -1,  1, -1,
189          1,  0,  1, -1, -1, -1,  0,  0
190     };
191 
192     private static final String testData[] = {
193         "a",
194         "A",
195         "e",
196         "E",
197         "\u00e9",
198         "\u00e8",
199         "\u00ea",
200         "\u00eb",
201         "ea",
202         "x"
203     };
204 
205     @Test
206     public void TestPrimary() {
207         TestUtils.doCollatorTest(myCollation, Collator.PRIMARY,
208                primarySourceData, primaryTargetData, primaryResults);
209     }
210 
211     @Test
212     public void TestSecondary() {
213         TestUtils.doCollatorTest(myCollation, Collator.SECONDARY,
214                secondarySourceData, secondaryTargetData, secondaryResults);
215     }
216 
217     @Test
218     public void TestTertiary() {
219         TestUtils.doCollatorTest(myCollation, Collator.TERTIARY,
220                tertiarySourceData, tertiaryTargetData, tertiaryResults);
221 
222         for (int i = 0; i < testData.length-1; i++) {
223             for (int j = i+1; j < testData.length; j++) {
224                 TestUtils.doCollatorTest(myCollation, testData[i], testData[j], -1);
225             }
226         }
227     }
228 
229     private final Collator myCollation = Collator.getInstance(Locale.ENGLISH);
230 }
< prev index next >