@@ -33,6 +33,12 @@ public void testDouble() throws IOException {
3333strategy .readNumber (fromString ("1e400" ));
3434fail ();
3535 }catch (MalformedJsonException expected ) {
36+ assertEquals ("JSON forbids NaN and infinities: Infinity at line 1 column 6 path $" ,expected .getMessage ());
37+ }
38+ try {
39+ strategy .readNumber (fromString ("\" not-a-number\" " ));
40+ fail ();
41+ }catch (NumberFormatException expected ) {
3642 }
3743 }
3844
@@ -52,24 +58,35 @@ public void testLongOrDouble() throws IOException {
5258strategy .readNumber (fromString ("1e400" ));
5359fail ();
5460 }catch (MalformedJsonException expected ) {
61+ assertEquals ("JSON forbids NaN and infinities: Infinity; at path $" ,expected .getMessage ());
62+ }
63+ try {
64+ strategy .readNumber (fromString ("\" not-a-number\" " ));
65+ fail ();
66+ }catch (JsonParseException expected ) {
67+ assertEquals ("Cannot parse not-a-number; at path $" ,expected .getMessage ());
5568 }
69+
5670assertEquals (Double .NaN ,strategy .readNumber (fromStringLenient ("NaN" )));
5771assertEquals (Double .POSITIVE_INFINITY ,strategy .readNumber (fromStringLenient ("Infinity" )));
5872assertEquals (Double .NEGATIVE_INFINITY ,strategy .readNumber (fromStringLenient ("-Infinity" )));
5973try {
6074strategy .readNumber (fromString ("NaN" ));
6175fail ();
6276 }catch (MalformedJsonException expected ) {
77+ assertEquals ("Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $" ,expected .getMessage ());
6378 }
6479try {
6580strategy .readNumber (fromString ("Infinity" ));
6681fail ();
6782 }catch (MalformedJsonException expected ) {
83+ assertEquals ("Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $" ,expected .getMessage ());
6884 }
6985try {
7086strategy .readNumber (fromString ("-Infinity" ));
7187fail ();
7288 }catch (MalformedJsonException expected ) {
89+ assertEquals ("Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $" ,expected .getMessage ());
7390 }
7491 }
7592
@@ -78,6 +95,13 @@ public void testBigDecimal() throws IOException {
7895assertEquals (new BigDecimal ("10.1" ),strategy .readNumber (fromString ("10.1" )));
7996assertEquals (new BigDecimal ("3.141592653589793238462643383279" ),strategy .readNumber (fromString ("3.141592653589793238462643383279" )));
8097assertEquals (new BigDecimal ("1e400" ),strategy .readNumber (fromString ("1e400" )));
98+
99+ try {
100+ strategy .readNumber (fromString ("\" not-a-number\" " ));
101+ fail ();
102+ }catch (JsonParseException expected ) {
103+ assertEquals ("Cannot parse not-a-number; at path $" ,expected .getMessage ());
104+ }
81105 }
82106
83107public void testNullsAreNeverExpected ()throws IOException {