(t *testing.T)
| 2101 | } |
| 2102 | |
| 2103 | func TestDecimal_DivRound2(t *testing.T) { |
| 2104 | for _, tc := range createDivTestCases() { |
| 2105 | d := tc.d |
| 2106 | if sign(tc.d2) == 0 { |
| 2107 | continue |
| 2108 | } |
| 2109 | d2 := tc.d2 |
| 2110 | prec := tc.prec |
| 2111 | q := d.DivRound(d2, prec) |
| 2112 | if sign(q)*sign(d)*sign(d2) < 0 { |
| 2113 | t.Errorf("sign of quotient wrong, got: %v/%v is about %v", d, d2, q) |
| 2114 | } |
| 2115 | x := q.Mul(d2).Abs().Sub(d.Abs()).Mul(New(2, 0)) |
| 2116 | if x.Cmp(d2.Abs().Mul(New(1, -prec))) > 0 { |
| 2117 | t.Errorf("wrong rounding, got: %v/%v prec=%d is about %v", d, d2, prec, q) |
| 2118 | } |
| 2119 | if x.Cmp(d2.Abs().Mul(New(-1, -prec))) <= 0 { |
| 2120 | t.Errorf("wrong rounding, got: %v/%v prec=%d is about %v", d, d2, prec, q) |
| 2121 | } |
| 2122 | } |
| 2123 | } |
| 2124 | |
| 2125 | func TestDecimal_RoundCash(t *testing.T) { |
| 2126 | tests := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…