-
Notifications
You must be signed in to change notification settings - Fork 2
/
option_test.go
48 lines (44 loc) · 991 Bytes
/
option_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
package reflecthelper
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestOption(t *testing.T) {
t.Run("init option", func(t *testing.T) {
opt := NewOption()
assert.Equal(t, byte(0), opt.FloatFormat)
})
t.Run("functional options", func(t *testing.T) {
opt := NewOption().Assign(
WithBaseSystem(10),
WithBitSize(64, 128),
WithFloatConfiguration(-1, 't'),
WithTimeLayouts("hello"),
WithCustomAssigner(nil, true),
)
assert.Equal(t, byte('g'), opt.FloatFormat)
opt = NewOption().Assign(
WithBaseSystem(10),
WithBitSize(64, 128),
WithFloatConfiguration(-1, 'f'),
WithTimeLayouts("hello"),
WithCustomAssigner(nil, true),
)
assert.Equal(t, byte('f'), opt.FloatFormat)
})
}
func TestNewDefaultOption(t *testing.T) {
tests := []struct {
name string
}{
{
name: "new default option",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := NewDefaultOption()
assert.NotNil(t, got)
})
}
}