Skip to content

Commit

Permalink
Added tests for unboxing at a specified key
Browse files Browse the repository at this point in the history
  • Loading branch information
clayellis committed Jul 20, 2016
1 parent 4802b93 commit b376eaf
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Tests/UnboxTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,42 @@ class UnboxTests: XCTestCase {
XCTFail("Unexpected error thrown: \(error)")
}
}

func testUnboxingStartingAtCustomKey() {
let dictionary: UnboxableDictionary = [
"A": [
"int": 14
]
]

do {
let unboxed: UnboxTestSimpleMock = try Unbox(dictionary, at: "A")
XCTAssertEqual(unboxed.int, 14)
} catch {
XCTFail("Unexpected error thrown: \(error)")
}
}

func testUnboxingStartingAtMissingCustomKey() {
let dictionary: UnboxableDictionary = [
"A": [
"int": 3
]
]

do {
let unboxed: UnboxTestSimpleMock = try Unbox(dictionary, at: "B")
XCTAssertEqual(unboxed.int, 3)
} catch {
switch error {
case UnboxValueError.MissingValueForKey(let missingKey):
XCTAssertEqual(missingKey, "B")
default:
XCTFail("Unexpected error thrown: \(error)")
}
}
}

}

private func UnboxTestDictionaryWithAllRequiredKeysWithValidValues(nested: Bool) -> UnboxableDictionary {
Expand Down

0 comments on commit b376eaf

Please sign in to comment.