Last active
February 28, 2016 18:27
-
-
Save marcellanz/50b52bf75266ac500467 to your computer and use it in GitHub Desktop.
CharScanner.parseJsonNumber fails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// actually used "new JsonSlurper().parseText" with | |
// [{"newValue":4.940656458412465441765687928682213723650598026143247644255856825006755072702087518652998363616359923797965646954457177309266567103559397963987747960107818781263007131903114045278458171678489821036887186360569987307230500063874091535649843873124733972731696151400317153853980741262385655911710266585566867681870395603106249319452715914924553293054565444011274801297099995419319894090804165633245247571478690147267801593552386115501348035264934720193790268107107491703332226844753335720832431936092382893458368060106011506169809753078342277318329247904982524730776375927247874656084778203734469699533647017972677717585125660551199131504891101451037862738167250955837389733598993664809941164205702637090279242767544565229087538682506419718265533447265625E-324,"oldValue":179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368,"id":"ValueChanged","attributeId":"bla","className":"org.opendolphin.core.comm.ValueChangedCommand"}] | |
// coming from org.opendolphin.core.comm.JsonCodecTest.testProperTypeEnAndDecoding | |
void testGroovyJsonNumberScanning() { | |
String maxValue0 = BigDecimal.valueOf(Double.MAX_VALUE); | |
Number number0 = CharScanner.parseJsonNumber(maxValue0.toCharArray(), 0, maxValue0.length()) | |
String maxValue1 = new BigDecimal(Double.MAX_VALUE).toString(); | |
Number number1 = CharScanner.parseJsonNumber(maxValue1.toCharArray(), 0, maxValue1.length()) | |
String maxValue2 = new BigDecimal(Double.MAX_VALUE).toString() + ".0"; // or +"e1" | |
Number number2 = CharScanner.parseJsonNumber(maxValue2.toCharArray(), 0, maxValue2.length()) | |
assert number0.doubleValue() > 0.0 | |
assert number1.doubleValue() == 0.0 | |
assert number2.doubleValue() > 0.0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment