Skip to content

Commit b0de0e3

Browse files
Test for string printable option on input strings
This checks that the string-printable option only applies to input strings. This also adds a test to make sure no printable characters can be present when the option is activated.
1 parent 542a26d commit b0de0e3

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed
Binary file not shown.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
public class Test {
2+
3+
public static String check(String t) {
4+
String s = t.concat("$£¥\u0000\u0008\u0010\u001F");
5+
// This should be disallowed because "\u0000" is not printable
6+
assert(!s.equals("\u0000$£¥\u0000\u0008\u0010\u001F"));
7+
// This can fail when t="a" which is printable
8+
assert(!s.equals("a$£¥\u0000\u0008\u0010\u001F"));
9+
return s;
10+
}
11+
12+
public static boolean check_char(String s, char c) {
13+
if(s == null)
14+
return false;
15+
// This should be -1 for all non-printable character
16+
int i = s.indexOf(c);
17+
boolean b = (i == -1 || (c >= ' ' && c <= '~'));
18+
assert(b);
19+
return b;
20+
}
21+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
Test.class
3+
--refine-strings --function Test.check --string-max-length 100 --string-printable --java-assume-inputs-non-null
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
assertion.* file Test.java line 6 .* SUCCESS
7+
assertion.* file Test.java line 8 .* FAILURE
8+
--
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
Test.class
3+
--refine-strings --function Test.check_char --string-max-length 100 --string-printable
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
assertion.* file Test.java line 18 .* SUCCESS
7+
--

0 commit comments

Comments
 (0)