|
|
package starrocks
|
|
|
|
|
|
import (
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
"testing"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
func TestInArgs(t *testing.T) {
|
|
|
now := time.Date(2000, 1, 1, 0, 0, 0, 0, time.Local)
|
|
|
var table = []struct {
|
|
|
args []interface{}
|
|
|
want string
|
|
|
}{
|
|
|
{
|
|
|
args: []interface{}{1, 0, 2, 4},
|
|
|
want: "(1,0,2,4)",
|
|
|
},
|
|
|
{
|
|
|
args: []interface{}{1.0, 0, 2.1, 4.0},
|
|
|
want: "(1,0,2.1,4)",
|
|
|
},
|
|
|
{
|
|
|
args: []interface{}{"1", "0", "2", "4"},
|
|
|
want: "('1','0','2','4')",
|
|
|
},
|
|
|
{
|
|
|
args: []interface{}{now, now},
|
|
|
want: "('2000-01-01 00:00:00','2000-01-01 00:00:00')",
|
|
|
},
|
|
|
}
|
|
|
c := &Condition{}
|
|
|
for _, input := range table {
|
|
|
got := c.InArgs(input.args)
|
|
|
assert.Equal(t, input.want, got)
|
|
|
}
|
|
|
}
|
|
|
func TestArg(t *testing.T) {
|
|
|
now := time.Date(2000, 1, 1, 0, 0, 0, 0, time.Local)
|
|
|
var table = []struct {
|
|
|
args []interface{}
|
|
|
want string
|
|
|
}{
|
|
|
{
|
|
|
args: []interface{}{1, 0, 2, 4},
|
|
|
want: "1",
|
|
|
},
|
|
|
{
|
|
|
args: []interface{}{1.0, 0, 2.1, 4.0},
|
|
|
want: "1",
|
|
|
},
|
|
|
{
|
|
|
args: []interface{}{"1", "0", "2", "4"},
|
|
|
want: "'1'",
|
|
|
},
|
|
|
{
|
|
|
args: []interface{}{now, now},
|
|
|
want: "'2000-01-01 00:00:00'",
|
|
|
},
|
|
|
}
|
|
|
c := &Condition{}
|
|
|
for _, input := range table {
|
|
|
got := c.Arg(input.args[0])
|
|
|
assert.Equal(t, input.want, got)
|
|
|
}
|
|
|
} |
...
|
...
|
|