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

Function TestUpscale

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

Source from the content-addressed store, hash-verified

84}
85
86func TestUpscale(t *testing.T) {
87 tests := []struct {
88 x, y *Decimal
89 a, b *BigInt
90 s int32
91 }{
92 {x: New(1, 0), y: New(100, -1), a: NewBigInt(10), b: NewBigInt(100), s: -1},
93 {x: New(1, 0), y: New(10, -1), a: NewBigInt(10), b: NewBigInt(10), s: -1},
94 {x: New(1, 0), y: New(10, 0), a: NewBigInt(1), b: NewBigInt(10), s: 0},
95 {x: New(1, 1), y: New(1, 0), a: NewBigInt(10), b: NewBigInt(1), s: 0},
96 {x: New(10, -2), y: New(1, -1), a: NewBigInt(10), b: NewBigInt(10), s: -2},
97 {x: New(1, -2), y: New(100, 1), a: NewBigInt(1), b: NewBigInt(100000), s: -2},
98 }
99 for _, tc := range tests {
100 t.Run(fmt.Sprintf("%s, %s", tc.x, tc.y), func(t *testing.T) {
101 a, b, s, err := upscale(tc.x, tc.y, new(BigInt))
102 if err != nil {
103 t.Fatal(err)
104 }
105 if a.Cmp(tc.a) != 0 {
106 t.Errorf("a: expected %s, got %s", tc.a, a)
107 }
108 if b.Cmp(tc.b) != 0 {
109 t.Errorf("b: expected %s, got %s", tc.b, b)
110 }
111 if s != tc.s {
112 t.Errorf("s: expected %d, got %d", tc.s, s)
113 }
114 })
115 }
116}
117
118func TestAdd(t *testing.T) {
119 tests := []struct {

Callers

nothing calls this directly

Calls 5

NewFunction · 0.85
NewBigIntFunction · 0.85
upscaleFunction · 0.85
RunMethod · 0.80
CmpMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…