MCPcopy Create free account
hub / github.com/dgraph-io/dgraph / TestProcessBinaryBigFloat

Function TestProcessBinaryBigFloat

query/math_test.go:631–691  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

629}
630
631func TestProcessBinaryBigFloat(t *testing.T) {
632 tests := []struct {
633 in *mathTree
634 out types.Val
635 }{
636 {in: &mathTree{
637 Fn: "+",
638 Child: []*mathTree{
639 {Const: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(2.15)}},
640 {Const: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(1.15)}},
641 }},
642 out: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(3.3)},
643 },
644 {in: &mathTree{
645 Fn: "-",
646 Child: []*mathTree{
647 {Const: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(100)}},
648 {Const: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(1)}},
649 }},
650 out: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(99)},
651 },
652 {in: &mathTree{
653 Fn: "*",
654 Child: []*mathTree{
655 {Const: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(3)}},
656 {Const: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(3)}},
657 }},
658 out: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(9)},
659 },
660 {in: &mathTree{
661 Fn: "/",
662 Child: []*mathTree{
663 {Const: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(12)}},
664 {Const: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(4)}},
665 }},
666 out: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(3)},
667 },
668 {in: &mathTree{
669 Fn: "max",
670 Child: []*mathTree{
671 {Const: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(1)}},
672 {Const: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(100)}},
673 }},
674 out: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(100)},
675 },
676 {in: &mathTree{
677 Fn: "min",
678 Child: []*mathTree{
679 {Const: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(1)}},
680 {Const: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(100)}},
681 }},
682 out: types.Val{Tid: types.BigFloatID, Value: *big.NewFloat(1)},
683 },
684 }
685 for _, tc := range tests {
686 t.Logf("Test %s", tc.in.Fn)
687 err := processBinary(tc.in)
688 require.NoError(t, err)

Callers

nothing calls this directly

Calls 1

processBinaryFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…