mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 03:15:32 -04:00
Merge pull request #788 from hofi1/bugfix/fix-JSON-flakiness
Fix string compare unit tests
This commit is contained in:
commit
e6d37c469d
@ -762,8 +762,8 @@ public class JSONMLTest {
|
|||||||
final String xml = JSONML.toString(originalObject);
|
final String xml = JSONML.toString(originalObject);
|
||||||
final JSONObject revertedObject = JSONML.toJSONObject(xml, false);
|
final JSONObject revertedObject = JSONML.toJSONObject(xml, false);
|
||||||
final String newJson = revertedObject.toString();
|
final String newJson = revertedObject.toString();
|
||||||
assertTrue("JSON Objects are not similar",originalObject.similar(revertedObject));
|
assertTrue("JSON Objects are not similar", originalObject.similar(revertedObject));
|
||||||
assertEquals("original JSON does not equal the new JSON",originalJson, newJson);
|
assertTrue("JSON Strings are not similar", new JSONObject(originalJson).similar(new JSONObject(newJson)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// these tests do not pass for the following reasons:
|
// these tests do not pass for the following reasons:
|
||||||
|
@ -2095,7 +2095,9 @@ public class JSONObjectTest {
|
|||||||
"}";
|
"}";
|
||||||
JSONObject jsonObject = new JSONObject(jsonObjectStr);
|
JSONObject jsonObject = new JSONObject(jsonObjectStr);
|
||||||
assertTrue("jsonObject valueToString() incorrect",
|
assertTrue("jsonObject valueToString() incorrect",
|
||||||
JSONObject.valueToString(jsonObject).equals(jsonObject.toString()));
|
new JSONObject(JSONObject.valueToString(jsonObject))
|
||||||
|
.similar(new JSONObject(jsonObject.toString()))
|
||||||
|
);
|
||||||
String jsonArrayStr =
|
String jsonArrayStr =
|
||||||
"[1,2,3]";
|
"[1,2,3]";
|
||||||
JSONArray jsonArray = new JSONArray(jsonArrayStr);
|
JSONArray jsonArray = new JSONArray(jsonArrayStr);
|
||||||
@ -2106,7 +2108,8 @@ public class JSONObjectTest {
|
|||||||
map.put("key2", "val2");
|
map.put("key2", "val2");
|
||||||
map.put("key3", "val3");
|
map.put("key3", "val3");
|
||||||
assertTrue("map valueToString() incorrect",
|
assertTrue("map valueToString() incorrect",
|
||||||
jsonObject.toString().equals(JSONObject.valueToString(map)));
|
new JSONObject(jsonObject.toString())
|
||||||
|
.similar(new JSONObject(JSONObject.valueToString(map))));
|
||||||
Collection<Integer> collection = new ArrayList<Integer>();
|
Collection<Integer> collection = new ArrayList<Integer>();
|
||||||
collection.add(Integer.valueOf(1));
|
collection.add(Integer.valueOf(1));
|
||||||
collection.add(Integer.valueOf(2));
|
collection.add(Integer.valueOf(2));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user