You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by "Richard Liang (JIRA)" <ji...@apache.org> on 2006/02/20 15:11:24 UTC

[jira] Created: (HARMONY-107) java.text.DecimalFormat does not parse infinite values correctly

java.text.DecimalFormat does not parse infinite values correctly
----------------------------------------------------------------

         Key: HARMONY-107
         URL: http://issues.apache.org/jira/browse/HARMONY-107
     Project: Harmony
        Type: Bug
  Components: Classlib  
    Reporter: Richard Liang


In Java 1.4.2 Spec of java.text.DecimalFormat.parse(String, ParsePosition), it's said:
Values that cannot fit into a Long are returned as Doubles. This includes values with a fractional part, infinite values, NaN, and the value -0.0.

The test cases will fail if excuting under Harmony and pass on RI:

    //  Test whether DecimalFormat can parse Positive infinity correctly
    public void testParseInfinityBigDecimalFalse() {
        DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance();
        DecimalFormatSymbols symbols = new DecimalFormatSymbols();
        Number number = format.parse(symbols.getInfinity(), new ParsePosition(0));

        assertTrue(number instanceof Double);
        assertTrue(Double.isInfinite(number.doubleValue()));
    }

    // Test whether DecimalFormat can parse Negative infinity correctly
    public void testParseMinusInfinityBigDecimalFalse() {
        DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance();
        DecimalFormatSymbols symbols = new DecimalFormatSymbols();
        Number number = format.parse("-" + symbols.getInfinity(),
                new ParsePosition(0));

        assertTrue(number instanceof Double);
        assertTrue(Double.isInfinite(number.doubleValue()));
    }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira