-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
42 lines (37 loc) · 1.01 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
package main
import (
"testing"
"time"
)
func TestCalcInitTime(t *testing.T) {
now := time.Now()
reference := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
d := CalculateDurationUntilFirstTrigger(17, reference)
if d.Hours() != 17 {
t.Error(d)
}
}
func TestCalcInitTimeClosePast(t *testing.T) {
now := time.Now()
reference := time.Date(now.Year(), now.Month(), now.Day(), 5, 30, 0, 0, now.Location())
d := CalculateDurationUntilFirstTrigger(5, reference)
if d.Hours() != 0 {
t.Error(d)
}
}
func TestCalcInitTimeClose(t *testing.T) {
now := time.Now()
reference := time.Date(now.Year(), now.Month(), now.Day(), 4, 30, 0, 0, now.Location())
d := CalculateDurationUntilFirstTrigger(5, reference)
if d.Hours() != 0.5 {
t.Error(d)
}
}
func TestCalcInitTimePast(t *testing.T) {
now := time.Now()
reference := time.Date(now.Year(), now.Month(), now.Day(), 10, 0, 0, 0, now.Location())
d := CalculateDurationUntilFirstTrigger(5, reference)
if d.Hours() != 19 {
t.Error(d)
}
}