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.
|
// 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;
|
peekedLong = negative ? value : -value;
|
||||||
pos += i;
|
pos += i;
|
||||||
return peeked = PEEKED_LONG;
|
return peeked = PEEKED_LONG;
|
||||||
|
@ -560,6 +560,18 @@ public final class JsonReaderTest extends TestCase {
|
|||||||
} catch (NumberFormatException expected) {
|
} catch (NumberFormatException expected) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* This test fails because there's no double for 9223372036854775808, and our
|
||||||
|
Loading…
Reference in New Issue
Block a user