Commit 413e28da authored by Andrew Gerrand's avatar Andrew Gerrand

archive/zip: actually test uncompressed size

Fixes #7292.

LGTM=dsymonds
R=dsymonds
CC=golang-codereviews
https://golang.org/cl/61650046
parent d908ae17
......@@ -355,8 +355,6 @@ func readTestFile(t *testing.T, zt ZipTest, ft ZipTestFile, f *File) {
testFileMode(t, zt.Name, f, ft.Mode)
size0 := f.UncompressedSize
var b bytes.Buffer
r, err := f.Open()
if err != nil {
......@@ -364,10 +362,6 @@ func readTestFile(t *testing.T, zt ZipTest, ft ZipTestFile, f *File) {
return
}
if size1 := f.UncompressedSize; size0 != size1 {
t.Errorf("file %q changed f.UncompressedSize from %d to %d", f.Name, size0, size1)
}
_, err = io.Copy(&b, r)
if err != ft.ContentErr {
t.Errorf("%s: copying contents: %v (want %v)", zt.Name, err, ft.ContentErr)
......@@ -377,6 +371,14 @@ func readTestFile(t *testing.T, zt ZipTest, ft ZipTestFile, f *File) {
}
r.Close()
size := int(f.UncompressedSize)
if size == 1<<32-1 {
size = int(f.UncompressedSize64)
}
if g := b.Len(); g != size {
t.Errorf("%v: read %v bytes but f.UncompressedSize == %v", f.Name, g, size)
}
var c []byte
if ft.Content != nil {
c = ft.Content
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment