Skip to content

Conversation

@run2000
Copy link
Contributor

@run2000 run2000 commented Jul 24, 2016

This adds some new tests for JSONObject#valueToString() and JSONObject#write() methods. These are very similar in functionality, but have a subtle case that is different when creating a string for a JSONString object that returns null. Goes through cases where an exception is thrown, and where toString() also returns null.

Also fixed up a test on JSONStringer for object nesting, which didn't fail where it should've.

Finally, JSONObject#toMap() and JSONArray#toList() get some unit test coverage.

Also find a couple of tests currently commented out. These depend on the pull request #241 on JSON-java, that replaces Writer with Appendable. These tests won't compile until that request goes in, though it will also cause one of the tests in JSONStringTest to fail.

run2000 added 7 commits July 23, 2016 19:12
Explicitly test variations of toString() and write() for different indent levels, and different method overloads. Also create some tests for the new toList() and toMap() methods for coverage improvements to JSONArray and JSONObject.
Both toMap() and toList() return deep copies, which are also mutable. That is, any changes to the JSONObject or JSONArray do not affect the newly create Map or List, and vice-versa. The resulting objects can be altered.
This set of tests demonstrates what happens when JSONString returns various results from its toJSONString() method. Tests for null returns and exceptions thrown. Also tests what happens for non-JSONString objects. The intent is to cover JSONObject's valueToString() and writeValue() methods.
The idiom was started in the first few methods, but not continued further down where JSONException was expected. False success may have resulted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants