[ {"name": "a year's costs over 12,000 miles: 50.3p a mile, though the rounded parts add up to 50.4", "args": [{"depreciation": {"minor": 300000, "currency": "GBP"}, "fuel": {"minor": 180000, "currency": "GBP"}, "maintenance": {"minor": 60000, "currency": "GBP"}, "insurance": {"minor": 45000, "currency": "GBP"}, "tax": {"minor": 19000, "currency": "GBP"}}, 12000], "expect": {"totalCost": {"minor": 604000, "currency": "GBP"}, "depreciationTenths": 250, "fuelTenths": 150, "maintenanceTenths": 50, "insuranceTenths": 38, "taxTenths": 16, "totalTenths": 503, "perMile": "50.3"}}, {"name": "one mile: every penny is ten tenths", "args": [{"depreciation": {"minor": 100, "currency": "GBP"}, "fuel": {"minor": 200, "currency": "GBP"}, "maintenance": {"minor": 300, "currency": "GBP"}, "insurance": {"minor": 400, "currency": "GBP"}, "tax": {"minor": 500, "currency": "GBP"}}, 1], "expect": {"totalCost": {"minor": 1500, "currency": "GBP"}, "depreciationTenths": 1000, "fuelTenths": 2000, "maintenanceTenths": 3000, "insuranceTenths": 4000, "taxTenths": 5000, "totalTenths": 15000, "perMile": "1500.0"}}, {"name": "nothing spent is 0.0p a mile", "args": [{"depreciation": {"minor": 0, "currency": "GBP"}, "fuel": {"minor": 0, "currency": "GBP"}, "maintenance": {"minor": 0, "currency": "GBP"}, "insurance": {"minor": 0, "currency": "GBP"}, "tax": {"minor": 0, "currency": "GBP"}}, 5000], "expect": {"totalCost": {"minor": 0, "currency": "GBP"}, "depreciationTenths": 0, "fuelTenths": 0, "maintenanceTenths": 0, "insuranceTenths": 0, "taxTenths": 0, "totalTenths": 0, "perMile": "0.0"}}, {"name": "a car that gained value has negative depreciation", "args": [{"depreciation": {"minor": -12000, "currency": "GBP"}, "fuel": {"minor": 0, "currency": "GBP"}, "maintenance": {"minor": 0, "currency": "GBP"}, "insurance": {"minor": 0, "currency": "GBP"}, "tax": {"minor": 0, "currency": "GBP"}}, 10000], "expect": {"totalCost": {"minor": -12000, "currency": "GBP"}, "depreciationTenths": -12, "fuelTenths": 0, "maintenanceTenths": 0, "insuranceTenths": 0, "taxTenths": 0, "totalTenths": -12, "perMile": "-1.2"}}, {"name": "half a tenth rounds up", "args": [{"depreciation": {"minor": 5, "currency": "GBP"}, "fuel": {"minor": 0, "currency": "GBP"}, "maintenance": {"minor": 0, "currency": "GBP"}, "insurance": {"minor": 0, "currency": "GBP"}, "tax": {"minor": 0, "currency": "GBP"}}, 100], "expect": {"totalCost": {"minor": 5, "currency": "GBP"}, "depreciationTenths": 1, "fuelTenths": 0, "maintenanceTenths": 0, "insuranceTenths": 0, "taxTenths": 0, "totalTenths": 1, "perMile": "0.1"}}, {"name": "a negative half a tenth rounds away from zero", "args": [{"depreciation": {"minor": -5, "currency": "GBP"}, "fuel": {"minor": 0, "currency": "GBP"}, "maintenance": {"minor": 0, "currency": "GBP"}, "insurance": {"minor": 0, "currency": "GBP"}, "tax": {"minor": 0, "currency": "GBP"}}, 100], "expect": {"totalCost": {"minor": -5, "currency": "GBP"}, "depreciationTenths": -1, "fuelTenths": 0, "maintenanceTenths": 0, "insuranceTenths": 0, "taxTenths": 0, "totalTenths": -1, "perMile": "-0.1"}}, {"name": "just under half a tenth rounds down", "args": [{"depreciation": {"minor": 0, "currency": "GBP"}, "fuel": {"minor": 49, "currency": "GBP"}, "maintenance": {"minor": 0, "currency": "GBP"}, "insurance": {"minor": 0, "currency": "GBP"}, "tax": {"minor": 0, "currency": "GBP"}}, 1000], "expect": {"totalCost": {"minor": 49, "currency": "GBP"}, "depreciationTenths": 0, "fuelTenths": 0, "maintenanceTenths": 0, "insuranceTenths": 0, "taxTenths": 0, "totalTenths": 0, "perMile": "0.0"}}, {"name": "a van over 30,000 miles in euro cents", "args": [{"depreciation": {"minor": 900000, "currency": "EUR"}, "fuel": {"minor": 1350000, "currency": "EUR"}, "maintenance": {"minor": 210000, "currency": "EUR"}, "insurance": {"minor": 120000, "currency": "EUR"}, "tax": {"minor": 30000, "currency": "EUR"}}, 30000], "expect": {"totalCost": {"minor": 2610000, "currency": "EUR"}, "depreciationTenths": 300, "fuelTenths": 450, "maintenanceTenths": 70, "insuranceTenths": 40, "taxTenths": 10, "totalTenths": 870, "perMile": "87.0"}}, {"name": "three-mile trip: 1 penny of tax is 3.3 tenths, rounded to 3", "args": [{"depreciation": {"minor": 0, "currency": "GBP"}, "fuel": {"minor": 0, "currency": "GBP"}, "maintenance": {"minor": 0, "currency": "GBP"}, "insurance": {"minor": 0, "currency": "GBP"}, "tax": {"minor": 1, "currency": "GBP"}}, 3], "expect": {"totalCost": {"minor": 1, "currency": "GBP"}, "depreciationTenths": 0, "fuelTenths": 0, "maintenanceTenths": 0, "insuranceTenths": 0, "taxTenths": 3, "totalTenths": 3, "perMile": "0.3"}}, {"name": "zero miles is an error", "args": [{"depreciation": {"minor": 100, "currency": "GBP"}, "fuel": {"minor": 0, "currency": "GBP"}, "maintenance": {"minor": 0, "currency": "GBP"}, "insurance": {"minor": 0, "currency": "GBP"}, "tax": {"minor": 0, "currency": "GBP"}}, 0], "expectError": "miles must be a whole number above zero"}, {"name": "negative miles is an error", "args": [{"depreciation": {"minor": 100, "currency": "GBP"}, "fuel": {"minor": 0, "currency": "GBP"}, "maintenance": {"minor": 0, "currency": "GBP"}, "insurance": {"minor": 0, "currency": "GBP"}, "tax": {"minor": 0, "currency": "GBP"}}, -10], "expectError": "miles must be a whole number above zero"}, {"name": "fractional miles is an error", "args": [{"depreciation": {"minor": 100, "currency": "GBP"}, "fuel": {"minor": 0, "currency": "GBP"}, "maintenance": {"minor": 0, "currency": "GBP"}, "insurance": {"minor": 0, "currency": "GBP"}, "tax": {"minor": 0, "currency": "GBP"}}, 10.5], "expectError": "miles must be a whole number above zero"}, {"name": "mixed currencies are refused", "args": [{"depreciation": {"minor": 100, "currency": "GBP"}, "fuel": {"minor": 100, "currency": "EUR"}, "maintenance": {"minor": 0, "currency": "GBP"}, "insurance": {"minor": 0, "currency": "GBP"}, "tax": {"minor": 0, "currency": "GBP"}}, 100], "expectError": "currency mismatch"} ]