Skip to content

Commit f604e19

Browse files
committed
Add test for scanning float32
1 parent 9b84d9b commit f604e19

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

queries_test.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ func TestParams(t *testing.T) {
510510
"",
511511
[]byte{1, 2, 3},
512512
[]byte{},
513+
float32(1.12313),
513514
float64(1.12313554),
514515
true,
515516
false,
@@ -543,21 +544,22 @@ func TestParams(t *testing.T) {
543544
}
544545
case time.Time:
545546
same = decodedval.UTC() == val
546-
case int64:
547-
switch intVal := val.(type) {
547+
default:
548+
rettype := reflect.TypeOf(retval)
549+
switch origval := val.(type) {
550+
case int8:
551+
same = rettype.Kind() == reflect.Int64 && decodedval == int64(origval)
548552
case int16:
549-
same = decodedval == int64(intVal)
553+
same = rettype.Kind() == reflect.Int64 && decodedval == int64(origval)
550554
case int32:
551-
same = decodedval == int64(intVal)
552-
case int8:
553-
same = decodedval == int64(intVal)
555+
same = rettype.Kind() == reflect.Int64 && decodedval == int64(origval)
554556
case int:
555-
same = decodedval == int64(intVal)
557+
same = rettype.Kind() == reflect.Int64 && decodedval == int64(origval)
558+
case float32:
559+
same = rettype.Kind() == reflect.Float64 && decodedval == float64(origval)
556560
default:
557561
same = retval == val
558562
}
559-
default:
560-
same = retval == val
561563
}
562564
if !same {
563565
t.Error("Value don't match", retval, val)

types_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import (
88

99
func TestMakeGoLangScanType(t *testing.T) {
1010
if (reflect.TypeOf(int64(0)) != makeGoLangScanType(typeInfo{TypeId: typeInt8})) {
11-
t.Errorf("invalid type returned for typeDateTime")
11+
t.Errorf("invalid type returned for typeInt8")
1212
}
1313
if (reflect.TypeOf(float64(0)) != makeGoLangScanType(typeInfo{TypeId: typeFlt4})) {
14-
t.Errorf("invalid type returned for typeDateTime")
14+
t.Errorf("invalid type returned for typeFlt4")
1515
}
1616
if (reflect.TypeOf(float64(0)) != makeGoLangScanType(typeInfo{TypeId: typeFlt8})) {
17-
t.Errorf("invalid type returned for typeDateTime")
17+
t.Errorf("invalid type returned for typeFlt8")
1818
}
1919
if (reflect.TypeOf("") != makeGoLangScanType(typeInfo{TypeId: typeVarChar})) {
20-
t.Errorf("invalid type returned for typeDateTime")
20+
t.Errorf("invalid type returned for typeVarChar")
2121
}
2222
if (reflect.TypeOf(time.Time{}) != makeGoLangScanType(typeInfo{TypeId: typeDateTime})) {
2323
t.Errorf("invalid type returned for typeDateTime")
@@ -38,7 +38,7 @@ func TestMakeGoLangScanType(t *testing.T) {
3838
t.Errorf("invalid type returned for typeIntN")
3939
}
4040
if (reflect.TypeOf([]byte{}) != makeGoLangScanType(typeInfo{TypeId: typeMoney, Size: 8})) {
41-
t.Errorf("invalid type returned for typeIntN")
41+
t.Errorf("invalid type returned for typeMoney")
4242
}
4343
}
4444

0 commit comments

Comments
 (0)