Skip to content

Commit 9ebdc88

Browse files
Test for String.lastIndexOf with empty argument
1 parent 707ed94 commit 9ebdc88

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
public class Test {
2+
int fromIndex;
3+
4+
public void check(String input_String1, String input_String2, int i) {
5+
if(input_String1 != null && input_String2 != null) {
6+
if (i == 0) {
7+
// The last occurrence of the empty string "" is considered to
8+
// occur at the index value this.length()
9+
int lio = input_String1.lastIndexOf(input_String2);
10+
if (input_String2.length() == 0)
11+
assert lio == input_String1.length();
12+
} else if (i == 1) {
13+
// Contradiction with the previous condition (should fail).
14+
assert "foo".lastIndexOf("") != 3;
15+
} else if (i == 2 && input_String2.length() > 0) {
16+
int lio = input_String1.lastIndexOf(input_String2.charAt(0), fromIndex);
17+
if (input_String2.length() == 0)
18+
assert lio == fromIndex;
19+
} else if (i == 3) {
20+
assert "foo".lastIndexOf("", 2) != 2;
21+
}
22+
}
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
Test.class
3+
--function Test.check --refine-strings --string-max-length 100
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
assertion at file Test.java line 11 .* SUCCESS$
7+
assertion at file Test.java line 14 .* FAILURE$
8+
assertion at file Test.java line 18 .* SUCCESS$
9+
assertion at file Test.java line 20 .* FAILURE$

0 commit comments

Comments
 (0)