summaryrefslogtreecommitdiff
path: root/libgo/go/compress/flate/flate_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/compress/flate/flate_test.go')
-rw-r--r--libgo/go/compress/flate/flate_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/libgo/go/compress/flate/flate_test.go b/libgo/go/compress/flate/flate_test.go
index 3f67025cd76..341d8071313 100644
--- a/libgo/go/compress/flate/flate_test.go
+++ b/libgo/go/compress/flate/flate_test.go
@@ -11,7 +11,9 @@ package flate
import (
"bytes"
"encoding/hex"
+ "io"
"io/ioutil"
+ "strings"
"testing"
)
@@ -258,3 +260,15 @@ func TestStreams(t *testing.T) {
}
}
}
+
+func TestTruncatedStreams(t *testing.T) {
+ const data = "\x00\f\x00\xf3\xffhello, world\x01\x00\x00\xff\xff"
+
+ for i := 0; i < len(data)-1; i++ {
+ r := NewReader(strings.NewReader(data[:i]))
+ _, err := io.Copy(ioutil.Discard, r)
+ if err != io.ErrUnexpectedEOF {
+ t.Errorf("io.Copy(%d) on truncated stream: got %v, want %v", i, err, io.ErrUnexpectedEOF)
+ }
+ }
+}