Skip to content

Commit 8279e91

Browse files
committed
Constant propagation of CProverString.setLength()
Only minimal tests are added at this point. The error conditions (like index out of bounds) will be handled by the models. Once we have models that use CProverString.setLength(), more comprehensive tests will be added.
1 parent fd4a8ec commit 8279e91

File tree

14 files changed

+250
-1
lines changed

14 files changed

+250
-1
lines changed
Binary file not shown.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import org.cprover.CProverString;
2+
3+
public class Test
4+
{
5+
public void testSuccess1()
6+
{
7+
StringBuffer sb = new StringBuffer("abc");
8+
CProverString.setLength(sb, 0);
9+
assert sb.toString().equals("");
10+
}
11+
12+
public void testSuccess2()
13+
{
14+
StringBuffer sb = new StringBuffer("abc");
15+
CProverString.setLength(sb, 2);
16+
assert sb.toString().equals("ab");
17+
}
18+
19+
public void testSuccess3()
20+
{
21+
StringBuffer sb = new StringBuffer("abc");
22+
CProverString.setLength(sb, 3);
23+
assert sb.toString().equals("abc");
24+
}
25+
26+
public void testSuccess4()
27+
{
28+
StringBuffer sb = new StringBuffer("abc");
29+
CProverString.setLength(sb, 4);
30+
assert sb.toString().equals("abc\u0000");
31+
}
32+
33+
public void testSuccess5()
34+
{
35+
StringBuffer sb = new StringBuffer("abc");
36+
CProverString.setLength(sb, 5);
37+
assert sb.toString().equals("abc\u0000\u0000");
38+
}
39+
40+
public void testSuccess6(StringBuffer sb)
41+
{
42+
CProverString.setLength(sb, 0);
43+
assert sb.toString().equals("");
44+
}
45+
46+
public void testNoPropagation1()
47+
{
48+
StringBuffer sb = new StringBuffer("abc");
49+
CProverString.setLength(sb, -1);
50+
assert sb.toString().equals("abc");
51+
}
52+
53+
public void testNoPropagation2(StringBuffer sb)
54+
{
55+
CProverString.setLength(sb, 3);
56+
assert sb.toString().equals("abc");
57+
}
58+
59+
public void testNoPropagation3(int newLength)
60+
{
61+
StringBuffer sb = new StringBuffer("abc");
62+
CProverString.setLength(sb, newLength);
63+
assert sb.toString().equals("abc");
64+
}
65+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE symex-driven-lazy-loading-expected-failure
2+
Test.class
3+
--function Test.testNoPropagation1 --show-vcc --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --property 'java::Test.testNoPropagation1:()V.assertion.1'
4+
^Generated [0-9]+ VCC\(s\), 1 remaining after simplification$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
--
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE symex-driven-lazy-loading-expected-failure
2+
Test.class
3+
--function Test.testNoPropagation2 --show-vcc --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --property 'java::Test.testNoPropagation2:(Ljava/lang/StringBuffer;)V.assertion.1'
4+
^Generated [0-9]+ VCC\(s\), 1 remaining after simplification$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
--
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE symex-driven-lazy-loading-expected-failure
2+
Test.class
3+
--function Test.testNoPropagation3 --show-vcc --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --property 'java::Test.testNoPropagation3:(I)V.assertion.1'
4+
^Generated [0-9]+ VCC\(s\), 1 remaining after simplification$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
--
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
Test.class
3+
--function Test.testSuccess1 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
4+
^Generated [0-9]+ VCC\(s\), 0 remaining after simplification$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
^VERIFICATION SUCCESSFUL$
8+
--
9+
--
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
Test.class
3+
--function Test.testSuccess2 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
4+
^Generated [0-9]+ VCC\(s\), 0 remaining after simplification$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
^VERIFICATION SUCCESSFUL$
8+
--
9+
--
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
Test.class
3+
--function Test.testSuccess3 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
4+
^Generated [0-9]+ VCC\(s\), 0 remaining after simplification$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
^VERIFICATION SUCCESSFUL$
8+
--
9+
--
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
Test.class
3+
--function Test.testSuccess4 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
4+
^Generated [0-9]+ VCC\(s\), 0 remaining after simplification$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
^VERIFICATION SUCCESSFUL$
8+
--
9+
--
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
Test.class
3+
--function Test.testSuccess5 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
4+
^Generated [0-9]+ VCC\(s\), 0 remaining after simplification$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
^VERIFICATION SUCCESSFUL$
8+
--
9+
--

0 commit comments

Comments
 (0)