File: stdlib_test.go

package info (click to toggle)
golang-github-klauspost-compress 1.17.2%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 46,376 kB
  • sloc: asm: 23,058; sh: 73; makefile: 11
file content (27 lines) | stat: -rw-r--r-- 673 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package gzstd

import (
	"bytes"
	"compress/gzip"
	"testing"
)

func TestGzipDoubleClose(t *testing.T) {
	// reset the pool for the default compression so we can make sure duplicates
	// aren't added back by double close
	addLevelPool(gzip.DefaultCompression)

	w := bytes.NewBufferString("")
	writer := NewWriter(w, gzip.DefaultCompression)
	writer.Close()

	// the second close shouldn't have added the same writer
	// so we pull out 2 writers from the pool and make sure they're different
	w1 := gzipWriterPools[poolIndex(gzip.DefaultCompression)].Get()
	w2 := gzipWriterPools[poolIndex(gzip.DefaultCompression)].Get()

	if w1 == w2 {
		t.Fatal("got same writer")
	}

}