1
0
mirror of https://github.com/golang/go synced 2024-09-29 00:34:30 -06:00

add two Delete panic test cases

This commit is contained in:
go101 2023-11-16 01:35:37 +08:00
parent 59d7433ecf
commit 600069cd14

View File

@ -672,8 +672,10 @@ func TestDeletePanics(t *testing.T) {
{"with negative second index", []int{42}, 1, -1}, {"with negative second index", []int{42}, 1, -1},
{"with out-of-bounds first index", []int{42}, 2, 3}, {"with out-of-bounds first index", []int{42}, 2, 3},
{"with out-of-bounds second index", []int{42}, 0, 2}, {"with out-of-bounds second index", []int{42}, 0, 2},
{"with out-of-bounds both indexes", []int{42}, 2, 2},
{"with invalid i>j", []int{42}, 1, 0}, {"with invalid i>j", []int{42}, 1, 0},
{"s[i:j] is valid and j > len(s)", s, 0, 4}, {"s[i:j] is valid and j > len(s)", s, 0, 4},
{"s[i:j] is valid and i == j > len(s)", s, 4, 4},
} { } {
if !panics(func() { Delete(test.s, test.i, test.j) }) { if !panics(func() { Delete(test.s, test.i, test.j) }) {
t.Errorf("Delete %s: got no panic, want panic", test.name) t.Errorf("Delete %s: got no panic, want panic", test.name)