forked from RecoLabs/gnata
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgnata_test.go
More file actions
43 lines (39 loc) · 941 Bytes
/
gnata_test.go
File metadata and controls
43 lines (39 loc) · 941 Bytes
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
package gnata_test
import (
"testing"
"github.com/rbbydotdev/gnata-sqlite"
)
func TestCompile(t *testing.T) {
expr, err := gnata.Compile("Account.name")
if err != nil {
t.Fatalf("unexpected compile error: %v", err)
}
if expr == nil {
t.Fatal("expected non-nil expression")
}
}
func TestDeepEqual(t *testing.T) {
tests := []struct {
a, b any
want bool
}{
{nil, nil, true},
{nil, 1.0, false},
{1.0, 1.0, true},
{1.0, 2.0, false},
{"hello", "hello", true},
{"hello", "world", false},
{true, true, true},
{true, false, false},
{[]any{1.0, 2.0}, []any{1.0, 2.0}, true},
{[]any{1.0}, []any{1.0, 2.0}, false},
{map[string]any{"a": 1.0}, map[string]any{"a": 1.0}, true},
{map[string]any{"a": 1.0}, map[string]any{"a": 2.0}, false},
}
for _, tt := range tests {
got := gnata.DeepEqual(tt.a, tt.b)
if got != tt.want {
t.Errorf("DeepEqual(%v, %v) = %v, want %v", tt.a, tt.b, got, tt.want)
}
}
}