commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 39575] New: - Function math.fraction.ProperFractionFormat.parse(String, ParsePosition) return illogical result
Date Sat, 13 May 2006 21:20:22 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39575>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39575

           Summary: Function
                    math.fraction.ProperFractionFormat.parse(String,
                    ParsePosition) return illogical result
           Product: Commons
           Version: 1.1 Final
          Platform: Other
               URL: http://jakarta.apache.org/commons/math/apidocs/org/apach
                    e/commons/math/fraction/ProperFractionFormat.html#parse(
                    java.lang.String,%20java.text.ParsePosition)
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Math
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: nhung.nnguyen@gmail.com
OtherBugsDependingO 3,4
             nThis:


Hello,

I find illogical returned result from function "Fraction parse(String source, 
ParsePostion pos)" (in class ProperFractionFormat of the Fraction Package) of 
the Commons Math library. Please see the following code segment for more 
details:

"
ProperFractionFormat properFormat = new ProperFractionFormat();
result = null;
String source = "1 -1 / 2";
ParsePosition pos = new ParsePosition(0);

//Test 1 : fail 
public void testParseNegative(){
 
   String source = "-1 -2 / 3";
   ParsePosition pos = new ParsePosition(0);

   Fraction actual = properFormat.parse(source, pos);
   assertNull(actual);
}

// Test2: success
public void testParseNegative(){
 
   String source = "-1 -2 / 3";
   ParsePosition pos = new ParsePosition(0);

   Fraction actual = properFormat.parse(source, pos);  // return Fraction 1/3
   assertEquals(1, source.getNumerator());
   assertEquals(3, source.getDenominator());
}

"

Note: Similarly, when I passed in the following inputs: 
  input 2: (source = “1 2 / -3”, pos = 0)
  input 3: ( source = ” -1 -2 / 3”, pos = 0)

Function "Fraction parse(String, ParsePosition)" returned Fraction 1/3 (means 
the result Fraction had numerator = 1 and  denominator = 3)for all 3 inputs 
above.
 
I think the function does not handle parsing the numberator/ denominator 
properly incase input string provide invalid numerator/denominator. 

Thank you!

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message