diff --git a/queries_test.go b/queries_test.go index 679ae184..d9b03b70 100644 --- a/queries_test.go +++ b/queries_test.go @@ -510,6 +510,7 @@ func TestParams(t *testing.T) { "", []byte{1, 2, 3}, []byte{}, + float32(1.12313), float64(1.12313554), true, false, @@ -543,21 +544,22 @@ func TestParams(t *testing.T) { } case time.Time: same = decodedval.UTC() == val - case int64: - switch intVal := val.(type) { + default: + rettype := reflect.TypeOf(retval) + switch origval := val.(type) { + case int8: + same = rettype.Kind() == reflect.Int64 && decodedval == int64(origval) case int16: - same = decodedval == int64(intVal) + same = rettype.Kind() == reflect.Int64 && decodedval == int64(origval) case int32: - same = decodedval == int64(intVal) - case int8: - same = decodedval == int64(intVal) + same = rettype.Kind() == reflect.Int64 && decodedval == int64(origval) case int: - same = decodedval == int64(intVal) + same = rettype.Kind() == reflect.Int64 && decodedval == int64(origval) + case float32: + same = rettype.Kind() == reflect.Float64 && decodedval == float64(origval) default: same = retval == val } - default: - same = retval == val } if !same { t.Error("Value don't match", retval, val) diff --git a/types_test.go b/types_test.go index fa7e6486..df482052 100644 --- a/types_test.go +++ b/types_test.go @@ -8,16 +8,16 @@ import ( func TestMakeGoLangScanType(t *testing.T) { if (reflect.TypeOf(int64(0)) != makeGoLangScanType(typeInfo{TypeId: typeInt8})) { - t.Errorf("invalid type returned for typeDateTime") + t.Errorf("invalid type returned for typeInt8") } if (reflect.TypeOf(float64(0)) != makeGoLangScanType(typeInfo{TypeId: typeFlt4})) { - t.Errorf("invalid type returned for typeDateTime") + t.Errorf("invalid type returned for typeFlt4") } if (reflect.TypeOf(float64(0)) != makeGoLangScanType(typeInfo{TypeId: typeFlt8})) { - t.Errorf("invalid type returned for typeDateTime") + t.Errorf("invalid type returned for typeFlt8") } if (reflect.TypeOf("") != makeGoLangScanType(typeInfo{TypeId: typeVarChar})) { - t.Errorf("invalid type returned for typeDateTime") + t.Errorf("invalid type returned for typeVarChar") } if (reflect.TypeOf(time.Time{}) != makeGoLangScanType(typeInfo{TypeId: typeDateTime})) { t.Errorf("invalid type returned for typeDateTime") @@ -38,7 +38,7 @@ func TestMakeGoLangScanType(t *testing.T) { t.Errorf("invalid type returned for typeIntN") } if (reflect.TypeOf([]byte{}) != makeGoLangScanType(typeInfo{TypeId: typeMoney, Size: 8})) { - t.Errorf("invalid type returned for typeIntN") + t.Errorf("invalid type returned for typeMoney") } }