-
Notifications
You must be signed in to change notification settings - Fork 36
/
jsonql_test.go
71 lines (66 loc) · 988 Bytes
/
jsonql_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
67
68
69
70
71
package jsonql
import (
"fmt"
"testing"
)
func TestParse(t *testing.T) {
jsonString := `
[
{
"name": "elgs",
"gender": "m",
"skills": [
"Golang",
"Java",
"C"
]
},
{
"name": "enny",
"gender": "f",
"skills": [
"IC",
"Electric design",
"Verification"
]
},
{
"name": "sam",
"gender": "m",
"skills": [
"Eating",
"Sleeping",
"Crawling"
]
}
]
`
parser, err := NewStringQuery(jsonString)
if err != nil {
t.Error(err)
}
var pass = []struct {
in string
}{
{"name='elgs'"},
{"gender='f'"},
{"skills.[1]='Sleeping'"},
{"skills contains 'Verification'"},
}
var fail = []struct {
in string
ex interface{}
}{}
for _, v := range pass {
result, err := parser.Query(v.in)
if err != nil {
t.Error(v.in, err)
}
fmt.Println(v.in, result)
// if v.ex != result {
// t.Error("Expected:", v.ex, "actual:", result)
// }
}
for range fail {
}
}