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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 190 |
191 if err := w.Flush(); err != nil { | 191 if err := w.Flush(); err != nil { |
192 t.Fatal(err) | 192 t.Fatal(err) |
193 } | 193 } |
194 | 194 |
195 n3 := buf.Len() | 195 n3 := buf.Len() |
196 if n2 == n3 { | 196 if n2 == n3 { |
197 t.Fatal("Flush didn't flush any data") | 197 t.Fatal("Flush didn't flush any data") |
198 } | 198 } |
199 } | 199 } |
| 200 |
| 201 // Multiple gzip files concatenated form a valid gzip file. |
| 202 func TestConcat(t *testing.T) { |
| 203 var buf bytes.Buffer |
| 204 w := NewWriter(&buf) |
| 205 w.Write([]byte("hello ")) |
| 206 w.Close() |
| 207 w = NewWriter(&buf) |
| 208 w.Write([]byte("world\n")) |
| 209 w.Close() |
| 210 |
| 211 r, err := NewReader(&buf) |
| 212 data, err := ioutil.ReadAll(r) |
| 213 if string(data) != "hello world\n" || err != nil { |
| 214 t.Fatalf("ReadAll = %q, %v, want %q, nil", data, err, "hello wor
ld") |
| 215 } |
| 216 } |
LEFT | RIGHT |