Path: blob/master/test/jdk/java/util/Locale/Bug8025703.java
41149 views
/*1* Copyright (c) 2013, 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 802570326* @summary Verify implementation for Locale matching.27* @run main Bug802570328*/2930import java.util.*;31import java.util.Locale.LanguageRange;3233public class Bug8025703 {3435public static void main(String[] args) {36boolean err = false;3738String[][] mappings = {{"ilw", "gal"},39{"meg", "cir"},40{"pcr", "adx"},41{"xia", "acn"},42{"yos", "zom"}};4344for (int i = 0; i < mappings.length; i++) {45List<LanguageRange> got = LanguageRange.parse(mappings[i][0]);46ArrayList<LanguageRange> expected = new ArrayList<>();47expected.add(new LanguageRange(mappings[i][0], 1.0));48expected.add(new LanguageRange(mappings[i][1], 1.0));4950if (!expected.equals(got)) {51err = true;52System.err.println("Incorrect language ranges. ");53for (LanguageRange lr : expected) {54System.err.println(" Expected: range="55+ lr.getRange() + ", weight=" + lr.getWeight());56}57for (LanguageRange lr : got) {58System.err.println(" Got: range="59+ lr.getRange() + ", weight=" + lr.getWeight());60}61}62}6364if (err) {65throw new RuntimeException("Failed.");66}67}6869}70717273