{
  "$schema": "../cases.schema.json",
  "format": 1,
  "domain": "number",
  "title": {
    "en": "Numbers in words",
    "pt-BR": "Números por extenso"
  },
  "functions": [
    {
      "id": "number.convertToWords",
      "level": "extended",
      "summary": "Formats an integer as its Brazilian Portuguese cardinal number words (\"por extenso\").",
      "description": "Writes an integer in Brazilian Portuguese cardinal words (\"por extenso\"): for example, 1235 is \"mil duzentos e trinta e cinco\".\n\n- Accepts integers from -999 999 999 999 999 to 999 999 999 999 999. The function truncates a non-integer toward zero and puts \"menos\" before a negative number.\n- `options.gender` (`\"masculine\"` by default, or `\"feminine\"`) agrees \"um/uma\", \"dois/duas\" and the hundreds (\"duzentos/duzentas\") with the noun the number qualifies.\n- The last group takes an \"e\" before it only when it is below 100 or a round hundred: 1200 is \"mil e duzentos\" and 1100 is \"mil e cem\", while 1235 is \"mil duzentos e trinta e cinco\" and 1101 is \"mil cento e um\".\n- Returns an empty string for a value outside that range, not finite, or not a number.\n- Zero is \"zero\", and so is any value that truncates to 0 (`-0.5`, never \"menos zero\"). The result is always lower case.\n- With `\"feminine\"`, only the thousands group and the last group change (2000 is \"duas mil\", 21 is \"vinte e uma\"). The multiplier of \"milhão\", \"bilhão\" and \"trilhão\" stays masculine (2 000 000 is \"dois milhões\").",
      "params": [
        {
          "name": "value",
          "type": "number"
        },
        {
          "name": "options",
          "type": "ConvertNumberToWordsOptions",
          "optional": true
        }
      ],
      "returns": "string",
      "cases": [
        {
          "id": "number.convertToWords#[0]",
          "args": [
            0
          ],
          "expect": {
            "returns": "zero"
          }
        },
        {
          "id": "number.convertToWords#[1]",
          "args": [
            1
          ],
          "expect": {
            "returns": "um"
          }
        },
        {
          "id": "number.convertToWords#[3]",
          "args": [
            3
          ],
          "expect": {
            "returns": "três"
          }
        },
        {
          "id": "number.convertToWords#[100]",
          "args": [
            100
          ],
          "expect": {
            "returns": "cem"
          }
        },
        {
          "id": "number.convertToWords#[101]",
          "args": [
            101
          ],
          "expect": {
            "returns": "cento e um"
          }
        },
        {
          "id": "number.convertToWords#[123]",
          "args": [
            123
          ],
          "expect": {
            "returns": "cento e vinte e três"
          }
        },
        {
          "id": "number.convertToWords#[1000]",
          "args": [
            1000
          ],
          "expect": {
            "returns": "mil"
          }
        },
        {
          "id": "number.convertToWords#[1000000]",
          "args": [
            1000000
          ],
          "expect": {
            "returns": "um milhão"
          }
        },
        {
          "id": "number.convertToWords#negative",
          "args": [
            -3
          ],
          "expect": {
            "returns": "menos três"
          }
        },
        {
          "id": "number.convertToWords#truncates-fraction",
          "args": [
            12.9
          ],
          "expect": {
            "returns": "doze"
          },
          "note": "the fractional part is dropped; asserted by the reference (JS) unit tests"
        },
        {
          "id": "number.convertToWords#[-12.9]",
          "args": [
            -12.9
          ],
          "expect": {
            "returns": "menos doze"
          },
          "note": "JavaScript's own test: non-integer values should truncate toward zero before converting"
        },
        {
          "id": "number.convertToWords#[1001]",
          "args": [
            1001
          ],
          "expect": {
            "returns": "mil e um"
          },
          "note": "JavaScript docs example"
        },
        {
          "id": "number.convertToWords#[2000000]",
          "args": [
            2000000
          ],
          "expect": {
            "returns": "dois milhões"
          },
          "note": "JavaScript docs example"
        },
        {
          "id": "number.convertToWords#[-42]",
          "args": [
            -42
          ],
          "expect": {
            "returns": "menos quarenta e dois"
          },
          "note": "JavaScript docs example"
        },
        {
          "id": "number.convertToWords#feminine-two",
          "args": [
            2,
            {
              "gender": "feminine"
            }
          ],
          "expect": {
            "returns": "duas"
          },
          "note": "JavaScript docs example"
        },
        {
          "id": "number.convertToWords#[1200]",
          "args": [
            1200
          ],
          "expect": {
            "returns": "mil e duzentos"
          },
          "note": "JavaScript docs: the last group takes an e only when below 100 or a round hundred"
        },
        {
          "id": "number.convertToWords#[1100]",
          "args": [
            1100
          ],
          "expect": {
            "returns": "mil e cem"
          },
          "note": "JavaScript docs: the last group takes an e only when below 100 or a round hundred"
        },
        {
          "id": "number.convertToWords#[1235]",
          "args": [
            1235
          ],
          "expect": {
            "returns": "mil duzentos e trinta e cinco"
          },
          "note": "JavaScript docs example"
        },
        {
          "id": "number.convertToWords#[1101]",
          "args": [
            1101
          ],
          "expect": {
            "returns": "mil cento e um"
          },
          "note": "JavaScript docs: the last group takes an e only when below 100 or a round hundred"
        },
        {
          "id": "number.convertToWords#feminine-hundreds",
          "args": [
            200,
            {
              "gender": "feminine"
            }
          ],
          "expect": {
            "returns": "duzentas"
          },
          "note": "hundreds agree with the gender"
        },
        {
          "id": "number.convertToWords#feminine-one",
          "args": [
            1,
            {
              "gender": "feminine"
            }
          ],
          "expect": {
            "returns": "uma"
          },
          "note": "feminine one"
        },
        {
          "id": "number.convertToWords#maximum",
          "args": [
            999999999999999
          ],
          "expect": {
            "returns": "novecentos e noventa e nove trilhões novecentos e noventa e nove bilhões novecentos e noventa e nove milhões novecentos e noventa e nove mil novecentos e noventa e nove"
          },
          "note": "JavaScript's own test: should convert the maximum supported value (999999999999999, 999 trillion)"
        },
        {
          "id": "number.convertToWords#above-maximum",
          "args": [
            1000000000000000
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: should return '' above the maximum supported value"
        },
        {
          "id": "number.convertToWords#below-minimum",
          "args": [
            -1000000000000000
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: should return '' below the negative of the maximum supported value"
        },
        {
          "id": "number.convertToWords#null",
          "args": [
            null
          ],
          "expect": {
            "returns": ""
          },
          "note": "not a finite number"
        }
      ]
    }
  ]
}
