Skip to content

Commit

Permalink
Add falsely passing double array roundtrip test (CoreOffice#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
bwetherfield committed Jul 27, 2019
1 parent 7c9a020 commit a01c4e7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 0 additions & 1 deletion Sources/XMLCoder/Auxiliaries/Box/SingleElementBox.swift
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
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
Expand Up @@ -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)
}
}

0 comments on commit a01c4e7

Please sign in to comment.