1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 07:50:52 -07:00

Merge pull request #86 from strkkk/add-isEmpty-method-usage

add usage of isEmpty method
This commit is contained in:
Sean Leary 2018-05-26 09:55:41 -05:00 committed by GitHub
commit dedb044f67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 17 deletions

View file

@ -65,7 +65,7 @@ public class CookieListTest {
public void emptyStringCookieList() { public void emptyStringCookieList() {
String cookieStr = ""; String cookieStr = "";
JSONObject jsonObject = CookieList.toJSONObject(cookieStr); JSONObject jsonObject = CookieList.toJSONObject(cookieStr);
assertTrue(jsonObject.length() == 0); assertTrue(jsonObject.isEmpty());
} }
/** /**

View file

@ -35,7 +35,7 @@ public class EnumTest {
// If there are no getters then the object is empty. // If there are no getters then the object is empty.
MyEnum myEnum = MyEnum.VAL2; MyEnum myEnum = MyEnum.VAL2;
JSONObject jsonObject = new JSONObject(myEnum); JSONObject jsonObject = new JSONObject(myEnum);
assertTrue("simple enum has no getters", jsonObject.length() == 0); assertTrue("simple enum has no getters", jsonObject.isEmpty());
// enum with a getters should create a non-empty object // enum with a getters should create a non-empty object
MyEnumField myEnumField = MyEnumField.VAL2; MyEnumField myEnumField = MyEnumField.VAL2;

View file

@ -691,7 +691,7 @@ public class JSONArrayTest {
JSONArray jsonArray = new JSONArray(arrayStr1); JSONArray jsonArray = new JSONArray(arrayStr1);
jsonArray.remove(0); jsonArray.remove(0);
assertTrue("array should be empty", null == jsonArray.remove(5)); assertTrue("array should be empty", null == jsonArray.remove(5));
assertTrue("jsonArray should be empty", jsonArray.length() == 0); assertTrue("jsonArray should be empty", jsonArray.isEmpty());
} }
/** /**

View file

@ -141,7 +141,7 @@ public class JSONObjectTest {
@Test @Test
public void emptyJsonObject() { public void emptyJsonObject() {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
assertTrue("jsonObject should be empty", jsonObject.length() == 0); assertTrue("jsonObject should be empty", jsonObject.isEmpty());
} }
/** /**
@ -184,7 +184,7 @@ public class JSONObjectTest {
public void jsonObjectByNullMap() { public void jsonObjectByNullMap() {
Map<String, Object> map = null; Map<String, Object> map = null;
JSONObject jsonObject = new JSONObject(map); JSONObject jsonObject = new JSONObject(map);
assertTrue("jsonObject should be empty", jsonObject.length() == 0); assertTrue("jsonObject should be empty", jsonObject.isEmpty());
} }
/** /**
@ -1122,7 +1122,7 @@ public class JSONObjectTest {
BigDecimal bigDecimal = new BigDecimal( BigDecimal bigDecimal = new BigDecimal(
"123456789012345678901234567890.12345678901234567890123456789"); "123456789012345678901234567890.12345678901234567890123456789");
jsonObject = new JSONObject(bigDecimal); jsonObject = new JSONObject(bigDecimal);
assertTrue("large bigDecimal is not stored", jsonObject.length() == 0); assertTrue("large bigDecimal is not stored", jsonObject.isEmpty());
/** /**
* JSONObject put(String, Object) method stores and serializes * JSONObject put(String, Object) method stores and serializes
@ -2244,11 +2244,11 @@ public class JSONObjectTest {
public void jsonObjectPutOnceNull() { public void jsonObjectPutOnceNull() {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.putOnce(null, null); jsonObject.putOnce(null, null);
assertTrue("jsonObject should be empty", jsonObject.length() == 0); assertTrue("jsonObject should be empty", jsonObject.isEmpty());
jsonObject.putOnce("", null); jsonObject.putOnce("", null);
assertTrue("jsonObject should be empty", jsonObject.length() == 0); assertTrue("jsonObject should be empty", jsonObject.isEmpty());
jsonObject.putOnce(null, ""); jsonObject.putOnce(null, "");
assertTrue("jsonObject should be empty", jsonObject.length() == 0); assertTrue("jsonObject should be empty", jsonObject.isEmpty());
} }
/** /**
@ -2424,11 +2424,11 @@ public class JSONObjectTest {
String str = "{\"myKey\": \"myval\"}"; String str = "{\"myKey\": \"myval\"}";
JSONObject jsonObjectRemove = new JSONObject(str); JSONObject jsonObjectRemove = new JSONObject(str);
jsonObjectRemove.remove("myKey"); jsonObjectRemove.remove("myKey");
assertEquals("jsonObject should be empty",0 ,jsonObjectRemove.length()); assertTrue("jsonObject should be empty", jsonObjectRemove.isEmpty());
JSONObject jsonObjectPutNull = new JSONObject(str); JSONObject jsonObjectPutNull = new JSONObject(str);
jsonObjectPutNull.put("myKey", (Object) null); jsonObjectPutNull.put("myKey", (Object) null);
assertEquals("jsonObject should be empty",0 ,jsonObjectPutNull.length()); assertTrue("jsonObject should be empty", jsonObjectPutNull.isEmpty());
} }

View file

@ -21,7 +21,7 @@ public class PropertyTest {
public void shouldHandleNullProperties() { public void shouldHandleNullProperties() {
Properties properties = null; Properties properties = null;
JSONObject jsonObject = Property.toJSONObject(properties); JSONObject jsonObject = Property.toJSONObject(properties);
assertTrue("jsonObject should be empty", jsonObject.length() == 0); assertTrue("jsonObject should be empty", jsonObject.isEmpty());
} }
/** /**
@ -32,7 +32,7 @@ public class PropertyTest {
public void shouldHandleEmptyProperties() { public void shouldHandleEmptyProperties() {
Properties properties = new Properties(); Properties properties = new Properties();
JSONObject jsonObject = Property.toJSONObject(properties); JSONObject jsonObject = Property.toJSONObject(properties);
assertTrue("jsonObject should be empty", jsonObject.length() == 0); assertTrue("jsonObject should be empty", jsonObject.isEmpty());
} }
/** /**

View file

@ -34,7 +34,7 @@ public class XMLTest {
public void shouldHandleNullXML() { public void shouldHandleNullXML() {
String xmlStr = null; String xmlStr = null;
JSONObject jsonObject = XML.toJSONObject(xmlStr); JSONObject jsonObject = XML.toJSONObject(xmlStr);
assertTrue("jsonObject should be empty", jsonObject.length() == 0); assertTrue("jsonObject should be empty", jsonObject.isEmpty());
} }
/** /**
@ -45,7 +45,7 @@ public class XMLTest {
String xmlStr = ""; String xmlStr = "";
JSONObject jsonObject = XML.toJSONObject(xmlStr); JSONObject jsonObject = XML.toJSONObject(xmlStr);
assertTrue("jsonObject should be empty", jsonObject.length() == 0); assertTrue("jsonObject should be empty", jsonObject.isEmpty());
} }
/** /**
@ -55,7 +55,7 @@ public class XMLTest {
public void shouldHandleNonXML() { public void shouldHandleNonXML() {
String xmlStr = "{ \"this is\": \"not xml\"}"; String xmlStr = "{ \"this is\": \"not xml\"}";
JSONObject jsonObject = XML.toJSONObject(xmlStr); JSONObject jsonObject = XML.toJSONObject(xmlStr);
assertTrue("xml string should be empty", jsonObject.length() == 0); assertTrue("xml string should be empty", jsonObject.isEmpty());
} }
/** /**
@ -200,7 +200,7 @@ public class XMLTest {
public void shouldHandleEmptyJSONXML() { public void shouldHandleEmptyJSONXML() {
JSONObject jsonObject= new JSONObject(); JSONObject jsonObject= new JSONObject();
String xmlStr = XML.toString(jsonObject); String xmlStr = XML.toString(jsonObject);
assertTrue("xml string should be empty", xmlStr.length() == 0); assertTrue("xml string should be empty", xmlStr.isEmpty());
} }
/** /**