PureXML/Tests/ModelTests.swift
Mihaela Mihaljevic 708390242c chore: scaffold PureXML pure-Swift XML package
Root Swift package mirroring PureYAML's structure, rules, and verification
gates. Includes the XML node model (Node, Element, Attribute, QualifiedName),
a working emitter (Serializer) with escaping and pretty/compact options, and
structural validation. The parser surface is stable; parse() raises
notImplemented until the scanner lands, pinned by a test.

- dependency-free, namespaced under PureXML
- portability and style gates carried over (style, namespacing, forbidden
  patterns, swiftformat, swiftlint, linux, wasm, windows CI)
- 11 tests passing
2026-06-07 23:20:20 +02:00

30 lines
909 B
Swift

@testable import PureXML
import Testing
@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("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>")
}
}