| 2474 | } |
| 2475 | |
| 2476 | func TestDecimal_Value(t *testing.T) { |
| 2477 | // Make sure this does implement the database/sql's driver.Valuer interface |
| 2478 | var d Decimal |
| 2479 | if _, ok := interface{}(d).(driver.Valuer); !ok { |
| 2480 | t.Error("Decimal does not implement driver.Valuer") |
| 2481 | } |
| 2482 | |
| 2483 | // check that normal case is handled appropriately |
| 2484 | a := New(1234, -2) |
| 2485 | expected := "12.34" |
| 2486 | value, err := a.Value() |
| 2487 | if err != nil { |
| 2488 | t.Errorf("Decimal(12.34).Value() failed with message: %s", err) |
| 2489 | } else if value.(string) != expected { |
| 2490 | t.Errorf("%s does not equal to %s", a, expected) |
| 2491 | } |
| 2492 | } |
| 2493 | |
| 2494 | // old tests after this line |
| 2495 | |