1
0
mirror of https://github.com/golang/go synced 2024-11-24 13:10:11 -07:00

regexp: add find test cases for matching edges of multibyte characters

There are currently similar tests for Replace but not for Find.
Given the nature of the matching implementation, it seems unlikely,
but given rune handling is separate for Find vs Replace, it would be
good to have explicit regression tests for otherwise easily missed
corner cases.
This commit is contained in:
Anuraag Agrawal 2024-06-05 15:55:15 +09:00
parent 1b07b774c0
commit ab96ee7da9

View File

@ -99,6 +99,11 @@ var findTests = []FindTest{
{`\B`, "xx yy", build(2, 1, 1, 4, 4)},
{`(|a)*`, "aa", build(3, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2)},
// Multibyte characters -- verify that we don't try to match in the middle
// of a character.
{"[a-c]*", "\u65e5", build(2, 0, 0, 3, 3)},
{"[^\u65e5]", "abc\u65e5def", build(6, 0, 1, 1, 2, 2, 3, 6, 7, 7, 8, 8, 9)},
// RE2 tests
{`[^\S\s]`, "abcd", nil},
{`[^\S[:space:]]`, "abcd", nil},