MCPcopy
hub / github.com/shopspring/decimal / TestNullDecimal_Value

Function TestNullDecimal_Value

decimal_test.go:3264–3288  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3262}
3263
3264func TestNullDecimal_Value(t *testing.T) {
3265 // Make sure this does implement the database/sql's driver.Valuer interface
3266 var nullDecimal NullDecimal
3267 if _, ok := interface{}(nullDecimal).(driver.Valuer); !ok {
3268 t.Error("NullDecimal does not implement driver.Valuer")
3269 }
3270
3271 // check that null is handled appropriately
3272 value, err := nullDecimal.Value()
3273 if err != nil {
3274 t.Errorf("NullDecimal{}.Valid() failed with message: %s", err)
3275 } else if value != nil {
3276 t.Errorf("%v is not nil", value)
3277 }
3278
3279 // check that normal case is handled appropriately
3280 a := NullDecimal{Decimal: New(1234, -2), Valid: true}
3281 expected := "12.34"
3282 value, err = a.Value()
3283 if err != nil {
3284 t.Errorf("NullDecimal(12.34).Value() failed with message: %s", err)
3285 } else if value.(string) != expected {
3286 t.Errorf("%v does not equal %v", a, expected)
3287 }
3288}
3289
3290func TestBinary(t *testing.T) {
3291 for _, y := range testTable {

Callers

nothing calls this directly

Calls 2

ValueMethod · 0.95
NewFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…