diff options
author | Evgenii Kliuchnikov <eustas@google.com> | 2023-08-29 03:59:55 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-08-29 04:00:29 -0700 |
commit | ed738e842d2fbdf2d6459e39267a633c4a9b2f5d (patch) | |
tree | 66d65f2a9bf3dec372ceda26358ccc78ac3decab | |
parent | e7313b0c4e9d57a4655a7e306a06269124f509b4 (diff) | |
download | brotli-1.1.0.zip brotli-1.1.0.tar.gz brotli-1.1.0.tar.bz2 |
PiperOrigin-RevId: 560982956
-rw-r--r-- | go/cbrotli/cbrotli_test.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/go/cbrotli/cbrotli_test.go b/go/cbrotli/cbrotli_test.go index 36ad2ba..254c0cd 100644 --- a/go/cbrotli/cbrotli_test.go +++ b/go/cbrotli/cbrotli_test.go @@ -141,7 +141,8 @@ func TestEncoderLargeInput(t *testing.T) { } func TestEncoderFlush(t *testing.T) { - input := make([]byte, 1000) + const payload = 32766 // Enough to force encoder emit 2 chunks + input := make([]byte, payload) rand.Read(input) out := bytes.Buffer{} e := NewWriter(&out, WriterOptions{Quality: 5}) @@ -156,11 +157,16 @@ func TestEncoderFlush(t *testing.T) { if out.Len() == 0 { t.Fatalf("0 bytes written after Flush()") } - decompressed := make([]byte, 1000) + decompressed := make([]byte, payload) reader := NewReader(bytes.NewReader(out.Bytes())) n, err := reader.Read(decompressed) + if n >= len(decompressed) || err != nil { + t.Errorf("Expected {<%v, nil}, but got {%v, %v}", len(decompressed), n, err) + } + m, err := reader.Read(decompressed[n:]) + n += m if n != len(decompressed) || err != nil { - t.Errorf("Expected <%v, nil>, but <%v, %v>", len(decompressed), n, err) + t.Errorf("Expected {%v, nil}, but got {%v, %v}", len(decompressed), n, err) } reader.Close() if !bytes.Equal(decompressed, input) { |