diff --git a/Sources/XMLCoder/Auxiliaries/Box/SingleElementBox.swift b/Sources/XMLCoder/Auxiliaries/Box/SingleElementBox.swift index 99540f44..9e64fd69 100644 --- a/Sources/XMLCoder/Auxiliaries/Box/SingleElementBox.swift +++ b/Sources/XMLCoder/Auxiliaries/Box/SingleElementBox.swift @@ -14,7 +14,6 @@ struct SingleElementBox: SimpleBox { } extension SingleElementBox: Box { - var isNull: Bool { return false } diff --git a/Tests/XMLCoderTests/Minimal/BoxTreeTests.swift b/Tests/XMLCoderTests/Minimal/BoxTreeTests.swift index cbd2c3eb..81ebdd0e 100644 --- a/Tests/XMLCoderTests/Minimal/BoxTreeTests.swift +++ b/Tests/XMLCoderTests/Minimal/BoxTreeTests.swift @@ -28,12 +28,13 @@ class BoxTreeTests: XCTestCase { elements: [e1, e2], attributes: [] ) - // FIXME: Use `XCTUnwrap` when commonly available + guard let boxTree = root.transformToBoxTree() as? KeyedBox else { XCTFail("boxtTree is not a KeyedBox"); return } let foo = boxTree.elements["foo"] XCTAssertEqual(foo.count, 2) + } } diff --git a/Tests/XMLCoderTests/SimpleChoiceTests.swift b/Tests/XMLCoderTests/SimpleChoiceTests.swift index 9c3ab4b7..e2555424 100644 --- a/Tests/XMLCoderTests/SimpleChoiceTests.swift +++ b/Tests/XMLCoderTests/SimpleChoiceTests.swift @@ -95,4 +95,18 @@ class SimpleChoiceTests: XCTestCase { let decoded = try XMLDecoder().decode([IntOrString].self, from: encoded) XCTAssertEqual(original, decoded) } + + func testIntOrStringDoubleArrayRoundTrip() throws { + let original: [[IntOrString]] = [[ + .int(1), + .string("two"), + .string("three"), + .int(4), + .int(5), + ]] + let encoded = try XMLEncoder().encode(original, withRootKey: "container") + print(String(data: encoded, encoding: .utf8)) + let decoded = try XMLDecoder().decode([[IntOrString]].self, from: encoded) + XCTAssertEqual(original, decoded) + } }