Skip to content

Commit 31366ad

Browse files
Tests for StringBuilder.setCharAt
1 parent f4285e7 commit 31366ad

File tree

5 files changed

+94
-0
lines changed

5 files changed

+94
-0
lines changed
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
public class Test {
2+
public String det()
3+
{
4+
StringBuilder builder = new StringBuilder("abcdefghijklmnopqrstuvwxyz");
5+
builder.setCharAt(3, '!');
6+
builder.setCharAt(5, '!');
7+
builder.setCharAt(7, '!');
8+
builder.setCharAt(9, '!');
9+
builder.setCharAt(13, '!');
10+
builder.setCharAt(15, '!');
11+
builder.setCharAt(17, '!');
12+
builder.setCharAt(19, '!');
13+
builder.setCharAt(4, ':');
14+
builder.setCharAt(5, ':');
15+
builder.setCharAt(6, ':');
16+
builder.setCharAt(9, ':');
17+
builder.setCharAt(10, ':');
18+
builder.setCharAt(11, ':');
19+
builder.setCharAt(16, ':');
20+
builder.setCharAt(18, ':');
21+
return builder.toString();
22+
}
23+
24+
public String nonDet(String s, char c, int i)
25+
{
26+
StringBuilder builder = new StringBuilder(s);
27+
if(i + 5 >= s.length() || 19 >= s.length() || i < 0)
28+
return "Out of bounds";
29+
builder.setCharAt(i, c);
30+
builder.setCharAt(i+5, 'x');
31+
builder.setCharAt(7, '!');
32+
builder.setCharAt(9, '!');
33+
builder.setCharAt(13, '!');
34+
builder.setCharAt(15, '!');
35+
builder.setCharAt(17, '!');
36+
builder.setCharAt(19, '!');
37+
builder.setCharAt(4, ':');
38+
builder.setCharAt(5, ':');
39+
builder.setCharAt(6, c);
40+
builder.setCharAt(9, ':');
41+
builder.setCharAt(10, ':');
42+
builder.setCharAt(11, ':');
43+
builder.setCharAt(16, ':');
44+
builder.setCharAt(18, ':');
45+
return builder.toString();
46+
}
47+
48+
public String withDependency(boolean b)
49+
{
50+
StringBuilder builder = new StringBuilder("abcdefghijklmnopqrstuvwxyz");
51+
builder.setCharAt(3, '!');
52+
builder.setCharAt(5, '!');
53+
54+
if(b) {
55+
assert builder.toString().startsWith("abc!");
56+
} else {
57+
assert !builder.toString().startsWith("abc!");
58+
}
59+
return builder.toString();
60+
}
61+
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
Test.class
3+
--function Test.withDependency --max-nondet-string-length 1000
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
assertion at file Test.java line 55 .*: SUCCESS
7+
assertion at file Test.java line 57 .*: FAILURE
8+
--
9+
--
10+
Check that when a dependency is present, the correct constraints are added
11+
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
Test.class
3+
--function Test.det --verbosity 10 --cover location
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
coverage.* file Test.java line 21 .*: SATISFIED
7+
--
8+
adding lemma .*nondet_infinite_array
9+
--
10+
Check that using the string dependence informations, no lemma involving arrays is added
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
Test.class
3+
--function Test.nonDet --verbosity 10 --cover location --max-nondet-string-length 1000
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
coverage.* file Test.java line 45 .*: SATISFIED
7+
--
8+
adding lemma .*nondet_infinite_array
9+
--
10+
Check that using the string dependence informations, no lemma involving arrays is added

0 commit comments

Comments
 (0)