aboutsummaryrefslogtreecommitdiff
path: root/internal/compress/zlib
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-05 21:25:39 +0800
committerGravatar Runxi Yu2026-03-05 21:25:39 +0800
commit9ba4a988bcc7879b62e0c0fff910113df481c599 (patch)
tree0b5d4318af242b96102a857a8593e59b1b9f2c3a /internal/compress/zlib
parent*: Fix wsl_v5 again (diff)
signatureNo signature
*: Fix various lints
Diffstat (limited to 'internal/compress/zlib')
-rw-r--r--internal/compress/zlib/reader_reset.go2
-rw-r--r--internal/compress/zlib/reader_test.go2
-rw-r--r--internal/compress/zlib/writer_test.go12
3 files changed, 15 insertions, 1 deletions
diff --git a/internal/compress/zlib/reader_reset.go b/internal/compress/zlib/reader_reset.go
index fbcaccac..fe675c73 100644
--- a/internal/compress/zlib/reader_reset.go
+++ b/internal/compress/zlib/reader_reset.go
@@ -57,7 +57,7 @@ func (z *Reader) reset(r io.Reader, dict []byte) error {
}
haveDict := z.scratch[1]&0x20 != 0
- if haveDict {
+ if haveDict { //nolint:nestif
readN, z.err = io.ReadFull(z.r, z.scratch[0:4])
readNUint64, err := intconv.IntToUint64(readN)
diff --git a/internal/compress/zlib/reader_test.go b/internal/compress/zlib/reader_test.go
index 6fda1f27..13f32dbc 100644
--- a/internal/compress/zlib/reader_test.go
+++ b/internal/compress/zlib/reader_test.go
@@ -151,6 +151,8 @@ var zlibTests = []zlibTest{
}
func TestDecompressor(t *testing.T) {
+ t.Parallel()
+
b := new(bytes.Buffer)
for _, tt := range zlibTests {
in := bytes.NewReader(tt.compressed)
diff --git a/internal/compress/zlib/writer_test.go b/internal/compress/zlib/writer_test.go
index b2bbd6be..2a8318a6 100644
--- a/internal/compress/zlib/writer_test.go
+++ b/internal/compress/zlib/writer_test.go
@@ -25,6 +25,8 @@ var data = []string{
// Tests that compressing and then decompressing the given file at the given compression level and dictionary
// yields equivalent bytes to the original file.
func testFileLevelDict(t *testing.T, fn string, level int, d string) {
+ t.Helper()
+
// Read the file, as golden output.
golden, err := os.Open(fn)
if err != nil {
@@ -51,6 +53,8 @@ func testFileLevelDict(t *testing.T, fn string, level int, d string) {
}
func testLevelDict(t *testing.T, fn string, b0 []byte, level int, d string) {
+ t.Helper()
+
// Make dictionary, if given.
var dict []byte
if d != "" {
@@ -135,6 +139,8 @@ func testLevelDict(t *testing.T, fn string, b0 []byte, level int, d string) {
}
func TestWriter(t *testing.T) {
+ t.Parallel()
+
for i, s := range data {
b := []byte(s)
tag := fmt.Sprintf("#%d", i)
@@ -149,6 +155,8 @@ func TestWriter(t *testing.T) {
}
func TestWriterBig(t *testing.T) {
+ t.Parallel()
+
for i, fn := range filenames {
testFileLevelDict(t, fn, DefaultCompression, "")
testFileLevelDict(t, fn, NoCompression, "")
@@ -169,6 +177,8 @@ func TestWriterBig(t *testing.T) {
}
func TestWriterDict(t *testing.T) {
+ t.Parallel()
+
const dictionary = "0123456789."
for i, fn := range filenames {
testFileLevelDict(t, fn, DefaultCompression, dictionary)
@@ -190,6 +200,8 @@ func TestWriterDict(t *testing.T) {
}
func TestWriterDictIsUsed(t *testing.T) {
+ t.Parallel()
+
var (
input = []byte("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")
buf bytes.Buffer