-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencode_test.go
57 lines (48 loc) · 1.05 KB
/
encode_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
package ncserial
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
type testMapWithTag struct {
HTTP Directives `kv:"http"`
}
type testMapWithOutTag struct {
HTTP Directives
}
func TestMapWithTag(t *testing.T) {
emptyBlk := NewEmptyBlock()
test := testMapWithTag{
HTTP: Directives{
NewOption([]string{"abc", "bcd"}),
},
}
ds, err := MarshalD(test)
if err != nil {
t.Fatal(err)
}
for _, d := range ds {
emptyBlk.AddDirective(d)
}
str := emptyBlk.String()
assert.True(t, strings.Contains(strings.ToLower(str), "http"))
assert.True(t, strings.Contains(strings.ToLower(str), "abc bcd;"))
}
func TestMapWithOutTag(t *testing.T) {
emptyBlk := NewEmptyBlock()
test := testMapWithOutTag{
HTTP: Directives{
NewOption([]string{"abc", "bcd"}),
},
}
ds, err := MarshalD(test)
if err != nil {
t.Fatal(err)
}
for _, d := range ds {
emptyBlk.AddDirective(d)
}
str := emptyBlk.String()
assert.False(t, strings.Contains(strings.ToLower(str), "http"))
assert.True(t, strings.Contains(strings.ToLower(str), "abc bcd;"))
}