import Testing
@testable import PureXML
@Suite("Adversarial Critic Tests")
struct AdversarialCriticTests {
@Test("xml prefix on QName references is accepted without explicit xmlns:xml declaration")
func test_xmlPrefixOnQNameReference() throws {
_ = try PureXML.Schema.Document("""
""")
}
@Test("foreign elements and attributes inside simpleType restriction are ignored and accepted")
func test_foreignElementsAndAttributesInSimpleType() throws {
_ = try PureXML.Schema.Document("""
""")
}
@Test("complex type check with different namespace configurations and prefixes")
func test_complexTypeCheckNamespaceComplexity() throws {
// 1. Unprefixed reference to simple type when targetNamespace is default namespace - accepted
_ = try PureXML.Schema.Document("""
""")
// 2. Prefixed reference to simple type - accepted
_ = try PureXML.Schema.Document("""
""")
// 3. Unprefixed reference to simple type in no-targetNamespace schema - accepted
_ = try PureXML.Schema.Document("""
""")
// 4. Default namespace set to XSD namespace referencing simple/complex types
_ = try PureXML.Schema.Document("""
""")
}
@Test("schema element order: accepts foreign elements interspersed and before imports/includes/redefines")
func test_schemaChildrenOrder_foreignElements() throws {
// 1. Foreign elements before imports
_ = try PureXML.Schema.Document("""
""")
// 2. Foreign elements interspersed
_ = try PureXML.Schema.Document("""
""")
// 3. Foreign elements with same local names as global declarations (e.g. element/attribute)
// should not trigger seenDeclaration = true for the schemaChildrenOrderErrors check.
_ = try PureXML.Schema.Document("""
""")
}
@Test("import constraints: valid import cases")
func test_importConstraints_valid() throws {
// 1. Importing a namespace with a schema that has a targetNamespace (different from imported namespace)
_ = try PureXML.Schema.Document("""
""")
// 2. Importing a namespace with a schema that has NO targetNamespace
_ = try PureXML.Schema.Document("""
""")
// 3. Importing no-namespace schema with a schema that HAS targetNamespace
_ = try PureXML.Schema.Document("""
""")
}
}