Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/text/resources/Collator/Bug4804273.java
38855 views
/*1* Copyright (c) 2007, 2011, 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* @summary updating collation tables for swedish27*/2829import java.text.*;30import java.util.*;3132public class Bug4804273 {3334/********************************************************35*********************************************************/36public static void main (String[] args) {37Locale reservedLocale = Locale.getDefault();38try {39int errors=0;4041Locale loc = new Locale ("sv", "se"); // Swedish4243Locale.setDefault (loc);44Collator col = Collator.getInstance ();4546String[] data = {"A",47"Aa",48"Ae",49"B",50"Y",51"U\u0308", // U-umlaut52"Z",53"A\u030a", // A-ring54"A\u0308", // A-umlaut55"\u00c6", // AE ligature56"O\u0308", // O-umlaut57"a\u030b", // a-double-acute58"\u00d8", // O-stroke59"a",60"aa",61"ae",62"b",63"y",64"u\u0308", // u-umlaut65"z",66"A\u030b", // A-double-acute67"a\u030a", // a-ring68"a\u0308", // a-umlaut69"\u00e6", // ae ligature70"o\u0308", // o-umlaut71"\u00f8", // o-stroke72};737475String[] sortedData = {"a",76"A",77"aa",78"Aa",79"ae",80"Ae",81"b",82"B",83"y",84"Y",85"u\u0308", // o-umlaut86"U\u0308", // o-umlaut87"z",88"Z",89"a\u030a", // a-ring90"A\u030a", // A-ring91"a\u0308", // a-umlaut92"A\u0308", // A-umlaut93"a\u030b", // a-double-acute94"A\u030b", // A-double-acute95"\u00e6", // ae ligature96"\u00c6", // AE ligature97"o\u0308", // o-umlaut98"O\u0308", // O-umlaut99"\u00f8", // o-stroke100"\u00d8", // O-stroke101};102103Arrays.sort (data, col);104105System.out.println ("Using " + loc.getDisplayName());106for (int i = 0; i < data.length; i++) {107System.out.println(data[i] + " : " + sortedData[i]);108if (sortedData[i].compareTo(data[i]) != 0) {109errors++;110}111}//end for112113if (errors > 0)114throw new RuntimeException("There are " + errors +115" words sorted incorrectly!");116} finally {117// restore the reserved locale118Locale.setDefault(reservedLocale);119}120}//end main121122}//end class CollatorTest123124125