Skip to content

Commit 29e9cd2

Browse files
committed
Improve: New regression tests for ligatures
1 parent 7dd6209 commit 29e9cd2

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

scripts/test_stringzilla.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,6 +2826,18 @@ void test_utf8_case() {
28262826
let_assert(auto m = str("straßebahn").utf8_case_insensitive_find("SS"), m.offset == 4 && m.length == 2);
28272827
let_assert(auto m = str("Eine straßebahn").utf8_case_insensitive_find("SS"), m.offset == 9 && m.length == 2);
28282828

2829+
// Same case-folding, but different relation
2830+
let_assert(auto m = str("HelloäeßHelloL").utf8_case_insensitive_find("helloäesshellol"),
2831+
m.offset == 0 && m.length == 16);
2832+
let_assert(auto m = str("helloäesshellol").utf8_case_insensitive_find("HelloäeßHelloL"),
2833+
m.offset == 0 && m.length == 16);
2834+
2835+
// Same case-folding, but different relation and needle length due to uppercase tripple-byte 'ẞ' (U+1E9E, E1 BA 9E)
2836+
let_assert(auto m = str("HelloäeẞHelloL").utf8_case_insensitive_find("helloäesshellol"),
2837+
m.offset == 0 && m.length == 17);
2838+
let_assert(auto m = str("helloäesshellol").utf8_case_insensitive_find("HelloäeẞHelloL"),
2839+
m.offset == 0 && m.length == 16);
2840+
28292841
// Haystack "STRASSE", Needle "straße"
28302842
let_assert(auto m = str("STRASSE").utf8_case_insensitive_find("straße"),
28312843
m.offset == 0 && m.length == 7); // Matches "STRASSE" (7 bytes)
@@ -3087,6 +3099,12 @@ void test_utf8_case() {
30873099
let_assert(auto m = str("Ligature ſt check").utf8_case_insensitive_find("st"), m.offset == 9 && m.length == 3);
30883100
let_assert(auto m = str("end with ſt").utf8_case_insensitive_find("st"), m.offset == 9 && m.length == 3);
30893101

3102+
// More complex ligatures
3103+
let_assert(auto m = str("ffiJaCä").utf8_case_insensitive_find("fija"), m.offset == 0 && m.length == 5);
3104+
let_assert(auto m = str("ffiJaCä").utf8_case_insensitive_find("fija"), m.offset == 0 && m.length == 5);
3105+
let_assert(auto m = str("alffiJaCä").utf8_case_insensitive_find("fija"), m.offset == 2 && m.length == 5);
3106+
let_assert(auto m = str("alffiJaCä").utf8_case_insensitive_find("fija"), m.offset == 2 && m.length == 5);
3107+
30903108
// 'st' (U+FB06, EF AC 86)
30913109
let_assert(auto m = str("Big st").utf8_case_insensitive_find("st"), m.offset == 4 && m.length == 3);
30923110

0 commit comments

Comments
 (0)