Files
2020-02-26 20:39:25 +08:00

26 lines
412 B
Go

package dialect
import (
"reflect"
"testing"
)
func TestDataTypeOf(t *testing.T) {
dial := &sqlite3{}
cases := []struct {
Value interface{}
Type string
}{
{"Tom", "text"},
{123, "integer"},
{1.2, "real"},
{[]int{1, 2, 3}, "blob"},
}
for _, c := range cases {
if typ := dial.DataTypeOf(reflect.ValueOf(c.Value)); typ != c.Type {
t.Fatalf("expect %s, but got %s", c.Type, typ)
}
}
}