MCPcopy
hub / github.com/go-sql-driver/mysql / TestFloat32

Function TestFloat32

driver_test.go:545–567  ·  driver_test.go::TestFloat32
(t *testing.T)

Source from the content-addressed store, hash-verified

543}
544
545func TestFloat32(t *testing.T) {
546 runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
547 types := [2]string{"FLOAT", "DOUBLE"}
548 in := float32(42.23)
549 var out float32
550 var rows *sql.Rows
551 for _, v := range types {
552 dbt.mustExec("CREATE TABLE " + tbl + " (value " + v + ")")
553 dbt.mustExec("INSERT INTO "+tbl+" VALUES (?)", in)
554 rows = dbt.mustQuery("SELECT value FROM " + tbl)
555 if rows.Next() {
556 rows.Scan(&out)
557 if in != out {
558 dbt.Errorf("%s: %g != %g", v, in, out)
559 }
560 } else {
561 dbt.Errorf("%s: no data", v)
562 }
563 rows.Close()
564 dbt.mustExec("DROP TABLE IF EXISTS " + tbl)
565 }
566 })
567}
568
569func TestFloat64(t *testing.T) {
570 runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {

Callers

nothing calls this directly

Calls 6

runTestsParallelFunction · 0.85
mustExecMethod · 0.80
mustQueryMethod · 0.80
ScanMethod · 0.80
NextMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected