-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: crash when converting invalid JSON object (#68)
Co-authored-by: xiaoweii <[email protected]>
- Loading branch information
1 parent
be5d15c
commit 890b347
Showing
4 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
@testable import Clickstream | ||
import XCTest | ||
|
||
class ToJsonStringUtilTest: XCTestCase { | ||
func testNullObjectToJsonString() { | ||
let attr: JsonObject = [ | ||
"user": {} | ||
] | ||
XCTAssertTrue(attr.toJsonString() == "") | ||
} | ||
|
||
func testNSObjectToJsonString() { | ||
let attr: JsonObject = [ | ||
"user": NSObject() | ||
] | ||
XCTAssertTrue(attr.toJsonString() == "") | ||
} | ||
|
||
func testNanObjectToJsonString() { | ||
let attr: JsonObject = [ | ||
"doubleKey": Double.nan | ||
] | ||
XCTAssertTrue(attr.toJsonString() == "") | ||
} | ||
|
||
func testInfiniteObjectToJsonString() { | ||
let attr: JsonObject = [ | ||
"doubleKey": Double.infinity | ||
] | ||
XCTAssertTrue(attr.toJsonString() == "") | ||
} | ||
|
||
func testDateObjectToJsonString() { | ||
let attr: JsonObject = [ | ||
"dateKey": Date() | ||
] | ||
XCTAssertTrue(attr.toJsonString() == "") | ||
} | ||
} |