Adapt existing StringBuilder tests

Activate two tests marked FUTURE that can meanwhile be solved by the string
solver. Also adapt tests so they cannot be solved via constant propagation, and
load the models library.
This commit is contained in:
Daniel Poetzl 2019-10-08 12:02:18 +01:00
parent a543b91cee
commit b44fd4109e
12 changed files with 33 additions and 23 deletions

View File

@ -1,8 +1,15 @@
public class StringBuilderCapLen01 public class StringBuilderCapLen01
{ {
public static void main(String[] args) public static void test(boolean choice)
{ {
StringBuilder buffer = new StringBuilder("Diffblue is leader in automatic test case generation"); String s =
choice
? "Diffblue is leader in automatic test case generation"
: "";
StringBuilder buffer = new StringBuilder(s);
if(!choice)
return;
assert buffer.toString().equals("Diffblue is leader in automatic test case generation"); assert buffer.toString().equals("Diffblue is leader in automatic test case generation");
assert buffer.length()==52; assert buffer.length()==52;

View File

@ -1,6 +1,6 @@
FUTURE FUTURE
StringBuilderCapLen01.class StringBuilderCapLen01.class
--max-nondet-string-length 1000 --function StringBuilderCapLen01.test --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
^EXIT=0$ ^EXIT=0$
^SIGNAL=0$ ^SIGNAL=0$
^VERIFICATION SUCCESSFUL$ ^VERIFICATION SUCCESSFUL$

View File

@ -1,10 +1,11 @@
public class StringBuilderChars01 public class StringBuilderChars01
{ {
public static void main(String[] args) public static void test(boolean choice)
{ {
StringBuilder buffer = new StringBuilder("Diffblue Limited"); String s = choice ? "Diffblue" : "abcdefgh";
StringBuilder buffer = new StringBuilder(s);
assert buffer.toString().equals("Diffblue Limited"); assert !choice || buffer.toString().equals("Diffblue");
assert buffer.charAt(0)!=buffer.charAt(4); assert buffer.charAt(0)!=buffer.charAt(4);
char[] charArray = new char[buffer.length()]; char[] charArray = new char[buffer.length()];
@ -20,9 +21,9 @@ public class StringBuilderChars01
buffer.setCharAt(0, 'H'); buffer.setCharAt(0, 'H');
buffer.setCharAt(6, 'T'); buffer.setCharAt(6, 'T');
assert buffer.toString().equals("HiffBlTe Limited"); assert !choice || buffer.toString().equals("HiffblTe");
buffer.reverse(); buffer.reverse();
assert buffer.toString().equals("detimiL eTlBffiH"); assert !choice || buffer.toString().equals("eTlbffiH");
} }
} }

View File

@ -1,6 +1,6 @@
FUTURE THOROUGH
StringBuilderChars01.class StringBuilderChars01.class
--max-nondet-string-length 1000 --unwind 100 --function StringBuilderChars01.test --unwind 10 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
^EXIT=0$ ^EXIT=0$
^SIGNAL=0$ ^SIGNAL=0$
^VERIFICATION SUCCESSFUL$ ^VERIFICATION SUCCESSFUL$

View File

@ -1,10 +1,11 @@
public class StringBuilderChars05 public class StringBuilderChars05
{ {
public static void main(String[] args) public static void test(boolean choice)
{ {
StringBuilder buffer = new StringBuilder("Diffblue Limited"); String s = choice ? "Diffblue Limited" : "Diffblue Unlimited";
StringBuilder buffer = new StringBuilder(s);
buffer.setCharAt(0, 'H'); buffer.setCharAt(0, 'H');
buffer.setCharAt(6, 'T'); buffer.setCharAt(6, 'T');
assert buffer.toString().equals("HiffBllTe Limited"); assert !choice || buffer.toString().equals("HiffBllTe Limited");
} }
} }

View File

@ -1,6 +1,6 @@
FUTURE CORE
StringBuilderChars05.class StringBuilderChars05.class
--max-nondet-string-length 1000 --unwind 100 --function StringBuilderChars05.test --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
^EXIT=10$ ^EXIT=10$
^SIGNAL=0$ ^SIGNAL=0$
^VERIFICATION FAILED$ ^VERIFICATION FAILED$

View File

@ -1,10 +1,10 @@
CORE CORE
test_set_length.class test_set_length.class
--max-nondet-string-length 100 --function test_set_length.main --function test_set_length.main --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
^EXIT=10$ ^EXIT=10$
^SIGNAL=0$ ^SIGNAL=0$
^\[.*assertion.1\].* line 8.* SUCCESS$ ^\[.*assertion.1\].* line 9.* SUCCESS$
^\[.*assertion.2\].* line 9.* SUCCESS$ ^\[.*assertion.2\].* line 10.* SUCCESS$
^\[.*assertion.3\].* line 10.* FAILURE$ ^\[.*assertion.3\].* line 11.* FAILURE$
-- --
non equal types non equal types

View File

@ -1,10 +1,11 @@
public class test_set_length public class test_set_length
{ {
public static void main() public static void main(boolean choice)
{ {
StringBuilder s = new StringBuilder("abc"); String s = choice ? "abc" : "abcxyz";
s.setLength(10); StringBuilder sb = new StringBuilder(s);
String t = s.toString(); sb.setLength(10);
String t = sb.toString();
assert(t.startsWith("abc")); assert(t.startsWith("abc"));
assert(t.length() == 10); assert(t.length() == 10);
assert(t.length() == 3); assert(t.length() == 3);