-
Notifications
You must be signed in to change notification settings - Fork 122
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
don't parse multiple degree symbols and be more flexible in whitespace when parsing temperature #190
don't parse multiple degree symbols and be more flexible in whitespace when parsing temperature #190
Changes from 4 commits
08735c1
a966935
6fa21b6
63369fe
6687a57
6affa29
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 |
---|---|---|
|
@@ -55,6 +55,18 @@ class TemperatureSpec extends FlatSpec with Matchers { | |
Temperature("ZZ F").failed.get should be(QuantityParseException("Unable to parse Temperature", "ZZ F")) | ||
} | ||
|
||
they should "be flexible in parsing strings with regard to degree symbol and whitespace" in { | ||
Temperature("10.22 f").get should be (Fahrenheit(10.22)) | ||
Temperature("10.22 °f").get should be (Fahrenheit(10.22)) | ||
Temperature("10.22 °f").get should be (Fahrenheit(10.22)) | ||
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. I guess this is ok though I can imagine somebody arguing that we should only allow one format. How is this for other units? do we allow e.g. 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. We already allow this syntax with the current Temperature parsing regex. I was just adding tests to make sure I didn't break anything while I was changing the regex. 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. Excellent 👍 |
||
Temperature("10.22 ° f").get should be (Fahrenheit(10.22)) | ||
Temperature("10.22 ° f").get should be (Fahrenheit(10.22)) | ||
Temperature("10.22 ° f").get should be (Fahrenheit(10.22)) | ||
Temperature("10.22°f").get should be (Fahrenheit(10.22)) | ||
|
||
Temperature("10.22°°f").failed.get should be (QuantityParseException("Unable to parse Temperature", "10.22°°f")) | ||
} | ||
|
||
they should "properly convert to all supported Units of Measure (Scale)" in { | ||
val x = Kelvin(0) | ||
x.toKelvinScale should be(0) | ||
|
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.
For consistency, I suggest one of the following:
[ ]*°?[ ]*
*°? *
[\\p{Zs}\\t]*°?[\\p{Zs}\\t]*
(See http://www.fileformat.info/info/unicode/category/Zs/list.htm for the meaning of
\p{Zs}
)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.
Ok this is addressed in the latest version.