forked from rickar/cal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathholiday_defs_dk_test.go
75 lines (65 loc) · 3.06 KB
/
holiday_defs_dk_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
package cal
import (
"testing"
"time"
)
func TestDanishHolidays(t *testing.T) {
c := NewCalendar()
c.Observed = ObservedExact
AddDanishHolidays(c)
tests := []testStruct{
{time.Date(2016, 1, 1, 12, 0, 0, 0, time.UTC), true, "Nytårsdag"},
{time.Date(2016, 3, 25, 12, 0, 0, 0, time.UTC), true, "Skærtorsdag"},
{time.Date(2016, 3, 25, 12, 0, 0, 0, time.UTC), true, "Langfredagen"},
{time.Date(2016, 3, 27, 12, 0, 0, 0, time.UTC), true, "Påskedag"},
{time.Date(2016, 3, 28, 12, 0, 0, 0, time.UTC), true, "2. påskedag"},
{time.Date(2016, 4, 22, 12, 0, 0, 0, time.UTC), true, "Store Bededag"},
{time.Date(2016, 5, 5, 12, 0, 0, 0, time.UTC), true, "Kristi Himmelfartsdag"},
{time.Date(2016, 5, 15, 12, 0, 0, 0, time.UTC), true, "Pinsedag"},
{time.Date(2016, 5, 16, 12, 0, 0, 0, time.UTC), true, "2. pinsedag"},
{time.Date(2016, 6, 5, 12, 0, 0, 0, time.UTC), false, "Grundlovsdag"},
{time.Date(2016, 12, 24, 12, 0, 0, 0, time.UTC), false, "Juleaften"},
{time.Date(2016, 12, 25, 12, 0, 0, 0, time.UTC), true, "Juledag"},
{time.Date(2016, 12, 26, 12, 0, 0, 0, time.UTC), true, "2. juledag"},
{time.Date(2016, 12, 31, 12, 0, 0, 0, time.UTC), false, "Nytårsaften"},
{time.Date(2017, 1, 1, 12, 0, 0, 0, time.UTC), true, "Nytårsdag"},
{time.Date(2017, 4, 13, 12, 0, 0, 0, time.UTC), true, "Skærtorsdag"},
{time.Date(2017, 4, 14, 12, 0, 0, 0, time.UTC), true, "Langfredag"},
{time.Date(2017, 4, 16, 12, 0, 0, 0, time.UTC), true, "Påskedag"},
{time.Date(2017, 4, 17, 12, 0, 0, 0, time.UTC), true, "2. påskedag"},
{time.Date(2017, 5, 12, 12, 0, 0, 0, time.UTC), true, "Store Bededag"},
{time.Date(2017, 5, 25, 12, 0, 0, 0, time.UTC), true, "Kristi Himmelfartsdag"},
{time.Date(2017, 6, 4, 12, 0, 0, 0, time.UTC), true, "Pinsedag"},
{time.Date(2017, 6, 5, 13, 0, 0, 0, time.UTC), true, "2. pinsedag"},
{time.Date(2017, 12, 24, 12, 0, 0, 0, time.UTC), false, "Juleaften"},
{time.Date(2017, 12, 25, 12, 0, 0, 0, time.UTC), true, "Juledag"},
{time.Date(2017, 12, 26, 12, 0, 0, 0, time.UTC), true, "2. juledag"},
{time.Date(2017, 12, 31, 12, 0, 0, 0, time.UTC), false, "Nytårsaften"},
{time.Date(2018, 1, 1, 12, 0, 0, 0, time.UTC), true, "Nytårsdag"},
}
for _, test := range tests {
got := c.IsHoliday(test.t)
if got != test.want {
t.Errorf("got: %t for %s; want: %t (%s)", got, test.name, test.want, test.t)
}
}
}
func TestDanishTraditions(t *testing.T) {
c := NewCalendar()
c.Observed = ObservedExact
AddDanishTraditions(c)
tests := []testStruct{
{time.Date(2016, 6, 5, 12, 0, 0, 0, time.UTC), true, "Grundlovsdag"},
{time.Date(2016, 12, 24, 12, 0, 0, 0, time.UTC), true, "Juleaften"},
{time.Date(2016, 12, 31, 12, 0, 0, 0, time.UTC), true, "Nytårsaften"},
{time.Date(2017, 6, 5, 12, 0, 0, 0, time.UTC), true, "Grundlovsdag"},
{time.Date(2017, 12, 24, 12, 0, 0, 0, time.UTC), true, "Juleaften"},
{time.Date(2017, 12, 31, 12, 0, 0, 0, time.UTC), true, "Nytårsaften"},
}
for _, test := range tests {
got := c.IsHoliday(test.t)
if got != test.want {
t.Errorf("got: %t for %s; want: %t (%s)", got, test.name, test.want, test.t)
}
}
}