diff options
Diffstat (limited to 'libgo/go/compress/lzw/reader_test.go')
-rw-r--r-- | libgo/go/compress/lzw/reader_test.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libgo/go/compress/lzw/reader_test.go b/libgo/go/compress/lzw/reader_test.go index e5be12f54e8..6f155b1bdee 100644 --- a/libgo/go/compress/lzw/reader_test.go +++ b/libgo/go/compress/lzw/reader_test.go @@ -114,11 +114,19 @@ func TestReader(t *testing.T) { func benchmarkDecoder(b *testing.B, n int) { b.StopTimer() b.SetBytes(int64(n)) - buf0, _ := ioutil.ReadFile("../testdata/e.txt") - buf0 = buf0[:10000] + buf0, err := ioutil.ReadFile("../testdata/e.txt") + if err != nil { + b.Fatal(err) + } + if len(buf0) == 0 { + b.Fatalf("test file has no data") + } compressed := new(bytes.Buffer) w := NewWriter(compressed, LSB, 8) for i := 0; i < n; i += len(buf0) { + if len(buf0) > n-i { + buf0 = buf0[:n-i] + } io.Copy(w, bytes.NewBuffer(buf0)) } w.Close() |