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

Function TestAdd

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

Source from the content-addressed store, hash-verified

116}
117
118func TestAdd(t *testing.T) {
119 tests := []struct {
120 x, y string
121 r string
122 }{
123 {x: "1", y: "10", r: "11"},
124 {x: "1", y: "1e1", r: "11"},
125 {x: "1e1", y: "1", r: "11"},
126 {x: ".1e1", y: "100e-1", r: "11.0"},
127 }
128 for _, tc := range tests {
129 t.Run(fmt.Sprintf("%s, %s", tc.x, tc.y), func(t *testing.T) {
130 x := newDecimal(t, testCtx, tc.x)
131 y := newDecimal(t, testCtx, tc.y)
132 d := new(Decimal)
133 _, err := testCtx.Add(d, x, y)
134 if err != nil {
135 t.Fatal(err)
136 }
137 s := d.String()
138 if s != tc.r {
139 t.Fatalf("expected: %s, got: %s", tc.r, s)
140 }
141 })
142 }
143}
144
145func TestCmp(t *testing.T) {
146 tests := []struct {

Callers

nothing calls this directly

Calls 4

newDecimalFunction · 0.85
RunMethod · 0.80
AddMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…