-
Notifications
You must be signed in to change notification settings - Fork 2
/
options_test.go
58 lines (54 loc) · 992 Bytes
/
options_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
package currency
import (
"testing"
"time"
)
func TestWithDate(t *testing.T) {
testCases := []struct {
name string
day int
month time.Month
year int
expDate string
}{
{
name: "D M YYYY format",
day: 1,
month: time.March,
year: 2023,
expDate: "01032023",
},
{
name: "DD M YYYY format",
day: 12,
month: time.May,
year: 2023,
expDate: "12052023",
},
{
name: "D MM YYYY format",
day: 3,
month: time.December,
year: 2023,
expDate: "03122023",
},
{
name: "DD MM YYYY format",
day: 20,
month: time.November,
year: 2023,
expDate: "20112023",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
tcmb := &TCMB{}
o := WithDate(tc.day, tc.month, tc.year)
o(tcmb)
if tcmb.date != tc.expDate {
t.Errorf("expected date: %s\nactual date: %s", tc.expDate, tcmb.date)
}
t.Logf("date: %s", tcmb.date)
})
}
}