[
{
"name": "85 t of wheat from 10 ha is 8.5 t/ha and 3.44 t/acre",
"args": [
"85",
"10",
"ha",
2
],
"expect": {
"perHectare": "8.5",
"perAcre": "3.44",
"hectares": "10",
"acres": "24.71"
}
},
{
"name": "250 t from 100 acres is 2.5 t/acre and 6.18 t/ha",
"args": [
"250",
"100",
"acre",
2
],
"expect": {
"perHectare": "6.18",
"perAcre": "2.5",
"hectares": "40.47",
"acres": "100"
}
},
{
"name": "a fractional harvest from a fractional area, to three places",
"args": [
"12.345",
"1.5",
"ha",
3
],
"expect": {
"perHectare": "8.23",
"perAcre": "3.331",
"hectares": "1.5",
"acres": "3.707"
}
},
{
"name": "a trial plot in square metres",
"args": [
"500",
"2500",
"m2",
2
],
"expect": {
"perHectare": "2000",
"perAcre": "809.37",
"hectares": "0.25",
"acres": "0.62"
}
},
{
"name": "1.005 t/ha rounds half up to 1.01, where a float says 1.00",
"args": [
"1.005",
"1",
"ha",
2
],
"expect": {
"perHectare": "1.01",
"perAcre": "0.41",
"hectares": "1",
"acres": "2.47"
}
},
{
"name": "nothing harvested is zero per hectare",
"args": [
"0",
"3.2",
"ha",
2
],
"expect": {
"perHectare": "0",
"perAcre": "0",
"hectares": "3.2",
"acres": "7.91"
}
},
{
"name": "zero decimals rounds to whole numbers, half up",
"args": [
"7",
"3",
"ha",
0
],
"expect": {
"perHectare": "2",
"perAcre": "1",
"hectares": "3",
"acres": "7"
}
},
{
"name": "a garden plot in square feet: 9.7 kg from 30.25 ft² is exactly 13968 kg/acre",
"args": [
"9.7",
"30.25",
"ft2",
4
],
"expect": {
"perHectare": "34515.6797",
"perAcre": "13968",
"hectares": "0.0003",
"acres": "0.0007"
}
},
{
"name": "trailing zeros are trimmed and leading zeros accepted",
"args": [
"085.000",
"010",
"ha",
3
],
"expect": {
"perHectare": "8.5",
"perAcre": "3.44",
"hectares": "10",
"acres": "24.711"
}
},
{
"name": "zero area is an error",
"args": [
"85",
"0",
"ha",
2
],
"expectError": "area must be greater than zero"
},
{
"name": "a unit that is not an area is an error",
"args": [
"85",
"10",
"kg",
2
],
"expectError": "cannot convert kg (mass) to m2 (area)"
},
{
"name": "an unknown unit is an error",
"args": [
"85",
"10",
"hectare",
2
],
"expectError": "unknown unit \"hectare\""
},
{
"name": "a negative quantity is an error",
"args": [
"-5",
"10",
"ha",
2
],
"expectError": "quantity must be plain non-negative decimal text"
},
{
"name": "exponent notation is an error",
"args": [
"1e3",
"10",
"ha",
2
],
"expectError": "quantity must be plain non-negative decimal text"
},
{
"name": "more than 12 significant digits is an error",
"args": [
"1234567890123",
"10",
"ha",
2
],
"expectError": "has too many digits"
},
{
"name": "more than 6 decimal places is an error",
"args": [
"85",
"10.1234567",
"ha",
2
],
"expectError": "has too many digits"
},
{
"name": "decimals above 12 is an error",
"args": [
"85",
"10",
"ha",
13
],
"expectError": "decimals must be a whole number from 0 to 12"
},
{
"name": "a trailing newline after quantity is not plain decimal text",
"args": [
"12.5\n",
"10",
"ha",
2
],
"expectError": "quantity must be plain non-negative decimal text"
},
{
"name": "a trailing newline after area is not plain decimal text",
"args": [
"5",
"10\n",
"ha",
2
],
"expectError": "area must be plain non-negative decimal text"
}
]