Skip to content

Commit 2d7e636

Browse files
Test for the string-non-empty option
1 parent 33a31a1 commit 2d7e636

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed
Binary file not shown.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
public class Test {
2+
3+
static void checkMinLength(String arg1, String arg2, int nondet) {
4+
// Filter
5+
if (arg1 == null || arg2 == null)
6+
return;
7+
8+
// The validity of the following assertion depends on
9+
// whether --string-non-empty is used
10+
if(nondet == 0) {
11+
assert arg1.length() > 0;
12+
} else if(nondet == 1) {
13+
assert arg2.length() > 0;
14+
} else if(nondet == 2) {
15+
// For this assertion to be valid, also need to limit the length of
16+
// strings because overflows could cause the sum to be negative.
17+
assert arg1.length() + arg2.length() > 1;
18+
} else {
19+
assert arg1.length() > 1;
20+
}
21+
}
22+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
Test.class
3+
--function Test.checkMinLength
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
assertion.* line 11 function java::Test.checkMinLength.*: FAILURE
7+
assertion.* line 13 function java::Test.checkMinLength.*: FAILURE
8+
assertion.* line 17 function java::Test.checkMinLength.*: FAILURE
9+
assertion.* line 19 function java::Test.checkMinLength.*: FAILURE
10+
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.checkMinLength --string-non-empty
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
assertion.* line 11 function java::Test.checkMinLength.*: SUCCESS
7+
assertion.* line 13 function java::Test.checkMinLength.*: SUCCESS
8+
assertion.* line 19 function java::Test.checkMinLength.*: FAILURE
9+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
Test.class
3+
--function Test.checkMinLength --string-non-empty --max-nondet-string-length 100000
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
assertion.* line 11 function java::Test.checkMinLength.*: SUCCESS
7+
assertion.* line 13 function java::Test.checkMinLength.*: SUCCESS
8+
assertion.* line 17 function java::Test.checkMinLength.*: SUCCESS
9+
assertion.* line 19 function java::Test.checkMinLength.*: FAILURE
10+

0 commit comments

Comments
 (0)