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

add usage of isEmpty method

This commit is contained in:
Andrei Paikin 2018-05-25 22:47:05 +03:00
parent 20d90bfb0b
commit d00501eabd
6 changed files with 17 additions and 17 deletions

View file

@ -65,7 +65,7 @@ public class CookieListTest {
public void emptyStringCookieList() {
String 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.
MyEnum myEnum = MyEnum.VAL2;
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
MyEnumField myEnumField = MyEnumField.VAL2;

View file

@ -691,7 +691,7 @@ public class JSONArrayTest {
JSONArray jsonArray = new JSONArray(arrayStr1);
jsonArray.remove(0);
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
public void emptyJsonObject() {
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() {
Map<String, Object> map = null;
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(
"123456789012345678901234567890.12345678901234567890123456789");
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
@ -2244,11 +2244,11 @@ public class JSONObjectTest {
public void jsonObjectPutOnceNull() {
JSONObject jsonObject = new JSONObject();
jsonObject.putOnce(null, null);
assertTrue("jsonObject should be empty", jsonObject.length() == 0);
assertTrue("jsonObject should be empty", jsonObject.isEmpty());
jsonObject.putOnce("", null);
assertTrue("jsonObject should be empty", jsonObject.length() == 0);
assertTrue("jsonObject should be empty", jsonObject.isEmpty());
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\"}";
JSONObject jsonObjectRemove = new JSONObject(str);
jsonObjectRemove.remove("myKey");
assertEquals("jsonObject should be empty",0 ,jsonObjectRemove.length());
assertTrue("jsonObject should be empty", jsonObjectRemove.isEmpty());
JSONObject jsonObjectPutNull = new JSONObject(str);
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() {
Properties properties = null;
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() {
Properties properties = new 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() {
String xmlStr = null;
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 = "";
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() {
String xmlStr = "{ \"this is\": \"not xml\"}";
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() {
JSONObject jsonObject= new JSONObject();
String xmlStr = XML.toString(jsonObject);
assertTrue("xml string should be empty", xmlStr.length() == 0);
assertTrue("xml string should be empty", xmlStr.isEmpty());
}
/**