Skip to content

Commit b2d0d2c

Browse files
Merge pull request #4477 from romainbrenguier/feature/cprover-string-format
Use CProverString.format as interface to the solver builtin function
2 parents 23af75f + 7c34ea4 commit b2d0d2c

15 files changed

+234
-406
lines changed
Binary file not shown.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
public class Test {
2+
public static String testHex(int i) {
3+
String u = String.format("di%xlue", i);
4+
if (u.equals("diffblue"))
5+
assert(false);
6+
else if (u.startsWith("di"))
7+
assert(false);
8+
else
9+
assert(false);
10+
return u;
11+
}
12+
13+
public static String testInt(int i) {
14+
String u = String.format("Hello %d !", i);
15+
if (u.equals("Hello 10 !"))
16+
assert(false);
17+
else if (!u.startsWith("Hello"))
18+
assert(false);
19+
else
20+
assert(false);
21+
return u;
22+
}
23+
24+
public static String string1(String s) {
25+
if (s == null)
26+
return "null!";
27+
String u = String.format("Hello %s !", s);
28+
if (u.equals("Hello world !"))
29+
assert(false);
30+
else if (u.startsWith("impossible!"))
31+
assert(false);
32+
else
33+
assert(false);
34+
return u;
35+
}
36+
37+
public static String string2(String s, String t) {
38+
if (s == null || t == null)
39+
return "null null";
40+
String u = String.format("%s %s", s, t);
41+
assert(!u.equals("ab"));
42+
return u;
43+
}
44+
45+
public static String string3(String s, String t) {
46+
if (s == null || t == null)
47+
return "null null";
48+
String u = String.format("%s%s%s", s, t, s);
49+
assert(s.length() != 1 || u.charAt(0) == u.charAt(u.length() - 1));
50+
return u;
51+
}
52+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
Test.class
3+
--function Test.testHex --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --property "java::Test.testHex:(I)Ljava/lang/String;.assertion.1"
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
line 5 assertion at file Test.java .*: FAILURE
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
Test.class
3+
--function Test.testHex --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --property "java::Test.testHex:(I)Ljava/lang/String;.assertion.2"
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
line 7 assertion at file Test.java .*: FAILURE
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE symex-driven-lazy-loading-expected-failure
2+
Test.class
3+
--function Test.testHex --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --property "java::Test.testHex:(I)Ljava/lang/String;.assertion.3"
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
line 9 assertion at file Test.java .*: SUCCESS
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
Test.class
3+
--function Test.testInt --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --property "java::Test.testInt:(I)Ljava/lang/String;.assertion.1"
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
line 16 assertion at file Test.java .*: FAILURE
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE symex-driven-lazy-loading-expected-failure
2+
Test.class
3+
--function Test.testInt --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --property "java::Test.testInt:(I)Ljava/lang/String;.assertion.2"
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
line 18 assertion at file Test.java .*: SUCCESS
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
Test.class
3+
--function Test.testInt --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --property "java::Test.testInt:(I)Ljava/lang/String;.assertion.3"
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
line 20 assertion at file Test.java .*: FAILURE
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
Test.class
3+
--function Test.string1 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
line 29 assertion at file Test.java .*: FAILURE
7+
line 31 assertion at file Test.java .*: SUCCESS
8+
line 33 assertion at file Test.java .*: FAILURE
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
Test.class
3+
--function Test.string2 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --max-nondet-string-length 20 --property "java::Test.string2:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;.assertion.1"
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
line 41 assertion at file Test.java .*: SUCCESS
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
Test.class
3+
--function Test.string3 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --max-nondet-string-length 5 --property "java::Test.string3:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;.assertion.1"
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
line 49 assertion at file Test.java .*: SUCCESS

0 commit comments

Comments
 (0)