-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathformat_cpt_test.go
131 lines (125 loc) · 2.67 KB
/
format_cpt_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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package timekit
import (
"testing"
"time"
)
func TestFormatCptOfYyyyMm(t *testing.T) {
d, _ := time.ParseInLocation(YyyyMmDdHhMmSs, "2022-04-30 10:00:00", time.Local)
type args struct {
d time.Time
}
tests := []struct {
name string
args args
want string
}{
{
name: "FormatCptOfYyyyMm",
args: args{d: d},
want: "202204",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := FormatCptOfYyyyMm(tt.args.d); got != tt.want {
t.Errorf("FormatCptOfYyyyMm() = %v, want %v", got, tt.want)
}
})
}
}
func TestFormatCptOfYyyyMmDd(t *testing.T) {
d, _ := time.ParseInLocation(YyyyMmDdHhMmSs, "2022-04-01 10:00:00", time.Local)
type args struct {
d time.Time
}
tests := []struct {
name string
args args
want string
}{
{
name: "FormatCptOfYyyyMmDd",
args: args{d: d},
want: "20220401",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := FormatCptOfYyyyMmDd(tt.args.d); got != tt.want {
t.Errorf("FormatCptOfYyyyMmDd() = %v, want %v", got, tt.want)
}
})
}
}
func TestFormatCptOfYyyyMmDdHh(t *testing.T) {
d, _ := time.ParseInLocation(YyyyMmDdHhMmSs, "2022-04-13 23:59:00", time.Local)
type args struct {
d time.Time
}
tests := []struct {
name string
args args
want string
}{
{
name: "FormatCptOfYyyyMmDdHh",
args: args{d: d},
want: "2022041323",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := FormatCptOfYyyyMmDdHh(tt.args.d); got != tt.want {
t.Errorf("FormatCptOfYyyyMmDdHh() = %v, want %v", got, tt.want)
}
})
}
}
func TestFormatCptOfYyyyMmDdHhMm(t *testing.T) {
d, _ := time.ParseInLocation(YyyyMmDdHhMmSsSss, "2022-04-13 10:59:00.999", time.Local)
type args struct {
d time.Time
}
tests := []struct {
name string
args args
want string
}{
{
name: "FormatCptOfYyyyMmDdHhMm",
args: args{d: d},
want: "202204131059",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := FormatCptOfYyyyMmDdHhMm(tt.args.d); got != tt.want {
t.Errorf("FormatCptOfYyyyMmDdHhMm() = %v, want %v", got, tt.want)
}
})
}
}
func TestFormatCptOfYyyyMmDdHhMmSs(t *testing.T) {
d, _ := time.ParseInLocation(YyyyMmDdHhMmSsSss, "2022-04-13 13:20:01.123", time.Local)
type args struct {
d time.Time
}
tests := []struct {
name string
args args
want string
}{
{
name: "FormatCptOfYyyyMmDdHhMmSs",
args: args{d: d},
want: "20220413132001",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := FormatCptOfYyyyMmDdHhMmSs(tt.args.d); got != tt.want {
t.Errorf("FormatCptOfYyyyMmDdHhMmSs() = %v, want %v", got, tt.want)
}
})
}
}