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

Function TestDecimal_Uninitialized

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

Source from the content-addressed store, hash-verified

1619}
1620
1621func TestDecimal_Uninitialized(t *testing.T) {
1622 a := Decimal{}
1623 b := Decimal{}
1624
1625 decs := []Decimal{
1626 a,
1627 a.rescale(10),
1628 a.Abs(),
1629 a.Add(b),
1630 a.Sub(b),
1631 a.Mul(b),
1632 a.Shift(0),
1633 a.Div(New(1, -1)),
1634 a.Round(2),
1635 a.Floor(),
1636 a.Ceil(),
1637 a.Truncate(2),
1638 }
1639
1640 for _, d := range decs {
1641 if d.String() != "0" {
1642 t.Errorf("expected 0, got %s", d.String())
1643 }
1644 if d.StringFixed(3) != "0.000" {
1645 t.Errorf("expected 0, got %s", d.StringFixed(3))
1646 }
1647 if d.StringScaled(-2) != "0" {
1648 t.Errorf("expected 0, got %s", d.StringScaled(-2))
1649 }
1650 }
1651
1652 if a.Cmp(b) != 0 {
1653 t.Errorf("a != b")
1654 }
1655 if a.Sign() != 0 {
1656 t.Errorf("a.Sign() != 0")
1657 }
1658 if a.Exponent() != 0 {
1659 t.Errorf("a.Exponent() != 0")
1660 }
1661 if a.IntPart() != 0 {
1662 t.Errorf("a.IntPar() != 0")
1663 }
1664 f, _ := a.Float64()
1665 if f != 0 {
1666 t.Errorf("a.Float64() != 0")
1667 }
1668 if a.Rat().RatString() != "0" {
1669 t.Errorf("a.Rat() != 0, got %s", a.Rat().RatString())
1670 }
1671}
1672
1673func TestDecimal_Add(t *testing.T) {
1674 type Inp struct {

Callers

nothing calls this directly

Calls 15

rescaleMethod · 0.95
AbsMethod · 0.95
AddMethod · 0.95
SubMethod · 0.95
MulMethod · 0.95
ShiftMethod · 0.95
DivMethod · 0.95
RoundMethod · 0.95
FloorMethod · 0.95
CeilMethod · 0.95
TruncateMethod · 0.95
CmpMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…