File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed
regression/jbmc-strings/VerifStringLastIndexOf Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 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+ int i = math_min (fromIndex , s .length () - 1 );
14+ for (; i >= 0 ; i --) {
15+ if (s .charAt (i ) == ch ) {
16+ return i ;
17+ }
18+ }
19+ return -1 ;
20+ }
21+
22+ public int check (String s , char ch , int fromIndex ) {
23+ int reference = referenceLastIndexOf (s , ch , fromIndex );
24+ int jbmc_result = s .lastIndexOf (ch , fromIndex );
25+ assert (reference == jbmc_result );
26+ return jbmc_result ;
27+ }
28+ }
Original file line number Diff line number Diff line change 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$
You can’t perform that action at this time.
0 commit comments