]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/crypto/sha256/sha256_test.go
[dev.boringcrypto] all: merge master into dev.boringcrypto
[gostls13.git] / src / crypto / sha256 / sha256_test.go
index 91a4edde047f68bb85ea9f635f746e45bb454ff7..a762afc4d9e8ff6878ec0ed1202e36972d47e8eb 100644 (file)
@@ -294,6 +294,23 @@ func TestLargeHashes(t *testing.T) {
        }
 }
 
+func TestAllocations(t *testing.T) {
+       if boring.Enabled {
+               t.Skip("BoringCrypto doesn't allocate the same way as stdlib")
+       }
+       in := []byte("hello, world!")
+       out := make([]byte, 0, Size)
+       h := New()
+       n := int(testing.AllocsPerRun(10, func() {
+               h.Reset()
+               h.Write(in)
+               out = h.Sum(out[:0])
+       }))
+       if n > 0 {
+               t.Errorf("allocs = %d, want 0", n)
+       }
+}
+
 var bench = New()
 var buf = make([]byte, 8192)