harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r408565 - in /incubator/harmony/enhanced/classlib/trunk/modules/text: make/common/build.xml src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java
Date Mon, 22 May 2006 04:17:39 GMT
Author: smishura
Date: Sun May 21 21:17:36 2006
New Revision: 408565

URL: http://svn.apache.org/viewvc?rev=408565&view=rev
Log:
Apply patch for HARMONY-474 (Bugs in org.apache.harmony.text.tests.java.text.NumberFormatTest)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/build.xml
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/build.xml?rev=408565&r1=408564&r2=408565&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/build.xml Sun May 21
21:17:36 2006
@@ -106,7 +106,6 @@
                     <exclude name="org/apache/harmony/text/tests/java/text/CollatorTest.java"/>
                     <exclude name="org/apache/harmony/text/tests/java/text/DecimalFormatTest.java"/>
                     <exclude name="org/apache/harmony/text/tests/java/text/MessageFormatTest.java"/>
-                    <exclude name="org/apache/harmony/text/tests/java/text/NumberFormatTest.java"/>
                 </fileset>
             </batchtest>
         </junit>

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java?rev=408565&r1=408564&r2=408565&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java
Sun May 21 21:17:36 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,57 +36,57 @@
 
 		pos = new FieldPosition(0);
 		out = format.format(new Long(Long.MAX_VALUE), new StringBuffer(), pos);
-		assertTrue("Wrong result L1: " + out, out.toString().equals(
-				"9,223,372,036,854,775,807"));
+        assertEquals("Wrong result L1: " + out, "9,223,372,036,854,775,807",
+                out.toString());
 
 		pos = new FieldPosition(0);
 		out = format.format(new Long(Long.MIN_VALUE), new StringBuffer(), pos);
-		assertTrue("Wrong result L2: " + out, out.toString().equals(
-				"-9,223,372,036,854,775,808"));
+        assertEquals("Wrong result L2: " + out, "-9,223,372,036,854,775,808",
+                out.toString());
 
 		pos = new FieldPosition(0);
 		out = format.format(new java.math.BigInteger(String
 				.valueOf(Long.MAX_VALUE)), new StringBuffer(), pos);
-		assertTrue("Wrong result BI1: " + out, out.toString().equals(
-				"9,223,372,036,854,775,807"));
+        assertEquals("Wrong result BI1: " + out, "9,223,372,036,854,775,807",
+                out.toString());
 
 		pos = new FieldPosition(0);
 		out = format.format(new java.math.BigInteger(String
 				.valueOf(Long.MIN_VALUE)), new StringBuffer(), pos);
-		assertTrue("Wrong result BI2: " + out, out.toString().equals(
-				"-9,223,372,036,854,775,808"));
+        assertEquals("Wrong result BI2: " + out, "-9,223,372,036,854,775,808",
+                out.toString());
 
 		java.math.BigInteger big;
 		pos = new FieldPosition(0);
 		big = new java.math.BigInteger(String.valueOf(Long.MAX_VALUE))
 				.add(new java.math.BigInteger("1"));
 		out = format.format(big, new StringBuffer(), pos);
-		assertTrue("Wrong result BI3: " + out, out.toString().equals(
-				"9,223,372,036,854,776,000"));
+        assertEquals("Wrong result BI3: " + out, "9,223,372,036,854,775,808",
+                out.toString());
 
 		pos = new FieldPosition(0);
 		big = new java.math.BigInteger(String.valueOf(Long.MIN_VALUE))
 				.add(new java.math.BigInteger("-1"));
 		out = format.format(big, new StringBuffer(), pos);
-		assertTrue("Wrong result BI4: " + out, out.toString().equals(
-				"-9,223,372,036,854,776,000"));
+		assertEquals("Wrong result BI4: " + out, "-9,223,372,036,854,775,809",
+                out.toString());
 
 		pos = new FieldPosition(0);
 		out = format.format(new java.math.BigDecimal("51.348"),
 				new StringBuffer(), pos);
-		assertTrue("Wrong result BD1: " + out, out.toString().equals("51.348"));
+		assertEquals("Wrong result BD1: " + out, "51.348", out.toString());
 
 		pos = new FieldPosition(0);
 		out = format.format(new java.math.BigDecimal("51"), new StringBuffer(),
 				pos);
-		assertTrue("Wrong result BD2: " + out, out.toString().equals("51"));
+		assertEquals("Wrong result BD2: " + out, "51", out.toString());
 
 	}
 
 	/**
 	 * @tests java.text.NumberFormat#getIntegerInstance()
 	 */
