(t *testing.T)
| 1671 | } |
| 1672 | |
| 1673 | func TestDecimal_Add(t *testing.T) { |
| 1674 | type Inp struct { |
| 1675 | a string |
| 1676 | b string |
| 1677 | } |
| 1678 | |
| 1679 | inputs := map[Inp]string{ |
| 1680 | Inp{"2", "3"}: "5", |
| 1681 | Inp{"2454495034", "3451204593"}: "5905699627", |
| 1682 | Inp{"24544.95034", ".3451204593"}: "24545.2954604593", |
| 1683 | Inp{".1", ".1"}: "0.2", |
| 1684 | Inp{".1", "-.1"}: "0", |
| 1685 | Inp{"0", "1.001"}: "1.001", |
| 1686 | } |
| 1687 | |
| 1688 | for inp, res := range inputs { |
| 1689 | a, err := NewFromString(inp.a) |
| 1690 | if err != nil { |
| 1691 | t.FailNow() |
| 1692 | } |
| 1693 | b, err := NewFromString(inp.b) |
| 1694 | if err != nil { |
| 1695 | t.FailNow() |
| 1696 | } |
| 1697 | c := a.Add(b) |
| 1698 | if c.String() != res { |
| 1699 | t.Errorf("expected %s, got %s", res, c.String()) |
| 1700 | } |
| 1701 | } |
| 1702 | } |
| 1703 | |
| 1704 | func TestDecimal_Sub(t *testing.T) { |
| 1705 | type Inp struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…