Skip to content

Commit

Permalink
zstd: Add IgnoreChecksum test to basic decoder UTs (#584)
Browse files Browse the repository at this point in the history
  • Loading branch information
WojciechMula authored May 9, 2022
1 parent 2f43739 commit 449d064
Showing 1 changed file with 14 additions and 12 deletions.
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

0 comments on commit 449d064

Please sign in to comment.