-
Notifications
You must be signed in to change notification settings - Fork 0
/
function_test.go
51 lines (42 loc) · 1.08 KB
/
function_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
package db
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestFunction(t *testing.T) {
{
fn := Func("MOD", 29, 9)
assert.Equal(t, "MOD", fn.Name())
assert.Equal(t, []interface{}{29, 9}, fn.Arguments())
}
{
fn := Func("HELLO")
assert.Equal(t, "HELLO", fn.Name())
assert.Equal(t, []interface{}(nil), fn.Arguments())
}
{
fn := Func("CONCAT", "a")
assert.Equal(t, "CONCAT", fn.Name())
assert.Equal(t, []interface{}{"a"}, fn.Arguments())
}
{
fn := Func("CONCAT", "a", "b", "c")
assert.Equal(t, "CONCAT", fn.Name())
assert.Equal(t, []interface{}{"a", "b", "c"}, fn.Arguments())
}
{
fn := Func("IN", []interface{}{"a", "b", "c"})
assert.Equal(t, "IN", fn.Name())
assert.Equal(t, []interface{}{[]interface{}{"a", "b", "c"}}, fn.Arguments())
}
{
fn := Func("IN", []interface{}{"a"})
assert.Equal(t, "IN", fn.Name())
assert.Equal(t, []interface{}{[]interface{}{"a"}}, fn.Arguments())
}
{
fn := Func("IN", []interface{}(nil))
assert.Equal(t, "IN", fn.Name())
assert.Equal(t, []interface{}{[]interface{}(nil)}, fn.Arguments())
}
}