MCPcopy Create free account
hub / github.com/cockroachdb/apd / TestFloor

Function TestFloor

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

Source from the content-addressed store, hash-verified

386}
387
388func TestFloor(t *testing.T) {
389 tests := map[float64]int64{
390 0: 0,
391 -0.1: -1,
392 0.1: 0,
393 -0.9: -1,
394 0.9: 0,
395 -1: -1,
396 1: 1,
397 -1.1: -2,
398 1.1: 1,
399 }
400
401 for f, r := range tests {
402 t.Run(fmt.Sprint(f), func(t *testing.T) {
403 d, err := new(Decimal).SetFloat64(f)
404 if err != nil {
405 t.Fatal(err)
406 }
407 _, err = testCtx.Floor(d, d)
408 if err != nil {
409 t.Fatal(err)
410 }
411 i, err := d.Int64()
412 if err != nil {
413 t.Fatal(err)
414 }
415 if i != r {
416 t.Fatalf("got %v, expected %v", i, r)
417 }
418 })
419 }
420}
421
422func TestFormat(t *testing.T) {
423 tests := map[string]struct {

Callers

nothing calls this directly

Calls 4

RunMethod · 0.80
SetFloat64Method · 0.80
FloorMethod · 0.45
Int64Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…