forked from rickar/cal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
holiday_defs_us_test.go
71 lines (67 loc) · 1.17 KB
/
holiday_defs_us_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
package cal
import (
"testing"
"time"
)
func TestAddUSHolidays(t *testing.T) {
// The following is all of the national holidays in US for the year 2017
type date struct {
day int
month time.Month
}
holidays := map[string]date{
"new_year": {
day: 1,
month: time.January,
},
"mlk": {
day: 16,
month: time.January,
},
"presidents": {
day: 20,
month: time.February,
},
"memorial": {
day: 29,
month: time.May,
},
"independence": {
day: 4,
month: time.July,
},
"labor": {
day: 4,
month: time.September,
},
"columbus": {
day: 9,
month: time.October,
},
"veterans": {
day: 11,
month: time.November,
},
"thanksgiving": {
day: 23,
month: time.November,
},
"christmas": {
day: 25,
month: time.December,
},
}
for name, holiday := range holidays {
t.Run(name, func(t *testing.T) {
c := NewCalendar()
AddUsHolidays(c)
i := time.Date(2017, holiday.month, holiday.day, 0, 0, 0, 0, time.UTC)
if !c.IsHoliday(i) {
t.Errorf("Expected %q to be a holiday but wasn't", i)
}
if c.IsWorkday(i) {
t.Errorf("Did not expect %q to be a holiday", i)
}
})
}
}