PureXML/Tests/ModelTests.swift
Mihaela Mihaljevic 83e6e27d12 style(format): adopt --importgrouping testable-bottom from canonical rules-swift
Group @testable imports at the bottom, per public/rules-swift's swiftformat. A
behavior-preserving import-ordering reformat across 252 files (mostly tests).
--trailingclosures was deliberately not adopted (cosmetic, and swiftformat flags
it as caution-worthy).
2026-06-18 20:33:07 +02:00

40 lines
1.3 KiB
Swift

import Testing
@testable import PureXML
@Suite("Model")
struct ModelTests {
@Test("Qualified name splits a prefixed name")
func test_qualifiedNameSplitsPrefix() {
let name = PureXML.Model.QualifiedName("xs:element")
#expect(name.prefix == "xs")
#expect(name.localName == "element")
#expect(name.description == "xs:element")
}
@Test("Qualified name keeps a bare name whole")
func test_qualifiedNameKeepsBareName() {
let name = PureXML.Model.QualifiedName("element")
#expect(name.prefix == nil)
#expect(name.localName == "element")
}
@Test("A malformed colon placement does not split; the name stays unprefixed")
func test_qualifiedNameMalformedColons() {
for raw in [":local", "prefix:", "::"] {
let name = PureXML.Model.QualifiedName(raw)
#expect(name.prefix == nil, "'\(raw)' must not yield a prefix")
#expect(name.localName == raw, "'\(raw)' is kept whole")
#expect(name.description == raw)
}
}
@Test("Element text concatenates text and CDATA children")
func test_elementTextConcatenates() {
let element = PureXML.Model.Element(
"p",
children: [.text("Hello "), .cdata("<world>")],
)
#expect(element.text == "Hello <world>")
}
}