-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathformat_test.go
112 lines (108 loc) · 2.39 KB
/
format_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
package date_range_format
import (
"testing"
"time"
)
type TestCase struct {
key string
lang string
d1 time.Time
d2 time.Time
result string
}
var testCases = []TestCase{
{
"uk-same-date",
"uk",
time.Date(2017, 1, 1, 0, 0, 0, 0, time.Local),
time.Date(2017, 1, 1, 0, 0, 0, 0, time.Local),
"1 січня 2017",
},
{
"uk-same-month",
"uk",
time.Date(2017, 1, 1, 0, 0, 0, 0, time.Local),
time.Date(2017, 1, 5, 0, 0, 0, 0, time.Local),
"1 - 5 січня 2017",
},
{
"uk-same-year",
"uk",
time.Date(2017, 1, 30, 0, 0, 0, 0, time.Local),
time.Date(2017, 2, 7, 0, 0, 0, 0, time.Local),
"30 січня - 7 лютого 2017",
},
{
"uk-different-years",
"uk",
time.Date(2016, 12, 30, 0, 0, 0, 0, time.Local),
time.Date(2017, 1, 6, 0, 0, 0, 0, time.Local),
"30 грудня 2016 - 6 січня 2017",
},
{
"ru-same-date",
"ru",
time.Date(2017, 1, 1, 0, 0, 0, 0, time.Local),
time.Date(2017, 1, 1, 0, 0, 0, 0, time.Local),
"1 января 2017",
},
{
"ru-same-month",
"ru",
time.Date(2017, 1, 1, 0, 0, 0, 0, time.Local),
time.Date(2017, 1, 5, 0, 0, 0, 0, time.Local),
"1 - 5 января 2017",
},
{
"ru-same-year",
"ru",
time.Date(2017, 1, 30, 0, 0, 0, 0, time.Local),
time.Date(2017, 2, 7, 0, 0, 0, 0, time.Local),
"30 января - 7 февраля 2017",
},
{
"ru-different-years",
"ru",
time.Date(2016, 12, 30, 0, 0, 0, 0, time.Local),
time.Date(2017, 1, 6, 0, 0, 0, 0, time.Local),
"30 декабря 2016 - 6 января 2017",
},
{
"en-same-date",
"en",
time.Date(2017, 1, 1, 0, 0, 0, 0, time.Local),
time.Date(2017, 1, 1, 0, 0, 0, 0, time.Local),
"January, 1 2017",
},
{
"en-same-month",
"en",
time.Date(2017, 1, 1, 0, 0, 0, 0, time.Local),
time.Date(2017, 1, 5, 0, 0, 0, 0, time.Local),
"January, 1-5 2017",
},
{
"en-same-year",
"en",
time.Date(2017, 1, 30, 0, 0, 0, 0, time.Local),
time.Date(2017, 2, 7, 0, 0, 0, 0, time.Local),
"January, 30 - February, 7 2017",
},
{
"en-different-years",
"en",
time.Date(2016, 12, 30, 0, 0, 0, 0, time.Local),
time.Date(2017, 1, 6, 0, 0, 0, 0, time.Local),
"December, 30 2016 - January, 6 2017",
},
}
func TestDateRangeFormat(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.key, func(t *testing.T){
f := DateRangeFormat(tc.lang, tc.d1, tc.d2)
if f != tc.result {
t.Errorf("got %s; want %s", f, tc.result)
}
})
}
}