@testable import PureXML
import Testing
/// `length`, `minLength`, and `maxLength` on `xs:QName` do not constrain the
/// value: XSD 1.0 Datatypes 4.3.1 leaves the unit of length unspecified for
/// QName, so (like Xerces and the XSTS NIST oracle) any QName satisfies them
/// (#147). Lexical QName validity is still enforced.
@Suite("QName length facets")
struct SchemaQNameLengthTests {
private func schema(_ facet: String) throws -> PureXML.Schema.Document {
try PureXML.Schema.Document("""
\(facet)
""")
}
@Test("length, minLength, and maxLength never reject a valid QName")
func test_lengthIsNonConstraining() throws {
#expect(try schema(#""#).validate("abcdefghij").isEmpty)
#expect(try schema(#""#).validate("abcdefghij").isEmpty)
#expect(try schema(#""#).validate("abc").isEmpty)
}
@Test("Lexical QName validity is still enforced")
func test_qnameStillValidated() throws {
// A leading digit is not a valid NCName, so not a valid QName.
#expect(try !schema(#""#).validate("1bad").isEmpty)
}
}