More number parsing improvements.
This commit is contained in:
parent
448063dde1
commit
b0a172944a
@ -658,7 +658,7 @@ public class JsonReader implements Closeable {
|
||||
}
|
||||
|
||||
if (c == -1 || !isLiteral((char) c)) {
|
||||
if (fitsInLong) {
|
||||
if (fitsInLong && (integer != Long.MIN_VALUE || negative)) {
|
||||
peekedInteger = negative ? integer : -integer;
|
||||
pos += i;
|
||||
return peeked = PEEKED_INTEGER;
|
||||
|
@ -454,6 +454,22 @@ public final class JsonReaderTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This test fails because there's no double for 9223372036854775808, and our
|
||||
* long parsing uses Double.parseDouble() for fractional values.
|
||||
*/
|
||||
public void testPeekLargerThanLongMaxValue() throws IOException {
|
||||
JsonReader reader = new JsonReader(new StringReader("[9223372036854775808]"));
|
||||
reader.setLenient(true);
|
||||
reader.beginArray();
|
||||
assertEquals(NUMBER, reader.peek());
|
||||
try {
|
||||
reader.nextLong();
|
||||
fail();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This test fails because there's no double for -9223372036854775809, and our
|
||||
* long parsing uses Double.parseDouble() for fractional values.
|
||||
|
Loading…
Reference in New Issue
Block a user