fix(stringx): return empty string from FirstN when n is negative (#5620)

This commit is contained in:
SapirBaruch
2026-06-21 05:30:48 +03:00
committed by GitHub
parent d9cb246301
commit 18305200d2
2 changed files with 16 additions and 0 deletions

View File

@@ -190,6 +190,18 @@ func TestFirstN(t *testing.T) {
n: 10,
expect: "我是中国人",
},
{
name: "negative n returns empty string",
input: "hello world",
n: -1,
expect: "",
},
{
name: "negative n with utf8 returns empty string",
input: "我是中国人",
n: -5,
expect: "",
},
}
for _, test := range tests {