-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes_test.go
More file actions
69 lines (65 loc) · 1.31 KB
/
types_test.go
File metadata and controls
69 lines (65 loc) · 1.31 KB
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
package jsonpath
import "testing"
func TestFilterCondition(t *testing.T) {
tests := []struct {
name string
field string
operator string
value interface{}
}{
{
name: "simple field condition",
field: "name",
operator: "==",
value: "John",
},
{
name: "nested field condition",
field: "user.name",
operator: "!=",
value: "Jane",
},
{
name: "numeric comparison",
field: "age",
operator: ">",
value: 18,
},
{
name: "boolean condition",
field: "active",
operator: "==",
value: true,
},
{
name: "null comparison",
field: "optional",
operator: "==",
value: nil,
},
{
name: "array index condition",
field: "items[0].id",
operator: "<",
value: 100,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
fc := &filterCondition{
field: tt.field,
operator: tt.operator,
value: tt.value,
}
if fc.field != tt.field {
t.Errorf("filterCondition.field = %v, want %v", fc.field, tt.field)
}
if fc.operator != tt.operator {
t.Errorf("filterCondition.operator = %v, want %v", fc.operator, tt.operator)
}
if fc.value != tt.value {
t.Errorf("filterCondition.value = %v, want %v", fc.value, tt.value)
}
})
}
}