[
{ "name": "a whole answer: 1000 a year, £10 an order, 50p to hold, is 200", "args": [1000, {"minor": 1000, "currency": "GBP"}, {"minor": 50, "currency": "GBP"}, "half-up"], "expect": 200 },
{ "name": "a perfect square stays put when rounding up", "args": [1000, {"minor": 1000, "currency": "GBP"}, {"minor": 50, "currency": "GBP"}, "up"], "expect": 200 },
{ "name": "sqrt(400000) = 632.46 rounds half-up to 632", "args": [10000, {"minor": 4000, "currency": "GBP"}, {"minor": 200, "currency": "GBP"}, "half-up"], "expect": 632 },
{ "name": "sqrt(400000) = 632.46 rounds up to 633", "args": [10000, {"minor": 4000, "currency": "GBP"}, {"minor": 200, "currency": "GBP"}, "up"], "expect": 633 },
{ "name": "a fractional 2DS/H: sqrt(208333.33) = 456.44 rounds to 456", "args": [5000, {"minor": 2500, "currency": "GBP"}, {"minor": 120, "currency": "GBP"}, "half-up"], "expect": 456 },
{ "name": "an exact half, sqrt(6.25) = 2.5, rounds half-up to 3", "args": [25, {"minor": 1, "currency": "GBP"}, {"minor": 8, "currency": "GBP"}, "half-up"], "expect": 3 },
{ "name": "an exact half, sqrt(6.25) = 2.5, rounds half-even to 2 (Math.round would say 3)", "args": [25, {"minor": 1, "currency": "GBP"}, {"minor": 8, "currency": "GBP"}, "half-even"], "expect": 2 },
{ "name": "an exact half, sqrt(12.25) = 3.5, rounds half-even to 4", "args": [49, {"minor": 1, "currency": "GBP"}, {"minor": 8, "currency": "GBP"}, "half-even"], "expect": 4 },
{ "name": "just under a half, sqrt(6.24) = 2.498, rounds half-up to 2", "args": [312, {"minor": 1, "currency": "GBP"}, {"minor": 100, "currency": "GBP"}, "half-up"], "expect": 2 },
{ "name": "a hair over a whole number, sqrt(40000.01), rounds up to 201", "args": [4000001, {"minor": 1, "currency": "GBP"}, {"minor": 200, "currency": "GBP"}, "up"], "expect": 201 },
{ "name": "a hair over a whole number, sqrt(40000.01), rounds down to 200", "args": [4000001, {"minor": 1, "currency": "GBP"}, {"minor": 200, "currency": "GBP"}, "down"], "expect": 200 },
{ "name": "no demand orders nothing, even rounding up", "args": [0, {"minor": 1000, "currency": "EUR"}, {"minor": 50, "currency": "EUR"}, "up"], "expect": 0 },
{ "name": "a free order gives zero", "args": [1000, {"minor": 0, "currency": "EUR"}, {"minor": 50, "currency": "EUR"}, "half-up"], "expect": 0 },
{ "name": "costs in two currencies are an error", "args": [1000, {"minor": 1000, "currency": "GBP"}, {"minor": 50, "currency": "EUR"}, "half-up"], "expectError": "currency mismatch" },
{ "name": "a zero holding cost is an error", "args": [1000, {"minor": 1000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, "half-up"], "expectError": "holdingCost must be greater than zero" },
{ "name": "negative demand is an error", "args": [-1, {"minor": 1000, "currency": "GBP"}, {"minor": 50, "currency": "GBP"}, "half-up"], "expectError": "annualDemand must be a whole number of units, not negative" },
{ "name": "fractional demand is an error", "args": [10.5, {"minor": 1000, "currency": "GBP"}, {"minor": 50, "currency": "GBP"}, "half-up"], "expectError": "annualDemand must be a whole number of units, not negative" },
{ "name": "a negative order cost is an error", "args": [1000, {"minor": -1, "currency": "GBP"}, {"minor": 50, "currency": "GBP"}, "half-up"], "expectError": "orderCost must not be negative" },
{ "name": "8DS beyond 2^53 - 1 is an error", "args": [1000000000, {"minor": 10000000, "currency": "GBP"}, {"minor": 50, "currency": "GBP"}, "half-up"], "expectError": "too large" },
{ "name": "an unknown rounding mode is an error", "args": [1000, {"minor": 1000, "currency": "GBP"}, {"minor": 50, "currency": "GBP"}, "nearest"], "expectError": "unknown rounding mode" }
]