LEFT | RIGHT |
(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 } |
LEFT | RIGHT |