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

Function TestBigIntGetString

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

Source from the content-addressed store, hash-verified

2392}
2393
2394func TestBigIntGetString(t *testing.T) {
2395 format := func(base int) string {
2396 switch base {
2397 case 2:
2398 return "%b"
2399 case 8:
2400 return "%o"
2401 case 16:
2402 return "%x"
2403 }
2404 return "%d"
2405 }
2406
2407 z := new(BigInt)
2408 for i, test := range stringTests {
2409 if !test.ok {
2410 continue
2411 }
2412 z.SetInt64(test.val)
2413
2414 if test.base == 10 {
2415 if got := z.String(); got != test.out {
2416 t.Errorf("#%da got %s; want %s", i, got, test.out)
2417 }
2418 }
2419
2420 f := format(test.base)
2421 got := fmt.Sprintf(f, z)
2422 if f == "%d" {
2423 if got != fmt.Sprintf("%d", test.val) {
2424 t.Errorf("#%db got %s; want %d", i, got, test.val)
2425 }
2426 } else {
2427 if got != test.out {
2428 t.Errorf("#%dc got %s; want %s", i, got, test.out)
2429 }
2430 }
2431 }
2432}
2433
2434func TestBigIntSetString(t *testing.T) {
2435 tmp := new(BigInt)

Callers

nothing calls this directly

Calls 2

SetInt64Method · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…