negative zero test and fix (#1069)
This commit is contained in:
parent
41e48f7aa3
commit
9a2421997e
@ -728,7 +728,7 @@ public class JsonReader implements Closeable {
|
||||
}
|
||||
|
||||
// We've read a complete number. Decide if it's a PEEKED_LONG or a PEEKED_NUMBER.
|
||||
if (last == NUMBER_CHAR_DIGIT && fitsInLong && (value != Long.MIN_VALUE || negative)) {
|
||||
if (last == NUMBER_CHAR_DIGIT && fitsInLong && (value != Long.MIN_VALUE || negative) && (value!=0 || false==negative)) {
|
||||
peekedLong = negative ? value : -value;
|
||||
pos += i;
|
||||
return peeked = PEEKED_LONG;
|
||||
|
@ -561,6 +561,18 @@ public final class JsonReaderTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue 1053, negative zero.
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testNegativeZero() throws Exception {
|
||||
JsonReader reader = new JsonReader(reader("[-0]"));
|
||||
reader.setLenient(false);
|
||||
reader.beginArray();
|
||||
assertEquals(NUMBER, reader.peek());
|
||||
assertEquals("-0", reader.nextString());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test fails because there's no double for 9223372036854775808, and our
|
||||
* long parsing uses Double.parseDouble() for fractional values.
|
||||
|
Loading…
Reference in New Issue
Block a user