import Testing
@testable import PureXML
@Suite("XSD top-level group applicability (topLevelGroup)")
struct SchemaTopLevelGroupTests {
private let xsd = "xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
private func compiles(_ body: String) -> Bool {
(try? PureXML.Schema.Document("\(body)")) != nil
}
@Test("A top-level group with ref/minOccurs/maxOccurs is rejected")
func test_topLevelForbiddenRejected() {
#expect(!compiles(""))
#expect(!compiles(""))
#expect(!compiles(""))
}
@Test("A top-level group in redefine with minOccurs/maxOccurs is rejected")
func test_redefineForbiddenRejected() {
let baseRed = ""
let loader: (String) -> String? = { $0 == "base.xsd" ? "\(baseRed)" : nil }
let redefineMin = """
"""
#expect((try? PureXML.Schema.Document("\(redefineMin)", schemaLoader: loader)) == nil)
}
@Test("A plain top-level group declaration compiles")
func test_plainTopLevelAccepted() {
#expect(compiles(""))
}
@Test("A local group ref with occurrence compiles")
func test_localParticleAccepted() {
#expect(compiles(
""
+ ""
+ ""
+ "",
))
}
}