mirror of
https://github.com/geektutu/7days-golang.git
synced 2024-04-21 12:32:11 +00:00
26 lines
412 B
Go
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)
|
|
}
|
|
}
|
|
}
|