mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
Adds testing for -0 with optNumber
This commit is contained in:
parent
1967bee236
commit
cfe6851d8c
1 changed files with 74 additions and 36 deletions
|
@ -5,6 +5,7 @@ import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -514,7 +515,7 @@ public class JSONObjectTest {
|
||||||
// include an unsupported object for coverage
|
// include an unsupported object for coverage
|
||||||
try {
|
try {
|
||||||
jsonObject.accumulate("myArray", Double.NaN);
|
jsonObject.accumulate("myArray", Double.NaN);
|
||||||
assertTrue("Expected exception", false);
|
fail("Expected exception");
|
||||||
} catch (JSONException ignored) {}
|
} catch (JSONException ignored) {}
|
||||||
|
|
||||||
// validate JSON
|
// validate JSON
|
||||||
|
@ -545,7 +546,7 @@ public class JSONObjectTest {
|
||||||
// include an unsupported object for coverage
|
// include an unsupported object for coverage
|
||||||
try {
|
try {
|
||||||
jsonObject.append("myArray", Double.NaN);
|
jsonObject.append("myArray", Double.NaN);
|
||||||
assertTrue("Expected exception", false);
|
fail("Expected exception");
|
||||||
} catch (JSONException ignored) {}
|
} catch (JSONException ignored) {}
|
||||||
|
|
||||||
// validate JSON
|
// validate JSON
|
||||||
|
@ -595,6 +596,9 @@ public class JSONObjectTest {
|
||||||
"\"longStrKey\":\"987654321098765432\","+
|
"\"longStrKey\":\"987654321098765432\","+
|
||||||
"\"doubleKey\":-23.45e7,"+
|
"\"doubleKey\":-23.45e7,"+
|
||||||
"\"doubleStrKey\":\"00001.000\","+
|
"\"doubleStrKey\":\"00001.000\","+
|
||||||
|
"\"BigDecimalStrKey\":\"19007199254740993.35481234487103587486413587843213584\","+
|
||||||
|
"\"negZeroKey\":-0.0,"+
|
||||||
|
"\"negZeroStrKey\":\"-0.0\","+
|
||||||
"\"arrayKey\":[0,1,2],"+
|
"\"arrayKey\":[0,1,2],"+
|
||||||
"\"objectKey\":{\"myKey\":\"myVal\"}"+
|
"\"objectKey\":{\"myKey\":\"myVal\"}"+
|
||||||
"}";
|
"}";
|
||||||
|
@ -611,10 +615,26 @@ public class JSONObjectTest {
|
||||||
jsonObject.getDouble("doubleKey") == -23.45e7);
|
jsonObject.getDouble("doubleKey") == -23.45e7);
|
||||||
assertTrue("doubleStrKey should be double",
|
assertTrue("doubleStrKey should be double",
|
||||||
jsonObject.getDouble("doubleStrKey") == 1);
|
jsonObject.getDouble("doubleStrKey") == 1);
|
||||||
|
assertTrue("doubleKey can be float",
|
||||||
|
jsonObject.getFloat("doubleKey") == -23.45e7f);
|
||||||
|
assertTrue("doubleStrKey can be float",
|
||||||
|
jsonObject.getFloat("doubleStrKey") == 1f);
|
||||||
assertTrue("opt doubleKey should be double",
|
assertTrue("opt doubleKey should be double",
|
||||||
jsonObject.optDouble("doubleKey") == -23.45e7);
|
jsonObject.optDouble("doubleKey") == -23.45e7);
|
||||||
assertTrue("opt doubleKey with Default should be double",
|
assertTrue("opt doubleKey with Default should be double",
|
||||||
jsonObject.optDouble("doubleStrKey", Double.NaN) == 1);
|
jsonObject.optDouble("doubleStrKey", Double.NaN) == 1);
|
||||||
|
assertTrue("opt negZeroKey should be double",
|
||||||
|
Double.compare(jsonObject.optDouble("negZeroKey"), -0.0d) == 0);
|
||||||
|
assertTrue("opt negZeroStrKey with Default should be double",
|
||||||
|
Double.compare(jsonObject.optDouble("negZeroStrKey"), -0.0d) == 0);
|
||||||
|
assertTrue("optNumber negZeroKey should return Double",
|
||||||
|
jsonObject.optNumber("negZeroKey") instanceof Double);
|
||||||
|
assertTrue("optNumber negZeroStrKey should return Double",
|
||||||
|
jsonObject.optNumber("negZeroStrKey") instanceof Double);
|
||||||
|
assertTrue("optNumber negZeroKey should be -0.0",
|
||||||
|
Double.compare(jsonObject.optNumber("negZeroKey").doubleValue(), -0.0d) == 0);
|
||||||
|
assertTrue("optNumber negZeroStrKey should be -0.0",
|
||||||
|
Double.compare(jsonObject.optNumber("negZeroStrKey").doubleValue(), -0.0d) == 0);
|
||||||
assertTrue("optFloat doubleKey should be float",
|
assertTrue("optFloat doubleKey should be float",
|
||||||
jsonObject.optFloat("doubleKey") == -23.45e7f);
|
jsonObject.optFloat("doubleKey") == -23.45e7f);
|
||||||
assertTrue("optFloat doubleKey with Default should be float",
|
assertTrue("optFloat doubleKey with Default should be float",
|
||||||
|
@ -641,12 +661,14 @@ public class JSONObjectTest {
|
||||||
jsonObject.optNumber("longKey") instanceof Long);
|
jsonObject.optNumber("longKey") instanceof Long);
|
||||||
assertTrue("optNumber double should return Double",
|
assertTrue("optNumber double should return Double",
|
||||||
jsonObject.optNumber("doubleKey") instanceof Double);
|
jsonObject.optNumber("doubleKey") instanceof Double);
|
||||||
assertTrue("optNumber Str int should return BigDecimal",
|
assertTrue("optNumber Str int should return Integer",
|
||||||
jsonObject.optNumber("intStrKey") instanceof BigDecimal);
|
jsonObject.optNumber("intStrKey") instanceof Integer);
|
||||||
assertTrue("optNumber Str long should return BigDecimal",
|
assertTrue("optNumber Str long should return Long",
|
||||||
jsonObject.optNumber("longStrKey") instanceof BigDecimal);
|
jsonObject.optNumber("longStrKey") instanceof Long);
|
||||||
assertTrue("optNumber Str double should return BigDecimal",
|
assertTrue("optNumber Str double should return Double",
|
||||||
jsonObject.optNumber("doubleStrKey") instanceof BigDecimal);
|
jsonObject.optNumber("doubleStrKey") instanceof Double);
|
||||||
|
assertTrue("optNumber BigDecimalStrKey should return BigDecimal",
|
||||||
|
jsonObject.optNumber("BigDecimalStrKey") instanceof BigDecimal);
|
||||||
assertTrue("xKey should not exist",
|
assertTrue("xKey should not exist",
|
||||||
jsonObject.isNull("xKey"));
|
jsonObject.isNull("xKey"));
|
||||||
assertTrue("stringKey should exist",
|
assertTrue("stringKey should exist",
|
||||||
|
@ -804,14 +826,14 @@ public class JSONObjectTest {
|
||||||
JSONObject jsonObject = new JSONObject(str);
|
JSONObject jsonObject = new JSONObject(str);
|
||||||
try {
|
try {
|
||||||
jsonObject.getBoolean("nonKey");
|
jsonObject.getBoolean("nonKey");
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("expecting an exception message",
|
assertTrue("expecting an exception message",
|
||||||
"JSONObject[\"nonKey\"] not found.".equals(e.getMessage()));
|
"JSONObject[\"nonKey\"] not found.".equals(e.getMessage()));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
jsonObject.getBoolean("stringKey");
|
jsonObject.getBoolean("stringKey");
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("Expecting an exception message",
|
assertTrue("Expecting an exception message",
|
||||||
"JSONObject[\"stringKey\"] is not a Boolean.".
|
"JSONObject[\"stringKey\"] is not a Boolean.".
|
||||||
|
@ -819,7 +841,7 @@ public class JSONObjectTest {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
jsonObject.getString("nonKey");
|
jsonObject.getString("nonKey");
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("Expecting an exception message",
|
assertTrue("Expecting an exception message",
|
||||||
"JSONObject[\"nonKey\"] not found.".
|
"JSONObject[\"nonKey\"] not found.".
|
||||||
|
@ -827,7 +849,7 @@ public class JSONObjectTest {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
jsonObject.getString("trueKey");
|
jsonObject.getString("trueKey");
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("Expecting an exception message",
|
assertTrue("Expecting an exception message",
|
||||||
"JSONObject[\"trueKey\"] not a string.".
|
"JSONObject[\"trueKey\"] not a string.".
|
||||||
|
@ -835,7 +857,7 @@ public class JSONObjectTest {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
jsonObject.getDouble("nonKey");
|
jsonObject.getDouble("nonKey");
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("Expecting an exception message",
|
assertTrue("Expecting an exception message",
|
||||||
"JSONObject[\"nonKey\"] not found.".
|
"JSONObject[\"nonKey\"] not found.".
|
||||||
|
@ -843,7 +865,23 @@ public class JSONObjectTest {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
jsonObject.getDouble("stringKey");
|
jsonObject.getDouble("stringKey");
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
assertTrue("Expecting an exception message",
|
||||||
|
"JSONObject[\"stringKey\"] is not a number.".
|
||||||
|
equals(e.getMessage()));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
jsonObject.getFloat("nonKey");
|
||||||
|
fail("Expected an exception");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
assertTrue("Expecting an exception message",
|
||||||
|
"JSONObject[\"nonKey\"] not found.".
|
||||||
|
equals(e.getMessage()));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
jsonObject.getFloat("stringKey");
|
||||||
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("Expecting an exception message",
|
assertTrue("Expecting an exception message",
|
||||||
"JSONObject[\"stringKey\"] is not a number.".
|
"JSONObject[\"stringKey\"] is not a number.".
|
||||||
|
@ -851,7 +889,7 @@ public class JSONObjectTest {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
jsonObject.getInt("nonKey");
|
jsonObject.getInt("nonKey");
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("Expecting an exception message",
|
assertTrue("Expecting an exception message",
|
||||||
"JSONObject[\"nonKey\"] not found.".
|
"JSONObject[\"nonKey\"] not found.".
|
||||||
|
@ -859,7 +897,7 @@ public class JSONObjectTest {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
jsonObject.getInt("stringKey");
|
jsonObject.getInt("stringKey");
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("Expecting an exception message",
|
assertTrue("Expecting an exception message",
|
||||||
"JSONObject[\"stringKey\"] is not an int.".
|
"JSONObject[\"stringKey\"] is not an int.".
|
||||||
|
@ -867,7 +905,7 @@ public class JSONObjectTest {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
jsonObject.getLong("nonKey");
|
jsonObject.getLong("nonKey");
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("Expecting an exception message",
|
assertTrue("Expecting an exception message",
|
||||||
"JSONObject[\"nonKey\"] not found.".
|
"JSONObject[\"nonKey\"] not found.".
|
||||||
|
@ -875,7 +913,7 @@ public class JSONObjectTest {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
jsonObject.getLong("stringKey");
|
jsonObject.getLong("stringKey");
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("Expecting an exception message",
|
assertTrue("Expecting an exception message",
|
||||||
"JSONObject[\"stringKey\"] is not a long.".
|
"JSONObject[\"stringKey\"] is not a long.".
|
||||||
|
@ -883,7 +921,7 @@ public class JSONObjectTest {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
jsonObject.getJSONArray("nonKey");
|
jsonObject.getJSONArray("nonKey");
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("Expecting an exception message",
|
assertTrue("Expecting an exception message",
|
||||||
"JSONObject[\"nonKey\"] not found.".
|
"JSONObject[\"nonKey\"] not found.".
|
||||||
|
@ -891,7 +929,7 @@ public class JSONObjectTest {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
jsonObject.getJSONArray("stringKey");
|
jsonObject.getJSONArray("stringKey");
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("Expecting an exception message",
|
assertTrue("Expecting an exception message",
|
||||||
"JSONObject[\"stringKey\"] is not a JSONArray.".
|
"JSONObject[\"stringKey\"] is not a JSONArray.".
|
||||||
|
@ -899,7 +937,7 @@ public class JSONObjectTest {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
jsonObject.getJSONObject("nonKey");
|
jsonObject.getJSONObject("nonKey");
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("Expecting an exception message",
|
assertTrue("Expecting an exception message",
|
||||||
"JSONObject[\"nonKey\"] not found.".
|
"JSONObject[\"nonKey\"] not found.".
|
||||||
|
@ -907,7 +945,7 @@ public class JSONObjectTest {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
jsonObject.getJSONObject("stringKey");
|
jsonObject.getJSONObject("stringKey");
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("Expecting an exception message",
|
assertTrue("Expecting an exception message",
|
||||||
"JSONObject[\"stringKey\"] is not a JSONObject.".
|
"JSONObject[\"stringKey\"] is not a JSONObject.".
|
||||||
|
@ -1004,18 +1042,18 @@ public class JSONObjectTest {
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
jsonObject.getBigDecimal("bigInt");
|
jsonObject.getBigDecimal("bigInt");
|
||||||
assertTrue("expected an exeption", false);
|
fail("expected an exeption");
|
||||||
} catch (JSONException ignored) {}
|
} catch (JSONException ignored) {}
|
||||||
obj = jsonObject.optBigDecimal("bigInt", BigDecimal.ONE);
|
obj = jsonObject.optBigDecimal("bigInt", BigDecimal.ONE);
|
||||||
assertTrue("expected BigDecimal", obj.equals(BigDecimal.ONE));
|
assertTrue("expected BigDecimal", obj.equals(BigDecimal.ONE));
|
||||||
try {
|
try {
|
||||||
jsonObject.getBigInteger("bigDec");
|
jsonObject.getBigInteger("bigDec");
|
||||||
assertTrue("expected an exeption", false);
|
fail("expected an exeption");
|
||||||
} catch (JSONException ignored) {}
|
} catch (JSONException ignored) {}
|
||||||
jsonObject.put("stringKey", "abc");
|
jsonObject.put("stringKey", "abc");
|
||||||
try {
|
try {
|
||||||
jsonObject.getBigDecimal("stringKey");
|
jsonObject.getBigDecimal("stringKey");
|
||||||
assertTrue("expected an exeption", false);
|
fail("expected an exeption");
|
||||||
} catch (JSONException ignored) {}
|
} catch (JSONException ignored) {}
|
||||||
obj = jsonObject.optBigInteger("bigDec", BigInteger.ONE);
|
obj = jsonObject.optBigInteger("bigDec", BigInteger.ONE);
|
||||||
assertTrue("expected BigInteger", obj instanceof BigInteger);
|
assertTrue("expected BigInteger", obj instanceof BigInteger);
|
||||||
|
@ -1092,11 +1130,11 @@ public class JSONObjectTest {
|
||||||
jsonArray.put(Boolean.TRUE);
|
jsonArray.put(Boolean.TRUE);
|
||||||
try {
|
try {
|
||||||
jsonArray.getBigInteger(2);
|
jsonArray.getBigInteger(2);
|
||||||
assertTrue("should not be able to get big int", false);
|
fail("should not be able to get big int");
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
try {
|
try {
|
||||||
jsonArray.getBigDecimal(2);
|
jsonArray.getBigDecimal(2);
|
||||||
assertTrue("should not be able to get big dec", false);
|
fail("should not be able to get big dec");
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
assertTrue("optBigInt is default", jsonArray.optBigInteger(2, BigInteger.ONE).equals(BigInteger.ONE));
|
assertTrue("optBigInt is default", jsonArray.optBigInteger(2, BigInteger.ONE).equals(BigInteger.ONE));
|
||||||
assertTrue("optBigDec is default", jsonArray.optBigDecimal(2, BigDecimal.ONE).equals(BigDecimal.ONE));
|
assertTrue("optBigDec is default", jsonArray.optBigDecimal(2, BigDecimal.ONE).equals(BigDecimal.ONE));
|
||||||
|
@ -1851,7 +1889,7 @@ public class JSONObjectTest {
|
||||||
String str = "{\"myKey\":true, \"myOtherKey\":false}";
|
String str = "{\"myKey\":true, \"myOtherKey\":false}";
|
||||||
JSONObject jsonObject = new JSONObject(str);
|
JSONObject jsonObject = new JSONObject(str);
|
||||||
jsonObject.append("myKey", "hello");
|
jsonObject.append("myKey", "hello");
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("Expecting an exception message",
|
assertTrue("Expecting an exception message",
|
||||||
"JSONObject[myKey] is not a JSONArray.".
|
"JSONObject[myKey] is not a JSONArray.".
|
||||||
|
@ -1862,7 +1900,7 @@ public class JSONObjectTest {
|
||||||
String str = "{\"myKey\":true, \"myOtherKey\":false}";
|
String str = "{\"myKey\":true, \"myOtherKey\":false}";
|
||||||
JSONObject jsonObject = new JSONObject(str);
|
JSONObject jsonObject = new JSONObject(str);
|
||||||
jsonObject.increment("myKey");
|
jsonObject.increment("myKey");
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("Expecting an exception message",
|
assertTrue("Expecting an exception message",
|
||||||
"Unable to increment [\"myKey\"].".
|
"Unable to increment [\"myKey\"].".
|
||||||
|
@ -1873,7 +1911,7 @@ public class JSONObjectTest {
|
||||||
String str = "{\"myKey\":true, \"myOtherKey\":false}";
|
String str = "{\"myKey\":true, \"myOtherKey\":false}";
|
||||||
JSONObject jsonObject = new JSONObject(str);
|
JSONObject jsonObject = new JSONObject(str);
|
||||||
jsonObject.get(null);
|
jsonObject.get(null);
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("Expecting an exception message",
|
assertTrue("Expecting an exception message",
|
||||||
"Null key.".
|
"Null key.".
|
||||||
|
@ -1882,7 +1920,7 @@ public class JSONObjectTest {
|
||||||
try {
|
try {
|
||||||
// invalid numberToString()
|
// invalid numberToString()
|
||||||
JSONObject.numberToString((Number)null);
|
JSONObject.numberToString((Number)null);
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("Expecting an exception message",
|
assertTrue("Expecting an exception message",
|
||||||
"Null pointer".
|
"Null pointer".
|
||||||
|
@ -1892,7 +1930,7 @@ public class JSONObjectTest {
|
||||||
// null put key
|
// null put key
|
||||||
JSONObject jsonObject = new JSONObject("{}");
|
JSONObject jsonObject = new JSONObject("{}");
|
||||||
jsonObject.put(null, 0);
|
jsonObject.put(null, 0);
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (NullPointerException ignored) {
|
} catch (NullPointerException ignored) {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -1900,21 +1938,21 @@ public class JSONObjectTest {
|
||||||
JSONObject jsonObject = new JSONObject("{}");
|
JSONObject jsonObject = new JSONObject("{}");
|
||||||
jsonObject.putOnce("hello", "world");
|
jsonObject.putOnce("hello", "world");
|
||||||
jsonObject.putOnce("hello", "world!");
|
jsonObject.putOnce("hello", "world!");
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("", true);
|
assertTrue("", true);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// test validity of invalid double
|
// test validity of invalid double
|
||||||
JSONObject.testValidity(Double.NaN);
|
JSONObject.testValidity(Double.NaN);
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("", true);
|
assertTrue("", true);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// test validity of invalid float
|
// test validity of invalid float
|
||||||
JSONObject.testValidity(Float.NEGATIVE_INFINITY);
|
JSONObject.testValidity(Float.NEGATIVE_INFINITY);
|
||||||
assertTrue("Expected an exception", false);
|
fail("Expected an exception");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
assertTrue("", true);
|
assertTrue("", true);
|
||||||
}
|
}
|
||||||
|
@ -2294,7 +2332,7 @@ public class JSONObjectTest {
|
||||||
// assertTrue("should convert null to empty string", "".equals(string));
|
// assertTrue("should convert null to empty string", "".equals(string));
|
||||||
try {
|
try {
|
||||||
value = jsonObjectNull.get("key");
|
value = jsonObjectNull.get("key");
|
||||||
assertTrue("get() null should throw exception", false);
|
fail("get() null should throw exception");
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue