Skip to content

Commit

Permalink
Added a test for various literals
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitribouniol committed Apr 18, 2021
1 parent ce5fdde commit 860576f
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Tests/DynamicCodableTests/DynamicCodableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,50 @@ final class DynamicCodableTests: XCTestCase {
XCTAssertEqual(test[.int(2)], .int(2))
}

func testLiterals() {
let test: DynamicCodable = nil
XCTAssertEqual(test, .nil) // Make sure XCTAssertEqual doesn't mis-interpret nil

XCTAssertEqual(DynamicCodable.int(5), 5)
XCTAssertEqual(DynamicCodable.float64(5.5), 5.5)
XCTAssertEqual(DynamicCodable.bool(true), true)
XCTAssertEqual(DynamicCodable.bool(false), false)
XCTAssertEqual(DynamicCodable.string("A"), "A")
XCTAssertEqual(DynamicCodable.string("1"), "\(1)")
XCTAssertEqual(
DynamicCodable.unkeyed(
[
.empty,
.nil,
.bool(true),
.int(5),
.float64(5.5),
.string("A")
]
), [
.empty,
nil,
true,
5,
5.5,
"A"
]
)
XCTAssertEqual(
DynamicCodable.keyed(
[
.string("A"): .string("A"),
.int(1): .int(1),
.string("1"): .string("2")
]
), [
"A": "A",
1: 1,
"1": "2"
]
)
}

func testPrimitiveDecoding() {
do {
let data = """
Expand Down

0 comments on commit 860576f

Please sign in to comment.