Skip to content

Commit 8aee772

Browse files
Owen Jonestautschnig
Owen Jones
authored andcommitted
Regression tests
Create regression tests for parseInt with radix and add failing regression tests for parseInt and parseInt with radix marked KNOWNBUG (see issue #664 which is about making them parse).
1 parent 0c8152c commit 8aee772

File tree

12 files changed

+128
-10
lines changed

12 files changed

+128
-10
lines changed

regression/strings-smoke-tests/java_parseint/test.desc

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ test_parseint.class
33
--refine-strings
44
^EXIT=10$
55
^SIGNAL=0$
6-
^\[.*assertion.1\].* line 7.* SUCCESS$
7-
^\[.*assertion.2\].* line 8.* FAILURE$
8-
--
6+
^\[.*assertion.1\].* line 8.* SUCCESS$
7+
^\[.*assertion.2\].* line 9.* FAILURE$
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
public class test_parseint
22
{
3-
public static void main(String[] argv)
4-
{
5-
String twelve = new String("12");
6-
int parsed = Integer.parseInt(twelve);
7-
assert(parsed == 12);
8-
assert(parsed != 12);
9-
}
3+
public static void main(String[] args)
4+
{
5+
if (args.length == 1) {
6+
String twelve = new String("12");
7+
int parsed1 = Integer.parseInt(twelve);
8+
assert(parsed1 == 12);
9+
assert(parsed1 != 12);
10+
}
11+
}
1012
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
KNOWNBUG
2+
test_parseint.class
3+
--refine-strings
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[.*assertion.1\].* line 9.* SUCCESS$
7+
^\[.*assertion.2\].* line 10.* FAILURE$
8+
^\[.*assertion.3\].* line 17.* SUCCESS$
9+
^\[.*assertion.4\].* line 18.* FAILURE$
10+
--
11+
--
12+
Issue #664 is about turning these tests on
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
public class test_parseint
2+
{
3+
public static void main(String[] args)
4+
{
5+
if (args.length == 2) {
6+
// 2^31-1, max value of Integer
7+
String max_int = new String("2147483647");
8+
int parsed2 = Integer.parseInt(max_int);
9+
assert(parsed2 == 2147483647);
10+
assert(parsed2 != 2147483647);
11+
}
12+
else if (args.length == 3) {
13+
// -2^31, min value of Integer, and longest string we could have without
14+
// leading zeroes
15+
String min_int = new String("-2147483648");
16+
int parsed3 = Integer.parseInt(min_int);
17+
assert(parsed3 == -2147483648);
18+
assert(parsed3 != -2147483648);
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CORE
2+
test_parseint_with_radix.class
3+
--refine-strings
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[.*assertion.1\].* line 8.* SUCCESS$
7+
^\[.*assertion.2\].* line 9.* FAILURE$
8+
^\[.*assertion.3\].* line 14.* SUCCESS$
9+
^\[.*assertion.4\].* line 15.* FAILURE$
10+
^\[.*assertion.5\].* line 20.* SUCCESS$
11+
^\[.*assertion.6\].* line 21.* FAILURE$
12+
^\[.*assertion.7\].* line 26.* SUCCESS$
13+
^\[.*assertion.8\].* line 27.* FAILURE$
14+
^\[.*assertion.9\].* line 32.* SUCCESS$
15+
^\[.*assertion.10\].* line 33.* FAILURE$
16+
--
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
public class test_parseint_with_radix
2+
{
3+
public static void main(String[] args)
4+
{
5+
if (args.length == 1) {
6+
String str1 = new String("F");
7+
int parsed1 = Integer.parseInt(str1, 16);
8+
assert(parsed1 == 15);
9+
assert(parsed1 != 15);
10+
}
11+
else if (args.length == 2) {
12+
String str2 = new String("123");
13+
int parsed2 = Integer.parseInt(str2, 10);
14+
assert(parsed2 == 123);
15+
assert(parsed2 != 123);
16+
}
17+
else if (args.length == 3) {
18+
String str3 = new String("77");
19+
int parsed3 = Integer.parseInt(str3, 8);
20+
assert(parsed3 == 63);
21+
assert(parsed3 != 63);
22+
}
23+
else if (args.length == 4) {
24+
String str4 = new String("-101");
25+
int parsed4 = Integer.parseInt(str4, 2);
26+
assert(parsed4 == -5);
27+
assert(parsed4 != -5);
28+
}
29+
else if (args.length == 5) {
30+
String str5 = new String("00aB");
31+
int parsed5 = Integer.parseInt(str5, 16);
32+
assert(parsed5 == 171);
33+
assert(parsed5 != 171);
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
KNOWNBUG
2+
test_parseint_with_radix.class
3+
--refine-strings
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[.*assertion.1\].* line 9.* SUCCESS$
7+
^\[.*assertion.2\].* line 10.* FAILURE$
8+
^\[.*assertion.3\].* line 16.* SUCCESS$
9+
^\[.*assertion.4\].* line 17.* FAILURE$
10+
--
11+
--
12+
Issue #664 is about turning these tests on
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
public class test_parseint_with_radix
2+
{
3+
public static void main(String[] args)
4+
{
5+
if (args.length == 1) {
6+
// 2^31-1, max value of Integer
7+
String str1 = new String("7FFFFFFF");
8+
int parsed1 = Integer.parseInt(str1, 16);
9+
assert(parsed1 == 2147483647);
10+
assert(parsed1 != 2147483647);
11+
}
12+
else if (args.length == 2) {
13+
// -2^31, min value of Integer, and longest string we could have
14+
String str2 = new String("-100000000000000000000000000000000");
15+
int parsed2 = Integer.parseInt(str2, 2);
16+
assert(parsed2 == -2147483648);
17+
assert(parsed2 != -2147483648);
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)