github.com/koron/hk@v0.0.0-20150303213137-b8aeaa3ab34c/time_test.go (about) 1 package main 2 3 import ( 4 "testing" 5 "time" 6 ) 7 8 func TestRoundDur(t *testing.T) { 9 ts := []struct { 10 w int 11 d time.Duration 12 }{ 13 {2, 121 * time.Second}, 14 {2, 149 * time.Second}, 15 {3, 151 * time.Second}, 16 {3, 179 * time.Second}, 17 } 18 19 for _, ts := range ts { 20 g := roundDur(ts.d, time.Minute) 21 if ts.w != g { 22 t.Errorf("%d != %d", g, ts.w) 23 } 24 } 25 }