Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zstd: Add IgnoreChecksum test to basic decoder UTs #584

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions zstd/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,19 @@ func TestErrorWriter(t *testing.T) {

func TestNewDecoder(t *testing.T) {
for _, n := range []int{1, 4} {
t.Run(fmt.Sprintf("cpu-%d", n), func(t *testing.T) {
newFn := func() (*Decoder, error) {
return NewReader(nil, WithDecoderConcurrency(n))
}
testDecoderFile(t, "testdata/decoder.zip", newFn)
dec, err := newFn()
if err != nil {
t.Fatal(err)
}
testDecoderDecodeAll(t, "testdata/decoder.zip", dec)
})
for _, ignoreCRC := range []bool{false, true} {
t.Run(fmt.Sprintf("cpu-%d", n), func(t *testing.T) {
newFn := func() (*Decoder, error) {
return NewReader(nil, WithDecoderConcurrency(n), IgnoreChecksum(ignoreCRC))
}
testDecoderFile(t, "testdata/decoder.zip", newFn)
dec, err := newFn()
if err != nil {
t.Fatal(err)
}
testDecoderDecodeAll(t, "testdata/decoder.zip", dec)
})
}
}
}

Expand Down Expand Up @@ -1738,7 +1740,7 @@ func TestResetNil(t *testing.T) {
}

func TestIgnoreChecksum(t *testing.T) {
// zstd file containing text "compress\n" and has a xxhash checksum
// zstd file containing text "compress\n" and has an xxhash checksum
zstdBlob := []byte{0x28, 0xb5, 0x2f, 0xfd, 0x24, 0x09, 0x49, 0x00, 0x00, 'C', 'o', 'm', 'p', 'r', 'e', 's', 's', '\n', 0x79, 0x6e, 0xe0, 0xd2}

// replace letter 'c' with 'C', so decoding should fail.
Expand Down