forked from diffblue/cbmc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for generics array and strings
This adds an int greater than string-max-length in a generic array. This is to check that TG-2138 is fixed. Before the issue was solved setting the array to 101 was in contradiction with default axioms added by the string solver.
- Loading branch information
1 parent
b83182f
commit 0e8a863
Showing
6 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+834 Bytes
regression/jbmc-strings/max-length-generic-array/IntegerTests.class
Binary file not shown.
44 changes: 44 additions & 0 deletions
44
regression/jbmc-strings/max-length-generic-array/IntegerTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
public class IntegerTests { | ||
|
||
public static Boolean testMyGenSet(Integer key) { | ||
if (key == null) return null; | ||
MyGenSet<Integer> ms = new MyGenSet<>(); | ||
ms.array[0] = 101; | ||
if (ms.contains(key)) return true; | ||
return false; | ||
} | ||
|
||
public static Boolean testMySet(Integer key) { | ||
if (key == null) return null; | ||
MySet ms = new MySet(); | ||
ms.array[0] = 101; | ||
if (ms.contains(key)) return true; | ||
return false; | ||
} | ||
|
||
} | ||
|
||
class MyGenSet<E> { | ||
E[] array; | ||
@SuppressWarnings("unchecked") | ||
MyGenSet() { | ||
array = (E[]) new Object[1]; | ||
} | ||
boolean contains(E o) { | ||
if (o.equals(array[0])) | ||
return true; | ||
return false; | ||
} | ||
} | ||
|
||
class MySet { | ||
Integer[] array; | ||
MySet() { | ||
array = new Integer[1]; | ||
} | ||
boolean contains(Integer o) { | ||
if (o.equals(array[0])) | ||
return true; | ||
return false; | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
19 changes: 19 additions & 0 deletions
19
regression/jbmc-strings/max-length-generic-array/test.desc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
CORE | ||
IntegerTests.class | ||
-refine-strings --string-max-length 100 IntegerTests.class --function IntegerTests.testMySet --cover location | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
coverage.* line 12 function java::IntegerTests.testMySet.* bytecode-index 1 .* SATISFIED | ||
coverage.* line 12 function java::IntegerTests.testMySet.* bytecode-index 3 .* SATISFIED | ||
coverage.* line 13 function java::IntegerTests.testMySet.* bytecode-index 4 .* SATISFIED | ||
coverage.* line 13 function java::IntegerTests.testMySet.* bytecode-index 6 .* SATISFIED | ||
coverage.* line 13 function java::IntegerTests.testMySet.* bytecode-index 7 .* SATISFIED | ||
coverage.* line 14 function java::IntegerTests.testMySet.* bytecode-index 12 .* SATISFIED | ||
coverage.* line 14 function java::IntegerTests.testMySet.* bytecode-index 13 .* SATISFIED | ||
coverage.* line 15 function java::IntegerTests.testMySet.* bytecode-index 16 .* SATISFIED | ||
coverage.* line 15 function java::IntegerTests.testMySet.* bytecode-index 17 .* SATISFIED | ||
coverage.* line 16 function java::IntegerTests.testMySet.* bytecode-index 21 .* SATISFIED | ||
coverage.* line 15 function java::IntegerTests.testMySet.* bytecode-index 19 .* SATISFIED | ||
coverage.* line 15 function java::IntegerTests.testMySet.* bytecode-index 20 .* SATISFIED | ||
coverage.* line 16 function java::IntegerTests.testMySet.* bytecode-index 22 .* SATISFIED | ||
coverage.* line 16 function java::IntegerTests.testMySet.* bytecode-index 23 .* SATISFIED |
20 changes: 20 additions & 0 deletions
20
regression/jbmc-strings/max-length-generic-array/test_gen.desc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
CORE | ||
IntegerTests.class | ||
-refine-strings --string-max-length 100 IntegerTests.class --function IntegerTests.testMyGenSet --cover location | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
coverage.* line 4 function java::IntegerTests.testMyGenSet.* bytecode-index 1 .* SATISFIED | ||
coverage.* line 4 function java::IntegerTests.testMyGenSet.* bytecode-index 3 .* SATISFIED | ||
coverage.* line 5 function java::IntegerTests.testMyGenSet.* bytecode-index 4 .* SATISFIED | ||
coverage.* line 5 function java::IntegerTests.testMyGenSet.* bytecode-index 6 .* SATISFIED | ||
coverage.* line 5 function java::IntegerTests.testMyGenSet.* bytecode-index 7 .* SATISFIED | ||
coverage.* line 6 function java::IntegerTests.testMyGenSet.* bytecode-index 10 .* SATISFIED | ||
coverage.* line 6 function java::IntegerTests.testMyGenSet.* bytecode-index 13 .* SATISFIED | ||
coverage.* line 6 function java::IntegerTests.testMyGenSet.* bytecode-index 14 .* SATISFIED | ||
coverage.* line 7 function java::IntegerTests.testMyGenSet.* bytecode-index 17 .* SATISFIED | ||
coverage.* line 7 function java::IntegerTests.testMyGenSet.* bytecode-index 18 .* SATISFIED | ||
coverage.* line 8 function java::IntegerTests.testMyGenSet.* bytecode-index 22 .* SATISFIED | ||
coverage.* line 7 function java::IntegerTests.testMyGenSet.* bytecode-index 20 .* SATISFIED | ||
coverage.* line 7 function java::IntegerTests.testMyGenSet.* bytecode-index 21 .* SATISFIED | ||
coverage.* line 8 function java::IntegerTests.testMyGenSet.* bytecode-index 23 .* SATISFIED | ||
coverage.* line 8 function java::IntegerTests.testMyGenSet.* bytecode-index 24 .* SATISFIED |