@@ -365,7 +365,7 @@ func TestInt(t *testing.T) {
365
365
})
366
366
}
367
367
368
- func TestFloat (t * testing.T ) {
368
+ func TestFloat32 (t * testing.T ) {
369
369
runTests (t , dsn , func (dbt * DBTest ) {
370
370
types := [2 ]string {"FLOAT" , "DOUBLE" }
371
371
in := float32 (42.23 )
@@ -388,6 +388,52 @@ func TestFloat(t *testing.T) {
388
388
})
389
389
}
390
390
391
+ func TestFloat64 (t * testing.T ) {
392
+ runTests (t , dsn , func (dbt * DBTest ) {
393
+ types := [2 ]string {"FLOAT" , "DOUBLE" }
394
+ var expected float64 = 42.23
395
+ var out float64
396
+ var rows * sql.Rows
397
+ for _ , v := range types {
398
+ dbt .mustExec ("CREATE TABLE test (value " + v + ")" )
399
+ dbt .mustExec ("INSERT INTO test VALUES (42.23)" )
400
+ rows = dbt .mustQuery ("SELECT value FROM test" )
401
+ if rows .Next () {
402
+ rows .Scan (& out )
403
+ if expected != out {
404
+ dbt .Errorf ("%s: %g != %g" , v , expected , out )
405
+ }
406
+ } else {
407
+ dbt .Errorf ("%s: no data" , v )
408
+ }
409
+ dbt .mustExec ("DROP TABLE IF EXISTS test" )
410
+ }
411
+ })
412
+ }
413
+
414
+ func TestFloat64Placeholder (t * testing.T ) {
415
+ runTests (t , dsn , func (dbt * DBTest ) {
416
+ types := [2 ]string {"FLOAT" , "DOUBLE" }
417
+ var expected float64 = 42.23
418
+ var out float64
419
+ var rows * sql.Rows
420
+ for _ , v := range types {
421
+ dbt .mustExec ("CREATE TABLE test (id int, value " + v + ")" )
422
+ dbt .mustExec ("INSERT INTO test VALUES (1, 42.23)" )
423
+ rows = dbt .mustQuery ("SELECT value FROM test WHERE id = ?" , 1 )
424
+ if rows .Next () {
425
+ rows .Scan (& out )
426
+ if expected != out {
427
+ dbt .Errorf ("%s: %g != %g" , v , expected , out )
428
+ }
429
+ } else {
430
+ dbt .Errorf ("%s: no data" , v )
431
+ }
432
+ dbt .mustExec ("DROP TABLE IF EXISTS test" )
433
+ }
434
+ })
435
+ }
436
+
391
437
func TestString (t * testing.T ) {
392
438
runTests (t , dsn , func (dbt * DBTest ) {
393
439
types := [6 ]string {"CHAR(255)" , "VARCHAR(255)" , "TINYTEXT" , "TEXT" , "MEDIUMTEXT" , "LONGTEXT" }
0 commit comments