Functional Weave
Code in Rust

text.number-to-words@1.0.0

vectors.json

2,163 bytes · view raw

[
  { "name": "the cheque example", "args": [{ "minor": 123456, "currency": "GBP" }], "expect": "one thousand two hundred and thirty-four pounds and fifty-six pence" },
  { "name": "one pound is singular", "args": [{ "minor": 100, "currency": "GBP" }], "expect": "one pound" },
  { "name": "one penny is singular, and not one pence", "args": [{ "minor": 101, "currency": "GBP" }], "expect": "one pound and one penny" },
  { "name": "a single penny on its own", "args": [{ "minor": 1, "currency": "GBP" }], "expect": "one penny" },
  { "name": "under a pound leaves the pounds out", "args": [{ "minor": 50, "currency": "GBP" }], "expect": "fifty pence" },
  { "name": "a whole amount leaves the pence out", "args": [{ "minor": 1000, "currency": "GBP" }], "expect": "ten pounds" },
  { "name": "zero is zero pounds", "args": [{ "minor": 0, "currency": "GBP" }], "expect": "zero pounds" },
  { "name": "the British and inside the pounds", "args": [{ "minor": 10100, "currency": "GBP" }], "expect": "one hundred and one pounds" },
  { "name": "a hundred thousand pounds", "args": [{ "minor": 10000000, "currency": "GBP" }], "expect": "one hundred thousand pounds" },
  { "name": "a million pounds and a penny", "args": [{ "minor": 100000001, "currency": "GBP" }], "expect": "one million pounds and one penny" },
  { "name": "a credit note reads as minus", "args": [{ "minor": -2599, "currency": "GBP" }], "expect": "minus twenty-five pounds and ninety-nine pence" },
  { "name": "minus a single penny", "args": [{ "minor": -1, "currency": "GBP" }], "expect": "minus one penny" },
  { "name": "one euro and fifty cents", "args": [{ "minor": 150, "currency": "EUR" }], "expect": "one euro and fifty cents" },
  { "name": "euros are plural and one cent singular", "args": [{ "minor": 250001, "currency": "EUR" }], "expect": "two thousand five hundred euros and one cent" },
  { "name": "US dollars", "args": [{ "minor": 199, "currency": "USD" }], "expect": "one dollar and ninety-nine cents" },
  { "name": "a currency without listed unit names is an error, not a guess", "args": [{ "minor": 100, "currency": "JPY" }], "expectError": "no words for currency \"JPY\"" }
]