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 gzip | 5 package gzip |
6 | 6 |
7 import ( | 7 import ( |
8 "bufio" | 8 "bufio" |
9 "bytes" | 9 "bytes" |
10 "io/ioutil" | 10 "io/ioutil" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 w = NewWriter(&buf) | 207 w = NewWriter(&buf) |
208 w.Write([]byte("world\n")) | 208 w.Write([]byte("world\n")) |
209 w.Close() | 209 w.Close() |
210 | 210 |
211 r, err := NewReader(&buf) | 211 r, err := NewReader(&buf) |
212 data, err := ioutil.ReadAll(r) | 212 data, err := ioutil.ReadAll(r) |
213 if string(data) != "hello world\n" || err != nil { | 213 if string(data) != "hello world\n" || err != nil { |
214 t.Fatalf("ReadAll = %q, %v, want %q, nil", data, err, "hello wor
ld") | 214 t.Fatalf("ReadAll = %q, %v, want %q, nil", data, err, "hello wor
ld") |
215 } | 215 } |
216 } | 216 } |
| 217 |
| 218 func TestWriterReset(t *testing.T) { |
| 219 buf := new(bytes.Buffer) |
| 220 buf2 := new(bytes.Buffer) |
| 221 z := NewWriter(buf) |
| 222 msg := []byte("hello world") |
| 223 z.Write(msg) |
| 224 z.Close() |
| 225 z.Reset(buf2) |
| 226 z.Write(msg) |
| 227 z.Close() |
| 228 if buf.String() != buf2.String() { |
| 229 t.Errorf("buf2 %q != original buf of %q", buf2.String(), buf.Str
ing()) |
| 230 } |
| 231 } |
LEFT | RIGHT |