cover top level nullable types

This commit is contained in:
Oleksii Dykan
2017-10-23 11:50:55 +02:00
parent 9245ab15ef
commit 178d713799

View File

@@ -397,6 +397,17 @@ class TestCodableFirestore: XCTestCase {
_testRoundTrip(of: Employee.testValue)
}
func testEncodingTopLevelNullableType() {
// EnhancedBool is a type which encodes either as a Bool or as nil.
_testEncodeFailure(of: EnhancedBool.true)
_testEncodeFailure(of: EnhancedBool.false)
_testEncodeFailure(of: EnhancedBool.fileNotFound)
_testRoundTrip(of: TopLevelWrapper(EnhancedBool.true))
_testRoundTrip(of: TopLevelWrapper(EnhancedBool.false))
_testRoundTrip(of: TopLevelWrapper(EnhancedBool.fileNotFound))
}
func testTypeCoercion() {
_testRoundTripTypeCoercionFailure(of: [false, true], as: [Int].self)
_testRoundTripTypeCoercionFailure(of: [false, true], as: [Int8].self)