(t *testing.T)
| 1702 | } |
| 1703 | |
| 1704 | func TestDecimal_Sub(t *testing.T) { |
| 1705 | type Inp struct { |
| 1706 | a string |
| 1707 | b string |
| 1708 | } |
| 1709 | |
| 1710 | inputs := map[Inp]string{ |
| 1711 | Inp{"2", "3"}: "-1", |
| 1712 | Inp{"12", "3"}: "9", |
| 1713 | Inp{"-2", "9"}: "-11", |
| 1714 | Inp{"2454495034", "3451204593"}: "-996709559", |
| 1715 | Inp{"24544.95034", ".3451204593"}: "24544.6052195407", |
| 1716 | Inp{".1", "-.1"}: "0.2", |
| 1717 | Inp{".1", ".1"}: "0", |
| 1718 | Inp{"0", "1.001"}: "-1.001", |
| 1719 | Inp{"1.001", "0"}: "1.001", |
| 1720 | Inp{"2.3", ".3"}: "2", |
| 1721 | } |
| 1722 | |
| 1723 | for inp, res := range inputs { |
| 1724 | a, err := NewFromString(inp.a) |
| 1725 | if err != nil { |
| 1726 | t.FailNow() |
| 1727 | } |
| 1728 | b, err := NewFromString(inp.b) |
| 1729 | if err != nil { |
| 1730 | t.FailNow() |
| 1731 | } |
| 1732 | c := a.Sub(b) |
| 1733 | if c.String() != res { |
| 1734 | t.Errorf("expected %s, got %s", res, c.String()) |
| 1735 | } |
| 1736 | } |
| 1737 | } |
| 1738 | |
| 1739 | func TestDecimal_Neg(t *testing.T) { |
| 1740 | inputs := map[string]string{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…