diff options
| author | Carl Mastrangelo <carl.mastrangelo@gmail.com> | 2017-07-03 15:38:55 -0700 |
|---|---|---|
| committer | Filippo Valsorda <hi@filippo.io> | 2017-11-01 05:51:30 +0000 |
| commit | f265f5db5d71f120eb6e2cec25ab6dfc3fb249f3 (patch) | |
| tree | dbac9ccd39900bf9c80a7301881f1500ab722daf /src/archive | |
| parent | fb1fd6aee6af655a54193d961d5f11ff16580e6a (diff) | |
| download | go-f265f5db5d71f120eb6e2cec25ab6dfc3fb249f3.tar.xz | |
archive/zip, crypto/tls: use rand.Read instead of casting ints to bytes
Makes tests run ~1ms faster.
Change-Id: Ida509952469540280996d2bd9266724829e53c91
Reviewed-on: https://go-review.googlesource.com/47359
Reviewed-by: Filippo Valsorda <hi@filippo.io>
Run-TryBot: Filippo Valsorda <hi@filippo.io>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/archive')
| -rw-r--r-- | src/archive/zip/writer_test.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/archive/zip/writer_test.go b/src/archive/zip/writer_test.go index 3072f60027..e0bcad61d3 100644 --- a/src/archive/zip/writer_test.go +++ b/src/archive/zip/writer_test.go @@ -58,8 +58,8 @@ var writeTests = []WriteTest{ func TestWriter(t *testing.T) { largeData := make([]byte, 1<<17) - for i := range largeData { - largeData[i] = byte(rand.Int()) + if _, err := rand.Read(largeData); err != nil { + t.Fatal("rand.Read failed:", err) } writeTests[1].Data = largeData defer func() { @@ -201,8 +201,8 @@ func TestWriterUTF8(t *testing.T) { func TestWriterOffset(t *testing.T) { largeData := make([]byte, 1<<17) - for i := range largeData { - largeData[i] = byte(rand.Int()) + if _, err := rand.Read(largeData); err != nil { + t.Fatal("rand.Read failed:", err) } writeTests[1].Data = largeData defer func() { |
