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

Delta Between Two Patch Sets: src/pkg/time/time_test.go

Issue 5294074: code review 5294074: src/pkg/[n-z]*: gofix -r error (Closed)
Left Patch Set: Created 13 years, 4 months ago
Right Patch Set: diff -r b78bb4f2d2a3 https://go.googlecode.com/hg/ Created 13 years, 4 months 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:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/time/tick.go ('k') | src/pkg/time/zoneinfo_windows.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 time_test 5 package time_test
6 6
7 import ( 7 import (
8 "strconv" 8 "strconv"
9 "strings" 9 "strings"
10 "testing" 10 "testing"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 {"Mon Jan _2 15:04:05.000 2006", "Thu Feb 4 23:00:59x01 2010", "cannot parse"}, 380 {"Mon Jan _2 15:04:05.000 2006", "Thu Feb 4 23:00:59x01 2010", "cannot parse"},
381 {"Mon Jan _2 15:04:05.000 2006", "Thu Feb 4 23:00:59.xxx 2010", "cannot parse"}, 381 {"Mon Jan _2 15:04:05.000 2006", "Thu Feb 4 23:00:59.xxx 2010", "cannot parse"},
382 {"Mon Jan _2 15:04:05.000 2006", "Thu Feb 4 23:00:59.-123 2010", "fract ional second out of range"}, 382 {"Mon Jan _2 15:04:05.000 2006", "Thu Feb 4 23:00:59.-123 2010", "fract ional second out of range"},
383 } 383 }
384 384
385 func TestParseErrors(t *testing.T) { 385 func TestParseErrors(t *testing.T) {
386 for _, test := range parseErrorTests { 386 for _, test := range parseErrorTests {
387 _, err := Parse(test.format, test.value) 387 _, err := Parse(test.format, test.value)
388 if err == nil { 388 if err == nil {
389 t.Errorf("expected error for %q %q", test.format, test.v alue) 389 t.Errorf("expected error for %q %q", test.format, test.v alue)
390 » » } else if strings.Index(err.String(), test.expect) < 0 { 390 » » } else if strings.Index(err.Error(), test.expect) < 0 {
391 t.Errorf("expected error with %q for %q %q; got %s", tes t.expect, test.format, test.value, err) 391 t.Errorf("expected error with %q for %q %q; got %s", tes t.expect, test.format, test.value, err)
392 } 392 }
393 } 393 }
394 } 394 }
395 395
396 func TestNoonIs12PM(t *testing.T) { 396 func TestNoonIs12PM(t *testing.T) {
397 noon := Time{Hour: 12} 397 noon := Time{Hour: 12}
398 const expect = "12:00PM" 398 const expect = "12:00PM"
399 got := noon.Format("3:04PM") 399 got := noon.Format("3:04PM")
400 if got != expect { 400 if got != expect {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 for i := 0; i < b.N; i++ { 495 for i := 0; i < b.N; i++ {
496 time.Format("Mon Jan 2 15:04:05 2006") 496 time.Format("Mon Jan 2 15:04:05 2006")
497 } 497 }
498 } 498 }
499 499
500 func BenchmarkParse(b *testing.B) { 500 func BenchmarkParse(b *testing.B) {
501 for i := 0; i < b.N; i++ { 501 for i := 0; i < b.N; i++ {
502 Parse(ANSIC, "Mon Jan 2 15:04:05 2006") 502 Parse(ANSIC, "Mon Jan 2 15:04:05 2006")
503 } 503 }
504 } 504 }
LEFTRIGHT

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