(t *testing.T)
| 116 | } |
| 117 | |
| 118 | func TestAdd(t *testing.T) { |
| 119 | tests := []struct { |
| 120 | x, y string |
| 121 | r string |
| 122 | }{ |
| 123 | {x: "1", y: "10", r: "11"}, |
| 124 | {x: "1", y: "1e1", r: "11"}, |
| 125 | {x: "1e1", y: "1", r: "11"}, |
| 126 | {x: ".1e1", y: "100e-1", r: "11.0"}, |
| 127 | } |
| 128 | for _, tc := range tests { |
| 129 | t.Run(fmt.Sprintf("%s, %s", tc.x, tc.y), func(t *testing.T) { |
| 130 | x := newDecimal(t, testCtx, tc.x) |
| 131 | y := newDecimal(t, testCtx, tc.y) |
| 132 | d := new(Decimal) |
| 133 | _, err := testCtx.Add(d, x, y) |
| 134 | if err != nil { |
| 135 | t.Fatal(err) |
| 136 | } |
| 137 | s := d.String() |
| 138 | if s != tc.r { |
| 139 | t.Fatalf("expected: %s, got: %s", tc.r, s) |
| 140 | } |
| 141 | }) |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | func TestCmp(t *testing.T) { |
| 146 | tests := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…