File tree 3 files changed +34
-0
lines changed
regression/jbmc-strings/VerifStringLastIndexOf
3 files changed +34
-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
+ 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 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