Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1601)

Delta Between Two Patch Sets: src/pkg/archive/tar/reader_test.go

Issue 6700047: code review 6700047: archive/tar: read/write extended pax/gnu tar archives (Closed)
Left Patch Set: diff -r 439cb8bad388 https://code.google.com/p/go Created 11 years, 1 month ago
Right Patch Set: diff -r 439cb8bad388 https://code.google.com/p/go Created 11 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/archive/tar/reader.go ('k') | src/pkg/archive/tar/testdata/pax.tar » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package tar 5 package tar
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "crypto/md5" 9 "crypto/md5"
10 "fmt" 10 "fmt"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 func TestParsePAXHeader(t *testing.T) { 298 func TestParsePAXHeader(t *testing.T) {
299 paxTests := [][3]string{ 299 paxTests := [][3]string{
300 {"a", "a=name", "10 a=name\n"}, // Test case involving multiple acceptable lengths 300 {"a", "a=name", "10 a=name\n"}, // Test case involving multiple acceptable lengths
301 {"a", "a=name", "9 a=name\n"}, // Test case involving multiple acceptable length 301 {"a", "a=name", "9 a=name\n"}, // Test case involving multiple acceptable length
302 {"mtime", "mtime=1350244992.023960108", "30 mtime=1350244992.023 960108\n"}} 302 {"mtime", "mtime=1350244992.023960108", "30 mtime=1350244992.023 960108\n"}}
303 for _, test := range paxTests { 303 for _, test := range paxTests {
304 key, expected, raw := test[0], test[1], test[2] 304 key, expected, raw := test[0], test[1], test[2]
305 reader := bytes.NewBuffer([]byte(raw)) 305 reader := bytes.NewBuffer([]byte(raw))
306 headers, err := parsePAX(reader) 306 headers, err := parsePAX(reader)
307 if err != nil { 307 if err != nil {
308 » » » t.Fatalf("Couldn't parse correctly formatted headers %s" , err) 308 » » » t.Errorf("Couldn't parse correctly formatted headers: %v ", err)
dsymonds 2013/02/07 04:16:27 "...: %v" at the end of the error string. t.Error
shanemhansen 2013/02/07 04:35:43 Done.
309 » » » continue
309 } 310 }
310 if strings.EqualFold(headers[key], expected) { 311 if strings.EqualFold(headers[key], expected) {
311 » » » t.Fatalf("mtime header incorrectly parsed") 312 » » » t.Errorf("mtime header incorrectly parsed: got %s, wante d %s", headers[key], expected)
dsymonds 2013/02/07 04:16:27 include the got/want in the error output, and make
shanemhansen 2013/02/07 04:35:43 Done.
313 » » » continue
312 } 314 }
313 trailer := make([]byte, 100) 315 trailer := make([]byte, 100)
314 n, err := reader.Read(trailer) 316 n, err := reader.Read(trailer)
315 if err != io.EOF || n != 0 { 317 if err != io.EOF || n != 0 {
316 » » » t.Fatal("Buffer wasn't consumed") 318 » » » t.Error("Buffer wasn't consumed")
317 } 319 }
318 } 320 }
319 badHeader := bytes.NewBuffer([]byte("3 somelongkey=")) 321 badHeader := bytes.NewBuffer([]byte("3 somelongkey="))
320 if _, err := parsePAX(badHeader); err != ErrHeader { 322 if _, err := parsePAX(badHeader); err != ErrHeader {
321 t.Fatal("Unexpected success when parsing bad header") 323 t.Fatal("Unexpected success when parsing bad header")
322 } 324 }
323 } 325 }
324 326
325 func TestParsePAXTime(t *testing.T) { 327 func TestParsePAXTime(t *testing.T) {
326 // Some valid PAX time values 328 // Some valid PAX time values
(...skipping 28 matching lines...) Expand all
355 } 357 }
356 want := &Header{ 358 want := &Header{
357 Name: "a/b/c", 359 Name: "a/b/c",
358 Uid: 1000, 360 Uid: 1000,
359 ModTime: time.Unix(1350244992, 23960108), 361 ModTime: time.Unix(1350244992, 23960108),
360 } 362 }
361 if !reflect.DeepEqual(hdr, want) { 363 if !reflect.DeepEqual(hdr, want) {
362 t.Errorf("incorrect merge: got %+v, want %+v", hdr, want) 364 t.Errorf("incorrect merge: got %+v, want %+v", hdr, want)
363 } 365 }
364 } 366 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b