File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
main/java/com/google/gson/stream
test/java/com/google/gson/stream Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -728,7 +728,7 @@ private int peekNumber() throws IOException {
728728 }
729729
730730 // We've read a complete number. Decide if it's a PEEKED_LONG or a PEEKED_NUMBER.
731- if (last == NUMBER_CHAR_DIGIT && fitsInLong && (value != Long .MIN_VALUE || negative )) {
731+ if (last == NUMBER_CHAR_DIGIT && fitsInLong && (value != Long .MIN_VALUE || negative ) && ( value != 0 || false == negative ) ) {
732732 peekedLong = negative ? value : -value ;
733733 pos += i ;
734734 return peeked = PEEKED_LONG ;
Original file line number Diff line number Diff line change @@ -560,6 +560,18 @@ public void testLongLargerThanMinLongThatWrapsAround() throws IOException {
560560 } catch (NumberFormatException expected ) {
561561 }
562562 }
563+
564+ /**
565+ * Issue 1053, negative zero.
566+ * @throws Exception
567+ */
568+ public void testNegativeZero () throws Exception {
569+ JsonReader reader = new JsonReader (reader ("[-0]" ));
570+ reader .setLenient (false );
571+ reader .beginArray ();
572+ assertEquals (NUMBER , reader .peek ());
573+ assertEquals ("-0" , reader .nextString ());
574+ }
563575
564576 /**
565577 * This test fails because there's no double for 9223372036854775808, and our
You can’t perform that action at this time.
0 commit comments