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.
|
||||
*
|
||||
* 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,
|
||||
boolean exceptionalInput) {
|
||||
for(int i = 0; i < input.length; i++) {
|
||||
double d;
|
||||
|
||||
for (String s : input) {
|
||||
try {
|
||||
d = Double.parseDouble(input[i]);
|
||||
check(input[i]);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
if (! exceptionalInput) {
|
||||
Double.parseDouble(s);
|
||||
check(s);
|
||||
} catch (NumberFormatException e) {
|
||||
if (!exceptionalInput) {
|
||||
throw new RuntimeException("Double.parseDouble rejected " +
|
||||
"good string `" + input[i] +
|
||||
"good string `" + s +
|
||||
"'.");
|
||||
}
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
if (exceptionalInput) {
|
||||
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.
|
||||
*
|
||||
* 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,
|
||||
boolean exceptionalInput) {
|
||||
for(int i = 0; i < input.length; i++) {
|
||||
double d;
|
||||
|
||||
for (String s : input) {
|
||||
try {
|
||||
d = Float.parseFloat(input[i]);
|
||||
check(input[i]);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
if (! exceptionalInput) {
|
||||
Float.parseFloat(s);
|
||||
check(s);
|
||||
} catch (NumberFormatException e) {
|
||||
if (!exceptionalInput) {
|
||||
throw new RuntimeException("Float.parseFloat rejected " +
|
||||
"good string `" + input[i] +
|
||||
"good string `" + s +
|
||||
"'.");
|
||||
}
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
if (exceptionalInput) {
|
||||
throw new RuntimeException("Float.parseFloat accepted " +
|
||||
"bad string `" + input[i] +
|
||||
"bad string `" + s +
|
||||
"'.");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user