Revision: 7308 Author: [email protected] Date: Mon Dec 14 08:34:56 2009 Log: Add BigDecimal/BigInteger tests (some commented out until the functionality is actually implemented).
http://code.google.com/p/google-web-toolkit/source/detail?r=7308 Modified: /changes/jat/bigdecimal/user/test/com/google/gwt/i18n/client/NumberFormat_en_Test.java ======================================= --- /changes/jat/bigdecimal/user/test/com/google/gwt/i18n/client/NumberFormat_en_Test.java Wed Nov 18 13:48:28 2009 +++ /changes/jat/bigdecimal/user/test/com/google/gwt/i18n/client/NumberFormat_en_Test.java Mon Dec 14 08:34:56 2009 @@ -18,6 +18,9 @@ import com.google.gwt.junit.client.GWTTestCase; +import java.math.BigDecimal; +import java.math.BigInteger; + /** * GWT JUnit tests must extend GWTTestCase. */ @@ -63,6 +66,28 @@ str = NumberFormat.getFormat("#,##0.000").format(112589990684262.5); assertEquals("112,589,990,684,262.500", str); } + + public void testBigDecimal() { + BigDecimal decVal = new BigDecimal("1000000000000000000000000"); + String str = NumberFormat.getFormat("0.000").format(decVal); + assertEquals("1000000000000000000000000.000", str); + + // TODO(jat): enable when actually supported +// decVal = decVal.add(new BigDecimal(".1")); +// str = NumberFormat.getFormat("#,##0.000").format(decVal); +// assertEquals("1,000,000,000,000,000,000,000,000.100", str); + } + + public void testBigInteger() { + BigInteger intVal = new BigInteger("1000000000000000000000000"); + String str = NumberFormat.getFormat("#,##0").format(intVal); + assertEquals("1,000,000,000,000,000,000,000,000", str); + + // TODO(jat): enable when actually supported +// intVal = intVal.add(BigInteger.ONE); +// str = NumberFormat.getFormat("#,##0").format(intVal); +// assertEquals("1,000,000,000,000,000,000,000,001", str); + } public void testCurrency() { String str; @@ -288,7 +313,7 @@ public void testParseNotANumber() { try { - double d = NumberFormat.getDecimalFormat().parse("blue"); + NumberFormat.getDecimalFormat().parse("blue"); fail("Expected a NumberFormatException"); } catch (NumberFormatException e) { assertEquals("blue", e.getMessage()); -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
