valueToString() and write() tests#53
Merged
stleary merged 7 commits intostleary:masterfrom Aug 11, 2016
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds some new tests for
JSONObject#valueToString()andJSONObject#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 returnsnull. Goes through cases where an exception is thrown, and where toString() also returnsnull.Also fixed up a test on
JSONStringerfor object nesting, which didn't fail where it should've.Finally,
JSONObject#toMap()andJSONArray#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.