[ { "name": "24 ha at 200 L/ha and 2.5 L/ha with a 1000 L tank: four full tanks and 800 L", "args": [ 24, 200, 2.5, "litres", 1000 ], "expect": { "tankFills": 5, "fullTanks": 4, "fullTank": { "areaHectares": 5, "sprayLitres": 1000, "product": 12.5, "waterLitres": 987.5 }, "partialTank": { "areaHectares": 4, "sprayLitres": 800, "product": 10, "waterLitres": 790 }, "totalSprayLitres": 4800, "totalProduct": 60 } }, { "name": "a job of exactly two tanks has no part tank", "args": [ 10, 100, 1, "litres", 500 ], "expect": { "tankFills": 2, "fullTanks": 2, "fullTank": { "areaHectares": 5, "sprayLitres": 500, "product": 5, "waterLitres": 495 }, "partialTank": null, "totalSprayLitres": 1000, "totalProduct": 10 } }, { "name": "less than one tank: the full-tank recipe is still given", "args": [ 2, 200, 1.5, "litres", 1000 ], "expect": { "tankFills": 1, "fullTanks": 0, "fullTank": { "areaHectares": 5, "sprayLitres": 1000, "product": 7.5, "waterLitres": 992.5 }, "partialTank": { "areaHectares": 2, "sprayLitres": 400, "product": 3, "waterLitres": 397 }, "totalSprayLitres": 400, "totalProduct": 3 } }, { "name": "a solid product in kg does not displace water", "args": [ 12, 150, 0.25, "kilograms", 600 ], "expect": { "tankFills": 3, "fullTanks": 3, "fullTank": { "areaHectares": 4, "sprayLitres": 600, "product": 1, "waterLitres": 600 }, "partialTank": null, "totalSprayLitres": 1800, "totalProduct": 3 } }, { "name": "awkward numbers: the full and part tank products add up to the job's", "args": [ 7.3, 120, 0.67, "litres", 800 ], "expect": { "tankFills": 2, "fullTanks": 1, "fullTank": { "areaHectares": 6.6667, "sprayLitres": 800, "product": 4.467, "waterLitres": 795.533 }, "partialTank": { "areaHectares": 0.6333, "sprayLitres": 76, "product": 0.424, "waterLitres": 75.576 }, "totalSprayLitres": 876, "totalProduct": 4.891 } }, { "name": "129.2 ha at 250 L/ha is exactly 19 tanks of 1700 L, not 18 and a sliver", "args": [ 129.2, 250, 1, "litres", 1700 ], "expect": { "tankFills": 19, "fullTanks": 19, "fullTank": { "areaHectares": 6.8, "sprayLitres": 1700, "product": 6.8, "waterLitres": 1693.2 }, "partialTank": null, "totalSprayLitres": 32300, "totalProduct": 129.2 } }, { "name": "water only (no product)", "args": [ 5, 100, 0, "litres", 300 ], "expect": { "tankFills": 2, "fullTanks": 1, "fullTank": { "areaHectares": 3, "sprayLitres": 300, "product": 0, "waterLitres": 300 }, "partialTank": { "areaHectares": 2, "sprayLitres": 200, "product": 0, "waterLitres": 200 }, "totalSprayLitres": 500, "totalProduct": 0 } }, { "name": "the smallest area, one square metre", "args": [ 0.0001, 200, 1, "litres", 1000 ], "expect": { "tankFills": 1, "fullTanks": 0, "fullTank": { "areaHectares": 5, "sprayLitres": 1000, "product": 5, "waterLitres": 995 }, "partialTank": { "areaHectares": 0.0001, "sprayLitres": 0.02, "product": 0, "waterLitres": 0.02 }, "totalSprayLitres": 0.02, "totalProduct": 0 } }, { "name": "zero area is an error", "args": [ 0, 200, 1, "litres", 1000 ], "expectError": "areaHectares must be at least 0.0001 hectares" }, { "name": "a negative dose is an error", "args": [ 10, 200, -1, "litres", 1000 ], "expectError": "productDosePerHectare must be a finite number from 0 to 100" }, { "name": "zero water volume is an error", "args": [ 10, 0, 1, "litres", 1000 ], "expectError": "waterVolumeLitresPerHectare must be at least 0.1 litres" }, { "name": "zero tank is an error", "args": [ 10, 200, 1, "litres", 0 ], "expectError": "tankLitres must be at least 0.1 litres" }, { "name": "a liquid dose as large as the water volume is an error", "args": [ 10, 50, 50, "litres", 1000 ], "expectError": "productDosePerHectare must be less than waterVolumeLitresPerHectare for a liquid product" }, { "name": "an unknown dose unit is an error", "args": [ 10, 200, 1, "gallons", 1000 ], "expectError": "unknown doseUnit \"gallons\"" } ]