import Testing @testable import PureXML @Suite("Schema notation validity tests") struct SchemaNotationValidityTests { 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("Notation must specify public or system attribute") func test_notationAttributes() { // public only is valid #expect(throws: Never.self) { try compile(#""" """#) } // system only is valid #expect(throws: Never.self) { try compile(#""" """#) } // both is valid #expect(throws: Never.self) { try compile(#""" """#) } // neither is invalid #expect(rejects(#""" """#)) } @Test("SimpleType notation restriction enumeration check") func test_notationEnumeration() { // Valid enumeration referencing declared notation #expect(throws: Never.self) { try compile(#""" """#) } // Invalid enumeration referencing undeclared notation #expect(rejects(#""" """#)) // Notation in the XML namespace referenced with xml prefix #expect(throws: Never.self) { _ = try PureXML.Schema.Document(#""" """#) } // Notation with xmlns="" default namespace unbinding #expect(throws: Never.self) { _ = try PureXML.Schema.Document(#""" """#) } } }