-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrange_test.go
More file actions
61 lines (49 loc) · 1.48 KB
/
range_test.go
File metadata and controls
61 lines (49 loc) · 1.48 KB
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 gotime_test
import (
"testing"
"time"
"github.com/maniartech/gotime/v2"
"github.com/maniartech/gotime/v2/internal/utils"
)
func TestIsBetween(t *testing.T) {
now := time.Now()
yesterday := now.AddDate(0, 0, -1)
tomorrow := now.AddDate(0, 0, 1)
// Test with multiple times
result := gotime.IsBetween(now, yesterday, tomorrow)
expected := true
utils.AssertEqual(t, expected, result)
// Test with a single time
result = gotime.IsBetween(now, tomorrow, tomorrow)
expected = false
utils.AssertEqual(t, expected, result)
// Test with a single time
result = gotime.IsBetween(now, now, now)
expected = true
utils.AssertEqual(t, expected, result)
// Test with a single time
result = gotime.IsBetween(now, tomorrow, yesterday)
expected = true
utils.AssertEqual(t, expected, result)
}
func TestIsBetweenDates(t *testing.T) {
now := time.Now()
yesterday := now.AddDate(0, 0, -1)
tomorrow := now.AddDate(0, 0, 1)
// Test with multiple times
result := gotime.IsBetweenDates(now, yesterday, tomorrow)
expected := true
utils.AssertEqual(t, expected, result)
// Test with a single time
result = gotime.IsBetweenDates(now, tomorrow, tomorrow)
expected = false
utils.AssertEqual(t, expected, result)
// Test with a single time
result = gotime.IsBetweenDates(now, now, now)
expected = true
utils.AssertEqual(t, expected, result)
// Test with a single time
result = gotime.IsBetweenDates(now, tomorrow, yesterday)
expected = true
utils.AssertEqual(t, expected, result)
}