Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(663)

Delta Between Two Patch Sets: src/pkg/crypto/rand/rand_test.go

Issue 5639057: code review 5639057: compress/gzip: NewWriter no longer returns an error. (Closed)
Left Patch Set: Created 13 years, 1 month ago
Right Patch Set: diff -r 838fa1514da3 https://go.googlecode.com/hg/ Created 13 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
LEFTRIGHT
(no file at all)
1 // Copyright 2010 The Go Authors. All rights reserved. 1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package rand 5 package rand
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "compress/flate" 9 "compress/flate"
10 "testing" 10 "testing"
11 ) 11 )
12 12
13 func TestRead(t *testing.T) { 13 func TestRead(t *testing.T) {
14 var n int = 4e6 14 var n int = 4e6
15 if testing.Short() { 15 if testing.Short() {
16 n = 1e5 16 n = 1e5
17 } 17 }
18 b := make([]byte, n) 18 b := make([]byte, n)
19 n, err := Read(b) 19 n, err := Read(b)
20 if n != len(b) || err != nil { 20 if n != len(b) || err != nil {
21 t.Fatalf("Read(buf) = %d, %s", n, err) 21 t.Fatalf("Read(buf) = %d, %s", n, err)
22 } 22 }
23 23
24 var z bytes.Buffer 24 var z bytes.Buffer
25 » f := flate.NewWriter(&z, 5) 25 » f, _ := flate.NewWriter(&z, 5)
26 f.Write(b) 26 f.Write(b)
27 f.Close() 27 f.Close()
28 if z.Len() < len(b)*99/100 { 28 if z.Len() < len(b)*99/100 {
29 t.Fatalf("Compressed %d -> %d", len(b), z.Len()) 29 t.Fatalf("Compressed %d -> %d", len(b), z.Len())
30 } 30 }
31 } 31 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b