-
Notifications
You must be signed in to change notification settings - Fork 0
/
options_test.go
48 lines (36 loc) · 1.1 KB
/
options_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 ncserial
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestKeyValueOption(t *testing.T) {
name := "foo"
value := "bar"
k := NewKVOption(name, value)
assert.Equal(t, k.Name(), "foo")
assert.Equal(t, k.Value(), "bar")
k = NewKVOption(name, &value)
assert.Equal(t, k.Value(), "bar")
k = NewKVOption(name, false)
assert.Equal(t, k.Value(), "off")
k = NewKVOption(name, 5)
assert.Equal(t, k.Value(), "5")
k = NewKVOption(name, 0.5)
assert.Equal(t, k.Value(), "0.5")
k = NewKVOption(name, []string{"a", "b", "c"})
assert.Equal(t, k.Value(), "a b c")
assert.Equal(t, k.String(), "\nfoo a b c;")
k = NewKVOption(name, nil)
assert.Equal(t, k.String(), "\nfoo ;")
k = NewOption([]string{"foo", "bar"})
assert.Equal(t, k.Name(), "foo")
assert.Equal(t, k.Value(), "bar")
assert.Equal(t, k.String(), "\nfoo bar;")
k = NewOption([]string{"foo"})
assert.Equal(t, k.Name(), "foo")
assert.Equal(t, k.Value(), "")
assert.Equal(t, k.String(), "\nfoo ;")
k = NewOption([]string{"foo", "bar", "baz"})
assert.Equal(t, k.Name(), "foo")
assert.Equal(t, k.String(), "\nfoo bar baz;")
}