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

Function TestNewWithBigInt

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

Source from the content-addressed store, hash-verified

55}
56
57func TestNewWithBigInt(t *testing.T) {
58 tests := []string{
59 "0",
60 "1",
61 "-1",
62 }
63 for _, tc := range tests {
64 t.Run(tc, func(t *testing.T) {
65 expect, _, err := new(Decimal).SetString(tc)
66 if err != nil {
67 t.Fatal(err)
68 }
69 b, ok := new(BigInt).SetString(tc, 10)
70 if !ok {
71 t.Fatal("bad bigint")
72 }
73 d := NewWithBigInt(b, 0)
74 if d.Coeff.Sign() < 0 {
75 t.Fatal("unexpected negative coeff")
76 }
77 // Verify that changing b doesn't change d.
78 b.Set(NewBigInt(1234))
79 if d.CmpTotal(expect) != 0 {
80 t.Fatalf("expected %s, got %s", expect, d)
81 }
82 })
83 }
84}
85
86func TestUpscale(t *testing.T) {
87 tests := []struct {

Callers

nothing calls this directly

Calls 7

NewWithBigIntFunction · 0.85
NewBigIntFunction · 0.85
RunMethod · 0.80
CmpTotalMethod · 0.80
SetStringMethod · 0.45
SignMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…