Created FailableTests.testKeyPathSubscript test case

This commit is contained in:
Caleb Kleveter 2018-12-03 07:39:32 -06:00
parent 91c547c21a
commit f1058cfb6f
No known key found for this signature in database
GPG Key ID: B38DBD5CF2C98D69
1 changed files with 8 additions and 0 deletions

View File

@ -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)
]