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

Function TestBigIntSetString

bigint_test.go:2434–2467  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2432}
2433
2434func TestBigIntSetString(t *testing.T) {
2435 tmp := new(BigInt)
2436 for i, test := range stringTests {
2437 // initialize to a non-zero value so that issues with parsing
2438 // 0 are detected
2439 tmp.SetInt64(1234567890)
2440 n1, ok1 := new(BigInt).SetString(test.in, test.base)
2441 n2, ok2 := tmp.SetString(test.in, test.base)
2442 expected := NewBigInt(test.val)
2443 if ok1 != test.ok || ok2 != test.ok {
2444 t.Errorf("#%d (input '%s') ok incorrect (should be %t)", i, test.in, test.ok)
2445 continue
2446 }
2447 if !ok1 {
2448 if n1 != nil {
2449 t.Errorf("#%d (input '%s') n1 != nil", i, test.in)
2450 }
2451 continue
2452 }
2453 if !ok2 {
2454 if n2 != nil {
2455 t.Errorf("#%d (input '%s') n2 != nil", i, test.in)
2456 }
2457 continue
2458 }
2459
2460 if n1.Cmp(expected) != 0 {
2461 t.Errorf("#%d (input '%s') got: %s want: %d", i, test.in, n1, test.val)
2462 }
2463 if n2.Cmp(expected) != 0 {
2464 t.Errorf("#%d (input '%s') got: %s want: %d", i, test.in, n2, test.val)
2465 }
2466 }
2467}
2468
2469var formatTests = []struct {
2470 input string

Callers

nothing calls this directly

Calls 4

NewBigIntFunction · 0.85
SetInt64Method · 0.45
SetStringMethod · 0.45
CmpMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…