Skip to content

Commit 79d289e

Browse files
Improve the StringBuilder constructor tests
Split the tests for the different constructors, add assertions that are supposed to fail, and activate the tests that can be.
1 parent a73309e commit 79d289e

8 files changed

+78
-12
lines changed
Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
11
public class StringBuilderConstructors01
22
{
3-
public static void main(String[] args)
4-
{
5-
StringBuilder buffer1 = new StringBuilder();
6-
StringBuilder buffer2 = new StringBuilder(10);
7-
StringBuilder buffer3 = new StringBuilder("diffblue");
8-
9-
assert buffer1.length()==0;
10-
assert buffer2.length()==0;
11-
assert buffer3.length()>0;
12-
}
3+
public static void noArgPass() {
4+
StringBuilder buffer1 = new StringBuilder();
5+
assert buffer1.length() == 0;
6+
}
7+
8+
public static void noArgFail() {
9+
StringBuilder buffer1 = new StringBuilder();
10+
assert buffer1.length() != 0;
11+
}
12+
13+
public static void capacityPass() {
14+
StringBuilder buffer2 = new StringBuilder(10);
15+
assert buffer2.length() == 0;
16+
}
17+
18+
public static void capacityFail() {
19+
20+
StringBuilder buffer2 = new StringBuilder(10);
21+
assert buffer2.length() != 0;
22+
}
23+
24+
public static void stringPass() {
25+
StringBuilder buffer3 = new StringBuilder("diffblue");
26+
assert buffer3.length() == 8;
27+
}
28+
29+
public static void stringFail() {
30+
StringBuilder buffer3 = new StringBuilder("diffblue");
31+
assert buffer3.length() != 8;
32+
}
1333
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
KNOWNBUG
2+
StringBuilderConstructors01.class
3+
--function StringBuilderConstructors01.capacityFail --max-nondet-string-length 1000
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
--
8+
^warning: ignoring
9+
--
10+
This is not working currently because the StringBuilder constructor with
11+
capacity argument is not modelled.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
KNOWNBUG
2+
StringBuilderConstructors01.class
3+
--function StringBuilderConstructors01.capacityPass --max-nondet-string-length 1000
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
9+
--
10+
This is not working currently because the StringBuilder constructor with
11+
capacity argument is not modelled.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
StringBuilderConstructors01.class
3+
--function StringBuilderConstructors01.noArgFail --max-nondet-string-length 1000
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
--
8+
^warning: ignoring

jbmc/regression/jbmc-strings/StringBuilderConstructors01/test.desc renamed to jbmc/regression/jbmc-strings/StringBuilderConstructors01/test-no-arg-pass.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
KNOWNBUG
1+
CORE
22
StringBuilderConstructors01.class
3-
--max-nondet-string-length 1000
3+
--function StringBuilderConstructors01.noArgPass --max-nondet-string-length 1000
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
StringBuilderConstructors01.class
3+
--function StringBuilderConstructors01.stringFail --max-nondet-string-length 1000
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
--
8+
^warning: ignoring
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
StringBuilderConstructors01.class
3+
--function StringBuilderConstructors01.stringPass --max-nondet-string-length 1000
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

0 commit comments

Comments
 (0)