-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap_test.go
38 lines (29 loc) · 986 Bytes
/
map_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
package jq
import "testing"
func TestMapArr(tb *testing.T) {
b := NewBuffer()
root := b.appendVal(arr{"a", 1})
testOne(tb, NewMap(NewComma(Dot{}, Dot{})), b, root, arr{"a", "a", 1, 1})
testOne(tb, NewMapValues(NewComma(Dot{}, Dot{})), b, root, arr{"a", 1})
// tb.Logf("buffer\n%s", DumpBuffer(b))
}
func TestMapObj(tb *testing.T) {
b := NewBuffer()
root := b.appendVal(obj{"a", "q", "b", 2})
testOne(tb, NewMap(NewComma(Dot{}, Dot{})), b, root, arr{"q", "q", 2, 2})
testOne(tb, NewMapValues(NewComma(Dot{}, Dot{})), b, root, obj{"a", "q", "b", 2})
}
func TestMapObjObj(tb *testing.T) {
b := NewBuffer()
root := b.appendVal(obj{"a", obj{"x", "y", "y", "z"}, "b", obj{"x", "a", "z", arr{"b", "c"}}})
testOne(tb, NewMap(NewComma(
NewQuery("x"),
NewQuery("y"),
NewQuery("z"),
)), b, root, arr{"y", "z", nil, "a", nil, arr{"b", "c"}})
testOne(tb, NewMapValues(NewComma(
NewQuery("x"),
NewQuery("y"),
NewQuery("z"),
)), b, root, obj{"a", "y", "b", "a"})
}