-
Notifications
You must be signed in to change notification settings - Fork 0
/
select_test.go
66 lines (56 loc) · 1.22 KB
/
select_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
58
59
60
61
62
63
64
65
66
package jq
import (
"testing"
)
func TestSelect(tb *testing.T) {
b := NewBuffer()
root := b.appendVal(arr{
nil,
false,
true,
0,
1,
"a",
obj{},
arr{},
})
testOne(tb, NewArray(NewPipe(NewIter(), NewSelect(nil))), b, root, arr{true, 0, 1, "a", obj{}, arr{}})
b.Reset()
root = b.appendVal(arr{
obj{"a", nil},
obj{"a", false},
obj{"a", true},
obj{"a", 0},
obj{"a", 1},
obj{"a", "a"},
obj{"a", obj{}},
obj{"a", arr{}},
})
testOne(tb, NewArray(NewPipe(NewIter(), NewSelect(NewQuery("a")))), b, root, arr{
obj{"a", true},
obj{"a", 0},
obj{"a", 1},
obj{"a", "a"},
obj{"a", obj{}},
obj{"a", arr{}},
})
}
func TestSelectSpecial(tb *testing.T) {
b := NewBuffer()
_ = b.appendVal(make([]byte, 250))
root := b.appendVal(arr{
Null,
True,
False,
Zero,
One,
obj{},
})
testOne(tb, NewArray(NewPipe(NewIter(), NewSelect(nil))), b, root, arr{true, 0, 1, obj{}})
}
func TestPipeSelect(tb *testing.T) {
b := NewBuffer()
off := b.appendVal(arr{obj{"a", false, "v", 1}, obj{"a", true, "v", 2}, obj{"a", 1, "v", 3}, obj{"a", nil, "v", 4}})
exp := b.appendVal(arr{obj{"a", true, "v", 2}, obj{"a", 1, "v", 3}})
testOne(tb, NewArray(NewPipe(NewIter(), NewSelect(Key("a")))), b, off, exp)
}