Skip to content

Commit

Permalink
Merge pull request #1058 from r-plus/test/add_test_case_for_issue_1043
Browse files Browse the repository at this point in the history
test: Add test case for #1043
  • Loading branch information
tristanhimmelman committed Jun 25, 2019
2 parents 76f5352 + bc6377f commit ab1f85f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Tests/ObjectMapperTests/ImmutableTests.swift
Expand Up @@ -331,6 +331,34 @@ class ImmutableObjectTests: XCTestCase {
XCTAssertEqual(object?.immutable?.value, "Hello")
}

func testAsPropertyOfOptionalImmutableMappable() {
struct ImmutableObject: ImmutableMappable {
let value: String?
init(map: Map) throws {
self.value = try map.value("value")
}
}

struct Object: ImmutableMappable {
let immutable: ImmutableObject?
init(map: Map) throws {
self.immutable = try map.value("immutable")
}
}

let json: [String: Any] = [
"immutable": [
"value": "Hello"
]
]
do {
let object = try Mapper<Object>().map(JSON: json)
XCTAssertEqual(object.immutable?.value, "Hello")
} catch {
XCTFail()
}
}

}

struct Struct {
Expand Down

0 comments on commit ab1f85f

Please sign in to comment.