[
{ "name": "totals three lines", "args": [[{ "minor": 1000, "currency": "GBP" }, { "minor": 2550, "currency": "GBP" }, { "minor": 99, "currency": "GBP" }], "GBP"], "expect": { "minor": 3649, "currency": "GBP" } },
{ "name": "empty list is zero in the stated currency", "args": [[], "GBP"], "expect": { "minor": 0, "currency": "GBP" } },
{ "name": "credits reduce the total", "args": [[{ "minor": 5000, "currency": "GBP" }, { "minor": -1200, "currency": "GBP" }], "GBP"], "expect": { "minor": 3800, "currency": "GBP" } },
{ "name": "a foreign amount in the list is an error", "args": [[{ "minor": 100, "currency": "GBP" }, { "minor": 100, "currency": "USD" }], "GBP"], "expectError": "currency mismatch" },
{ "name": "one amount is its own total", "args": [[{ "minor": 250, "currency": "EUR" }], "EUR"], "expect": { "minor": 250, "currency": "EUR" } },
{ "name": "an empty list in a zero-decimal currency", "args": [[], "JPY"], "expect": { "minor": 0, "currency": "JPY" } },
{ "name": "credits can take the total below zero", "args": [[{ "minor": 1000, "currency": "GBP" }, { "minor": -1500, "currency": "GBP" }], "GBP"], "expect": { "minor": -500, "currency": "GBP" } },
{ "name": "ten 10p amounts make exactly one pound", "args": [[{ "minor": 10, "currency": "GBP" }, { "minor": 10, "currency": "GBP" }, { "minor": 10, "currency": "GBP" }, { "minor": 10, "currency": "GBP" }, { "minor": 10, "currency": "GBP" }, { "minor": 10, "currency": "GBP" }, { "minor": 10, "currency": "GBP" }, { "minor": 10, "currency": "GBP" }, { "minor": 10, "currency": "GBP" }, { "minor": 10, "currency": "GBP" }], "GBP"], "expect": { "minor": 100, "currency": "GBP" } },
{ "name": "large totals stay exact up to the largest safe integer", "args": [[{ "minor": 9007199254740000, "currency": "GBP" }, { "minor": 990, "currency": "GBP" }, { "minor": 1, "currency": "GBP" }], "GBP"], "expect": { "minor": 9007199254740991, "currency": "GBP" } },
{ "name": "every amount must be in the stated currency, not the first one's", "args": [[{ "minor": 100, "currency": "EUR" }, { "minor": 200, "currency": "EUR" }], "GBP"], "expectError": "currency mismatch" },
{ "name": "an invalid currency is refused even for an empty list", "args": [[], "gbp"], "expectError": "ISO 4217" }
]