From 413e28da0d13a2b3387c4a5eca2c848fe3ba790c Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Tue, 11 Feb 2014 16:09:42 +1100 Subject: [PATCH] archive/zip: actually test uncompressed size Fixes #7292. LGTM=dsymonds R=dsymonds CC=golang-codereviews https://golang.org/cl/61650046 --- src/pkg/archive/zip/reader_test.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pkg/archive/zip/reader_test.go b/src/pkg/archive/zip/reader_test.go index 4292a50e30..971fbedb5c 100644 --- a/src/pkg/archive/zip/reader_test.go +++ b/src/pkg/archive/zip/reader_test.go @@ -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