import Testing @testable import PureXML /// Canonical XML exclusive and 2.0 mode conformance, driven through the /// validation framework (its own suite to keep the main corpus under the cap). @Suite("Conformance corpus: C14N exclusive and 2.0") struct ConformanceCanonicalModesTests { private struct ModeSpec { let name: String let input: String let options: PureXML.Canonical.Options let expected: String } /// Exclusive C14N renders a namespace only where it is visibly used; Canonical /// XML 2.0 trims and drops ignorable whitespace text. private func corpus() throws -> [PureXML.Validation.ConformanceCase] { let specs = [ ModeSpec(name: "exclusive-drops-unused-ns", input: "", options: .exclusive, expected: ""), ModeSpec(name: "exclusive-renders-at-use", input: "", options: .exclusive, expected: ""), ModeSpec(name: "c2-drops-whitespace-nodes", input: " ", options: .canonical2, expected: ""), ModeSpec(name: "c2-trims-text", input: " hi ", options: .canonical2, expected: "hi"), ] return try specs.map { spec in let actual = try PureXML.Canonical.canonicalize(PureXML.parse(spec.input), options: spec.options) return PureXML.Validation.ConformanceCase(name: spec.name, actual: actual, expected: spec.expected) } } @Test("The C14N exclusive/2.0 conformance corpus passes with no located failures") func test_canonicalModesCorpusConforms() throws { let failures = try PureXML.Validation.Conformance.failures(in: corpus()) #expect(failures.isEmpty, "\(failures.map(\.reason))") } }