aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Donovan <adonovan@google.com>2024-01-05 15:54:03 -0500
committerAlan Donovan <adonovan@google.com>2024-01-05 21:35:07 +0000
commit8088b6db2341e6efdb9e0b0f43953ccd17fd9705 (patch)
tree22512abc1c0418912333353d25c33d822ffd738d
parentc0693f648a2fd98aae126ef4f68cd7b6ebff40cd (diff)
downloadgo-8088b6db2341e6efdb9e0b0f43953ccd17fd9705.tar.gz
go-8088b6db2341e6efdb9e0b0f43953ccd17fd9705.zip
slices: explicitly discard results of some functions
This will otherwise trigger an "unusedresult" vet check. Fixes #64978 Change-Id: Ie19aded0f808d394f389452c3ff7f3edc1ed710d Reviewed-on: https://go-review.googlesource.com/c/go/+/554196 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Bryan Mills <bcmills@google.com>
-rw-r--r--src/slices/slices_test.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/slices/slices_test.go b/src/slices/slices_test.go
index ab25bd8dfd..31d59abe17 100644
--- a/src/slices/slices_test.go
+++ b/src/slices/slices_test.go
@@ -557,7 +557,7 @@ func TestInsertPanics(t *testing.T) {
{"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)
}
}
@@ -684,7 +684,7 @@ func TestDeletePanics(t *testing.T) {
{"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)
}
}
@@ -906,10 +906,10 @@ func TestGrow(t *testing.T) {
}
// 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
@@ -921,7 +921,7 @@ func TestGrow(t *testing.T) {
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")
@@ -1037,7 +1037,7 @@ func TestReplacePanics(t *testing.T) {
{"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)
}
}