Skip to content

Commit 3ab853e

Browse files
Test comparing jbmc lastIndexOf with loop version
1 parent 985684a commit 3ab853e

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
public class Test {
2+
// This compares the model of indexOf to an implementation
3+
// using loops
4+
5+
public int math_min(int i, int j) {
6+
if (i < j)
7+
return i;
8+
else
9+
return j;
10+
}
11+
12+
public int referenceLastIndexOf(String s, char ch, int fromIndex) {
13+
for (int i = math_min(fromIndex, s.length() - 1); i >= 0; i--) {
14+
if (s.charAt(i) == ch) {
15+
return i;
16+
}
17+
}
18+
return -1;
19+
}
20+
21+
public int check(String s, char ch, int fromIndex) {
22+
int reference = referenceLastIndexOf(s, ch, fromIndex);
23+
int jbmc_result = s.lastIndexOf(ch, fromIndex);
24+
assert(reference == jbmc_result);
25+
return jbmc_result;
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
THOROUGH
2+
Test.class
3+
--function Test.check --refine-strings --string-max-length 50 --unwind 50 --java-assume-inputs-non-null
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
assertion at file Test.java line 32 .* SUCCESS$
7+
assertion at file Test.java line 34 .* FAILURE$

0 commit comments

Comments
 (0)