...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package apd
16
17 import "testing"
18
19
20
21 func TestErrDecimal(t *testing.T) {
22 ed := MakeErrDecimal(testCtx)
23 a := New(1, 0)
24 ed.Abs(a, a)
25 ed.Exp(a, a)
26 ed.Ln(a, a)
27 ed.Log10(a, a)
28 ed.Neg(a, a)
29 ed.Pow(a, a, a)
30 ed.QuoInteger(a, a, a)
31 ed.Rem(a, a, a)
32 ed.Round(a, a)
33 }
34
35
36
37 func TestMakeErrDecimalWithPrecision(t *testing.T) {
38 c := &Context{
39 Precision: 5,
40 MaxExponent: 2,
41 }
42 nc := c.WithPrecision(c.Precision * 2)
43 ed := MakeErrDecimal(nc)
44 if ed.Ctx.Precision != 10 {
45 t.Fatalf("expected %d, got %d", 10, ed.Ctx.Precision)
46 }
47 if c.Precision != 5 {
48 t.Fatalf("expected %d, got %d", 5, c.Precision)
49 }
50 if c.MaxExponent != 2 {
51 t.Fatalf("expected %d, got %d", 2, c.MaxExponent)
52 }
53 }
54
View as plain text