Skip to content

Commit ae3157c

Browse files
committed
Add some tests for CharacterClass.horizontalWhitespace
1 parent f1026b3 commit ae3157c

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
@@ -220,6 +220,30 @@ class RegexDSLTests: XCTestCase {
220220
}.matchingSemantics(.unicodeScalar).asciiOnlyWhitespace(asciiOnly)
221221
}
222222
}
223+
224+
// Make sure horizontal whitespace does not match newlines or other
225+
// vertical whitespace.
226+
try _testDSLCaptures(
227+
(" \u{A0} \u{9} \t ", " \u{A0} \u{9} \t "),
228+
(" \n", nil),
229+
(" \r", nil),
230+
(" \r\n", nil),
231+
(" \u{2028}", nil),
232+
matchType: Substring.self, ==)
233+
{
234+
OneOrMore(.horizontalWhitespace)
235+
}
236+
237+
// Horizontal whitespace in ASCII mode.
238+
try _testDSLCaptures(
239+
(" \u{9} \t ", " \u{9} \t "),
240+
("\u{A0}", nil),
241+
matchType: Substring.self, ==)
242+
{
243+
Regex {
244+
OneOrMore(.horizontalWhitespace)
245+
}.asciiOnlyWhitespace()
246+
}
223247
}
224248

225249
func testCharacterClassOperations() throws {

0 commit comments

Comments
 (0)