builtin: fix split_nth() and rsplit_nth() on an empty delimeter (#19005)

This commit is contained in:
katekyy 2023-07-29 23:12:51 +02:00 committed by GitHub
parent e78e468d5f
commit b622dca915
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -183,6 +183,15 @@ fn test_split_nth() {
assert e.split_nth(',,', 3).len == 3
assert e.split_nth(',', -1).len == 12
assert e.split_nth(',', 3).len == 3
f := '1:2:3'
assert f.split_nth(':', 2) == ['1', '2:3']
assert f.rsplit_nth(':', 2) == ['3', '1:2']
g := '123'
assert g.split_nth('', 2) == ['1', '23']
assert g.rsplit_nth('', 2) == ['3', '12']
h := ''
assert h.split_nth('', 2) == []
assert h.rsplit_nth('', 2) == []
}
fn test_rsplit_nth() {