This repository has been archived by the owner on Feb 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
github_test.go
80 lines (76 loc) · 1.68 KB
/
github_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
package main
import (
"testing"
"time"
)
func TestWorkdaysBetweenDates(t *testing.T) {
t.Parallel()
tables := []struct {
day1 time.Time
day2 time.Time
workdays int
}{
{
time.Date(2017, 10, 1, 0, 0, 0, 0, time.UTC),
time.Date(2017, 10, 31, 0, 0, 0, 0, time.UTC),
21,
},
{
time.Date(2017, 10, 31, 0, 0, 0, 0, time.UTC),
time.Date(2017, 10, 1, 0, 0, 0, 0, time.UTC),
21,
},
{
time.Date(2017, 10, 1, 0, 0, 0, 0, time.UTC),
time.Date(2017, 11, 1, 0, 0, 0, 0, time.UTC),
22,
},
{
time.Date(2017, 10, 8, 0, 0, 0, 0, time.UTC),
time.Date(2017, 10, 13, 0, 0, 0, 0, time.UTC),
4,
},
{
time.Date(2017, 10, 13, 0, 0, 0, 0, time.UTC),
time.Date(2017, 10, 14, 0, 0, 0, 0, time.UTC),
1,
},
{
time.Date(2017, 10, 13, 0, 0, 0, 0, time.UTC),
time.Date(2017, 10, 13, 0, 0, 0, 0, time.UTC),
0,
},
{
time.Date(2017, 10, 14, 0, 0, 0, 0, time.UTC),
time.Date(2017, 10, 14, 0, 0, 0, 0, time.UTC),
0,
},
{
time.Date(2017, 10, 14, 0, 0, 0, 0, time.UTC),
time.Date(2017, 10, 15, 0, 0, 0, 0, time.UTC),
0,
},
{
time.Date(2017, 10, 10, 0, 0, 0, 0, time.UTC),
time.Date(2017, 10, 12, 0, 0, 0, 0, time.UTC),
2,
},
{
time.Date(2017, 12, 10, 0, 0, 0, 0, time.UTC),
time.Date(2018, 1, 10, 0, 0, 0, 0, time.UTC),
22,
},
{
time.Date(2017, 10, 9, 0, 0, 0, 0, time.UTC),
time.Date(2017, 10, 15, 0, 0, 0, 0, time.UTC),
5,
},
}
for _, table := range tables {
workdays := workdaysBetweenDates(table.day1, table.day2)
if workdays != table.workdays {
t.Errorf("Workdays count between %s and %s are incorrect, got: %d, want: %d.",
table.day1, table.day2, workdays, table.workdays)
}
}
}