-
Notifications
You must be signed in to change notification settings - Fork 0
/
clock_test.go
74 lines (64 loc) · 1.04 KB
/
clock_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
package emoji
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestClock(t *testing.T) {
tests := []struct {
name string
t time.Time
want string
}{
{
name: "MST",
t: must("15:04:05 MST"),
want: "🕒",
},
{
name: "UTC",
t: must("15:04:05 UTC"),
want: "🕒",
},
{
name: "boundary-0",
t: must("00:04:05 EDT"),
want: "🕛",
},
{
name: "boundary-1",
t: must("01:04:05 EDT"),
want: "🕐",
},
{
name: "boundary-12",
t: must("12:04:05 EDT"),
want: "🕛",
},
{
name: "boundary-23",
t: must("23:59:59 EDT"),
want: "🕚",
},
// {
// name: "EEST",
// t: must("15:04:05 EEST"),
// want: "🕒",
// },
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Log(tt.t.String())
got := Clock(tt.t)
assert.Equal(t, tt.want, got)
})
}
}
func must(value string) time.Time {
const layout = "15:04:05 MST"
ts, err := time.Parse(layout, value)
if err != nil {
panic(err)
}
return ts
}