Path: blob/master/test/jdk/java/text/Collator/DummyTest.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 Dummy Collation27*/2829import java.text.Collator;30import java.text.RuleBasedCollator;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 DummyTest extends CollatorTest {4546public static void main(String[] args) throws Exception {47new DummyTest().run(args);48}4950private static final String DEFAULTRULES =51"='\u200B'=\u200C=\u200D=\u200E=\u200F"52// Control Characters53+ "=\u0000 =\u0001 =\u0002 =\u0003 =\u0004" //null, .. eot54+ "=\u0005 =\u0006 =\u0007 =\u0008 ='\u0009'" //enq, ...55+ "='\u000b' =\u000e" //vt,, so56+ "=\u000f ='\u0010' =\u0011 =\u0012 =\u0013" //si, dle, dc1, dc2, dc357+ "=\u0014 =\u0015 =\u0016 =\u0017 =\u0018" //dc4, nak, syn, etb, can58+ "=\u0019 =\u001a =\u001b =\u001c =\u001d" //em, sub, esc, fs, gs59+ "=\u001e =\u001f =\u007f" //rs, us, del60//....then the C1 Latin 1 reserved control codes61+ "=\u0080 =\u0081 =\u0082 =\u0083 =\u0084 =\u0085"62+ "=\u0086 =\u0087 =\u0088 =\u0089 =\u008a =\u008b"63+ "=\u008c =\u008d =\u008e =\u008f =\u0090 =\u0091"64+ "=\u0092 =\u0093 =\u0094 =\u0095 =\u0096 =\u0097"65+ "=\u0098 =\u0099 =\u009a =\u009b =\u009c =\u009d"66+ "=\u009e =\u009f"67// IGNORE except for secondary, tertiary difference68// Spaces69+ ";'\u0020';'\u00A0'" // spaces70+ ";'\u2000';'\u2001';'\u2002';'\u2003';'\u2004'" // spaces71+ ";'\u2005';'\u2006';'\u2007';'\u2008';'\u2009'" // spaces72+ ";'\u200A';'\u3000';'\uFEFF'" // spaces73+ ";'\r' ;'\t' ;'\n';'\f';'\u000b'" // whitespace7475// Non-spacing accents7677+ ";\u0301" // non-spacing acute accent78+ ";\u0300" // non-spacing grave accent79+ ";\u0306" // non-spacing breve accent80+ ";\u0302" // non-spacing circumflex accent81+ ";\u030c" // non-spacing caron/hacek accent82+ ";\u030a" // non-spacing ring above accent83+ ";\u030d" // non-spacing vertical line above84+ ";\u0308" // non-spacing diaeresis accent85+ ";\u030b" // non-spacing double acute accent86+ ";\u0303" // non-spacing tilde accent87+ ";\u0307" // non-spacing dot above/overdot accent88+ ";\u0304" // non-spacing macron accent89+ ";\u0337" // non-spacing short slash overlay (overstruck diacritic)90+ ";\u0327" // non-spacing cedilla accent91+ ";\u0328" // non-spacing ogonek accent92+ ";\u0323" // non-spacing dot-below/underdot accent93+ ";\u0332" // non-spacing underscore/underline accent94// with the rest of the general diacritical marks in binary order95+ ";\u0305" // non-spacing overscore/overline96+ ";\u0309" // non-spacing hook above97+ ";\u030e" // non-spacing double vertical line above98+ ";\u030f" // non-spacing double grave99+ ";\u0310" // non-spacing chandrabindu100+ ";\u0311" // non-spacing inverted breve101+ ";\u0312" // non-spacing turned comma above/cedilla above102+ ";\u0313" // non-spacing comma above103+ ";\u0314" // non-spacing reversed comma above104+ ";\u0315" // non-spacing comma above right105+ ";\u0316" // non-spacing grave below106+ ";\u0317" // non-spacing acute below107+ ";\u0318" // non-spacing left tack below108+ ";\u0319" // non-spacing tack below109+ ";\u031a" // non-spacing left angle above110+ ";\u031b" // non-spacing horn111+ ";\u031c" // non-spacing left half ring below112+ ";\u031d" // non-spacing up tack below113+ ";\u031e" // non-spacing down tack below114+ ";\u031f" // non-spacing plus sign below115+ ";\u0320" // non-spacing minus sign below116+ ";\u0321" // non-spacing palatalized hook below117+ ";\u0322" // non-spacing retroflex hook below118+ ";\u0324" // non-spacing double dot below119+ ";\u0325" // non-spacing ring below120+ ";\u0326" // non-spacing comma below121+ ";\u0329" // non-spacing vertical line below122+ ";\u032a" // non-spacing bridge below123+ ";\u032b" // non-spacing inverted double arch below124+ ";\u032c" // non-spacing hacek below125+ ";\u032d" // non-spacing circumflex below126+ ";\u032e" // non-spacing breve below127+ ";\u032f" // non-spacing inverted breve below128+ ";\u0330" // non-spacing tilde below129+ ";\u0331" // non-spacing macron below130+ ";\u0333" // non-spacing double underscore131+ ";\u0334" // non-spacing tilde overlay132+ ";\u0335" // non-spacing short bar overlay133+ ";\u0336" // non-spacing long bar overlay134+ ";\u0338" // non-spacing long slash overlay135+ ";\u0339" // non-spacing right half ring below136+ ";\u033a" // non-spacing inverted bridge below137+ ";\u033b" // non-spacing square below138+ ";\u033c" // non-spacing seagull below139+ ";\u033d" // non-spacing x above140+ ";\u033e" // non-spacing vertical tilde141+ ";\u033f" // non-spacing double overscore142+ ";\u0340" // non-spacing grave tone mark143+ ";\u0341" // non-spacing acute tone mark144+ ";\u0342;\u0343;\u0344;\u0345;\u0360;\u0361" // newer145+ ";\u0483;\u0484;\u0485;\u0486" // Cyrillic accents146147+ ";\u20D0;\u20D1;\u20D2" // symbol accents148+ ";\u20D3;\u20D4;\u20D5" // symbol accents149+ ";\u20D6;\u20D7;\u20D8" // symbol accents150+ ";\u20D9;\u20DA;\u20DB" // symbol accents151+ ";\u20DC;\u20DD;\u20DE" // symbol accents152+ ";\u20DF;\u20E0;\u20E1" // symbol accents153154+ ",'\u002D';\u00AD" // dashes155+ ";\u2010;\u2011;\u2012" // dashes156+ ";\u2013;\u2014;\u2015" // dashes157+ ";\u2212" // dashes158159// other punctuation160161+ "<'\u005f'" // underline/underscore (spacing)162+ "<\u00af" // overline or macron (spacing)163// + "<\u00ad" // syllable hyphen (SHY) or soft hyphen164+ "<'\u002c'" // comma (spacing)165+ "<'\u003b'" // semicolon166+ "<'\u003a'" // colon167+ "<'\u0021'" // exclamation point168+ "<\u00a1" // inverted exclamation point169+ "<'\u003f'" // question mark170+ "<\u00bf" // inverted question mark171+ "<'\u002f'" // slash172+ "<'\u002e'" // period/full stop173+ "<\u00b4" // acute accent (spacing)174+ "<'\u0060'" // grave accent (spacing)175+ "<'\u005e'" // circumflex accent (spacing)176+ "<\u00a8" // diaresis/umlaut accent (spacing)177+ "<'\u007e'" // tilde accent (spacing)178+ "<\u00b7" // middle dot (spacing)179+ "<\u00b8" // cedilla accent (spacing)180+ "<'\u0027'" // apostrophe181+ "<'\"'" // quotation marks182+ "<\u00ab" // left angle quotes183+ "<\u00bb" // right angle quotes184+ "<'\u0028'" // left parenthesis185+ "<'\u0029'" // right parenthesis186+ "<'\u005b'" // left bracket187+ "<'\u005d'" // right bracket188+ "<'\u007b'" // left brace189+ "<'\u007d'" // right brace190+ "<\u00a7" // section symbol191+ "<\u00b6" // paragraph symbol192+ "<\u00a9" // copyright symbol193+ "<\u00ae" // registered trademark symbol194+ "<'\u0040'" // at sign195+ "<\u00a4" // international currency symbol196+ "<\u00a2" // cent sign197+ "<'\u0024'" // dollar sign198+ "<\u00a3" // pound-sterling sign199+ "<\u00a5" // yen sign200+ "<'\u002a'" // asterisk201+ "<'\\u005c'" // backslash202+ "<'\u0026'" // ampersand203+ "<'\u0023'" // number sign204+ "<'\u0025'" // percent sign205+ "<'\u002b'" // plus sign206// + "<\u002d" // hyphen or minus sign207+ "<\u00b1" // plus-or-minus sign208+ "<\u00f7" // divide sign209+ "<\u00d7" // multiply sign210+ "<'\u003c'" // less-than sign211+ "<'\u003d'" // equal sign212+ "<'\u003e'" // greater-than sign213+ "<\u00ac" // end of line symbol/logical NOT symbol214+ "<'\u007c'" // vertical line/logical OR symbol215+ "<\u00a6" // broken vertical line216+ "<\u00b0" // degree symbol217+ "<\u00b5" // micro symbol218219// NUMERICS220221+ "<0<1<2<3<4<5<6<7<8<9"222+ "<\u00bc<\u00bd<\u00be" // 1/4,1/2,3/4 fractions223224// NON-IGNORABLES225+ "<a,A"226+ "<b,B"227+ "<c,C"228+ "<d,D"229+ "<\u00F0,\u00D0" // eth230+ "<e,E"231+ "<f,F"232+ "<g,G"233+ "<h,H"234+ "<i,I"235+ "<j,J"236+ "<k,K"237+ "<l,L"238+ "<m,M"239+ "<n,N"240+ "<o,O"241+ "<p,P"242+ "<q,Q"243+ "<r,R"244+ "<s, S & SS,\u00DF" // s-zet245+ "<t,T"246+ "&th, \u00FE & TH, \u00DE" // thorn247+ "<u,U"248+ "<v,V"249+ "<w,W"250+ "<x,X"251+ "<y,Y"252+ "<z,Z"253+ "&AE,\u00C6" // ae & AE ligature254+ "&AE,\u00E6"255+ "&OE,\u0152" // oe & OE ligature256+ "&OE,\u0153";257258/*259* Data for TestPrimary()260*/261private static final String[] primarySourceData = {262"p\u00EAche",263"abc",264"abc",265"abc",266"abc",267"abc",268"a\u00E6c",269"acHc",270"black"271};272273private static final String[] primaryTargetData = {274"p\u00E9ch\u00E9",275"abc",276"aBC",277"abch",278"abd",279"\u00E4bc",280"a\u00C6c",281"aCHc",282"black-bird"283};284285private static final int[] primaryResults = {2860, 0, 0, -1, -1, 0, 0, 0, -1287};288289/*290* Data for TestSecondary()291*/292private static final String[] secondarySourceData = {293"four",294"five",295"1",296"abc",297"abc",298"abcH",299"abc",300"acHc"301};302303private static final String[] secondaryTargetData = {304305"4",306"5",307"one",308"abc",309"aBc",310"abch",311"abd",312"aCHc"313};314315private static final int[] secondaryResults = {3160, 0, 0, 0, 0, 0, -1, 0317};318319/*320* Data for TestTertiary()321*/322private static final String[] tertiarySourceData = {323"ab'c",324"co-op",325"ab",326"ampersad",327"all",328"four",329"five",330"1",331"1",332"1",333"2",334"2",335"Hello",336"a<b",337"a<b",338"acc",339"acHc"340};341342private static final String[] tertiaryTargetData = {343"abc",344"COOP",345"abc",346"&",347"&",348"4",349"5",350"one",351"nne",352"pne",353"two",354"uwo",355"hellO",356"a<=b",357"abc",358"aCHc",359"aCHc"360};361362private static final int[] tertiaryResults = {363-1, 1, -1, -1, -1, -1, -1, 1, 1, -1,3641, -1, 1, 1, -1, -1, -1365};366367368private static final String[] testData = {369"a",370"A",371"\u00e4",372"\u00c4",373"ae",374"aE",375"Ae",376"AE",377"\u00e6",378"\u00c6",379"b",380"c",381"z"382};383384public void TestPrimary() {385doTest(getCollator(), Collator.PRIMARY,386primarySourceData, primaryTargetData, primaryResults);387}388389public void TestSecondary() {390doTest(getCollator(), Collator.SECONDARY,391secondarySourceData, secondaryTargetData, secondaryResults);392}393394public void TestTertiary() {395Collator col = getCollator();396397doTest(col, Collator.TERTIARY,398tertiarySourceData, tertiaryTargetData, tertiaryResults);399400for (int i = 0; i < testData.length-1; i++) {401for (int j = i+1; j < testData.length; j++) {402doTest(col, testData[i], testData[j], -1);403}404}405}406407private RuleBasedCollator myCollation = null;408private Collator getCollator() {409if (myCollation == null) {410try {411myCollation = new RuleBasedCollator412(DEFAULTRULES + "& C < ch, cH, Ch, CH & Five, 5 & Four, 4 & one, 1 & Ampersand; '&' & Two, 2 ");413} catch (Exception foo) {414errln("Collator creation failed.");415myCollation = (RuleBasedCollator)Collator.getInstance();416}417}418return myCollation;419}420}421422423