import Testing @testable import PureXML /// An element/attribute `default`/`fixed` value must be a valid value of its /// `type` (Attribute/Element Locally Valid, XSD 1.0), checked at compile time. /// Only a built-in type is checked (a named/inline user type is left to its own /// rules), covering the attO family (`fixed="abc"` on `xs:integer`). @Suite("Default/fixed value validity (compile time)") struct SchemaValueConstraintValidityTests { private func compile(_ body: String) throws { _ = try PureXML.Schema.Document(""" \(body) """) } private func rejects(_ body: String) -> Bool { do { try compile(body) return false } catch { return true } } @Test("a built-in-typed default/fixed value outside the type's value space is rejected") func test_invalidValues() { #expect(rejects(#""#)) #expect(rejects(#""#)) #expect(rejects(#""#)) #expect(rejects(#""#)) #expect(rejects(#""#)) } @Test("a valid built-in-typed default/fixed value compiles, with whitespace normalized") func test_validValues() throws { try compile(#""#) try compile(#""#) try compile(#""#) try compile(#""#) } @Test("a default/fixed value on a non-built-in type is left alone") func test_userTypeUnchecked() throws { try compile(#""" """#) } }