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

Function TestInt

driver_test.go:496–543  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

494}
495
496func TestInt(t *testing.T) {
497 runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
498 types := [5]string{"TINYINT", "SMALLINT", "MEDIUMINT", "INT", "BIGINT"}
499 in := int64(42)
500 var out int64
501 var rows *sql.Rows
502
503 // SIGNED
504 for _, v := range types {
505 dbt.mustExec("CREATE TABLE " + tbl + " (value " + v + ")")
506
507 dbt.mustExec("INSERT INTO "+tbl+" VALUES (?)", in)
508
509 rows = dbt.mustQuery("SELECT value FROM " + tbl)
510 if rows.Next() {
511 rows.Scan(&out)
512 if in != out {
513 dbt.Errorf("%s: %d != %d", v, in, out)
514 }
515 } else {
516 dbt.Errorf("%s: no data", v)
517 }
518 rows.Close()
519
520 dbt.mustExec("DROP TABLE IF EXISTS " + tbl)
521 }
522
523 // UNSIGNED ZEROFILL
524 for _, v := range types {
525 dbt.mustExec("CREATE TABLE " + tbl + " (value " + v + " ZEROFILL)")
526
527 dbt.mustExec("INSERT INTO "+tbl+" VALUES (?)", in)
528
529 rows = dbt.mustQuery("SELECT value FROM " + tbl)
530 if rows.Next() {
531 rows.Scan(&out)
532 if in != out {
533 dbt.Errorf("%s ZEROFILL: %d != %d", v, in, out)
534 }
535 } else {
536 dbt.Errorf("%s ZEROFILL: no data", v)
537 }
538 rows.Close()
539
540 dbt.mustExec("DROP TABLE IF EXISTS " + tbl)
541 }
542 })
543}
544
545func TestFloat32(t *testing.T) {
546 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