Add `test_null_yml()` to `EncoderTests` from #157

This commit is contained in:
Norio Nomura 2019-01-29 12:03:53 +09:00
parent 9ac276ffb7
commit 4556cfb81b
No known key found for this signature in database
GPG Key ID: D4A7318EB7F7138D
1 changed files with 25 additions and 1 deletions

View File

@ -316,6 +316,29 @@ class EncoderTests: XCTestCase { // swiftlint:disable:this type_body_length
expectEqual(type(of: decoded), Employee.self, "Expected decoded value to be of type Employee; got \(type(of: decoded)) instead.")
}
func test_null_yml() throws {
let s = """
n1: ~
n2: null
n3: NULL
n4: Null
n5:
"""
struct Test: Decodable {
let n1: String?
let n2: String?
let n3: String?
let n4: String?
let n5: String?
}
let t = try YAMLDecoder().decode(Test.self, from: s)
XCTAssertNil(t.n1)
XCTAssertNil(t.n2)
XCTAssertNil(t.n3)
XCTAssertNil(t.n4)
XCTAssertNil(t.n5)
}
// MARK: - Helper Functions
private func _testRoundTrip<T>(of value: T,
@ -1089,7 +1112,8 @@ extension EncoderTests {
("testValuesInUnkeyedContainer", testValuesInUnkeyedContainer),
("testDictionary", testDictionary),
("testNodeTypeMismatch", testNodeTypeMismatch),
("testDecodingConcreteTypeParameter", testDecodingConcreteTypeParameter)
("testDecodingConcreteTypeParameter", testDecodingConcreteTypeParameter),
("test_null_yml", test_null_yml)
]
}
}