mirror of
https://github.com/golang/go
synced 2024-11-19 15:44:44 -07:00
archive/zip: actually test uncompressed size
Fixes #7292. LGTM=dsymonds R=dsymonds CC=golang-codereviews https://golang.org/cl/61650046
This commit is contained in:
parent
d908ae17b2
commit
413e28da0d
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user