[K/N] Regex matching zero length should split surrogate pairs #KT-57401
Merge-request: KT-MR-11110 Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
7ecd7b8e61
commit
df16fa3306
@@ -529,17 +529,19 @@ class RegexTest {
|
||||
@Test fun splitByEmptyMatch() {
|
||||
val input = "test"
|
||||
|
||||
val emptyMatch = "".toRegex()
|
||||
for (pattern in listOf("", "(?<=)")) {
|
||||
val emptyMatch = pattern.toRegex()
|
||||
|
||||
testSplitEquals(listOf("", "t", "e", "s", "t", ""), input, emptyMatch)
|
||||
testSplitEquals(listOf("", "t", "est"), input, emptyMatch, limit = 3)
|
||||
testSplitEquals(listOf("", "t", "e", "s", "t", ""), input, emptyMatch)
|
||||
testSplitEquals(listOf("", "t", "est"), input, emptyMatch, limit = 3)
|
||||
|
||||
testSplitEquals("".split(""), "", emptyMatch)
|
||||
testSplitEquals("".split(""), "", emptyMatch)
|
||||
|
||||
testSplitEquals(
|
||||
if (regexSplitUnicodeCodePointHandling) listOf("", "\uD83D\uDE04", "\uD801", "") else listOf("", "\uD83D", "\uDE04", "\uD801", ""),
|
||||
"\uD83D\uDE04\uD801", emptyMatch
|
||||
)
|
||||
testSplitEquals(
|
||||
if (regexSplitUnicodeCodePointHandling) listOf("", "\uD83D\uDE04", "\uD801", "") else listOf("", "\uD83D", "\uDE04", "\uD801", ""),
|
||||
"\uD83D\uDE04\uD801", emptyMatch
|
||||
)
|
||||
}
|
||||
|
||||
val emptyMatchBeforeT = "(?=t)".toRegex()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user