]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/crypto/sha1/sha1_test.go
[dev.boringcrypto] all: merge master into dev.boringcrypto
[gostls13.git] / src / crypto / sha1 / sha1_test.go
index e369c3b7f491eee1e7cc2f30d1b6aa616b202fa9..f1a5448dd2dd75eb18b405c4237b9cf2dc93f063 100644 (file)
@@ -218,6 +218,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)