-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentries_test.go
50 lines (43 loc) · 989 Bytes
/
entries_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
package jq
import "testing"
func TestEntries(tb *testing.T) {
b := NewBuffer()
r := b.appendVal(obj{"a", 1, "b", "c", "d", arr{}, "e", obj{}})
key := b.appendVal("key")
val := b.appendVal("value")
testOne(tb, NewToEntries(), b, r,
arr{
obj{key, "a", val, 1},
obj{key, "b", val, "c"},
obj{key, "d", val, arr{}},
obj{key, "e", val, obj{}},
},
)
testOne(tb, NewToEntriesArrays(), b, r,
arr{
arr{"a", 1},
arr{"b", "c"},
arr{"d", arr{}},
arr{"e", obj{}},
},
)
testOne(tb, NewPipe(NewToEntries(), NewFromEntries()), b, r, r)
testOne(tb, NewPipe(NewToEntriesArrays(), NewFromEntries()), b, r, r)
testOne(tb, NewWithEntriesArrays(NewComma(
NewArray(NewPlus(Index(0), NewLiteral("_first")), Index(1)),
NewArray(NewPlus(Index(0), NewLiteral("_second")), Zero),
)), b, r,
obj{
"a_first", 1,
"a_second", 0,
"b_first", "c",
"b_second", 0,
"d_first",
arr{},
"d_second", 0,
"e_first",
obj{},
"e_second", 0,
},
)
}