diff --git a/Tests/XMLCoderTests/AdvancedFeatures/DynamicNodeEncodingTest.swift b/Tests/XMLCoderTests/AdvancedFeatures/DynamicNodeEncodingTest.swift index 2e321f64..2e08b46e 100644 --- a/Tests/XMLCoderTests/AdvancedFeatures/DynamicNodeEncodingTest.swift +++ b/Tests/XMLCoderTests/AdvancedFeatures/DynamicNodeEncodingTest.swift @@ -278,4 +278,35 @@ final class DynamicNodeEncodingTest: XCTestCase { encoding: "UTF-8")) XCTAssertEqual(String(data: data, encoding: .utf8)!, libraryXMLYNStrategy) } + + private struct SplitsData: Codable, DynamicNodeEncoding { + let version: String + + enum CodingKeys: String, CodingKey { + case version + } + + static func nodeEncoding(for key: CodingKey) -> XMLEncoder.NodeEncoding { + switch key { + case CodingKeys.version: + return .attribute + default: + return .both + } + } + } + + func testRootEncoding() throws { + let run = SplitsData(version: "1.8.0") + let encoder = XMLEncoder() + let encodedRun = try String(data: encoder.encode( + run, + withRootKey: "Run", + header: XMLHeader(version: 1.0, encoding: "UTF-8") + ), encoding: .utf8) + XCTAssertEqual(encodedRun, """ + + + """) + } } diff --git a/XMLCoder.xcodeproj/project.pbxproj b/XMLCoder.xcodeproj/project.pbxproj index b921635d..dc835e51 100644 --- a/XMLCoder.xcodeproj/project.pbxproj +++ b/XMLCoder.xcodeproj/project.pbxproj @@ -226,7 +226,6 @@ OBJ_135 /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = ""; }; OBJ_136 /* test_swiftpm.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = test_swiftpm.sh; sourceTree = ""; }; OBJ_137 /* test_xcodebuild.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = test_xcodebuild.sh; sourceTree = ""; }; - OBJ_138 /* lint.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = lint.sh; sourceTree = ""; }; OBJ_139 /* azure-pipelines.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = "azure-pipelines.yml"; sourceTree = ""; }; OBJ_14 /* ChoiceBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChoiceBox.swift; sourceTree = ""; }; OBJ_140 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; @@ -458,7 +457,6 @@ OBJ_135 /* CHANGELOG.md */, OBJ_136 /* test_swiftpm.sh */, OBJ_137 /* test_xcodebuild.sh */, - OBJ_138 /* lint.sh */, OBJ_139 /* azure-pipelines.yml */, OBJ_140 /* README.md */, OBJ_141 /* docs.sh */,