import Testing @testable import PureXML @Suite("Canonical XML 1.1: xml:base merging and xml:id") struct CanonicalC14N11Tests { private func canonicalize(_ xml: String, at path: [Int], _ options: PureXML.Canonical.Options) throws -> String { let document = try PureXML.parseTree(xml) var node = document for index in path { node = node.children[index] } return PureXML.Canonical.Canonicalizer(options: options).canonicalize(node) } @Test("1.1 merges the omitted-ancestor xml:base chain; 1.0 takes the nearest") func test_baseMerging() throws { let xml = "" try #expect(canonicalize(xml, at: [0, 0, 0], .canonical11) == "") try #expect(canonicalize(xml, at: [0, 0, 0], .inclusive) == "") } @Test("1.1 resolves the apex's own relative xml:base against the inherited chain") func test_apexRelativeBase() throws { let xml = "" try #expect(canonicalize(xml, at: [0, 0], .canonical11) == "") // 1.0 keeps the apex's own base unresolved (no merge). try #expect(canonicalize(xml, at: [0, 0], .inclusive) == "") } @Test("1.1 resolves dot segments in the merged base") func test_dotSegments() throws { let xml = "" try #expect(canonicalize(xml, at: [0, 0], .canonical11) == "") } @Test("1.1 does not inherit xml:id; 1.0 does") func test_xmlIdNotInherited() throws { let xml = "" try #expect(canonicalize(xml, at: [0, 0], .canonical11) == "") try #expect(canonicalize(xml, at: [0, 0], .inclusive) == "") } @Test("1.1 still inherits xml:lang and xml:space (nearest)") func test_langSpaceStillInherited() throws { let xml = "" try #expect(canonicalize(xml, at: [0, 0], .canonical11) == "") } }