import Testing
@testable import PureXML
/// An element with a `fixed` value constraint must carry its fixed character value
/// and no element children, even under a mixed content type (cvc-elt.5.2.2.2.1).
/// An empty element takes the fixed value, text equal to the fixed value is fine,
/// but element children make the element invalid.
@Suite("fixed element children")
struct SchemaFixedElementChildrenTests {
private func schema() throws -> PureXML.Schema.Document {
try PureXML.Schema.Document("""
""")
}
@Test("empty or matching text under a fixed mixed element is accepted")
func test_emptyOrMatchingTextAccepted() throws {
#expect(try schema().validate(#""#).isEmpty)
#expect(try schema().validate(#"abc"#).isEmpty)
}
@Test("a fixed mixed element with element children is rejected")
func test_childrenRejected() throws {
#expect(try !schema().validate(#"abc1"#).isEmpty)
#expect(try !schema().validate(#"1abc"#).isEmpty)
}
}