Skip to content

Commit bcf4a9d

Browse files
Add tests for String.format
This tests the new implementation of String.format using the java models.
1 parent f614a52 commit bcf4a9d

File tree

11 files changed

+117
-0
lines changed

11 files changed

+117
-0
lines changed
Binary file not shown.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
public class Test
2+
{
3+
public static String testHex(int i)
4+
{
5+
String u=String.format("di%xlue", i);
6+
if(u.equals("diffblue"))
7+
assert(false);
8+
else if(u.startsWith("di"))
9+
assert(false);
10+
else
11+
assert(false);
12+
return u;
13+
}
14+
15+
public static String testInt(int i)
16+
{
17+
String u=String.format("Hello %d !", i);
18+
if(u.equals("Hello 10 !"))
19+
assert(false);
20+
else if (!u.startsWith("Hello"))
21+
assert(false);
22+
else
23+
assert(false);
24+
return u;
25+
}
26+
27+
public static String string1(String s)
28+
{
29+
if(s == null)
30+
return "null!";
31+
String u=String.format("Hello %s !", s);
32+
if(u.equals("Hello world !"))
33+
assert(false);
34+
else if(u.startsWith("impossible!"))
35+
assert(false);
36+
else
37+
assert(false);
38+
return u;
39+
}
40+
41+
public static String string2(String s, String t)
42+
{
43+
if(s == null || t == null)
44+
return "null null";
45+
String u=String.format("%s %s", s, t);
46+
assert(!u.equals("ab"));
47+
return u;
48+
}
49+
50+
public static String string3(String s, String t)
51+
{
52+
if(s == null || t == null)
53+
return "null null";
54+
String u=String.format("%s%s%s", s, t, s);
55+
assert(s.length() != 1 || u.charAt(0) == u.charAt(u.length() - 1));
56+
return u;
57+
}
58+
59+
}
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 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
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 9 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 11 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 19 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 21 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 23 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 33 assertion at file Test.java .*: FAILURE
7+
line 35 assertion at file Test.java .*: SUCCESS
8+
line 37 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.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 46 assertion at file Test.java .*: SUCCESS
7+
8+

0 commit comments

Comments
 (0)