-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathperiodCalculator_test.go
44 lines (35 loc) · 1.13 KB
/
periodCalculator_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
package main
import (
"testing"
"time"
)
func Test_Next_WithValidInput_ReturnsCorrectAmountOfPeriods(t *testing.T) {
startDate := time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC)
endDate := time.Date(2000, 1, 1, 12, 0, 0, 0, time.UTC)
duration := time.Hour * time.Duration(1)
calc := newPeriodCalculator(startDate, endDate, duration)
countOfPeriods := 0
for calc.Next() {
t.Logf("Received date: %v\n", calc.current)
countOfPeriods++
}
expected := 12
if countOfPeriods != expected {
t.Fatalf("Invalid count of periods returned: %v, expected: %v", countOfPeriods, expected)
}
}
func Test_Next_WithMonobankLimits_ReturnsCorrectAmountOfPeriods(t *testing.T) {
startDate := time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC)
endDate := time.Date(2001, 1, 1, 0, 0, 0, 0, time.UTC)
duration := time.Second * time.Duration(2682000)
calc := newPeriodCalculator(startDate, endDate, duration)
countOfPeriods := 0
for calc.Next() {
t.Logf("Received date: %v\n", calc.current)
countOfPeriods++
}
expected := 12
if countOfPeriods != expected {
t.Fatalf("Invalid count of periods returned: %v, expected: %v", countOfPeriods, expected)
}
}