import Testing @testable import PureXML /// xs:string has whiteSpace="preserve", so a simple-content value keeps its /// leading/trailing and whitespace-only content; validation no longer trims it /// before the facet runs (#147, XSTS reI set). Element-only content still /// ignores indentation whitespace. @Suite("String content whitespace is preserved") struct SchemaStringWhitespaceTests { private func patternSchema(_ pattern: String) throws -> PureXML.Schema.Document { try PureXML.Schema.Document(""" """) } @Test("A tab-only value matches the \\t pattern (whitespace preserved)") func test_tabPreserved() throws { #expect(try patternSchema(#"\t"#).validate(" ").isEmpty) } @Test("A length facet on string counts preserved whitespace") func test_lengthCountsWhitespace() throws { let doc = try PureXML.Schema.Document(""" """) #expect(try doc.validate(" a ").isEmpty) // space,a,space = 3 chars #expect(try !doc.validate("a").isEmpty) // 1 char } @Test("Element-only content still ignores indentation whitespace") func test_elementOnlyIgnoresWhitespace() throws { let doc = try PureXML.Schema.Document(""" """) #expect(try doc.validate("\n x\n").isEmpty) } }