20869
|
1 |
/*
|
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*/
|
|
23 |
|
|
24 |
/*
|
|
25 |
* @test
|
|
26 |
* @bug 8025703
|
|
27 |
* @summary Verify implementation for Locale matching.
|
|
28 |
* @run main Bug8025703
|
|
29 |
*/
|
|
30 |
|
|
31 |
import java.util.*;
|
|
32 |
import java.util.Locale.LanguageRange;
|
|
33 |
|
|
34 |
public class Bug8025703 {
|
|
35 |
|
|
36 |
public static void main(String[] args) {
|
|
37 |
boolean err = false;
|
|
38 |
|
|
39 |
String[][] mappings = {{"ilw", "gal"},
|
|
40 |
{"meg", "cir"},
|
|
41 |
{"pcr", "adx"},
|
|
42 |
{"xia", "acn"},
|
|
43 |
{"yos", "zom"}};
|
|
44 |
|
|
45 |
for (int i = 0; i < mappings.length; i++) {
|
|
46 |
List<LanguageRange> got = LanguageRange.parse(mappings[i][0]);
|
|
47 |
ArrayList<LanguageRange> expected = new ArrayList<>();
|
|
48 |
expected.add(new LanguageRange(mappings[i][0], 1.0));
|
|
49 |
expected.add(new LanguageRange(mappings[i][1], 1.0));
|
|
50 |
|
|
51 |
if (!expected.equals(got)) {
|
|
52 |
err = true;
|
|
53 |
System.err.println("Incorrect language ranges. ");
|
|
54 |
for (LanguageRange lr : expected) {
|
|
55 |
System.err.println(" Expected: range="
|
|
56 |
+ lr.getRange() + ", weight=" + lr.getWeight());
|
|
57 |
}
|
|
58 |
for (LanguageRange lr : got) {
|
|
59 |
System.err.println(" Got: range="
|
|
60 |
+ lr.getRange() + ", weight=" + lr.getWeight());
|
|
61 |
}
|
|
62 |
}
|
|
63 |
}
|
|
64 |
|
|
65 |
if (err) {
|
|
66 |
throw new RuntimeException("Failed.");
|
|
67 |
}
|
|
68 |
}
|
|
69 |
|
|
70 |
}
|
|
71 |
|