Skip to content

Commit 9a545a0

Browse files
committed
Add some tests for CharacterClass.horizontalWhitespace
1 parent f111a57 commit 9a545a0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Tests/RegexBuilderTests/RegexDSLTests.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,30 @@ class RegexDSLTests: XCTestCase {
224224
}.matchingSemantics(.unicodeScalar).asciiOnlyWhitespace(asciiOnly)
225225
}
226226
}
227+
228+
// Make sure horizontal whitespace does not match newlines or other
229+
// vertical whitespace.
230+
try _testDSLCaptures(
231+
(" \u{A0} \u{9} \t ", " \u{A0} \u{9} \t "),
232+
(" \n", nil),
233+
(" \r", nil),
234+
(" \r\n", nil),
235+
(" \u{2028}", nil),
236+
matchType: Substring.self, ==)
237+
{
238+
OneOrMore(.horizontalWhitespace)
239+
}
240+
241+
// Horizontal whitespace in ASCII mode.
242+
try _testDSLCaptures(
243+
(" \u{9} \t ", " \u{9} \t "),
244+
("\u{A0}", nil),
245+
matchType: Substring.self, ==)
246+
{
247+
Regex {
248+
OneOrMore(.horizontalWhitespace)
249+
}.asciiOnlyWhitespace()
250+
}
227251
}
228252

229253
func testCharacterClassOperations() throws {

0 commit comments

Comments
 (0)