Skip to content

Correct tests for String.indexOf #1756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified regression/jbmc-strings/StringIndexOf/Test.class
Binary file not shown.
9 changes: 6 additions & 3 deletions regression/jbmc-strings/StringIndexOf/Test.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This test uses CProverString so should be compiled with
// javac Test.java ../cprover/CProverString.java

public class Test {

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

if (i == -1) {
for (int j = lower_bound; j < input_String.length(); j++)
assert input_String.charAt(j) != input_char;
assert org.cprover.CProverString.charAt(input_String, j) != input_char;
} else {
assert i >= lower_bound;
assert input_String.charAt(i) == input_char;
assert org.cprover.CProverString.charAt(input_String, i) == input_char;

for (int j = lower_bound; j < i; j++)
assert input_String.charAt(j) != input_char;
assert org.cprover.CProverString.charAt(input_String, j) != input_char;
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion regression/jbmc-strings/StringIndexOf/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CORE
Test.class
--refine-strings --function Test.check --unwind 4 --string-max-length 3 --java-assume-inputs-non-null
--refine-strings --function Test.check --unwind 4 --string-max-input-length 3 --java-assume-inputs-non-null
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
Expand Down
14 changes: 7 additions & 7 deletions regression/jbmc-strings/StringIndexOf/test2.desc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ Test.class
--refine-strings --function Test.check2 --unwind 10 --string-max-length 10 --java-assume-inputs-non-null
^EXIT=10$
^SIGNAL=0$
assertion at file Test.java line 32 .* SUCCESS
assertion at file Test.java line 34 .* SUCCESS
assertion at file Test.java line 36 .* SUCCESS
assertion at file Test.java line 38 .* SUCCESS
assertion at file Test.java line 40 .* SUCCESS
assertion at file Test.java line 42 .* SUCCESS
assertion at file Test.java line 43 .* FAILURE
assertion at file Test.java line 35 .* SUCCESS
assertion at file Test.java line 37 .* SUCCESS
assertion at file Test.java line 39 .* SUCCESS
assertion at file Test.java line 41 .* SUCCESS
assertion at file Test.java line 43 .* SUCCESS
assertion at file Test.java line 45 .* SUCCESS
assertion at file Test.java line 46 .* FAILURE
^VERIFICATION FAILED$
--