Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/lang/String/CompactString/CompareToIgnoreCase.java
41152 views
1
/*
2
* Copyright (c) 2015, 2021, 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
import org.testng.annotations.DataProvider;
25
import org.testng.annotations.Test;
26
27
import static org.testng.Assert.assertEquals;
28
29
/*
30
* @test
31
* @bug 8077559 8248655 8264544
32
* @summary Tests Compact String. This one is for String.compareToIgnoreCase.
33
* @run testng/othervm -XX:+CompactStrings CompareToIgnoreCase
34
* @run testng/othervm -XX:-CompactStrings CompareToIgnoreCase
35
*/
36
37
public class CompareToIgnoreCase extends CompactString {
38
39
@DataProvider
40
public Object[][] provider() {
41
return new Object[][] {
42
new Object[] { STRING_EMPTY, "A", -1 },
43
new Object[] { STRING_L1, "a", 0 },
44
new Object[] { STRING_L1, "A", 0 },
45
new Object[] { STRING_L1, "\uFF21", -65248 },
46
new Object[] { STRING_L1, "B", -1 },
47
new Object[] { STRING_L2, "AB", 0 },
48
new Object[] { STRING_L2, "aB", 0 },
49
new Object[] { STRING_L2, "\uFF21", -65248 },
50
new Object[] { STRING_L2, "A\uFF21", -65247 },
51
new Object[] { STRING_L4, "ABCD", 0 },
52
new Object[] { STRING_L4, "abcd", 0 },
53
new Object[] { STRING_L4, "ABc\uFF21", -65245 },
54
new Object[] { STRING_LLONG, "ABCDEFGH", 0 },
55
new Object[] { STRING_LLONG, "abcdefgh", 0 },
56
new Object[] { STRING_LLONG, "ABCDEFG\uFF21", -65241 },
57
new Object[] { STRING_LLONG, "abcdefg\uFF21", -65241 },
58
new Object[] { STRING_U1, "\uFF41", 0 },
59
new Object[] { STRING_U1,
60
"\uFF41\uFF42\uFF43\uFF44\uFF45\uFF46\uFF47\uFF48", -7 },
61
new Object[] { STRING_U1, "A", 65248 },
62
new Object[] { STRING_U2, "\uFF41", 1 },
63
new Object[] { STRING_U2, "\uFF41\uFF42", 0 },
64
new Object[] { STRING_U2,
65
"\uFF41\uFF42\uFF43\uFF44\uFF45\uFF46\uFF47\uFF48", -6 },
66
new Object[] { STRING_M12, "\uFF41a", 0 },
67
new Object[] { STRING_M12, "\uFF41\uFF42", -65249 },
68
new Object[] { STRING_M11, "a\uFF41", 0 },
69
new Object[] { STRING_M11, "a\uFF42", -1 },
70
new Object[] { STRING_SUPPLEMENTARY, STRING_SUPPLEMENTARY_LOWERCASE, 0 },
71
new Object[] { STRING_SUPPLEMENTARY, "\uD801\uDC28\uD801\uDC27\uFF41a", -38 },
72
new Object[] { STRING_SUPPLEMENTARY, "\uD802\uDC00\uD801\uDC01\uFF21A", -984 },
73
};
74
}
75
76
@Test(dataProvider = "provider")
77
public void testCompareToIgnoreCase(String str, String anotherString,
78
int expected) {
79
map.get(str)
80
.forEach(
81
(source, data) -> {
82
assertEquals(
83
data.compareToIgnoreCase(anotherString),
84
expected,
85
String.format(
86
"testing String(%s).compareToIgnoreCase(%s), source : %s, ",
87
escapeNonASCIIs(data),
88
escapeNonASCIIs(anotherString),
89
source));
90
});
91
}
92
}
93
94