OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 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 flate | 5 package flate |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes"; | 8 "bytes"; |
9 "fmt"; | 9 "fmt"; |
10 » "io"; | 10 » "io/ioutil"; |
11 "os"; | 11 "os"; |
12 "testing"; | 12 "testing"; |
13 ) | 13 ) |
14 | 14 |
15 type deflateTest struct { | 15 type deflateTest struct { |
16 in []byte; | 16 in []byte; |
17 level int; | 17 level int; |
18 out []byte; | 18 out []byte; |
19 } | 19 } |
20 | 20 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 } | 90 } |
91 } | 91 } |
92 | 92 |
93 func testToFromWithLevel(t *testing.T, level int, input []byte, name string) os.
Error { | 93 func testToFromWithLevel(t *testing.T, level int, input []byte, name string) os.
Error { |
94 buffer := bytes.NewBuffer([]byte{}); | 94 buffer := bytes.NewBuffer([]byte{}); |
95 w := NewDeflater(buffer, level); | 95 w := NewDeflater(buffer, level); |
96 w.Write(input); | 96 w.Write(input); |
97 w.Close(); | 97 w.Close(); |
98 inflater := NewInflater(buffer); | 98 inflater := NewInflater(buffer); |
99 » decompressed, err := io.ReadAll(inflater); | 99 » decompressed, err := ioutil.ReadAll(inflater); |
100 if err != nil { | 100 if err != nil { |
101 t.Errorf("reading inflater: %s", err); | 101 t.Errorf("reading inflater: %s", err); |
102 return err; | 102 return err; |
103 } | 103 } |
104 inflater.Close(); | 104 inflater.Close(); |
105 if bytes.Compare(input, decompressed) != 0 { | 105 if bytes.Compare(input, decompressed) != 0 { |
106 t.Errorf("decompress(compress(data)) != data: level=%d input=%s"
, level, name) | 106 t.Errorf("decompress(compress(data)) != data: level=%d input=%s"
, level, name) |
107 } | 107 } |
108 return nil; | 108 return nil; |
109 } | 109 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 "581966563941148961716832980455139729506687604740915420428429993
54102582911350224" + | 255 "581966563941148961716832980455139729506687604740915420428429993
54102582911350224" + |
256 "169076943166857424252250902693903481485645130306992519959043638
40284292674125734" + | 256 "169076943166857424252250902693903481485645130306992519959043638
40284292674125734" + |
257 "224477655841778861717372654620854982944989467873509295816526320
72258992368768457" + | 257 "224477655841778861717372654620854982944989467873509295816526320
72258992368768457" + |
258 "017823038096567883112289305809140572610865884845873101658151167
53332767488701482" + | 258 "017823038096567883112289305809140572610865884845873101658151167
53332767488701482" + |
259 "916741970151255978257270740643180860142814902414678047232759768
42696339357735429" + | 259 "916741970151255978257270740643180860142814902414678047232759768
42696339357735429" + |
260 "301867394397163886117642090040686633988568416810038723892144831
76070116684503887" + | 260 "301867394397163886117642090040686633988568416810038723892144831
76070116684503887" + |
261 "212364367043314091155733280182977988736590916659612402021778558
85487617616198937" + | 261 "212364367043314091155733280182977988736590916659612402021778558
85487617616198937" + |
262 "079438005666336488436508914480557103976521469602766258359905198
70423001794655367" + | 262 "079438005666336488436508914480557103976521469602766258359905198
70423001794655367" + |
263 "9" | 263 "9" |
264 } | 264 } |
OLD | NEW |