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

Function TestReduce

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

Source from the content-addressed store, hash-verified

799}
800
801func TestReduce(t *testing.T) {
802 tests := map[string]int{
803 "-0": 0,
804 "0": 0,
805 "0.0": 0,
806 "00": 0,
807 "0.00": 0,
808 "-01000": 3,
809 "01000": 3,
810 "-1": 0,
811 "1": 0,
812 "-10.000E4": 4,
813 "10.000E4": 4,
814 "-10.00": 3,
815 "10.00": 3,
816 "-10": 1,
817 "10": 1,
818 "-143200000000000000000000000000000000000000000000000000000000": 56,
819 "143200000000000000000000000000000000000000000000000000000000": 56,
820 "Inf": 0,
821 "NaN": 0,
822 }
823
824 for s, n := range tests {
825 t.Run(s, func(t *testing.T) {
826 d, _, err := NewFromString(s)
827 if err != nil {
828 t.Fatal(err)
829 }
830 _, got := d.Reduce(d)
831 if n != got {
832 t.Fatalf("got %v, expected %v", got, n)
833 }
834 })
835 }
836}
837
838// TestSizeof is meant to catch changes that unexpectedly increase
839// the size of the BigInt, Decimal, and Context structs.

Callers

nothing calls this directly

Calls 3

NewFromStringFunction · 0.85
RunMethod · 0.80
ReduceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…