forked from diffblue/cbmc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test comparing jbmc lastIndexOf with loop version
- Loading branch information
1 parent
985684a
commit 3ab853e
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
public class Test { | ||
// This compares the model of indexOf to an implementation | ||
// using loops | ||
|
||
public int math_min(int i, int j) { | ||
if (i < j) | ||
return i; | ||
else | ||
return j; | ||
} | ||
|
||
public int referenceLastIndexOf(String s, char ch, int fromIndex) { | ||
for (int i = math_min(fromIndex, s.length() - 1); i >= 0; i--) { | ||
if (s.charAt(i) == ch) { | ||
return i; | ||
} | ||
} | ||
return -1; | ||
} | ||
|
||
public int check(String s, char ch, int fromIndex) { | ||
int reference = referenceLastIndexOf(s, ch, fromIndex); | ||
int jbmc_result = s.lastIndexOf(ch, fromIndex); | ||
assert(reference == jbmc_result); | ||
return jbmc_result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
THOROUGH | ||
Test.class | ||
--function Test.check --refine-strings --string-max-length 50 --unwind 50 --java-assume-inputs-non-null | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
assertion at file Test.java line 32 .* SUCCESS$ | ||
assertion at file Test.java line 34 .* FAILURE$ |