diff options
author | Jesse Wilson <jessewilson@google.com> | 2009-08-04 13:50:38 -0700 |
---|---|---|
committer | Jesse Wilson <jessewilson@google.com> | 2009-08-04 14:04:50 -0700 |
commit | 7cf86eabacd844cae438db573d45727d7b3374bf (patch) | |
tree | 866057bb5ff77889e5f2e261c46b090d5677f348 /math/src/test/java | |
parent | 1f2d2815dc31bf3c464eec6d1de7e428d7f1dcf6 (diff) | |
download | libcore-7cf86eabacd844cae438db573d45727d7b3374bf.zip libcore-7cf86eabacd844cae438db573d45727d7b3374bf.tar.gz libcore-7cf86eabacd844cae438db573d45727d7b3374bf.tar.bz2 |
Updating math to Harmony r772995.
Notable changes:
- lots of trailing whitespace and "@since Android 1.0" tags removed
- shiftLeft(1) replaced with shiftLeftOneBit(). That case can be optimized
more aggressively than the general case. The new method exists in BigInteger
and calls through to a new method in BitLevel in the same way as Harmony.
This is a squashed commit of the following:
commit 3f071487bdb8fff0b4a71ce0219ee7e1e16369fb
Merge: 4fda354 10640b6
Author: Jesse Wilson <jessewilson@google.com>
Date: Tue Aug 4 12:02:25 2009 -0700
Merge branch 'math_772995' into math_dalvik
Conflicts:
libcore/math/.classpath
libcore/math/build.xml
libcore/math/src/main/java/java/math/BigDecimal.java
libcore/math/src/main/java/java/math/BigInteger.java
libcore/math/src/main/java/java/math/Division.java
libcore/math/src/main/java/java/math/Elementary.java
libcore/math/src/main/java/java/math/Logical.java
libcore/math/src/main/java/java/math/MathContext.java
libcore/math/src/main/java/java/math/Multiplication.java
libcore/math/src/main/java/java/math/Primality.java
libcore/math/src/main/java/java/math/RoundingMode.java
libcore/math/src/test/java/tests/api/java/math/BigDecimalTest.java
libcore/math/src/test/java/tests/api/java/math/BigIntegerTest.java
commit 4fda354bd7d2c0ee918c86fa89852310cc8f2af7
Author: Jesse Wilson <jessewilson@google.com>
Date: Wed Jul 29 17:12:27 2009 -0700
Dalvik Math
commit 10640b6b254200f1c89553072e50137f6ad46c84
Author: Jesse Wilson <jessewilson@google.com>
Date: Wed Jul 29 17:11:07 2009 -0700
Math 772995
commit 15302f6d09b3547f1018e3d228f233f8f72c7de9
Author: Jesse Wilson <jessewilson@google.com>
Date: Wed Jul 29 17:08:19 2009 -0700
Math 527399
Diffstat (limited to 'math/src/test/java')
-rw-r--r-- | math/src/test/java/tests/api/java/math/BigDecimalTest.java | 38 | ||||
-rw-r--r-- | math/src/test/java/tests/api/java/math/BigIntegerTest.java | 10 |
2 files changed, 47 insertions, 1 deletions
diff --git a/math/src/test/java/tests/api/java/math/BigDecimalTest.java b/math/src/test/java/tests/api/java/math/BigDecimalTest.java index 47e5b31..572f2c1 100644 --- a/math/src/test/java/tests/api/java/math/BigDecimalTest.java +++ b/math/src/test/java/tests/api/java/math/BigDecimalTest.java @@ -30,6 +30,7 @@ import java.io.ObjectOutputStream; import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; +import java.math.MathContext; @TestTargetClass(BigDecimal.class) public class BigDecimalTest extends junit.framework.TestCase { @@ -1310,6 +1311,41 @@ public class BigDecimalTest extends junit.framework.TestCase { BigDecimal zerotest = new BigDecimal("0.0000"); assertEquals("stripTrailingZero failed for 0.0000", 0, (zerotest.stripTrailingZeros()).scale() ); - } + } + @TestTargetNew( + level = TestLevel.PARTIAL_COMPLETE, + notes = "", + method = "abs", + args = {MathContext.class} + ) + 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 Constructor 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"); + } } diff --git a/math/src/test/java/tests/api/java/math/BigIntegerTest.java b/math/src/test/java/tests/api/java/math/BigIntegerTest.java index c640638..d04f742 100644 --- a/math/src/test/java/tests/api/java/math/BigIntegerTest.java +++ b/math/src/test/java/tests/api/java/math/BigIntegerTest.java @@ -1266,6 +1266,16 @@ public class BigIntegerTest extends junit.framework.TestCase { (i1.testBit(i) && !i2.testBit(i)) == res.testBit(i)); } } + + //regression for HARMONY-4653 + try{ + BigInteger.ZERO.andNot(null); + fail("should throw NPE"); + }catch(Exception e){ + //expected + } + BigInteger bi = new BigInteger(0, new byte[]{}); + assertEquals(BigInteger.ZERO, bi.andNot(BigInteger.ZERO)); } |