-
Notifications
You must be signed in to change notification settings - Fork 0
/
ms_test.go
96 lines (81 loc) · 1.53 KB
/
ms_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
package ms
import (
"testing"
)
func TestParseWithDays(t *testing.T) {
want := float64(172800000)
got, err := Parse("2 days")
if err != nil {
t.Errorf("%v", err)
return
}
if want != got {
t.Errorf("Expected %f but got %f", want, got)
}
}
func TestParseWithDaysShort(t *testing.T) {
want := float64(172800000)
got, err := Parse("2 d")
if err != nil {
t.Errorf("%v", err)
return
}
if want != got {
t.Errorf("Expected %f but got %f", want, got)
}
}
func TestParseWithHours(t *testing.T) {
want := float64(9000000)
got, err := Parse("2.5 hrs")
if err != nil {
t.Errorf("%v", err)
return
}
if want != got {
t.Errorf("Expected %f but got %f", want, got)
}
}
func TestParseWithHoursShort(t *testing.T) {
want := float64(36000000)
got, err := Parse("10 h")
if err != nil {
t.Errorf("%v", err)
return
}
if want != got {
t.Errorf("Expected %f but got %f", want, got)
}
}
func TestParseWithYears(t *testing.T) {
want := float64(31557600000)
got, err := Parse("1y")
if err != nil {
t.Errorf("%v", err)
return
}
if want != got {
t.Errorf("Expected %f but got %f", want, got)
}
}
func TestParseWithMinutes(t *testing.T) {
want := float64(60000)
got, err := Parse("1m")
if err != nil {
t.Errorf("%v", err)
return
}
if want != got {
t.Errorf("Expected %f but got %f", want, got)
}
}
func TestParseWithSeconds(t *testing.T) {
want := float64(5000)
got, err := Parse("5s")
if err != nil {
t.Errorf("%v", err)
return
}
if want != got {
t.Errorf("Expected %f but got %f", want, got)
}
}