Created FailableTests.testKeyPathSubscript test case
This commit is contained in:
parent
91c547c21a
commit
f1058cfb6f
|
@ -17,6 +17,13 @@ final class FailableTests: XCTestCase {
|
|||
XCTAssertEqual(story.value, "Long long ago...")
|
||||
}
|
||||
|
||||
func testKeyPathSubscript()throws {
|
||||
let string = "Hello World"
|
||||
let failable: Failable<String, EmptyValidation<String>> = try string.failable()
|
||||
|
||||
XCTAssertEqual(failable[keyPath: \.count], string.count)
|
||||
}
|
||||
|
||||
func testEncode()throws {
|
||||
let data: Failable<[String: String], EmptyValidation<[String: String]>> = try ["key": "value"].failable()
|
||||
let json = try String(data: JSONEncoder().encode(data), encoding: .utf8)
|
||||
|
@ -38,6 +45,7 @@ final class FailableTests: XCTestCase {
|
|||
static var allTests: [(String, (FailableTests) -> ()throws -> ())] = [
|
||||
("testInit", testInit),
|
||||
("testSet", testSet),
|
||||
("testKeyPathSubscript", testKeyPathSubscript),
|
||||
("testEncode", testEncode),
|
||||
("testDecode", testDecode)
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue