import Testing
@testable import PureXML
/// XSD 1.0 cos-all-limited (#158): a reference to a model group whose content is an
/// `all` group is itself an all-group particle, so its `maxOccurs` must be 1 (and
/// `minOccurs` 0 or 1). Mirrors corpus particlesEa025 (a group ref to an all group
/// with maxOccurs="2").
@Suite("XSD cos-all-limited group reference (#158)")
struct SchemaAllGroupReferenceTests {
private func allGroupRef(maxOccurs: String) -> String {
"""
"""
}
private func compiles(_ schema: String) -> Bool {
(try? PureXML.Schema.Document(schema)) != nil
}
@Test("a group reference to an all group with maxOccurs>1 is rejected (particlesEa025)")
func test_allGroupRefMaxOccursTwoRejected() {
#expect(!compiles(allGroupRef(maxOccurs: "2")))
}
@Test("a group reference to an all group with maxOccurs=1 is accepted")
func test_allGroupRefMaxOccursOneAccepted() {
#expect(compiles(allGroupRef(maxOccurs: "1")))
}
@Test("a group reference to a non-all (sequence) group with maxOccurs>1 is accepted")
func test_sequenceGroupRefMaxOccursTwoAccepted() {
let schema = """
"""
#expect(compiles(schema))
}
}