Skip to content

Commit bc145fd

Browse files
authored
Merge pull request #1756 from romainbrenguier/tests/index-of-corrections#TG-2246
Correct tests for String.indexOf
2 parents 47b4ee9 + bcb076b commit bc145fd

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed
49 Bytes
Binary file not shown.

regression/jbmc-strings/StringIndexOf/Test.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// This test uses CProverString so should be compiled with
2+
// javac Test.java ../cprover/CProverString.java
3+
14
public class Test {
25

36
public boolean check(String input_String, char input_char, int input_int) {
@@ -14,13 +17,13 @@ public boolean check(String input_String, char input_char, int input_int) {
1417

1518
if (i == -1) {
1619
for (int j = lower_bound; j < input_String.length(); j++)
17-
assert input_String.charAt(j) != input_char;
20+
assert org.cprover.CProverString.charAt(input_String, j) != input_char;
1821
} else {
1922
assert i >= lower_bound;
20-
assert input_String.charAt(i) == input_char;
23+
assert org.cprover.CProverString.charAt(input_String, i) == input_char;
2124

2225
for (int j = lower_bound; j < i; j++)
23-
assert input_String.charAt(j) != input_char;
26+
assert org.cprover.CProverString.charAt(input_String, j) != input_char;
2427
}
2528
return true;
2629
}

regression/jbmc-strings/StringIndexOf/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
Test.class
3-
--refine-strings --function Test.check --unwind 4 --string-max-length 3 --java-assume-inputs-non-null
3+
--refine-strings --function Test.check --unwind 4 --string-max-input-length 3 --java-assume-inputs-non-null
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$

regression/jbmc-strings/StringIndexOf/test2.desc

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ Test.class
33
--refine-strings --function Test.check2 --unwind 10 --string-max-length 10 --java-assume-inputs-non-null
44
^EXIT=10$
55
^SIGNAL=0$
6-
assertion at file Test.java line 32 .* SUCCESS
7-
assertion at file Test.java line 34 .* SUCCESS
8-
assertion at file Test.java line 36 .* SUCCESS
9-
assertion at file Test.java line 38 .* SUCCESS
10-
assertion at file Test.java line 40 .* SUCCESS
11-
assertion at file Test.java line 42 .* SUCCESS
12-
assertion at file Test.java line 43 .* FAILURE
6+
assertion at file Test.java line 35 .* SUCCESS
7+
assertion at file Test.java line 37 .* SUCCESS
8+
assertion at file Test.java line 39 .* SUCCESS
9+
assertion at file Test.java line 41 .* SUCCESS
10+
assertion at file Test.java line 43 .* SUCCESS
11+
assertion at file Test.java line 45 .* SUCCESS
12+
assertion at file Test.java line 46 .* FAILURE
1313
^VERIFICATION FAILED$
1414
--

0 commit comments

Comments
 (0)