Path: blob/master/test/jdk/sun/text/resources/Collator/Bug4804273.java
41152 views
/*1* Copyright (c) 2007, 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* @bug 480427326* @modules jdk.localedata27* @summary updating collation tables for swedish28*/2930import java.text.Collator;31import java.util.Arrays;32import java.util.Locale;3334public class Bug4804273 {3536/********************************************************37*********************************************************/38public static void main (String[] args) {39Locale reservedLocale = Locale.getDefault();40try {41int errors=0;4243Locale loc = new Locale ("sv", "se"); // Swedish4445Locale.setDefault (loc);46Collator col = Collator.getInstance ();4748String[] data = {"A",49"Aa",50"Ae",51"B",52"Y",53"U\u0308", // U-umlaut54"Z",55"A\u030a", // A-ring56"A\u0308", // A-umlaut57"\u00c6", // AE ligature58"O\u0308", // O-umlaut59"a\u030b", // a-double-acute60"\u00d8", // O-stroke61"a",62"aa",63"ae",64"b",65"y",66"u\u0308", // u-umlaut67"z",68"A\u030b", // A-double-acute69"a\u030a", // a-ring70"a\u0308", // a-umlaut71"\u00e6", // ae ligature72"o\u0308", // o-umlaut73"\u00f8", // o-stroke74};757677String[] sortedData = {"a",78"A",79"aa",80"Aa",81"ae",82"Ae",83"b",84"B",85"y",86"Y",87"u\u0308", // o-umlaut88"U\u0308", // o-umlaut89"z",90"Z",91"a\u030a", // a-ring92"A\u030a", // A-ring93"a\u0308", // a-umlaut94"A\u0308", // A-umlaut95"a\u030b", // a-double-acute96"A\u030b", // A-double-acute97"\u00e6", // ae ligature98"\u00c6", // AE ligature99"o\u0308", // o-umlaut100"O\u0308", // O-umlaut101"\u00f8", // o-stroke102"\u00d8", // O-stroke103};104105Arrays.sort (data, col);106107System.out.println ("Using " + loc.getDisplayName());108for (int i = 0; i < data.length; i++) {109System.out.println(data[i] + " : " + sortedData[i]);110if (sortedData[i].compareTo(data[i]) != 0) {111errors++;112}113}//end for114115if (errors > 0)116throw new RuntimeException("There are " + errors +117" words sorted incorrectly!");118} finally {119// restore the reserved locale120Locale.setDefault(reservedLocale);121}122}//end main123124}//end class CollatorTest125126127