(c *Context, done chan error, d, x, y *Decimal)
| 252 | } |
| 253 | |
| 254 | func (tc TestCase) Run(c *Context, done chan error, d, x, y *Decimal) (res Condition, err error) { |
| 255 | switch tc.Operation { |
| 256 | case "abs": |
| 257 | res, err = c.Abs(d, x) |
| 258 | case "add": |
| 259 | res, err = c.Add(d, x, y) |
| 260 | case "compare": |
| 261 | res, err = c.Cmp(d, x, y) |
| 262 | case "cuberoot": |
| 263 | res, err = c.Cbrt(d, x) |
| 264 | case "divide": |
| 265 | res, err = c.Quo(d, x, y) |
| 266 | case "divideint": |
| 267 | res, err = c.QuoInteger(d, x, y) |
| 268 | case "exp": |
| 269 | res, err = c.Exp(d, x) |
| 270 | case "ln": |
| 271 | res, err = c.Ln(d, x) |
| 272 | case "log10": |
| 273 | res, err = c.Log10(d, x) |
| 274 | case "minus": |
| 275 | res, err = c.Neg(d, x) |
| 276 | case "multiply": |
| 277 | res, err = c.Mul(d, x, y) |
| 278 | case "plus": |
| 279 | res, err = c.Add(d, x, decimalZero) |
| 280 | case "power": |
| 281 | res, err = c.Pow(d, x, y) |
| 282 | case "quantize": |
| 283 | res, err = c.Quantize(d, x, y.Exponent) |
| 284 | case "reduce": |
| 285 | _, res, err = c.Reduce(d, x) |
| 286 | case "remainder": |
| 287 | res, err = c.Rem(d, x, y) |
| 288 | case "squareroot": |
| 289 | res, err = c.Sqrt(d, x) |
| 290 | case "subtract": |
| 291 | res, err = c.Sub(d, x, y) |
| 292 | case "tointegral": |
| 293 | res, err = c.RoundToIntegralValue(d, x) |
| 294 | case "tointegralx": |
| 295 | res, err = c.RoundToIntegralExact(d, x) |
| 296 | |
| 297 | // Below used only in benchmarks. Tests call it themselves. |
| 298 | case "comparetotal": |
| 299 | x.CmpTotal(y) |
| 300 | case "tosci": |
| 301 | _ = x.String() |
| 302 | |
| 303 | default: |
| 304 | done <- fmt.Errorf("unknown operation: %s", tc.Operation) |
| 305 | } |
| 306 | return |
| 307 | } |
| 308 | |
| 309 | // BenchmarkGDA benchmarks a GDA test. It should not be used without specifying |
| 310 | // a sub-benchmark to run. For example: |
no test coverage detected