You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "nhung.nnguyen (JIRA)" <ji...@apache.org> on 2006/10/14 04:47:53 UTC
[jira] Commented: (MATH-42) [math] Function "Fraction
math.fraction.FractionFormat.parse(String, ParsePosition) " does not handle
parsing the numerater properly
[ http://issues.apache.org/jira/browse/MATH-42?page=comments#action_12442135 ]
nhung.nnguyen commented on MATH-42:
-----------------------------------
[[ Old comment, sent by email on Mon, 5 Jun 2006 23:54:56 -0500 ]]
Hi,
Thanks to let me know.
Have a good night, and best regards,
Nhung
> [math] Function "Fraction math.fraction.FractionFormat.parse(String, ParsePosition) " does not handle parsing the numerater properly
> ------------------------------------------------------------------------------------------------------------------------------------
>
> Key: MATH-42
> URL: http://issues.apache.org/jira/browse/MATH-42
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 1.1 Final
> Environment: Operating System: other
> Platform: Other
> Reporter: nhung.nnguyen
>
> Hello,
> While testing function "Fraction math.fraction.FractionFormat.parse(String,
> ParsePosition) ", I found it did not handle properly the case the input string
> passed in is incorrect.
> When I passed in a String that represented a Fraction to be parsed, if the
> Fraction embedded in the String had a whole value, while either the numerator
> or denominator had the negative sign, the function just returned
> 1/abs(denomitator).
> Please see the following code segment for more details:
> "
> NumberFormat nf = null;
>
> FractionFormat properFormat = FractionFormat.getProperInstance
> (Locale.getDefault());
> FractionFormat improperFormat = FractionFormat.getImproperInstance
> (Locale.getDefault());
>
> //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 provides negative numerator or negative
> denominator while there is the whole value.
> Thank you!
> Nhung
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org