@Test public void testNameOfDigit() { assertEquals("zero", ntn.nameOfDigit(0)); assertEquals("one", ntn.nameOfDigit(1)); assertEquals("two", ntn.nameOfDigit(2)); assertEquals("three", ntn.nameOfDigit(3)); assertEquals("four", ntn.nameOfDigit(4)); assertEquals("five", ntn.nameOfDigit(5)); assertEquals("six", ntn.nameOfDigit(6)); assertEquals("seven", ntn.nameOfDigit(7)); assertEquals("eight", ntn.nameOfDigit(8)); assertEquals("nine", ntn.nameOfDigit(9)); }
@Test public void testNameOfTensDigit() { assertEquals("ten", ntn.nameOfTensDigit(1)); assertEquals("twenty", ntn.nameOfTensDigit(2)); assertEquals("thirty", ntn.nameOfTensDigit(3)); assertEquals("forty", ntn.nameOfTensDigit(4)); assertEquals("fifty", ntn.nameOfTensDigit(5)); assertEquals("sixty", ntn.nameOfTensDigit(6)); assertEquals("seventy", ntn.nameOfTensDigit(7)); assertEquals("eighty", ntn.nameOfTensDigit(8)); assertEquals("ninety", ntn.nameOfTensDigit(9)); }
@Test public void testNameOfTeens() { assertEquals("ten", ntn.nameOfTeens(10)); assertEquals("eleven", ntn.nameOfTeens(11)); assertEquals("twelve", ntn.nameOfTeens(12)); assertEquals("thirteen", ntn.nameOfTeens(13)); assertEquals("fourteen", ntn.nameOfTeens(14)); assertEquals("fifteen", ntn.nameOfTeens(15)); assertEquals("sixteen", ntn.nameOfTeens(16)); assertEquals("seventeen", ntn.nameOfTeens(17)); assertEquals("eighteen", ntn.nameOfTeens(18)); assertEquals("nineteen", ntn.nameOfTeens(19)); }
@Test public void testNameOf() { assertEquals("twenty one", ntn.nameOf(21)); assertEquals("one hundred one", ntn.nameOf(101)); assertEquals("nine thousand two hundred one", ntn.nameOf(9201)); assertEquals("one hundred eleven", ntn.nameOf(111)); assertEquals("six thousand two", ntn.nameOf(6002)); assertEquals("five thousand thirteen", ntn.nameOf(5013)); assertEquals("four thousand three hundred twenty one", ntn.nameOf(4321)); // out of range numbers assertEquals("44321", ntn.nameOf(44321)); // more assertEquals("one", ntn.nameOf(1)); assertEquals("one", ntn.nameOf(1)); assertEquals("ninety nine", ntn.nameOf(99)); assertEquals("one hundred", ntn.nameOf(100)); assertEquals("one thousand", ntn.nameOf(1000)); assertEquals("one thousand ten", ntn.nameOf(1010)); assertEquals("one thousand eleven", ntn.nameOf(1011)); // TODO: delete these lines assertEquals("zero", ntn.nameOf(0)); assertEquals("ten", ntn.nameOf(10)); assertEquals("two hundred", ntn.nameOf(200)); assertEquals("three thousand three hundred thirty three", ntn.nameOf(3333)); assertEquals("one hundred one", ntn.nameOf(101)); assertEquals("one hundred ten", ntn.nameOf(110)); assertEquals("nine hundred ninety nine", ntn.nameOf(999)); assertEquals("one thousand", ntn.nameOf(1000)); assertEquals("two thousand eight", ntn.nameOf(2008)); assertEquals("two thousand thirty", ntn.nameOf(2030)); assertEquals("two thousand eleven", ntn.nameOf(2011)); assertEquals("two thousand two hundred one", ntn.nameOf(2201)); assertEquals("two thousand two hundred", ntn.nameOf(2200)); assertEquals("two thousand one hundred eleven", ntn.nameOf(2111)); assertEquals("nine thousand nine hundred ninety nine", ntn.nameOf(9999)); }
@Test public void testNumbersToWords() { assertEquals("Give me a high five", ntn.numbersToWords("Give me a high 5")); assertEquals("I'm sixteen years old.", ntn.numbersToWords("I'm 16 years old.")); assertEquals("seven hundred thirteenpeople died.", ntn.numbersToWords("713people died.")); assertEquals( "987737/eighty eight !=one thousand one hundred twenty two", ntn.numbersToWords("987737/88 !=1122")); assertEquals( "Today is two thousand eleven November eleventh.", ntn.numbersToWords("Today is 2011 November 11th.")); assertEquals( "Avogadro's Constant = six.two thousand two hundred fourteen x ten ^ twenty three mol -one", ntn.numbersToWords("Avogadro's Constant = 6.02214 x 10 ^ 23 mol -1")); // more assertEquals("Pi is roughly three.14159", ntn.numbersToWords("Pi is roughly 3.14159")); assertEquals("nine.ninety nine", ntn.numbersToWords("9.99")); // preceding zeros assertEquals("one hundred one", ntn.numbersToWords("0101")); assertEquals("one hundred eleven", ntn.numbersToWords("0111")); assertEquals("twenty three", ntn.numbersToWords("0023")); assertEquals("twenty three", ntn.numbersToWords("023")); assertEquals("ten", ntn.numbersToWords("0010")); assertEquals("ten", ntn.numbersToWords("010")); assertEquals("fifteen", ntn.numbersToWords("0015")); assertEquals("fifteen", ntn.numbersToWords("015")); assertEquals("one", ntn.numbersToWords("0001")); assertEquals("one", ntn.numbersToWords("001")); assertEquals("one", ntn.numbersToWords("01")); assertEquals("zero", ntn.numbersToWords("0000")); assertEquals("zero", ntn.numbersToWords("000")); assertEquals("zero", ntn.numbersToWords("00")); // TODO delete these lines assertEquals("Hello world!", ntn.numbersToWords("Hello world!")); assertEquals("Heone hundred ten wzeroroned!", ntn.numbersToWords("He110 w0r1d!")); assertEquals("The time is now three:fifteen.", ntn.numbersToWords("The time is now 3:15.")); assertEquals( "Pai = three.one thousand four hundred fifteen", ntn.numbersToWords("Pai = 3.1415")); assertEquals( "Tninehe quninety eightick brotwenty eightwn fthree hundred seventy eightox jueight hundred seventy sixmps oone thousandver the lathirty threezy doneotwog.", ntn.numbersToWords("T9he qu98ick bro28wn f378ox ju876mps o1000ver the la33zy d1o2g.")); assertEquals("nine thousand nine hundred ninety nine", ntn.numbersToWords("009999")); assertEquals("This is a 10000.", ntn.numbersToWords("This is a 10000.")); }