-	public void test_getIntegerInstance() {
+	public void test_getIntegerInstance() throws ParseException {
 		// Test for method java.text.NumberFormat getIntegerInstance()
 		Locale origLocale = Locale.getDefault();
 		Locale.setDefault(Locale.US);
@@ -100,23 +100,20 @@
 		assertEquals(
 				"Test2: NumberFormat.getIntegerInstance().format(35.76) returned wrong value",
 				"36", format.format(35.76));
-		try {
-			assertEquals(
-					"Test3: NumberFormat.getIntegerInstance().parse(\"35.76\") returned wrong number",
-					new Long(35), format.parse("35.76"));
-			assertEquals(
-					"Test4: NumberFormat.getIntegerInstance().parseObject(\"35.76\") returned wrong number",
-					new Long(35), format.parseObject("35.76"));
-		} catch (ParseException e) {
-			fail("Unexpected exception" + e);
-		}
+        assertEquals(
+                "Test3: NumberFormat.getIntegerInstance().parse(\"35.76\") returned wrong
number",
+                new Long(35), format.parse("35.76"));
+        assertEquals(
+                "Test4: NumberFormat.getIntegerInstance().parseObject(\"35.76\") returned
wrong number",
+                new Long(35), format.parseObject("35.76"));
 		Locale.setDefault(origLocale);
 	}
 
 	/**
 	 * @tests java.text.NumberFormat#getIntegerInstance(java.util.Locale)
 	 */
-	public void test_getIntegerInstanceLjava_util_Locale() {
+	public void test_getIntegerInstanceLjava_util_Locale()
+            throws ParseException {
 		// Test for method java.text.NumberFormat
 		// getIntegerInstance(java.util.Locale)
 		Locale usLocale = Locale.US;
@@ -130,16 +127,12 @@
 		assertEquals(
 				"Test2: NumberFormat.getIntegerInstance().format(-35.76) returned wrong value",
 				"-36", format.format(-35.76));
-		try {
-			assertEquals(
-					"Test3: NumberFormat.getIntegerInstance().parse(\"-36\") returned wrong number",
-					new Long(-36), format.parse("-36"));
-			assertEquals(
-					"Test4: NumberFormat.getIntegerInstance().parseObject(\"-36\") returned wrong number",
-					new Long(-36), format.parseObject("-36"));
-		} catch (ParseException e) {
-			fail("Unexpected exception" + e);
-		}
+        assertEquals(
+                "Test3: NumberFormat.getIntegerInstance().parse(\"-36\") returned wrong number",
+                new Long(-36), format.parse("-36"));
+        assertEquals(
+                "Test4: NumberFormat.getIntegerInstance().parseObject(\"-36\") returned wrong
number",
+                new Long(-36), format.parseObject("-36"));
 		assertEquals(
 				"Test5: NumberFormat.getIntegerInstance().getMaximumFractionDigits() returned wrong value",
 				0, format.getMaximumFractionDigits());
@@ -152,19 +145,19 @@
 		assertEquals(
 				"Test7: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).toPattern() returned
wrong pattern",
 				"#,##0;#,##0-", format.toPattern());
-		assertEquals(
-				"Test8: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).format(-35.76) returned
wrong value",
-				"36-", format.format(-35.76));
-		try {
-			assertEquals(
-					"Test9: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).parse(\"-36-\")
returned wrong number",
-					new Long(-36), format.parse("36-"));
-			assertEquals(
-					"Test10: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).parseObject(\"36-\")
returned wrong number",
-					new Long(-36), format.parseObject("36-"));
-		} catch (ParseException e) {
-			fail("Unexpected exception" + e);
-		}
+       // The following "assert" fails on RI. It should be a bug of RI.
+        // Reason: RI does not change European digits (U+0030...U+0039)
+        // to Arabic-Indic digits (U+0660...U+0669).
+        assertEquals(
+                "Test8: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).format(-35.76)
returned wrong value",
+                "\u0663\u0666-", format.format(-35.76));
+        assertEquals(
+                "Test9: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).parse(\"-36-\")
returned wrong number",
+                new Long(-36), format.parse("36-"));
+        assertEquals(
+                "Test10: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).parseObject(\"36-\")
returned wrong number",
+                new Long(-36), format.parseObject("36-"));
+		
 		assertEquals(
 				"Test11: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).getMaximumFractionDigits()
returned wrong value",
 				0, format.getMaximumFractionDigits());
@@ -182,7 +175,7 @@
 		// a subclass that supports currency formatting
 		Currency currH = Currency.getInstance("HUF");
 		NumberFormat format = NumberFormat.getInstance(new Locale("hu", "HU"));
-		assertTrue("Returned incorrect currency", format.getCurrency() == currH);
+		assertSame("Returned incorrect currency", currH, format.getCurrency());
 
 		// a subclass that doesn't support currency formatting
 		ChoiceFormat cformat = new ChoiceFormat(
@@ -212,7 +205,7 @@
 		Currency currA = Currency.getInstance("ARS");
 		NumberFormat format = NumberFormat.getInstance(new Locale("hu", "HU"));
 		format.setCurrency(currA);
-		assertTrue("Returned incorrect currency", format.getCurrency() == currA);
+		assertSame("Returned incorrect currency", currA, format.getCurrency());
 
 		// a subclass that doesn't support currency formatting
 		ChoiceFormat cformat = new ChoiceFormat(



Mime
View raw message