-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq_query_test.go
50 lines (48 loc) · 952 Bytes
/
q_query_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 dal
import (
"reflect"
"testing"
)
func Test_field_EqualTo(t *testing.T) {
const fieldName = "test_field"
type fields struct {
Name string
}
type args struct {
v any
}
type tst struct {
name string
fields fields
args args
want Condition
}
test := func(name string, value any) tst {
return tst{
name: name,
fields: fields{Name: fieldName},
args: args{v: value},
want: Comparison{
Operator: Equal,
Left: FieldRef{name: fieldName},
Right: Constant{Value: value},
},
}
}
tests := []tst{
test("int_0", 0),
test("int_1", 1),
test("string_empty", ""),
test("string_abc", "abc"),
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
f := FieldRef{
name: tt.fields.Name,
}
if got := f.EqualTo(tt.args.v); !reflect.DeepEqual(got, tt.want) {
t.Errorf("EqualTo(%v) = %T:%v, want %T:%v", tt.args.v, got, got, tt.want, tt.want)
}
})
}
}