import Testing @testable import PureXML /// Identity-constraint field values are compared in their shared value space. Two /// fields typed by different members of the decimal-derived numeric family (e.g. /// `xs:decimal` and `xs:unsignedByte`, selected via `xsi:type`) denote the same /// value when their numbers are equal, so `1` and `1` collide for a `unique`. /// Values in distinct primitive spaces never collide. @Suite("Identity-constraint cross-type value equality") struct SchemaIdentityValueEqualityTests { /// Mirrors the W3C idF015 shape: an `xsd:anyType` element whose instances carry /// `xsi:type` numeric overrides, gathered by a `unique`. private func schema() throws -> PureXML.Schema.Document { try PureXML.Schema.Document(""" """) } private func doc(_ decimalValue: String, _ unsignedValue: String) -> String { """ \(decimalValue) \(unsignedValue) """ } @Test("decimal and unsignedByte with the same number collide for unique") func test_crossNumericTypesCollide() throws { // 1 (decimal) and 1 (unsignedByte) are one value in the decimal value space. #expect(try !schema().validate(doc("1", "1")).isEmpty) // 1.0 (decimal) and 1 (unsignedByte) likewise. #expect(try !schema().validate(doc("1.0", "1")).isEmpty) // Distinct numbers do not collide. #expect(try schema().validate(doc("1", "2")).isEmpty) } }