Skip to content

Commit 1d28ec6

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

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

queries_test.go

Lines changed: 9 additions & 8 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,21 @@ 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+
switch origval := val.(type) {
548549
case int16:
549-
same = decodedval == int64(intVal)
550+
same = decodedval == int64(origval)
550551
case int32:
551-
same = decodedval == int64(intVal)
552+
same = decodedval == int64(origval)
552553
case int8:
553-
same = decodedval == int64(intVal)
554+
same = decodedval == int64(origval)
554555
case int:
555-
same = decodedval == int64(intVal)
556+
same = decodedval == int64(origval)
557+
case float32:
558+
same = decodedval == float64(origval)
556559
default:
557560
same = retval == val
558561
}
559-
default:
560-
same = retval == val
561562
}
562563
if !same {
563564
t.Error("Value don't match", retval, val)

types_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ 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})) {
2020
t.Errorf("invalid type returned for typeDateTime")

0 commit comments

Comments
 (0)