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

Function TestCeil

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

Source from the content-addressed store, hash-verified

352}
353
354func TestCeil(t *testing.T) {
355 tests := map[float64]int64{
356 0: 0,
357 -0.1: 0,
358 0.1: 1,
359 -0.9: 0,
360 0.9: 1,
361 -1: -1,
362 1: 1,
363 -1.1: -1,
364 1.1: 2,
365 }
366
367 for f, r := range tests {
368 t.Run(fmt.Sprint(f), func(t *testing.T) {
369 d, err := new(Decimal).SetFloat64(f)
370 if err != nil {
371 t.Fatal(err)
372 }
373 _, err = testCtx.Ceil(d, d)
374 if err != nil {
375 t.Fatal(err)
376 }
377 i, err := d.Int64()
378 if err != nil {
379 t.Fatal(err)
380 }
381 if i != r {
382 t.Fatalf("got %v, expected %v", i, r)
383 }
384 })
385 }
386}
387
388func TestFloor(t *testing.T) {
389 tests := map[float64]int64{

Callers

nothing calls this directly

Calls 4

RunMethod · 0.80
SetFloat64Method · 0.80
CeilMethod · 0.45
Int64Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…