Skip to content

Commit 5c716c1

Browse files
Add a CProverString class for string-smoke-tests
This defines useful string functions replacing standard java functions that cannot be directly supported in cbmc because of exception throwing.
1 parent 6b619e0 commit 5c716c1

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Binary file not shown.
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)