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

Function TestInt64

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

Source from the content-addressed store, hash-verified

249}
250
251func TestInt64(t *testing.T) {
252 tests := []struct {
253 x string
254 i int64
255 err bool
256 }{
257 {x: "0.12e1", err: true},
258 {x: "0.1e1", i: 1},
259 {x: "10", i: 10},
260 {x: "12.3e3", i: 12300},
261 {x: "1e-1", err: true},
262 {x: "1e2", i: 100},
263 {x: "1", i: 1},
264 {x: "NaN", err: true},
265 {x: "Inf", err: true},
266 {x: "9223372036854775807", i: 9223372036854775807},
267 {x: "-9223372036854775808", i: -9223372036854775808},
268 {x: "9223372036854775808", err: true},
269 }
270 for _, tc := range tests {
271 t.Run(tc.x, func(t *testing.T) {
272 x := newDecimal(t, testCtx, tc.x)
273 i, err := x.Int64()
274 hasErr := err != nil
275 if tc.err != hasErr {
276 t.Fatalf("expected error: %v, got error: %v", tc.err, err)
277 }
278 if hasErr {
279 return
280 }
281 if i != tc.i {
282 t.Fatalf("expected: %v, got %v", tc.i, i)
283 }
284 })
285 }
286}
287
288func TestQuoErr(t *testing.T) {
289 tests := []struct {

Callers

nothing calls this directly

Calls 3

newDecimalFunction · 0.85
RunMethod · 0.80
Int64Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…