From 36e2741a1ee094e4d9bf6bd5ff6dc9ef377145e7 Mon Sep 17 00:00:00 2001 From: Nate Cook Date: Mon, 3 Apr 2023 13:59:43 -0500 Subject: [PATCH] Test for \s matching CRLF when scalar matching In scalar matching mode, \s and \v both only match one of the CR/LF pair. --- Tests/RegexTests/UTS18Tests.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Tests/RegexTests/UTS18Tests.swift b/Tests/RegexTests/UTS18Tests.swift index 4cf68a153..ae7aa2aa0 100644 --- a/Tests/RegexTests/UTS18Tests.swift +++ b/Tests/RegexTests/UTS18Tests.swift @@ -286,6 +286,9 @@ extension UTS18Tests { // Test \v - vertical space lines = lineInput.matches(of: regex(#"\d{2}\v^"#).anchorsMatchLineEndings()) XCTAssertEqual(lines.count, 11) + // Test \s - whitespace + lines = lineInput.matches(of: regex(#"\d{2}\s^"#).anchorsMatchLineEndings()) + XCTAssertEqual(lines.count, 11) // Test anchors as line boundaries lines = lineInput.matches(of: regex(#"^\d{2}$"#).anchorsMatchLineEndings()) XCTAssertEqual(lines.count, 12) @@ -301,6 +304,10 @@ extension UTS18Tests { lines = lineInput.matches( of: regex(#"\d{2}\v(?=\d)"#).matchingSemantics(.unicodeScalar).anchorsMatchLineEndings()) XCTAssertEqual(lines.count, 10) + // Unicode scalar semantics - \s matches all except for \r\n sequence + lines = lineInput.matches( + of: regex(#"\d{2}\s(?=\d)"#).matchingSemantics(.unicodeScalar).anchorsMatchLineEndings()) + XCTAssertEqual(lines.count, 10) // Does not contain an empty line XCTAssertFalse(lineInput.contains(regex(#"^$"#)))