[ { "name": "100 cubic metres at 39.5 MJ/m³ is 1122.063 kWh", "args": [100, "cubic-metres", 39500], "expect": { "cubicMetresHundredths": 10000, "wattHours": 1122063 } }, { "name": "one cubic metre at 39.5 MJ/m³ rounds 11220.633 Wh to 11221", "args": [1, "cubic-metres", 39500], "expect": { "cubicMetresHundredths": 100, "wattHours": 11221 } }, { "name": "one cubic metre at the 38 MJ/m³ floor", "args": [1, "cubic-metres", 38000], "expect": { "cubicMetresHundredths": 100, "wattHours": 10795 } }, { "name": "100 units on an imperial meter is 283 m³, not 283.17 (the billing factor is 2.83)", "args": [100, "hundreds-cubic-feet", 39500], "expect": { "cubicMetresHundredths": 28300, "wattHours": 3175439 } }, { "name": "20 imperial units at 39.0 MJ/m³", "args": [20, "hundreds-cubic-feet", 39000], "expect": { "cubicMetresHundredths": 5660, "wattHours": 627049 } }, { "name": "a calorific value to three decimals, 39.472 MJ/m³", "args": [250, "cubic-metres", 39472], "expect": { "cubicMetresHundredths": 25000, "wattHours": 2803170 } }, { "name": "no gas used is no energy", "args": [0, "cubic-metres", 39500], "expect": { "cubicMetresHundredths": 0, "wattHours": 0 } }, { "name": "an exact half watt-hour rounds up", "args": [1, "cubic-metres", 7500], "expect": { "cubicMetresHundredths": 100, "wattHours": 2131 } }, { "name": "a million cubic metres stays exact past 2^53 in the intermediate product", "args": [1000000, "cubic-metres", 40000], "expect": { "cubicMetresHundredths": 100000000, "wattHours": 11362666667 } }, { "name": "a hundred billion imperial units, just under the exact-integer limit", "args": [100000000000, "hundreds-cubic-feet", 39500], "expect": { "cubicMetresHundredths": 28300000000000, "wattHours": 3175439233333333 } }, { "name": "the largest volume allowed at a normal calorific value is too much energy to be exact", "args": [1000000000000, "hundreds-cubic-feet", 39500], "expectError": "gas energy too large to calculate exactly" }, { "name": "a negative volume is refused", "args": [-5, "cubic-metres", 39500], "expectError": "volume must be a whole number of units" }, { "name": "a fractional volume is refused", "args": [10.5, "cubic-metres", 39500], "expectError": "volume must be a whole number of units" }, { "name": "a zero calorific value is refused", "args": [100, "cubic-metres", 0], "expectError": "calorific value must be a whole number of thousandths of a MJ/m³" }, { "name": "a calorific value in MJ rather than thousandths is out of range the other way", "args": [100, "cubic-metres", 100001], "expectError": "calorific value must be a whole number of thousandths of a MJ/m³" }, { "name": "an unknown unit is refused", "args": [100, "litres", 39500], "expectError": "unknown volume unit \"litres\"" } ]