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

Function TestDecimal_Sub

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

Source from the content-addressed store, hash-verified

1702}
1703
1704func 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
1739func TestDecimal_Neg(t *testing.T) {
1740 inputs := map[string]string{

Callers

nothing calls this directly

Calls 3

NewFromStringFunction · 0.85
SubMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…