[
{"name": "1:1 on £50 with no caps is £50", "args": [{"minor": 5000, "currency": "GBP"}, 10000, null, {"minor": 0, "currency": "GBP"}, null, {"minor": 0, "currency": "GBP"}], "expect": {"matched": {"minor": 5000, "currency": "GBP"}, "uncapped": {"minor": 5000, "currency": "GBP"}, "cappedBy": "none"}},
{"name": "2:1 on £50 is £100", "args": [{"minor": 5000, "currency": "GBP"}, 20000, null, {"minor": 0, "currency": "GBP"}, null, {"minor": 0, "currency": "GBP"}], "expect": {"matched": {"minor": 10000, "currency": "GBP"}, "uncapped": {"minor": 10000, "currency": "GBP"}, "cappedBy": "none"}},
{"name": "50p per £1 on £3.33 is 166.5p, rounded down to 166p", "args": [{"minor": 333, "currency": "GBP"}, 5000, null, {"minor": 0, "currency": "GBP"}, null, {"minor": 0, "currency": "GBP"}], "expect": {"matched": {"minor": 166, "currency": "GBP"}, "uncapped": {"minor": 166, "currency": "GBP"}, "cappedBy": "none"}},
{"name": "the donor cap limits the match to the room left: £1,000 cap, £950 used", "args": [{"minor": 10000, "currency": "GBP"}, 10000, {"minor": 100000, "currency": "GBP"}, {"minor": 95000, "currency": "GBP"}, null, {"minor": 0, "currency": "GBP"}], "expect": {"matched": {"minor": 5000, "currency": "GBP"}, "uncapped": {"minor": 10000, "currency": "GBP"}, "cappedBy": "donor"}},
{"name": "a donor who has used the whole cap gets nothing", "args": [{"minor": 10000, "currency": "GBP"}, 10000, {"minor": 100000, "currency": "GBP"}, {"minor": 100000, "currency": "GBP"}, null, {"minor": 0, "currency": "GBP"}], "expect": {"matched": {"minor": 0, "currency": "GBP"}, "uncapped": {"minor": 10000, "currency": "GBP"}, "cappedBy": "donor"}},
{"name": "a donor already over the cap gets nothing, not a negative match", "args": [{"minor": 10000, "currency": "GBP"}, 10000, {"minor": 100000, "currency": "GBP"}, {"minor": 120000, "currency": "GBP"}, null, {"minor": 0, "currency": "GBP"}], "expect": {"matched": {"minor": 0, "currency": "GBP"}, "uncapped": {"minor": 10000, "currency": "GBP"}, "cappedBy": "donor"}},
{"name": "a match exactly filling the cap is not reported as capped", "args": [{"minor": 5000, "currency": "GBP"}, 10000, {"minor": 100000, "currency": "GBP"}, {"minor": 95000, "currency": "GBP"}, null, {"minor": 0, "currency": "GBP"}], "expect": {"matched": {"minor": 5000, "currency": "GBP"}, "uncapped": {"minor": 5000, "currency": "GBP"}, "cappedBy": "none"}},
{"name": "the programme budget binds when it is tighter than the donor cap", "args": [{"minor": 10000, "currency": "GBP"}, 10000, {"minor": 100000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 500000, "currency": "GBP"}, {"minor": 497000, "currency": "GBP"}], "expect": {"matched": {"minor": 3000, "currency": "GBP"}, "uncapped": {"minor": 10000, "currency": "GBP"}, "cappedBy": "programme"}},
{"name": "the donor cap binds when it is tighter than the programme budget", "args": [{"minor": 10000, "currency": "GBP"}, 10000, {"minor": 100000, "currency": "GBP"}, {"minor": 98000, "currency": "GBP"}, {"minor": 500000, "currency": "GBP"}, {"minor": 400000, "currency": "GBP"}], "expect": {"matched": {"minor": 2000, "currency": "GBP"}, "uncapped": {"minor": 10000, "currency": "GBP"}, "cappedBy": "donor"}},
{"name": "when both caps leave the same room, the donor cap is named", "args": [{"minor": 10000, "currency": "GBP"}, 10000, {"minor": 100000, "currency": "GBP"}, {"minor": 98000, "currency": "GBP"}, {"minor": 500000, "currency": "GBP"}, {"minor": 498000, "currency": "GBP"}], "expect": {"matched": {"minor": 2000, "currency": "GBP"}, "uncapped": {"minor": 10000, "currency": "GBP"}, "cappedBy": "donor"}},
{"name": "a zero ratio matches nothing", "args": [{"minor": 10000, "currency": "GBP"}, 0, null, {"minor": 0, "currency": "GBP"}, null, {"minor": 0, "currency": "GBP"}], "expect": {"matched": {"minor": 0, "currency": "GBP"}, "uncapped": {"minor": 0, "currency": "GBP"}, "cappedBy": "none"}},
{"name": "a zero donation matches nothing", "args": [{"minor": 0, "currency": "GBP"}, 10000, null, {"minor": 0, "currency": "GBP"}, null, {"minor": 0, "currency": "GBP"}], "expect": {"matched": {"minor": 0, "currency": "GBP"}, "uncapped": {"minor": 0, "currency": "GBP"}, "cappedBy": "none"}},
{"name": "a negative ratio is an error", "args": [{"minor": 10000, "currency": "GBP"}, -1, null, {"minor": 0, "currency": "GBP"}, null, {"minor": 0, "currency": "GBP"}], "expectError": "ratioBasisPoints must be a non-negative integer"},
{"name": "a fractional ratio is an error", "args": [{"minor": 10000, "currency": "GBP"}, 1.5, null, {"minor": 0, "currency": "GBP"}, null, {"minor": 0, "currency": "GBP"}], "expectError": "ratioBasisPoints must be a non-negative integer"},
{"name": "a negative donation is an error", "args": [{"minor": -1, "currency": "GBP"}, 10000, null, {"minor": 0, "currency": "GBP"}, null, {"minor": 0, "currency": "GBP"}], "expectError": "donation must not be negative"},
{"name": "a cap in another currency is an error", "args": [{"minor": 10000, "currency": "GBP"}, 10000, {"minor": 100000, "currency": "EUR"}, {"minor": 0, "currency": "GBP"}, null, {"minor": 0, "currency": "GBP"}], "expectError": "currency mismatch: EUR and GBP"},
{"name": "negative matched so far is an error", "args": [{"minor": 10000, "currency": "GBP"}, 10000, null, {"minor": -5, "currency": "GBP"}, null, {"minor": 0, "currency": "GBP"}], "expectError": "donorMatchedSoFar must not be negative"}
]