{"with out-of-bounds index and = cap", a[:1:2], 2, b[:]},
{"with out-of-bounds index and < cap", a[:1:3], 2, b[:]},
} {
- if !panics(func() { Insert(test.s, test.i, test.v...) }) {
+ if !panics(func() { _ = Insert(test.s, test.i, test.v...) }) {
t.Errorf("Insert %s: got no panic, want panic", test.name)
}
}
{"s[i:j] is valid and j > len(s)", s, 0, 4},
{"s[i:j] is valid and i == j > len(s)", s, 3, 3},
} {
- 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)
}
}
}
// Test number of allocations.
- if n := testing.AllocsPerRun(100, func() { Grow(s2, cap(s2)-len(s2)) }); n != 0 {
+ if n := testing.AllocsPerRun(100, func() { _ = Grow(s2, cap(s2)-len(s2)) }); n != 0 {
t.Errorf("Grow should not allocate when given sufficient capacity; allocated %v times", n)
}
- if n := testing.AllocsPerRun(100, func() { Grow(s2, cap(s2)-len(s2)+1) }); n != 1 {
+ if n := testing.AllocsPerRun(100, func() { _ = Grow(s2, cap(s2)-len(s2)+1) }); n != 1 {
errorf := t.Errorf
if race.Enabled || testenv.OptimizationOff() {
errorf = t.Logf // this allocates multiple times in race detector mode
var gotPanic bool
func() {
defer func() { gotPanic = recover() != nil }()
- Grow(s1, -1)
+ _ = Grow(s1, -1)
}()
if !gotPanic {
t.Errorf("Grow(-1) did not panic; expected a panic")
{"s[i:j] is valid and j > len(s)", s, nil, 0, 4},
} {
ss, vv := Clone(test.s), Clone(test.v)
- if !panics(func() { Replace(ss, test.i, test.j, vv...) }) {
+ if !panics(func() { _ = Replace(ss, test.i, test.j, vv...) }) {
t.Errorf("Replace %s: should have panicked", test.name)
}
}