Skip to content

Commit 22dc353

Browse files
Add CProverString class for jbmc-strings tests
This defines string function to replace standard Java string functions that cannot be supported internally by CBMC because of exception throwing.
1 parent ef610b3 commit 22dc353

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
790 Bytes
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.cprover;
2+
3+
public final class CProverString {
4+
public static char charAt(String s, int i) {
5+
if (0 <= i && i < s.length())
6+
return s.charAt(i);
7+
else
8+
return '\u0000';
9+
}
10+
11+
public static String substring(String s, int i) {
12+
if (i <= 0)
13+
return s;
14+
else if (i >= s.length())
15+
return "";
16+
else
17+
return s.substring(i);
18+
}
19+
20+
public static String substring(String s, int i, int j) {
21+
if (i < 0)
22+
return substring(s, 0, j);
23+
if (j >= s.length())
24+
return substring(s, 0, s.length() - 1);
25+
if (i >= j)
26+
return "";
27+
return s.substring(i, j);
28+
}
29+
}

0 commit comments

Comments
 (0)