diff options
Diffstat (limited to 'sha3/allocations_test.go')
| -rw-r--r-- | sha3/allocations_test.go | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/sha3/allocations_test.go b/sha3/allocations_test.go deleted file mode 100644 index 36de5d5..0000000 --- a/sha3/allocations_test.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2023 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !noopt - -package sha3_test - -import ( - "runtime" - "testing" - - "golang.org/x/crypto/sha3" -) - -var sink byte - -func TestAllocations(t *testing.T) { - want := 0.0 - - if runtime.GOARCH == "s390x" { - // On s390x the returned hash.Hash is conditional so it escapes. - want = 3.0 - } - - t.Run("New", func(t *testing.T) { - if allocs := testing.AllocsPerRun(10, func() { - h := sha3.New256() - b := []byte("ABC") - h.Write(b) - out := make([]byte, 0, 32) - out = h.Sum(out) - sink ^= out[0] - }); allocs > want { - t.Errorf("expected zero allocations, got %0.1f", allocs) - } - }) - t.Run("NewShake", func(t *testing.T) { - if allocs := testing.AllocsPerRun(10, func() { - h := sha3.NewShake128() - b := []byte("ABC") - h.Write(b) - out := make([]byte, 0, 32) - out = h.Sum(out) - sink ^= out[0] - h.Read(out) - sink ^= out[0] - }); allocs > want { - t.Errorf("expected zero allocations, got %0.1f", allocs) - } - }) - t.Run("Sum", func(t *testing.T) { - if allocs := testing.AllocsPerRun(10, func() { - b := []byte("ABC") - out := sha3.Sum256(b) - sink ^= out[0] - }); allocs > want { - t.Errorf("expected zero allocations, got %0.1f", allocs) - } - }) -} |
