-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #260
- Loading branch information
Showing
3 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// CDATAMixedUsageTest.swift | ||
// XMLCoderTests | ||
// | ||
// Created by Johan Kool on 15/03/2023. | ||
// | ||
|
||
import XCTest | ||
import XMLCoder | ||
|
||
final class CDATAMixedUsageTest: XCTestCase { | ||
private struct DataEntry: Codable, Equatable { | ||
let value: String | ||
enum CodingKeys: String, CodingKey { | ||
case value = "" | ||
} | ||
} | ||
|
||
private struct Container: Codable, Equatable { | ||
let data: [DataEntry] | ||
} | ||
|
||
private let xml = | ||
""" | ||
<container> | ||
<data><![CDATA[lorem ipsum]]></data> | ||
<data>bla bla</data> | ||
</container> | ||
""".data(using: .utf8)! | ||
|
||
func testXMLWithMixedCDATAUsage() throws { | ||
let decoder = XMLDecoder() | ||
let result = try decoder.decode(Container.self, from: xml) | ||
XCTAssertEqual(result, Container(data: [.init(value: "lorem ipsum"), .init(value: "bla bla")])) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters