harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r570692 - /harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java
Date Wed, 29 Aug 2007 08:20:11 GMT
Author: pyang
Date: Wed Aug 29 01:20:10 2007
New Revision: 570692

URL: http://svn.apache.org/viewvc?rev=570692&view=rev
Log:
Apply patch for HARMONY-4688([classlib][math] MathContext tests)

Modified:
    harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java

Modified: harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java?rev=570692&r1=570691&r2=570692&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java
Wed Aug 29 01:20:10 2007
@@ -23,6 +23,8 @@
 import java.io.ObjectOutputStream;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.math.MathContext;
+import java.math.RoundingMode;
 
 
 public class BigDecimalTest extends junit.framework.TestCase {
@@ -917,4 +919,35 @@
 				((zerotest.stripTrailingZeros()).scale() == 0)
 				);		
 	}	
+
+	public void testMathContextConstruction() {
+        String a = "-12380945E+61";
+        BigDecimal aNumber = new BigDecimal(a);
+        int precision = 6;
+        RoundingMode rm = RoundingMode.HALF_DOWN;
+        MathContext mcIntRm = new MathContext(precision, rm);
+        MathContext mcStr = new MathContext("precision=6 roundingMode=HALF_DOWN");
+        MathContext mcInt = new MathContext(precision);
+        BigDecimal res = aNumber.abs(mcInt);
+        assertEquals("MathContext Constructer with int precision failed",
+                res, 
+                new BigDecimal("1.23809E+68"));
+        
+        assertEquals("Equal MathContexts are not Equal ",
+                mcIntRm,
+                mcStr);
+        
+        assertEquals("Different MathContext are reported as Equal ",
+        		mcInt.equals(mcStr),
+                false);
+        
+        assertEquals("Equal MathContexts have different hashcodes ",
+                mcIntRm.hashCode(),
+                mcStr.hashCode());
+       
+        assertEquals("MathContext.toString() returning incorrect value",
+                mcIntRm.toString(),
+                "precision=6 roundingMode=HALF_DOWN");
+	}
+
 }



Mime
View raw message