[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:
Abduqodiri Qurbonzoda
2023-07-26 14:19:25 +00:00
committed by Space Team
parent 7ecd7b8e61
commit df16fa3306
5 changed files with 12 additions and 40 deletions
+10 -8
View File
@@ -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()