-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcondition_test.go
61 lines (50 loc) · 2.12 KB
/
condition_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
package timekit
import (
"testing"
"time"
)
func TestIsMorning(t *testing.T) {
loc, _ := time.LoadLocation("America/Toronto")
if IsMorning(time.Date(2022, 1, 24, 22, 45, 22, 380000000, loc)) { // 2022-01-24 22:45:22.38 -0500 EST
t.Error("Incorrect condition, expected false but got true")
}
if !IsMorning(time.Date(2022, 1, 24, 1, 45, 22, 380000000, loc)) { // 2022-01-24 1:45:22.38 -0500 EST
t.Error("Incorrect condition, expected true but got false")
}
}
func TestIsAfternoon(t *testing.T) {
loc, _ := time.LoadLocation("America/Toronto")
if IsAfternoon(time.Date(2022, 1, 24, 22, 45, 22, 380000000, loc)) { // 2022-01-24 22:45:22.38 -0500 EST
t.Error("Incorrect condition, expected false but got true")
}
if !IsAfternoon(time.Date(2022, 1, 24, 13, 45, 22, 380000000, loc)) { // 2022-01-24 13:45:22.38 -0500 EST
t.Error("Incorrect condition, expected true but got false")
}
}
func TestIsEvening(t *testing.T) {
loc, _ := time.LoadLocation("America/Toronto")
if IsEvening(time.Date(2022, 1, 24, 22, 45, 22, 380000000, loc)) { // 2022-01-24 22:45:22.38 -0500 EST
t.Error("Incorrect condition, expected false but got true")
}
if !IsEvening(time.Date(2022, 1, 24, 18, 45, 22, 380000000, loc)) { // 2022-01-24 18:45:22.38 -0500 EST
t.Error("Incorrect condition, expected true but got false")
}
}
func TestIsNight(t *testing.T) {
loc, _ := time.LoadLocation("America/Toronto")
if IsNight(time.Date(2022, 1, 24, 1, 45, 22, 380000000, loc)) { // 2022-01-24 1:45:22.38 -0500 EST
t.Error("Incorrect condition, expected false but got true")
}
if !IsNight(time.Date(2022, 1, 24, 22, 45, 22, 380000000, loc)) { // 2022-01-24 22:45:22.38 -0500 EST
t.Error("Incorrect condition, expected true but got false")
}
}
func TestIsAfter6PM(t *testing.T) {
loc, _ := time.LoadLocation("America/Toronto")
if IsAfter6PM(time.Date(2022, 1, 24, 1, 45, 22, 380000000, loc)) { // 2022-01-24 1:45:22.38 -0500 EST
t.Error("Incorrect condition, expected false but got true")
}
if !IsAfter6PM(time.Date(2022, 1, 24, 22, 45, 22, 380000000, loc)) { // 2022-01-24 22:45:22.38 -0500 EST
t.Error("Incorrect condition, expected true but got false")
}
}