-
Notifications
You must be signed in to change notification settings - Fork 1
/
weekday_test.go
53 lines (36 loc) · 1.04 KB
/
weekday_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
package time
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestUnmarshalTextToWeekday(t *testing.T) {
var w Weekday
w.UnmarshalText([]byte("monday"))
assert.Equal(t, Monday, w)
w.UnmarshalText([]byte("tuesday"))
assert.Equal(t, Tuesday, w)
w.UnmarshalText([]byte("wednesday"))
assert.Equal(t, Wednesday, w)
w.UnmarshalText([]byte("Thursday"))
assert.Equal(t, Thursday, w)
w.UnmarshalText([]byte("Friday"))
assert.Equal(t, Friday, w)
w.UnmarshalText([]byte("Saturday"))
assert.Equal(t, Saturday, w)
w.UnmarshalText([]byte("sunday"))
assert.Equal(t, Sunday, w)
w.UnmarshalText([]byte("Sunday"))
assert.Equal(t, Sunday, w)
w.UnmarshalText([]byte("SUNDAY"))
assert.Equal(t, Sunday, w)
w.UnmarshalText([]byte("sUnDAY"))
assert.Equal(t, Sunday, w)
err := w.UnmarshalText([]byte("not a weekday"))
assert.Error(t, err)
assert.Equal(t, NotAWeekday, w)
}
func TestConversionToTimeWeekday(t *testing.T) {
assert.Equal(t, Monday, Weekday(time.Monday))
assert.Equal(t, time.Tuesday, time.Weekday(Tuesday))
}