-
Notifications
You must be signed in to change notification settings - Fork 0
/
time_test.go
71 lines (66 loc) · 1012 Bytes
/
time_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package pt_test
import (
"fmt"
"testing"
"time"
"github.com/gochore/pt"
)
func TestTime(t *testing.T) {
now := time.Now()
type args struct {
v time.Time
}
tests := []struct {
args args
want time.Time
}{
{
args: args{
v: time.Time{},
},
want: time.Time{},
},
{
args: args{
v: now,
},
want: now,
},
}
for _, tt := range tests {
t.Run(fmt.Sprint(tt.want), func(t *testing.T) {
if got := pt.Time(tt.args.v); !got.Equal(tt.want) {
t.Errorf("Time() = %v, want %v", got, tt.want)
}
})
}
}
func TestDuration(t *testing.T) {
type args struct {
v time.Duration
}
tests := []struct {
args args
want time.Duration
}{
{
args: args{
v: 0,
},
want: 0,
},
{
args: args{
v: time.Hour,
},
want: time.Hour,
},
}
for _, tt := range tests {
t.Run(fmt.Sprint(tt.want), func(t *testing.T) {
if got := pt.Duration(tt.args.v); *got != tt.want {
t.Errorf("Duration() = %v, want %v", got, tt.want)
}
})
}
}