-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencode_test.go
More file actions
56 lines (53 loc) · 884 Bytes
/
encode_test.go
File metadata and controls
56 lines (53 loc) · 884 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package narg
import (
"testing"
"time"
"github.com/kylelemons/godebug/diff"
)
func TestEncode(t *testing.T) {
v := &testConf{
Name: "foo",
Port: 80,
Debug: true,
Float: 3.14,
Hosts: []string{"a", "bee", "cee e"},
Ports: []int{1024, 1025},
PortsU: []uint8{0xff, 0xff},
Creation: time.Date(1999, time.December, 31, 23, 59, 59, 0, time.UTC),
Admin: testUser{
ID: 1,
Name: `Phil "Tandy" Miller`,
},
Users: []testUser{
{2, "Carol Pilbasian"},
{4, "Todd"},
},
}
exp := `name foo
port 80
debug true
float 3.14
hosts a bee "cee e"
ports 1024 1025
portsu 255 255
creation 1999-12-31T23:59:59Z
admin {
id 1
name "Phil \"Tandy\" Miller"
}
users {
id 2
name "Carol Pilbasian"
}
users {
id 4
name Todd
}`
act, err := EncodeString(v)
if err != nil {
t.Fatal(err)
}
if exp != act {
t.Error(diff.Diff(exp, act))
}
}