Skip to content

Commit 15c01de

Browse files
Tests for String.toUpperCase
1 parent fddb28e commit 15c01de

File tree

5 files changed

+80
-0
lines changed

5 files changed

+80
-0
lines changed
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
public class Test {
2+
public String det()
3+
{
4+
StringBuilder builder = new StringBuilder();
5+
builder.append("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toLowerCase());
6+
builder.append("abcdeghijklmnopfrstuqwxyzABCDvFGHIJKLMENOPQRSTUVWXYZ".toUpperCase());
7+
builder.append("abcdeghijlmnopqrstvwxyzABCDEFGHIJuKLMNOPQRSfkTUVWXYZ".toUpperCase());
8+
builder.append("acdefghijklmnopqrsuvwxyzABCDEFbGHIJKLMNOPtQRSTUVWXYZ".toUpperCase());
9+
builder.append("abcdfghijklmnopqrstuvwxyzABCDEFGHIJeKLMNOPQRSTUVWXYZ".toUpperCase());
10+
return builder.toString();
11+
}
12+
13+
public String nonDet(String s)
14+
{
15+
if(s.length() < 20)
16+
return "Short string";
17+
if(!s.startsWith("A"))
18+
return "String not starting with A";
19+
20+
StringBuilder builder = new StringBuilder();
21+
builder.append(s.toUpperCase());
22+
builder.append(s.toUpperCase());
23+
builder.append(":");
24+
builder.append(s);
25+
builder.append(":");
26+
builder.append(s.toUpperCase());
27+
builder.append(s.toUpperCase());
28+
return builder.toString();
29+
}
30+
31+
public String withDependency(String s, boolean b)
32+
{
33+
// Filter
34+
if(s == null || s.length() < 20)
35+
return "Short string";
36+
if(!s.endsWith("a"))
37+
return "String not ending with a";
38+
39+
// Act
40+
String result = s + s.toUpperCase();
41+
42+
// Assert
43+
if(b) {
44+
assert(result.endsWith("A"));
45+
} else {
46+
assert(!result.endsWith("A"));
47+
}
48+
return result;
49+
}
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
Test.class
3+
--function Test.withDependency --verbosity 10 --max-nondet-string-length 10000
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
assertion at file Test.java line 44 .*: SUCCESS
7+
assertion at file Test.java line 46 .*: FAILURE
8+
--
9+
--
10+
Check that when there are dependency, axioms are added correctly.
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 9 .*: 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 27 .*: 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)