(t *testing.T)
| 55 | } |
| 56 | |
| 57 | func 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 | |
| 86 | func TestUpscale(t *testing.T) { |
| 87 | tests := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…