import Testing @testable import PureXML @Suite("XSD attribute-use uniqueness and single ID") struct SchemaAttributeUniquenessTests { private func compiles(_ source: String) -> Bool { (try? PureXML.Schema.Document(source)) != nil } private let xsd = "xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"" @Test("Two attribute uses with the same name in one type or group are rejected") func test_duplicateAttributeRejected() { // Two local attributes of the same name directly in a complex type. #expect(!compiles("" + "" + "")) // A local attribute colliding with one pulled in through an attribute group. #expect(!compiles("" + "" + "")) // Two same-named attributes within one attribute group (ag-props-correct.2). #expect(!compiles("" + "")) } @Test("More than one ID-typed attribute is rejected (ct-props-correct.5)") func test_twoIDAttributesRejected() { #expect(!compiles("" + "" + "")) // A single ID attribute is fine. #expect(compiles("" + "" + "")) } @Test("Same local name in different namespaces, and a diamond, are not clashes") func test_distinctNamespacesAndDiamondAccepted() { // attQ010/attQ019: a local attribute and a reference to a same-local-name // attribute in an imported namespace are different attributes. (Must compile.) #expect(compiles("" + "" + "" + "")) // A diamond of attribute-group references reaching the same attribute once is // not a duplicate: g3 has attribute a; g1 and g2 both include g3; T includes // both. (Must compile.) #expect(compiles("" + "" + "" + "" + "")) } }