-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathformat_test.go
More file actions
34 lines (26 loc) · 752 Bytes
/
Copy pathformat_test.go
File metadata and controls
34 lines (26 loc) · 752 Bytes
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
package tinytime
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestParse(t *testing.T) {
tt, err := Parse(time.RFC3339, "2020-04-01T14:12:54Z")
assert.Nil(t, err)
assert.Equal(t, 1585750374, int(tt.unix))
}
func TestParseInLocation(t *testing.T) {
tt, err := ParseInLocation(time.RFC3339, "2020-04-01T14:12:54Z", time.UTC)
assert.Nil(t, err)
assert.Equal(t, 1585750374, int(tt.unix))
}
func TestAppendFormat(t *testing.T) {
tt := New(1585750374)
text := []byte("Time: ")
text = tt.AppendFormat(text, time.RFC3339)
assert.Equal(t, "Time: 2020-04-01T14:12:54Z", string(text))
}
func TestFormat(t *testing.T) {
tt := New(1585750374)
assert.Equal(t, "2020-04-01T14:12:54Z", string(tt.Format(time.RFC3339)))
}