diff options
Diffstat (limited to 'libgo/go/archive/zip/zip_test.go')
-rw-r--r-- | libgo/go/archive/zip/zip_test.go | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/libgo/go/archive/zip/zip_test.go b/libgo/go/archive/zip/zip_test.go index 3d5c759..b3a7caa 100644 --- a/libgo/go/archive/zip/zip_test.go +++ b/libgo/go/archive/zip/zip_test.go @@ -11,7 +11,6 @@ import ( "errors" "fmt" "hash" - "internal/race" "internal/testenv" "io" "io/ioutil" @@ -114,6 +113,47 @@ func TestFileHeaderRoundTrip64(t *testing.T) { testHeaderRoundTrip(fh, uint32max, fh.UncompressedSize64, t) } +func TestFileHeaderRoundTripModified(t *testing.T) { + fh := &FileHeader{ + Name: "foo.txt", + UncompressedSize: 987654321, + Modified: time.Now().Local(), + ModifiedTime: 1234, + ModifiedDate: 5678, + } + fi := fh.FileInfo() + fh2, err := FileInfoHeader(fi) + if err != nil { + t.Fatal(err) + } + if got, want := fh2.Modified, fh.Modified.UTC(); got != want { + t.Errorf("Modified: got %s, want %s\n", got, want) + } + if got, want := fi.ModTime(), fh.Modified.UTC(); got != want { + t.Errorf("Modified: got %s, want %s\n", got, want) + } +} + +func TestFileHeaderRoundTripWithoutModified(t *testing.T) { + fh := &FileHeader{ + Name: "foo.txt", + UncompressedSize: 987654321, + ModifiedTime: 1234, + ModifiedDate: 5678, + } + fi := fh.FileInfo() + fh2, err := FileInfoHeader(fi) + if err != nil { + t.Fatal(err) + } + if got, want := fh2.ModTime(), fh.ModTime(); got != want { + t.Errorf("Modified: got %s, want %s\n", got, want) + } + if got, want := fi.ModTime(), fh.ModTime(); got != want { + t.Errorf("Modified: got %s, want %s\n", got, want) + } +} + type repeatedByte struct { off int64 b byte @@ -268,7 +308,7 @@ func TestZip64EdgeCase(t *testing.T) { // Tests that we generate a zip64 file if the directory at offset // 0xFFFFFFFF, but not before. func TestZip64DirectoryOffset(t *testing.T) { - if testing.Short() && race.Enabled { + if testing.Short() { t.Skip("skipping in short mode") } t.Parallel() @@ -313,7 +353,7 @@ func TestZip64DirectoryOffset(t *testing.T) { // At 16k records, we need to generate a zip64 file. func TestZip64ManyRecords(t *testing.T) { - if testing.Short() && race.Enabled { + if testing.Short() { t.Skip("skipping in short mode") } t.Parallel() |