]> Cypherpunks repositories - gostls13.git/commitdiff
archive/zip: actually test uncompressed size
authorAndrew Gerrand <adg@golang.org>
Tue, 11 Feb 2014 05:09:42 +0000 (16:09 +1100)
committerAndrew Gerrand <adg@golang.org>
Tue, 11 Feb 2014 05:09:42 +0000 (16:09 +1100)
Fixes #7292.

LGTM=dsymonds
R=dsymonds
CC=golang-codereviews
https://golang.org/cl/61650046

src/pkg/archive/zip/reader_test.go

index 4292a50e30fd160030522473c3fb78a5bd5c2f62..971fbedb5c882202e15e63161bcc7ff1d390bff2 100644 (file)
@@ -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