mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
90.9% coverage
This commit is contained in:
parent
c4d9a9c5f9
commit
6a2c974581
1 changed files with 0 additions and 38 deletions
|
@ -650,39 +650,6 @@ public class JSONObjectTest {
|
||||||
// TODO test wrap(package)
|
// TODO test wrap(package)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void jsonObjectEquals() {
|
|
||||||
String str =
|
|
||||||
"{"+
|
|
||||||
"\"trueKey\":true,"+
|
|
||||||
"\"falseKey\":false,"+
|
|
||||||
"\"arrayKey\":[0,1,2],"+
|
|
||||||
"\"objectKey\":{"+
|
|
||||||
"\"myKey1\":\"myVal1\","+
|
|
||||||
"\"myKey2\":\"myVal2\","+
|
|
||||||
"\"myKey3\":\"myVal3\","+
|
|
||||||
"\"myKey4\":\"myVal4\""+
|
|
||||||
"}"+
|
|
||||||
"}";
|
|
||||||
String diffStr =
|
|
||||||
"{"+
|
|
||||||
"\"arrayKey\":[0]"+
|
|
||||||
"}";
|
|
||||||
JSONObject jsonObject = new JSONObject(str);
|
|
||||||
JSONObject otherJsonObject = new JSONObject(str);
|
|
||||||
JSONObject unequalJsonObject = new JSONObject(diffStr);
|
|
||||||
assertTrue("equal JSONObjects should be equal",
|
|
||||||
jsonObject.equals(otherJsonObject));
|
|
||||||
assertTrue("unequal JSONObjects should not be equal",
|
|
||||||
!jsonObject.equals(unequalJsonObject));
|
|
||||||
|
|
||||||
// make sure hashcode returns some interesting value
|
|
||||||
assertTrue("equal JSONObjects should have equal hashCode",
|
|
||||||
jsonObject.hashCode() == otherJsonObject.hashCode());
|
|
||||||
assertTrue("unequal JSONObjects should have unequal hashCode",
|
|
||||||
jsonObject.hashCode() != unequalJsonObject.hashCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonObjectParsingErrors() {
|
public void jsonObjectParsingErrors() {
|
||||||
int tryCount = 0;
|
int tryCount = 0;
|
||||||
|
@ -869,13 +836,8 @@ public class JSONObjectTest {
|
||||||
public void equals() {
|
public void equals() {
|
||||||
String str = "{\"key\":\"value\"}";
|
String str = "{\"key\":\"value\"}";
|
||||||
JSONObject aJsonObject = new JSONObject(str);
|
JSONObject aJsonObject = new JSONObject(str);
|
||||||
JSONObject bJsonObject = new JSONObject(str);
|
|
||||||
assertTrue("Same JSONObject should be equal to itself",
|
assertTrue("Same JSONObject should be equal to itself",
|
||||||
aJsonObject.equals(aJsonObject));
|
aJsonObject.equals(aJsonObject));
|
||||||
assertTrue("JSONObjects with equal content should be equal",
|
|
||||||
aJsonObject.equals(bJsonObject));
|
|
||||||
assertTrue("JSONObjects should not be equal to non J",
|
|
||||||
!aJsonObject.equals(new String()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue