/* * [Test.java] * * Summary: Test out any one of the number-to-words converters. * * Copyright: (c) 1999-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 1999-01-12 initial version */ package com.mindprod.inwords; import com.mindprod.common18.EIO; import java.io.OutputStreamWriter; import java.io.PrintWriter; import static java.lang.System.*; /** * Test out any one of the number-to-words converters. *

* To test Italian for example you would type * java.exe com.mindprod.inwords.Italian *

* In turn, the Italian.main method will invoke this Test class. * * @author Roedy Green, Canadian Mind Products * @version 1.0 1999-01-12 initial version * @since 1999-01-12 */ @SuppressWarnings( { "WeakerAccess" } ) public final class Test { /** * display a representative sampling of results. * * @param language delegate - which language to display */ public static void test( ToWords language ) { test( language, new DecimalCommas() ); } /** * display a representative sampling of results. * * @param language delegate - which language to display * @param numeric delegate - which "language" to use to display corresponding number e.g. DecimalCommas or * DecimalDots. */ public static void test( ToWords language, ToWords numeric ) { OutputStreamWriter eosw = new OutputStreamWriter( out, EIO.UTF8 ); // DO NOT CHANGE THIS TO getPrintWriter PrintWriter prw = new PrintWriter( eosw, false ); prw.println(); // ranges over which to conduct tests long[][] range = { { -1, 135 }, { 199, 235 }, { 299, 302 }, { 399, 402 }, { 499, 502 }, { 599, 602 }, { 699, 702 }, { 799, 802 }, { 899, 902 }, { 999, 1035 }, { 1099, 1135 }, { 1199, 1235 }, { 1969, 2002 }, { 2099, 2102 }, { 2199, 2202 }, { 2999, 3002 }, { 3099, 3102 }, { 3199, 3202 }, { 3999, 4002 }, { 4099, 4102 }, { 4199, 4202 }, { 4999, 5002 }, { 5099, 5102 }, { 5199, 5202 }, { 5999, 6002 }, { 6099, 6102 }, { 6199, 6202 }, { 6999, 7002 }, { 7099, 7102 }, { 7199, 7202 }, { 7999, 8002 }, { 8099, 8102 }, { 8199, 8202 }, { 8999, 9002 }, { 9099, 9102 }, { 9199, 9202 }, { 9999, 10035 }, { 21199, 21235 }, { 99999, 100001 }, { 999999, 1000001 }, { 9999999L, 10000001L }, { 20999999L, 21000001L }, { 99999999L, 100000002L }, { 100001999L, 100002002L }, { 100031999L, 100032002L }, { 100100999L, 100101002L }, { 100199999L, 100200002L }, { 100219999L, 100220002L }, { 123456789L, 123456789L }, { 999999999L, 1000000002L }, { 1199999999L, 1200000002L }, { 9999999999L, 10000000002L }, { 99999999999L, 100000000002L }, { 999999999999L, 1000000000002L }, { 9999999999999L, 10000000000002L }, { 99999999999999L, 100000000000002L }, { 999999999999999L, 1000000000000002L }, { 9999999999999999L, 10000000000000002L }, { 99999999999999999L, 100000000000000002L }, { 999999999999999999L, 1000000000000000002L }, { Long.MAX_VALUE - 2, Long.MAX_VALUE - 1 }, { -Long.MAX_VALUE, ( -Long.MAX_VALUE ) + 2 }, { -12345, -12345 }, { -123456, -123456 }, { -1234567, -1234567 }, { -12345678, -12345678 }, { -123456789, -123456789 } }; for ( long[] aRange : range ) { long from = aRange[ 0 ]; long to = aRange[ 1 ]; for ( long i = from; i <= to; i++ ) { // get words form of number String words = language.toWords( i ); if ( words.contains( " " ) ) { prw.println( "\007OOps! double space!" ); } // get decimal form of number String numerics; if ( numeric == null ) { numerics = Long.toString( i ); } else { numerics = numeric.toWords( i ); } prw.println( numerics + " " + words ); } // end for i } // end for r prw.close(); } // end test }