(t *testing.T)
| 1619 | } |
| 1620 | |
| 1621 | func 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 | |
| 1673 | func TestDecimal_Add(t *testing.T) { |
| 1674 | type Inp struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…