8327261: Parsing test for Double/Float succeeds w/o testing all bad cases
Reviewed-by: darcy, gli, joehw, jlu, bpb, lancea
This commit is contained in:
parent
08b03a329f
commit
9f7094079b
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -556,24 +556,21 @@ public class ParseDouble {
|
|||||||
*/
|
*/
|
||||||
private static void testParsing(String [] input,
|
private static void testParsing(String [] input,
|
||||||
boolean exceptionalInput) {
|
boolean exceptionalInput) {
|
||||||
for(int i = 0; i < input.length; i++) {
|
for (String s : input) {
|
||||||
double d;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
d = Double.parseDouble(input[i]);
|
Double.parseDouble(s);
|
||||||
check(input[i]);
|
check(s);
|
||||||
}
|
} catch (NumberFormatException e) {
|
||||||
catch (NumberFormatException e) {
|
if (!exceptionalInput) {
|
||||||
if (! exceptionalInput) {
|
|
||||||
throw new RuntimeException("Double.parseDouble rejected " +
|
throw new RuntimeException("Double.parseDouble rejected " +
|
||||||
"good string `" + input[i] +
|
"good string `" + s +
|
||||||
"'.");
|
"'.");
|
||||||
}
|
}
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
if (exceptionalInput) {
|
if (exceptionalInput) {
|
||||||
throw new RuntimeException("Double.parseDouble accepted " +
|
throw new RuntimeException("Double.parseDouble accepted " +
|
||||||
"bad string `" + input[i] +
|
"bad string `" + s +
|
||||||
"'.");
|
"'.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -276,24 +276,21 @@ public class ParseFloat {
|
|||||||
*/
|
*/
|
||||||
private static void testParsing(String [] input,
|
private static void testParsing(String [] input,
|
||||||
boolean exceptionalInput) {
|
boolean exceptionalInput) {
|
||||||
for(int i = 0; i < input.length; i++) {
|
for (String s : input) {
|
||||||
double d;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
d = Float.parseFloat(input[i]);
|
Float.parseFloat(s);
|
||||||
check(input[i]);
|
check(s);
|
||||||
}
|
} catch (NumberFormatException e) {
|
||||||
catch (NumberFormatException e) {
|
if (!exceptionalInput) {
|
||||||
if (! exceptionalInput) {
|
|
||||||
throw new RuntimeException("Float.parseFloat rejected " +
|
throw new RuntimeException("Float.parseFloat rejected " +
|
||||||
"good string `" + input[i] +
|
"good string `" + s +
|
||||||
"'.");
|
"'.");
|
||||||
}
|
}
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
if (exceptionalInput) {
|
if (exceptionalInput) {
|
||||||
throw new RuntimeException("Float.parseFloat accepted " +
|
throw new RuntimeException("Float.parseFloat accepted " +
|
||||||
"bad string `" + input[i] +
|
"bad string `" + s +
|
||||||
"'.");
|
"'.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user