-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflatjson_test.go
More file actions
49 lines (46 loc) · 759 Bytes
/
Copy pathflatjson_test.go
File metadata and controls
49 lines (46 loc) · 759 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
package flatjson
import (
"strconv"
"testing"
"github.com/alecthomas/assert/v2"
)
func TestFlatJSON(t *testing.T) {
for i, tc := range []struct {
v interface{}
fj string
}{
{
v: nil,
fj: "root = null;\n",
},
{
v: true,
fj: "root = true;\n",
},
{
v: false,
fj: "root = false;\n",
},
{
v: 0,
fj: "root = 0;\n",
},
{
v: []interface{}{},
fj: "root = [];\n",
},
{
v: map[string]interface{}{},
fj: "root = {};\n",
},
} {
t.Run(strconv.Itoa(i), func(t *testing.T) {
gotFJ, err := Marshal(tc.v)
assert.NoError(t, err)
assert.Equal(t, tc.fj, string(gotFJ))
actualV := tc.v
assert.NoError(t, Unmarshal([]byte(tc.fj), &actualV))
assert.Equal(t, tc.v, actualV)
})
}
}