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
27 lines
824 B
Swift
27 lines
824 B
Swift
@testable import PureXML
|
|
import Testing
|
|
|
|
@Suite("Validation")
|
|
struct ValidationTests {
|
|
@Test("Duplicate attribute is an error")
|
|
func test_duplicateAttributeIsError() {
|
|
let element = PureXML.Model.Element(
|
|
"input",
|
|
attributes: [.init("id", "a"), .init("id", "b")],
|
|
)
|
|
let issues = PureXML.Validation.Validator().collect(.element(element))
|
|
#expect(issues.count == 1)
|
|
#expect(issues.first?.severity == .error)
|
|
}
|
|
|
|
@Test("Unique attributes validate cleanly")
|
|
func test_uniqueAttributesValidate() throws {
|
|
let element = PureXML.Model.Element(
|
|
"input",
|
|
attributes: [.init("id", "a"), .init("name", "b")],
|
|
)
|
|
let issues = try PureXML.validate(.element(element))
|
|
#expect(issues.isEmpty)
|
|
}
|
|
}
|