Path: blob/master/test/jdk/java/text/Collator/EnglishTest.java
41149 views
/*1* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @library /java/text/testlib26* @summary test English Collation27*/2829import java.util.Locale;30import java.text.Collator;3132/*33(C) Copyright Taligent, Inc. 1996 - All Rights Reserved34(C) Copyright IBM Corp. 1996 - All Rights Reserved3536The original version of this source code and documentation is copyrighted and37owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These materials are38provided under terms of a License Agreement between Taligent and Sun. This39technology is protected by multiple US and International patents. This notice and40attribution to Taligent may not be removed.41Taligent is a registered trademark of Taligent, Inc.42*/4344public class EnglishTest extends CollatorTest {4546public static void main(String[] args) throws Exception {47new EnglishTest().run(args);48}4950/*51* Data for TestPrimary()52*/53private static final String[] primarySourceData = {54"p\u00EAche",55"abc",56"abc",57"abc",58"a\u00E6c"59};6061private static final String[] primaryTargetData = {62"p\u00E9ch\u00E9",63"aBC",64"abd",65"\u00E4bc",66"a\u00C6c"67};6869private static final int[] primaryResults = {700, 0, -1, 0, 0,71};7273/*74* Data for TestSecondary()75*/76private static final String[] secondarySourceData = {77"abc",78"abc",79"a\u00E6c",80"abc",81"abc",82"p\u00e9ch\u00e9"83};8485private static final String[] secondaryTargetData = {86"aBd",87"\u00E4bc",88"a\u00C6c",89"aBd",90"\u00E4bc",91"p\u00eache"92};9394private static final int[] secondaryResults = {95-1, -1, 0, -1, -1, -196};9798/*99* Data for TestTertiary() {100*/101private static final String[] tertiarySourceData = {102"ab",103"black-bird",104"black bird",105"black-bird",106"Hello",107"ABC",108"abc",109"blackbird",110"black-bird",111"black-bird",112"p\u00EAche",113"p\u00E9ch\u00E9",114"\u00C4B\u0308C\u0308",115"a\u0308bc",116"p\u00E9cher",117"roles",118"abc",119"A",120"A",121"ab",122"tcompareplain",123"ab",124"a#b",125"a#b",126"abc",127"Abcda",128"abcda",129"abcda",130"\u00E6bcda",131"\u00E4bcda",132"abc",133"abc",134"abc",135"abc",136"abc",137"acHc",138"a\u0308bc",139"thi\u0302s"140};141142private static final String[] tertiaryTargetData = {143"abc",144"blackbird",145"black-bird",146"black",147"hello",148"ABC",149"ABC",150"blackbirds",151"blackbirds",152"blackbird",153"p\u00E9ch\u00E9",154"p\u00E9cher",155"\u00C4B\u0308C\u0308",156"A\u0308bc",157"p\u00E9che",158"ro\u0302le",159"A\u00E1cd",160"A\u00E1cd",161"abc",162"abc",163"TComparePlain",164"aBc",165"a#B",166"a&b",167"a#c",168"abcda",169"\u00C4bcda",170"\u00E4bcda",171"\u00C4bcda",172"\u00C4bcda",173"ab#c",174"abc",175"ab=c",176"abd",177"\u00E4bc",178"aCHc",179"\u00E4bc",180"th\u00EEs"181};182183private static final int[] tertiaryResults = {184-1, 1, -1, 1, 1, 0, -1, -1, -1, 1,1851, -1, 0, -1, 1, 1, 1, -1, -1, -1,186-1, -1, -1, 1, 1, 1, -1, -1, 1, -1,1871, 0, 1, -1, -1, -1, 0, 0188};189190private static final String testData[] = {191"a",192"A",193"e",194"E",195"\u00e9",196"\u00e8",197"\u00ea",198"\u00eb",199"ea",200"x"201};202203public void TestPrimary() {204doTest(myCollation, Collator.PRIMARY,205primarySourceData, primaryTargetData, primaryResults);206}207208public void TestSecondary() {209doTest(myCollation, Collator.SECONDARY,210secondarySourceData, secondaryTargetData, secondaryResults);211}212213public void TestTertiary() {214doTest(myCollation, Collator.TERTIARY,215tertiarySourceData, tertiaryTargetData, tertiaryResults);216217for (int i = 0; i < testData.length-1; i++) {218for (int j = i+1; j < testData.length; j++) {219doTest(myCollation, testData[i], testData[j], -1);220}221}222}223224private final Collator myCollation = Collator.getInstance(Locale.ENGLISH);225}226227228