< prev index next >
test/jdk/java/text/Format/CompactNumberFormat/CompactFormatAndParseHelper.java
Print this page
rev 60594 : [mq]: 8251499
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2020, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -19,15 +19,14 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-import java.math.BigDecimal;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.ParsePosition;
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertEquals;
class CompactFormatAndParseHelper {
static void testFormat(NumberFormat cnf, Object number,
String expected) {
@@ -45,24 +44,13 @@
} else {
number = cnf.parse(parseString, position);
}
if (returnType != null) {
- assertEquals(number.getClass(), returnType, "Incorrect return type for string" + parseString);
+ assertEquals(number.getClass(), returnType,
+ "Incorrect return type for string '" + parseString + "'");
}
- if (number instanceof Double) {
- assertEquals(number.doubleValue(), (double) expected,
- "Incorrect parsing of the string '" + parseString + "'");
- } else if (number instanceof Long) {
- assertEquals(number.longValue(), (long) expected,
- "Incorrect parsing of the string '" + parseString + "'");
- } else if (number instanceof BigDecimal) {
- BigDecimal num = (BigDecimal) number;
- assertEquals(num, (BigDecimal) expected,
- "Incorrect parsing of the string '" + parseString + "'");
- } else {
assertEquals(number, expected, "Incorrect parsing of the string '"
+ parseString + "'");
}
- }
}
< prev index next >