(t *testing.T)
| 546 | } |
| 547 | |
| 548 | func TestNewFromBigIntWithExponent(t *testing.T) { |
| 549 | type Inp struct { |
| 550 | val *big.Int |
| 551 | exp int32 |
| 552 | } |
| 553 | tests := map[Inp]string{ |
| 554 | Inp{big.NewInt(123412345), -3}: "123412.345", |
| 555 | Inp{big.NewInt(2234), -1}: "223.4", |
| 556 | Inp{big.NewInt(323412345), 1}: "3234123450", |
| 557 | Inp{big.NewInt(423412345), 0}: "423412345", |
| 558 | Inp{big.NewInt(52341235), -5}: "523.41235", |
| 559 | Inp{big.NewInt(623412345), -6}: "623.412345", |
| 560 | Inp{big.NewInt(723412345), -7}: "72.3412345", |
| 561 | } |
| 562 | |
| 563 | // add negatives |
| 564 | for p, s := range tests { |
| 565 | if p.val.Cmp(Zero.value) > 0 { |
| 566 | tests[Inp{p.val.Neg(p.val), p.exp}] = "-" + s |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | for input, s := range tests { |
| 571 | d := NewFromBigInt(input.val, input.exp) |
| 572 | if d.String() != s { |
| 573 | t.Errorf("expected %s, got %s (%s, %d)", |
| 574 | s, d.String(), |
| 575 | d.value.String(), d.exp) |
| 576 | } |
| 577 | } |
| 578 | } |
| 579 | |
| 580 | func TestNewFromBigRat(t *testing.T) { |
| 581 | mustParseRat := func(val string) *big.Rat { |
nothing calls this directly
no test coverage detected
searching dependent graphs…