MCPcopy
hub / github.com/shopspring/decimal / TestDecimal_Add

Function TestDecimal_Add

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

Source from the content-addressed store, hash-verified

1671}
1672
1673func 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
1704func TestDecimal_Sub(t *testing.T) {
1705 type Inp struct {

Callers

nothing calls this directly

Calls 3

NewFromStringFunction · 0.85
AddMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…