-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
166 lines (130 loc) · 3.79 KB
/
main_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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
package main
import (
"log"
"testing"
"time"
)
var cst *time.Location
func init() {
var err error
cst, err = time.LoadLocation("America/Chicago")
if err != nil {
log.Fatal(err)
}
}
func TestDate_BusinessDaysUntil_Mon_Mon(t *testing.T) {
start := time.Date(2018, 11, 5, 0, 0, 0, 0, cst)
end := time.Date(2018, 11, 5, 0, 0, 0, 0, cst)
startDate := DateOf(start)
endDate := DateOf(end)
days := startDate.BusinessDaysUntil(endDate)
if days != 0 {
t.Fatalf("expected 0 for days, got %d", days)
}
}
func TestDate_BusinessDaysUntil_Mon_Tue(t *testing.T) {
start := time.Date(2018, 11, 5, 14, 0, 0, 0, cst)
end := time.Date(2018, 11, 6, 15, 0, 0, 0, cst)
startDate := DateOf(start)
endDate := DateOf(end)
days := startDate.BusinessDaysUntil(endDate)
if days != 1 {
t.Fatalf("expected 1 for days, got %d", days)
}
}
func TestDate_BusinessDaysUntil_Mon_Wed(t *testing.T) {
start := time.Date(2018, 11, 5, 0, 0, 0, 0, cst)
end := time.Date(2018, 11, 7, 0, 0, 0, 0, cst)
startDate := DateOf(start)
endDate := DateOf(end)
days := startDate.BusinessDaysUntil(endDate)
if days != 2 {
t.Fatalf("expected 2 for days, got %d", days)
}
}
func TestDate_BusinessDaysUntil_Fri_Fri(t *testing.T) {
start := time.Date(2018, 11, 2, 0, 0, 0, 0, cst)
end := time.Date(2018, 11, 2, 0, 0, 0, 0, cst)
startDate := DateOf(start)
endDate := DateOf(end)
days := startDate.BusinessDaysUntil(endDate)
if days != 0 {
t.Fatalf("expected 0 for days, got %d", days)
}
}
func TestDate_BusinessDaysUntil_Fri_Sat(t *testing.T) {
start := time.Date(2018, 11, 2, 0, 0, 0, 0, cst)
end := time.Date(2018, 11, 3, 0, 0, 0, 0, cst)
startDate := DateOf(start)
endDate := DateOf(end)
days := startDate.BusinessDaysUntil(endDate)
if days != 1 {
t.Fatalf("expected 1 for days, got %d", days)
}
}
func TestDate_BusinessDaysUntil_Fri_Sun(t *testing.T) {
start := time.Date(2018, 11, 2, 0, 0, 0, 0, cst)
end := time.Date(2018, 11, 4, 0, 0, 0, 0, cst)
startDate := DateOf(start)
endDate := DateOf(end)
days := startDate.BusinessDaysUntil(endDate)
if days != 1 {
t.Fatalf("expected 1 for days, got %d", days)
}
}
func TestDate_BusinessDaysUntil_Fri_Mon(t *testing.T) {
start := time.Date(2018, 11, 2, 0, 0, 0, 0, cst)
end := time.Date(2018, 11, 5, 0, 0, 0, 0, cst)
startDate := DateOf(start)
endDate := DateOf(end)
days := startDate.BusinessDaysUntil(endDate)
if days != 1 {
t.Fatalf("expected 1 for days, got %d", days)
}
}
func TestDate_BusinessDaysUntil_Fri_Tue(t *testing.T) {
start := time.Date(2018, 11, 2, 0, 0, 0, 0, cst)
end := time.Date(2018, 11, 6, 0, 0, 0, 0, cst)
startDate := DateOf(start)
endDate := DateOf(end)
days := startDate.BusinessDaysUntil(endDate)
if days != 2 {
t.Fatalf("expected 2 for days, got %d", days)
}
}
func TestDate_BusinessDaysUntil_Fri_Fri2(t *testing.T) {
start := time.Date(2018, 11, 2, 0, 0, 0, 0, cst)
end := time.Date(2018, 11, 2+7, 0, 0, 0, 0, cst)
startDate := DateOf(start)
endDate := DateOf(end)
days := startDate.BusinessDaysUntil(endDate)
if days != 5 {
t.Fatalf("expected 5 for days, got %d", days)
}
}
func TestDate_BusinessDaysUntil_Fri_Fri3(t *testing.T) {
start := time.Date(2018, 11, 2, 0, 0, 0, 0, cst)
end := time.Date(2018, 11, 2+7+7, 0, 0, 0, 0, cst)
startDate := DateOf(start)
endDate := DateOf(end)
days := startDate.BusinessDaysUntil(endDate)
if days != 10 {
t.Fatalf("expected 10 for days, got %d", days)
}
}
func TestDate_BusinessDaysUntil_Now(t *testing.T) {
start, err := time.Parse(time.RFC3339, "2018-11-05T14:10:25.073-05:00")
if err != nil {
t.Fatal(err)
}
end, err := time.Parse(time.RFC3339, "2018-11-06T15:39:07.272826-06:00")
if err != nil {
t.Fatal(err)
}
startDate := DateOf(start)
endDate := DateOf(end)
days := startDate.BusinessDaysUntil(endDate)
if days != 1 {
t.Fatalf("expected 1 for days, got %d", days)
}
}