-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LANG-1695: NumberUtils::isParseable does not recognise numbers ending in dot #1071
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -918,7 +918,9 @@ public void testIsParsable() { | |
assertFalse(NumberUtils.isParsable("pendro")); | ||
assertFalse(NumberUtils.isParsable("64, 2")); | ||
assertFalse(NumberUtils.isParsable("64.2.2")); | ||
assertFalse(NumberUtils.isParsable("64.")); | ||
assertTrue(NumberUtils.isParsable("64.")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add a test that 64.. is false There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @elharo sorry. My understanding of the ticket is that 64. is true i.e. parseable and valid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are right. I added a test for it |
||
assertFalse(NumberUtils.isParsable("64..")); | ||
assertTrue(NumberUtils.isParsable("-64.")); | ||
assertFalse(NumberUtils.isParsable("64L")); | ||
assertFalse(NumberUtils.isParsable("-")); | ||
assertFalse(NumberUtils.isParsable("--2")); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens in countries that flip the meaning of the comma and period?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps there could be another method that takes a Locale object. Otherwise, I don't think the current parser should concern itself with it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per current Javadoc "Parsable numbers include those Strings understood by Integer#parseInt(String), Long#parseLong(String), Float#parseFloat(String)} or Double#parseDouble(String)."
If those methods don't worry about countries that flip the meaning of the comma and period, we shouldn't do it here. That would be a breaking behavior change.
As to another method that uses Locales, that's in java.util so outside the advertised scope for commons-lang.