9
func TestDurationStrings(t *testing.T) {
10
cases := map[int]string{
12
1*12 + 3: "1 год 3 мес.",
14
2*12 + 4: "2 года 4 мес.",
15
3*12 + 3: "3 года 3 мес.",
16
4*12 + 7: "4 года 7 мес.",
17
5*12 + 4: "5 лет 4 мес.",
18
6*12 + 2: "6 лет 2 мес.",
19
7*12 + 1: "7 лет 1 мес.",
20
8*12 + 9: "8 лет 9 мес.",
21
9*12 + 4: "9 лет 4 мес.",
22
10*12 + 5: "10 лет 5 мес.",
24
17*12 + 2: "17 лет 2 мес.",
25
20*12 + 3: "20 лет 3 мес.",
26
21*12 + 4: "21 год 4 мес.",
27
22*12 + 9: "22 года 9 мес.",
28
23*12 + 8: "23 года 8 мес.",
29
24*12 + 7: "24 года 7 мес.",
30
25*12 + 6: "25 лет 6 мес.",
31
26*12 + 5: "26 лет 5 мес.",
32
27*12 + 4: "27 лет 4 мес.",
33
28*12 + 3: "28 лет 3 мес.",
34
29*12 + 2: "29 лет 2 мес.",
35
30*12 + 1: "30 лет 1 мес.",
38
for delta, expected := range cases {
39
actual := durationString(delta)
40
if actual != expected {
41
t.Errorf("durationString error: got %s; want %s", actual, expected)
46
func TestDuration(t *testing.T) {
54
StartDate: time.Date(2020, time.January, 1, 0, 0, 0, 0, time.UTC),
55
EndDate: time.Date(2020, time.February, 1, 0, 0, 0, 0, time.UTC),
62
StartDate: time.Date(2019, time.March, 10, 0, 0, 0, 0, time.UTC),
63
EndDate: time.Date(2020, time.April, 2, 0, 0, 0, 0, time.UTC),
70
StartDate: time.Date(2023, time.June, 4, 0, 0, 0, 0, time.UTC),
71
EndDate: time.Date(2023, time.June, 18, 0, 0, 0, 0, time.UTC),
78
StartDate: time.Date(2023, time.June, 6, 0, 0, 0, 0, time.UTC),
79
EndDate: time.Date(2023, time.June, 21, 0, 0, 0, 0, time.UTC),
86
StartDate: time.Date(2021, time.May, 6, 0, 0, 0, 0, time.UTC),
87
EndDate: time.Date(2022, time.July, 16, 0, 0, 0, 0, time.UTC),
93
for idx, item := range cases {
94
t.Run(strconv.Itoa(idx), func(t *testing.T) {
95
res := item.job.Duration()
97
t.Errorf("%s : got %s; want %s", item.job.Company, res, item.want)