Skip to content

Commit

Permalink
Add test to DefaultFalse when key is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
serjooo committed Feb 15, 2020
1 parent bef95eb commit 740ee09
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Tests/BetterCodableTests/DefaultFalseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ class DefaultFalseTests: XCTestCase {
let fixture = try JSONDecoder().decode(Fixture.self, from: jsonData)
XCTAssertEqual(fixture.truthy, false)
}

func testDecodingKeyNotPresentDefaultsToFalse() throws {
let jsonData = #"{}"#.data(using: .utf8)!
let fixture = try JSONDecoder().decode(Fixture.self, from: jsonData)
XCTAssertEqual(fixture.truthy, false)
}

func testEncodingDecodedFailableArrayDefaultsToEmptyArray() throws {
let jsonData = #"{ "truthy": null }"#.data(using: .utf8)!
Expand Down

0 comments on commit 740ee09

Please sign in to comment.