[ { "name": "insured for 150,000 of 200,000: a 40,000 loss pays 30,000", "args": [ { "minor": 4000000, "currency": "GBP" }, { "minor": 15000000, "currency": "GBP" }, { "minor": 20000000, "currency": "GBP" }, 10000, "half-up" ], "expect": { "payout": { "minor": 3000000, "currency": "GBP" }, "averageApplied": true, "insuredProportionBasisPoints": 7500, "shortfall": { "minor": 1000000, "currency": "GBP" } } }, { "name": "fully insured pays the loss", "args": [ { "minor": 4000000, "currency": "GBP" }, { "minor": 20000000, "currency": "GBP" }, { "minor": 20000000, "currency": "GBP" }, 10000, "half-up" ], "expect": { "payout": { "minor": 4000000, "currency": "GBP" }, "averageApplied": false, "insuredProportionBasisPoints": 10000, "shortfall": { "minor": 0, "currency": "GBP" } } }, { "name": "over-insured pays the loss, and the proportion stops at 100%", "args": [ { "minor": 4000000, "currency": "GBP" }, { "minor": 25000000, "currency": "GBP" }, { "minor": 20000000, "currency": "GBP" }, 10000, "half-up" ], "expect": { "payout": { "minor": 4000000, "currency": "GBP" }, "averageApplied": false, "insuredProportionBasisPoints": 10000, "shortfall": { "minor": 0, "currency": "GBP" } } }, { "name": "a total loss when underinsured pays the sum insured", "args": [ { "minor": 20000000, "currency": "GBP" }, { "minor": 15000000, "currency": "GBP" }, { "minor": 20000000, "currency": "GBP" }, 10000, "half-up" ], "expect": { "payout": { "minor": 15000000, "currency": "GBP" }, "averageApplied": true, "insuredProportionBasisPoints": 7500, "shortfall": { "minor": 5000000, "currency": "GBP" } } }, { "name": "special condition of average at 75%: insured for 80% of value, no average", "args": [ { "minor": 4000000, "currency": "GBP" }, { "minor": 16000000, "currency": "GBP" }, { "minor": 20000000, "currency": "GBP" }, 7500, "half-up" ], "expect": { "payout": { "minor": 4000000, "currency": "GBP" }, "averageApplied": false, "insuredProportionBasisPoints": 8000, "shortfall": { "minor": 0, "currency": "GBP" } } }, { "name": "special condition at 75%: insured for 70%, average applies in full proportion", "args": [ { "minor": 4000000, "currency": "GBP" }, { "minor": 14000000, "currency": "GBP" }, { "minor": 20000000, "currency": "GBP" }, 7500, "half-up" ], "expect": { "payout": { "minor": 2800000, "currency": "GBP" }, "averageApplied": true, "insuredProportionBasisPoints": 7000, "shortfall": { "minor": 1200000, "currency": "GBP" } } }, { "name": "insured for exactly 75% under the 75% condition: not below it, so no average", "args": [ { "minor": 4000000, "currency": "GBP" }, { "minor": 15000000, "currency": "GBP" }, { "minor": 20000000, "currency": "GBP" }, 7500, "half-up" ], "expect": { "payout": { "minor": 4000000, "currency": "GBP" }, "averageApplied": false, "insuredProportionBasisPoints": 7500, "shortfall": { "minor": 0, "currency": "GBP" } } }, { "name": "no average, but a loss above the sum insured is capped at it", "args": [ { "minor": 19000000, "currency": "GBP" }, { "minor": 16000000, "currency": "GBP" }, { "minor": 20000000, "currency": "GBP" }, 7500, "half-up" ], "expect": { "payout": { "minor": 16000000, "currency": "GBP" }, "averageApplied": false, "insuredProportionBasisPoints": 8000, "shortfall": { "minor": 3000000, "currency": "GBP" } } }, { "name": "a third insured: 1,000.00 x 1/3 is 333.333..., half-up 333.33", "args": [ { "minor": 100000, "currency": "GBP" }, { "minor": 10000000, "currency": "GBP" }, { "minor": 30000000, "currency": "GBP" }, 10000, "half-up" ], "expect": { "payout": { "minor": 33333, "currency": "GBP" }, "averageApplied": true, "insuredProportionBasisPoints": 3333, "shortfall": { "minor": 66667, "currency": "GBP" } } }, { "name": "the same rounded up", "args": [ { "minor": 100000, "currency": "GBP" }, { "minor": 10000000, "currency": "GBP" }, { "minor": 30000000, "currency": "GBP" }, 10000, "up" ], "expect": { "payout": { "minor": 33334, "currency": "GBP" }, "averageApplied": true, "insuredProportionBasisPoints": 3333, "shortfall": { "minor": 66666, "currency": "GBP" } } }, { "name": "two thirds: 666.666... half-up is 666.67", "args": [ { "minor": 100000, "currency": "GBP" }, { "minor": 20000000, "currency": "GBP" }, { "minor": 30000000, "currency": "GBP" }, 10000, "half-up" ], "expect": { "payout": { "minor": 66667, "currency": "GBP" }, "averageApplied": true, "insuredProportionBasisPoints": 6666, "shortfall": { "minor": 33333, "currency": "GBP" } } }, { "name": "no loss pays nothing", "args": [ { "minor": 0, "currency": "GBP" }, { "minor": 15000000, "currency": "GBP" }, { "minor": 20000000, "currency": "GBP" }, 10000, "half-up" ], "expect": { "payout": { "minor": 0, "currency": "GBP" }, "averageApplied": true, "insuredProportionBasisPoints": 7500, "shortfall": { "minor": 0, "currency": "GBP" } } }, { "name": "nothing insured pays nothing", "args": [ { "minor": 4000000, "currency": "GBP" }, { "minor": 0, "currency": "GBP" }, { "minor": 20000000, "currency": "GBP" }, 10000, "half-up" ], "expect": { "payout": { "minor": 0, "currency": "GBP" }, "averageApplied": true, "insuredProportionBasisPoints": 0, "shortfall": { "minor": 4000000, "currency": "GBP" } } }, { "name": "large values beyond 2^53 when multiplied: 9,000,000.00 of a 12,000,000.00 building insured for 10,000,000.00", "args": [ { "minor": 900000000, "currency": "GBP" }, { "minor": 1000000000, "currency": "GBP" }, { "minor": 1200000000, "currency": "GBP" }, 10000, "half-up" ], "expect": { "payout": { "minor": 750000000, "currency": "GBP" }, "averageApplied": true, "insuredProportionBasisPoints": 8333, "shortfall": { "minor": 150000000, "currency": "GBP" } } }, { "name": "a loss above the value at risk is refused", "args": [ { "minor": 300, "currency": "GBP" }, { "minor": 100, "currency": "GBP" }, { "minor": 200, "currency": "GBP" }, 10000, "half-up" ], "expectError": "loss must not exceed the value at risk" }, { "name": "a zero value at risk is refused", "args": [ { "minor": 0, "currency": "GBP" }, { "minor": 100, "currency": "GBP" }, { "minor": 0, "currency": "GBP" }, 10000, "half-up" ], "expectError": "valueAtRisk must be more than zero" }, { "name": "a negative sum insured is refused", "args": [ { "minor": 100, "currency": "GBP" }, { "minor": -1, "currency": "GBP" }, { "minor": 200, "currency": "GBP" }, 10000, "half-up" ], "expectError": "sumInsured must not be negative" }, { "name": "a negative loss is refused", "args": [ { "minor": -100, "currency": "GBP" }, { "minor": 100, "currency": "GBP" }, { "minor": 200, "currency": "GBP" }, 10000, "half-up" ], "expectError": "loss must not be negative" }, { "name": "a condition of 0 is refused", "args": [ { "minor": 100, "currency": "GBP" }, { "minor": 100, "currency": "GBP" }, { "minor": 200, "currency": "GBP" }, 0, "half-up" ], "expectError": "conditionBasisPoints must be from 1 to 10000" }, { "name": "a condition above 100% is refused", "args": [ { "minor": 100, "currency": "GBP" }, { "minor": 100, "currency": "GBP" }, { "minor": 200, "currency": "GBP" }, 10001, "half-up" ], "expectError": "conditionBasisPoints must be from 1 to 10000" }, { "name": "a fractional condition is refused", "args": [ { "minor": 100, "currency": "GBP" }, { "minor": 100, "currency": "GBP" }, { "minor": 200, "currency": "GBP" }, 7500.5, "half-up" ], "expectError": "conditionBasisPoints must be from 1 to 10000" }, { "name": "a sum insured in another currency is refused", "args": [ { "minor": 100, "currency": "GBP" }, { "minor": 100, "currency": "EUR" }, { "minor": 200, "currency": "GBP" }, 10000, "half-up" ], "expectError": "currency mismatch" } ]