Skip to content
1 change: 0 additions & 1 deletion Sources/XMLCoder/Auxiliaries/Box/SingleElementBox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ struct SingleElementBox: SimpleBox {
}

extension SingleElementBox: Box {

var isNull: Bool {
return false
}
Expand Down
3 changes: 2 additions & 1 deletion Tests/XMLCoderTests/Minimal/BoxTreeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}
}
14 changes: 14 additions & 0 deletions Tests/XMLCoderTests/SimpleChoiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,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)
}
}