-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add test to print nested json #806
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,5 +120,28 @@ class PrintableTests: XCTestCase { | |
XCTAssertTrue(description.range(of: "\"1\":2", options: NSString.CompareOptions.caseInsensitive) != nil) | ||
XCTAssertTrue(description.range(of: "\"2\":\"two\"", options: NSString.CompareOptions.caseInsensitive) != nil) | ||
XCTAssertTrue(description.range(of: "\"3\":null", options: NSString.CompareOptions.caseInsensitive) != nil) | ||
} | ||
} | ||
|
||
func testJson() { | ||
let dictionary = ["1":2,"2":2,"three":3,"list":["aa","bb","dd"], "foo": []] as NSDictionary | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: this dictionary should format with a trailing space after |
||
let json = JSON(dictionary) | ||
guard var description = json.rawString([.castNilToNSNull: true]) else { | ||
XCTFail("could not represent dictionary") | ||
return | ||
} | ||
description = description.replacingOccurrences(of: "\n", with: "") | ||
description = description.replacingOccurrences(of: " ", with: "") | ||
|
||
let dict2 = ["json": json, "baa": "boo"] as [String: Any?] | ||
let json2 = JSON(dict2) | ||
|
||
guard var description2 = json2.rawString([.castNilToNSNull: true]) else { | ||
XCTFail("could not represent json") | ||
return | ||
} | ||
description2 = description2.replacingOccurrences(of: "\n", with: "") | ||
description2 = description2.replacingOccurrences(of: " ", with: "") | ||
XCTAssertTrue(description2.range(of: "\"json\":{", options: NSString.CompareOptions.caseInsensitive) != nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line Length Violation: Line should be 100 characters or less: currently 110 characters (line_length) |
||
XCTAssertTrue(description2.range(of: description, options: NSString.CompareOptions.caseInsensitive) != nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line Length Violation: Line should be 100 characters or less: currently 109 characters (line_length) |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)