Debian Codegraph @

gzhttp/writer/gzstd/stdlib_test.go

raw
1 package gzstd
2
3 import (
4 "bytes"
5 "compress/gzip"
6 "testing"
7 )
8
9 func TestGzipDoubleClose(t *testing.T) {
10 // reset the pool for the default compression so we can make sure duplicates
11 // aren't added back by double close
12 addLevelPool(gzip.DefaultCompression)
13
14 w := bytes.NewBufferString("")
15 writer := NewWriter(w, gzip.DefaultCompression)
16 writer.Close()
17
18 // the second close shouldn't have added the same writer
19 // so we pull out 2 writers from the pool and make sure they're different
20 w1 := gzipWriterPools[poolIndex(gzip.DefaultCompression)].Get()
21 w2 := gzipWriterPools[poolIndex(gzip.DefaultCompression)].Get()
22
23 if w1 == w2 {
24 t.Fatal("got same writer")
25 }
26
27 }