Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/lang/String/CompactString/OffsetByCodePoints.java
41152 views
1
/*
2
* Copyright (c) 2015, 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
32
* @summary Tests Compact String. This one is for String.offsetByCodePoints.
33
* @run testng/othervm -XX:+CompactStrings OffsetByCodePoints
34
* @run testng/othervm -XX:-CompactStrings OffsetByCodePoints
35
*/
36
37
public class OffsetByCodePoints extends CompactString {
38
39
@DataProvider
40
public Object[][] provider() {
41
return new Object[][] {
42
43
new Object[] { STRING_SUPPLEMENTARY, 0, 1, 2 },
44
new Object[] { STRING_SUPPLEMENTARY, 0, 3, 5 },
45
new Object[] { STRING_SUPPLEMENTARY, 1, 1, 2 },
46
new Object[] { STRING_SUPPLEMENTARY, 1, 3, 5 },
47
new Object[] { STRING_SUPPLEMENTARY, 2, 1, 4 },
48
new Object[] { STRING_SUPPLEMENTARY, 2, 2, 5 },
49
new Object[] { STRING_SUPPLEMENTARY, 2, 3, 6 },
50
new Object[] { STRING_SUPPLEMENTARY, 3, 1, 4 },
51
new Object[] { STRING_SUPPLEMENTARY, 3, 2, 5 },
52
new Object[] { STRING_SUPPLEMENTARY, 3, 3, 6 }, };
53
}
54
55
@Test(dataProvider = "provider")
56
public void testOffsetByCodePoints(String str, int index,
57
int codePointOffset, int expected) {
58
map.get(str)
59
.forEach(
60
(source, data) -> {
61
assertEquals(
62
data.offsetByCodePoints(index,
63
codePointOffset),
64
expected,
65
String.format(
66
"testing String(%s).offsetByCodePoints(%d, %d), source : %s, ",
67
escapeNonASCIIs(data), index,
68
codePointOffset, source));
69
});
70
}
71
}
72
73