Skip to content

archive/zip: Error zip reader test  #7292

Description

@gopherbot

by iacob.campia:

By curiosity I was looking over the source code and spotted an error in the
/archive/zip/reader_test.go that when fixed, the test fails.

https://code.google.com/p/go/source/browse/src/pkg/archive/zip/reader_test.go#358


340:  func readTestFile(t *testing.T, zt ZipTest, ft ZipTestFile, f *File) {
       // ....

358:    size0 := f.UncompressedSize

        var b bytes.Buffer
        r, err := f.Open()
        if err != nil {
                t.Errorf("%s: %v", zt.Name, err)
                return
        }

367:    if size1 := f.UncompressedSize; size0 != size1 {
                t.Errorf("file %q changed f.UncompressedSize from %d to %d", f.Name, size0, size1)
        }

As seen in there, first it saves UncompresedSize value in size0 then compares it with
itself as size1 and not to the length of the uncompressed bytes.

If you fix it, the test will fail with:

--- FAIL: TestReader (0.01 seconds)
        reader_test.go:367: file "README" changed f.UncompressedSize from 4294967295 to 36

Yhe value of UncompresedSize is actually 4294967295 bytes and of the uncompressed data
36 bytes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions