github.com/number571/tendermint@v0.34.11-gost/libs/rand/random_test.go (about) 1 package rand 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestRandStr(t *testing.T) { 10 l := 243 11 s := Str(l) 12 assert.Equal(t, l, len(s)) 13 } 14 15 func TestRandBytes(t *testing.T) { 16 l := 243 17 b := Bytes(l) 18 assert.Equal(t, l, len(b)) 19 } 20 21 func BenchmarkRandBytes10B(b *testing.B) { 22 benchmarkRandBytes(b, 10) 23 } 24 func BenchmarkRandBytes100B(b *testing.B) { 25 benchmarkRandBytes(b, 100) 26 } 27 func BenchmarkRandBytes1KiB(b *testing.B) { 28 benchmarkRandBytes(b, 1024) 29 } 30 func BenchmarkRandBytes10KiB(b *testing.B) { 31 benchmarkRandBytes(b, 10*1024) 32 } 33 func BenchmarkRandBytes100KiB(b *testing.B) { 34 benchmarkRandBytes(b, 100*1024) 35 } 36 func BenchmarkRandBytes1MiB(b *testing.B) { 37 benchmarkRandBytes(b, 1024*1024) 38 } 39 40 func benchmarkRandBytes(b *testing.B, n int) { 41 for i := 0; i < b.N; i++ { 42 _ = Bytes(n) 43 } 44 b.ReportAllocs() 45 }