harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r446491 [15/24] - in /incubator/harmony/enhanced/classlib/trunk/modules: luni-kernel/.settings/ luni-kernel/META-INF/ luni-kernel/make/ luni-kernel/src/main/java/java/lang/ luni-kernel/src/main/java/java/lang/ref/ luni-kernel/src/main/java/...
Date Fri, 15 Sep 2006 03:08:13 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerAndTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerAndTest.java?view=diff&rev=446491&r1=446490&r2=446491
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerAndTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerAndTest.java Thu Sep 14 20:08:07 2006
@@ -1,432 +1,432 @@
-/*
- *  Copyright 2005 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.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-/**
- * @author Elena Semukhina
- * @version $Revision$
- */
-
-package org.apache.harmony.tests.java.math;
-
-import junit.framework.TestCase;
-import java.math.BigInteger;
-
-/**
- * Class:  java.math.BigInteger
- * Method: and 
- */
-public class BigIntegerAndTest extends TestCase {
-    /**
-     * And for zero and a positive number
-     */
-    public void testZeroPos() {
-        byte aBytes[] = {0};
-        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
-        int aSign = 0;
-        int bSign = 1;        
-        byte rBytes[] = {0};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", 0, result.signum());
-    }
-
-    /**
-     * And for zero and a negative number
-     */
-    public void testZeroNeg() {
-        byte aBytes[] = {0};
-        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
-        int aSign = 0;
-        int bSign = -1;        
-        byte rBytes[] = {0};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", 0, result.signum());
-    }
-
-    /**
-     * And for a positive number and zero 
-     */
-    public void testPosZero() {
-        byte aBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
-        byte bBytes[] = {0};
-        int aSign = 1;
-        int bSign = 0;        
-        byte rBytes[] = {0};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", 0, result.signum());
-    }
-
-    /**
-     * And for a negative number and zero  
-     */
-    public void testNegPos() {
-        byte aBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
-        byte bBytes[] = {0};
-        int aSign = -1;
-        int bSign = 0;        
-        byte rBytes[] = {0};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", 0, result.signum());
-    }
-
-    /**
-     * And for zero and zero
-     */
-    public void testZeroZero() {
-        byte aBytes[] = {0};
-        byte bBytes[] = {0};
-        int aSign = 0;
-        int bSign = 0;        
-        byte rBytes[] = {0};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", 0, result.signum());
-    }
-
-    /**
-     * And for zero and one
-     */
-    public void testZeroOne() {
-        BigInteger aNumber = BigInteger.ZERO;
-        BigInteger bNumber = BigInteger.ONE;
-        BigInteger result = aNumber.and(bNumber);
-        assertTrue(result.equals(BigInteger.ZERO));
-        assertEquals("incorrect sign", 0, result.signum());
-    }
-
-    /**
-     * And for one and one
-     */
-    public void testOneOne() {
-        BigInteger aNumber = BigInteger.ONE;
-        BigInteger bNumber = BigInteger.ONE;
-        BigInteger result = aNumber.and(bNumber);
-        assertTrue(result.equals(BigInteger.ONE));
-        assertEquals("incorrect sign", 1, result.signum());
-    }
-
-    /**
-     * And for two positive numbers of the same length
-     */
-    public void testPosPosSameLength() {
-        byte aBytes[] = {-128, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117};
-        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
-        int aSign = 1;
-        int bSign = 1;        
-        byte rBytes[] = {0, -128, 56, 100, 4, 4, 17, 37, 16, 1, 64, 1, 10, 3};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", 1, result.signum());
-    }
-
-    /**
-     * And for two positive numbers; the first is longer
-     */
-    public void testPosPosFirstLonger() {
-        byte aBytes[] = {-128, 9, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117, 23, 87, -25, -75};
-        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
-        int aSign = 1;
-        int bSign = 1;        
-        byte rBytes[] = {0, -2, -76, 88, 44, 1, 2, 17, 35, 16, 9, 2, 5, 6, 21};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", 1, result.signum());
-    }
-
-    /**
-     * And for two positive numbers; the first is shorter
-     */
-    public void testPosPosFirstShorter() {
-        byte aBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
-        byte bBytes[] = {-128, 9, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117, 23, 87, -25, -75};
-        int aSign = 1;
-        int bSign = 1;        
-        byte rBytes[] = {0, -2, -76, 88, 44, 1, 2, 17, 35, 16, 9, 2, 5, 6, 21};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", 1, result.signum());
-    }
-
-    /**
-     * And for two negative numbers of the same length
-     */
-    public void testNegNegSameLength() {
-        byte aBytes[] = {-128, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117};
-        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
-        int aSign = -1;
-        int bSign = -1;        
-        byte rBytes[] = {-1, 1, 2, 3, 3, 0, 65, -96, -48, -124, -60, 12, -40, -31, 97};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", -1, result.signum());
-    }
-
-    /**
-     * And for two negative numbers; the first is longer
-     */
-    public void testNegNegFirstLonger() {
-        byte aBytes[] = {-128, 9, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117, 23, 87, -25, -75};
-        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
-        int aSign = -1;
-        int bSign = -1;        
-        byte rBytes[] = {-1, 127, -10, -57, -101, 1, 2, 2, 2, -96, -16, 8, -40, -59, 68, -88, -88, 16, 73};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", -1, result.signum());
-    }
-
-    /**
-     * And for two negative numbers; the first is shorter
-     */
-    public void testNegNegFirstShorter() {
-        byte aBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
-        byte bBytes[] = {-128, 9, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117, 23, 87, -25, -75};
-        int aSign = -1;
-        int bSign = -1;        
-        byte rBytes[] = {-1, 127, -10, -57, -101, 1, 2, 2, 2, -96, -16, 8, -40, -59, 68, -88, -88, 16, 73};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", -1, result.signum());
-    }
-
-    /**
-     * And for two numbers of different signs and the same length
-     */
-    public void testPosNegSameLength() {
-        byte aBytes[] = {-128, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117};
-        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
-        int aSign = 1;
-        int bSign = -1;        
-        byte rBytes[] = {0, -6, -80, 72, 8, 75, 2, -79, 34, 16, -119};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", 1, result.signum());
-    }
-
-    /**
-     * And for two numbers of different signs and the same length
-     */
-    public void testNegPosSameLength() {
-        byte aBytes[] = {-128, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117};
-        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
-        int aSign = -1;
-        int bSign = 1;        
-        byte rBytes[] = {0, -2, 125, -60, -104, 1, 10, 6, 2, 32, 56, 2, 4, 4, 21};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", 1, result.signum());
-    }
-
-    /**
-     * And for a negative and a positive numbers; the first is longer
-     */
-    public void testNegPosFirstLonger() {
-        byte aBytes[] = {-128, 9, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117, 23, 87, -25, -75};
-        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
-        int aSign = -1;
-        int bSign = 1;        
-        byte rBytes[] = {73, -92, -48, 4, 12, 6, 4, 32, 48, 64, 0, 8, 3};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", 1, result.signum());
-    }
-
-    /**
-     * And for a negative and a positive numbers; the first is shorter
-     */
-    public void testNegPosFirstShorter() {
-        byte aBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
-        byte bBytes[] = {-128, 9, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117, 23, 87, -25, -75};
-        int aSign = -1;
-        int bSign = 1;        
-        byte rBytes[] = {0, -128, 9, 56, 100, 0, 0, 1, 1, 90, 1, -32, 0, 10, -126, 21, 82, -31, -95};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", 1, result.signum());
-    }
-
-    /**
-     * And for a positive and a negative numbers; the first is longer
-     */
-    public void testPosNegFirstLonger() {
-        byte aBytes[] = {-128, 9, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117, 23, 87, -25, -75};
-        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
-        int aSign = 1;
-        int bSign = -1;        
-        byte rBytes[] = {0, -128, 9, 56, 100, 0, 0, 1, 1, 90, 1, -32, 0, 10, -126, 21, 82, -31, -95};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", 1, result.signum());
-    }
-
-    /**
-     * And for a positive and a negative numbers; the first is shorter
-     */
-    public void testPosNegFirstShorter() {
-        byte aBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
-        byte bBytes[] = {-128, 9, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117, 23, 87, -25, -75};
-        int aSign = 1;
-        int bSign = -1;        
-        byte rBytes[] = {73, -92, -48, 4, 12, 6, 4, 32, 48, 64, 0, 8, 3};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", 1, result.signum());
-    }
-
-    /**
-     * Test for a special case
-     */
-    public void testSpecialCase1() {
-        byte aBytes[] = {-1, -1, -1, -1};
-        byte bBytes[] = {5, -4, -3, -2};
-        int aSign = -1;
-        int bSign = -1;        
-        byte rBytes[] = {-1, 0, 0, 0, 0};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", -1, result.signum());
-    }
-
-    /**
-     * Test for a special case
-     */
-    public void testSpecialCase2() {
-        byte aBytes[] = {-51};
-        byte bBytes[] = {-52, -51, -50, -49, -48};
-        int aSign = -1;
-        int bSign = 1;        
-        byte rBytes[] = {0, -52, -51, -50, -49, 16};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.and(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", 1, result.signum());
-    }
-}
+/*
+ *  Copyright 2005 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.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Elena Semukhina
+ * @version $Revision$
+ */
+
+package org.apache.harmony.tests.java.math;
+
+import junit.framework.TestCase;
+import java.math.BigInteger;
+
+/**
+ * Class:  java.math.BigInteger
+ * Method: and 
+ */
+public class BigIntegerAndTest extends TestCase {
+    /**
+     * And for zero and a positive number
+     */
+    public void testZeroPos() {
+        byte aBytes[] = {0};
+        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
+        int aSign = 0;
+        int bSign = 1;        
+        byte rBytes[] = {0};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", 0, result.signum());
+    }
+
+    /**
+     * And for zero and a negative number
+     */
+    public void testZeroNeg() {
+        byte aBytes[] = {0};
+        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
+        int aSign = 0;
+        int bSign = -1;        
+        byte rBytes[] = {0};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", 0, result.signum());
+    }
+
+    /**
+     * And for a positive number and zero 
+     */
+    public void testPosZero() {
+        byte aBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
+        byte bBytes[] = {0};
+        int aSign = 1;
+        int bSign = 0;        
+        byte rBytes[] = {0};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", 0, result.signum());
+    }
+
+    /**
+     * And for a negative number and zero  
+     */
+    public void testNegPos() {
+        byte aBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
+        byte bBytes[] = {0};
+        int aSign = -1;
+        int bSign = 0;        
+        byte rBytes[] = {0};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", 0, result.signum());
+    }
+
+    /**
+     * And for zero and zero
+     */
+    public void testZeroZero() {
+        byte aBytes[] = {0};
+        byte bBytes[] = {0};
+        int aSign = 0;
+        int bSign = 0;        
+        byte rBytes[] = {0};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", 0, result.signum());
+    }
+
+    /**
+     * And for zero and one
+     */
+    public void testZeroOne() {
+        BigInteger aNumber = BigInteger.ZERO;
+        BigInteger bNumber = BigInteger.ONE;
+        BigInteger result = aNumber.and(bNumber);
+        assertTrue(result.equals(BigInteger.ZERO));
+        assertEquals("incorrect sign", 0, result.signum());
+    }
+
+    /**
+     * And for one and one
+     */
+    public void testOneOne() {
+        BigInteger aNumber = BigInteger.ONE;
+        BigInteger bNumber = BigInteger.ONE;
+        BigInteger result = aNumber.and(bNumber);
+        assertTrue(result.equals(BigInteger.ONE));
+        assertEquals("incorrect sign", 1, result.signum());
+    }
+
+    /**
+     * And for two positive numbers of the same length
+     */
+    public void testPosPosSameLength() {
+        byte aBytes[] = {-128, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117};
+        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
+        int aSign = 1;
+        int bSign = 1;        
+        byte rBytes[] = {0, -128, 56, 100, 4, 4, 17, 37, 16, 1, 64, 1, 10, 3};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", 1, result.signum());
+    }
+
+    /**
+     * And for two positive numbers; the first is longer
+     */
+    public void testPosPosFirstLonger() {
+        byte aBytes[] = {-128, 9, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117, 23, 87, -25, -75};
+        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
+        int aSign = 1;
+        int bSign = 1;        
+        byte rBytes[] = {0, -2, -76, 88, 44, 1, 2, 17, 35, 16, 9, 2, 5, 6, 21};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", 1, result.signum());
+    }
+
+    /**
+     * And for two positive numbers; the first is shorter
+     */
+    public void testPosPosFirstShorter() {
+        byte aBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
+        byte bBytes[] = {-128, 9, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117, 23, 87, -25, -75};
+        int aSign = 1;
+        int bSign = 1;        
+        byte rBytes[] = {0, -2, -76, 88, 44, 1, 2, 17, 35, 16, 9, 2, 5, 6, 21};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", 1, result.signum());
+    }
+
+    /**
+     * And for two negative numbers of the same length
+     */
+    public void testNegNegSameLength() {
+        byte aBytes[] = {-128, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117};
+        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
+        int aSign = -1;
+        int bSign = -1;        
+        byte rBytes[] = {-1, 1, 2, 3, 3, 0, 65, -96, -48, -124, -60, 12, -40, -31, 97};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", -1, result.signum());
+    }
+
+    /**
+     * And for two negative numbers; the first is longer
+     */
+    public void testNegNegFirstLonger() {
+        byte aBytes[] = {-128, 9, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117, 23, 87, -25, -75};
+        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
+        int aSign = -1;
+        int bSign = -1;        
+        byte rBytes[] = {-1, 127, -10, -57, -101, 1, 2, 2, 2, -96, -16, 8, -40, -59, 68, -88, -88, 16, 73};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", -1, result.signum());
+    }
+
+    /**
+     * And for two negative numbers; the first is shorter
+     */
+    public void testNegNegFirstShorter() {
+        byte aBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
+        byte bBytes[] = {-128, 9, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117, 23, 87, -25, -75};
+        int aSign = -1;
+        int bSign = -1;        
+        byte rBytes[] = {-1, 127, -10, -57, -101, 1, 2, 2, 2, -96, -16, 8, -40, -59, 68, -88, -88, 16, 73};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", -1, result.signum());
+    }
+
+    /**
+     * And for two numbers of different signs and the same length
+     */
+    public void testPosNegSameLength() {
+        byte aBytes[] = {-128, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117};
+        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
+        int aSign = 1;
+        int bSign = -1;        
+        byte rBytes[] = {0, -6, -80, 72, 8, 75, 2, -79, 34, 16, -119};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", 1, result.signum());
+    }
+
+    /**
+     * And for two numbers of different signs and the same length
+     */
+    public void testNegPosSameLength() {
+        byte aBytes[] = {-128, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117};
+        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
+        int aSign = -1;
+        int bSign = 1;        
+        byte rBytes[] = {0, -2, 125, -60, -104, 1, 10, 6, 2, 32, 56, 2, 4, 4, 21};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", 1, result.signum());
+    }
+
+    /**
+     * And for a negative and a positive numbers; the first is longer
+     */
+    public void testNegPosFirstLonger() {
+        byte aBytes[] = {-128, 9, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117, 23, 87, -25, -75};
+        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
+        int aSign = -1;
+        int bSign = 1;        
+        byte rBytes[] = {73, -92, -48, 4, 12, 6, 4, 32, 48, 64, 0, 8, 3};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", 1, result.signum());
+    }
+
+    /**
+     * And for a negative and a positive numbers; the first is shorter
+     */
+    public void testNegPosFirstShorter() {
+        byte aBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
+        byte bBytes[] = {-128, 9, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117, 23, 87, -25, -75};
+        int aSign = -1;
+        int bSign = 1;        
+        byte rBytes[] = {0, -128, 9, 56, 100, 0, 0, 1, 1, 90, 1, -32, 0, 10, -126, 21, 82, -31, -95};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", 1, result.signum());
+    }
+
+    /**
+     * And for a positive and a negative numbers; the first is longer
+     */
+    public void testPosNegFirstLonger() {
+        byte aBytes[] = {-128, 9, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117, 23, 87, -25, -75};
+        byte bBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
+        int aSign = 1;
+        int bSign = -1;        
+        byte rBytes[] = {0, -128, 9, 56, 100, 0, 0, 1, 1, 90, 1, -32, 0, 10, -126, 21, 82, -31, -95};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", 1, result.signum());
+    }
+
+    /**
+     * And for a positive and a negative numbers; the first is shorter
+     */
+    public void testPosNegFirstShorter() {
+        byte aBytes[] = {-2, -3, -4, -4, 5, 14, 23, 39, 48, 57, 66, 5, 14, 23};
+        byte bBytes[] = {-128, 9, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, -117, 23, 87, -25, -75};
+        int aSign = 1;
+        int bSign = -1;        
+        byte rBytes[] = {73, -92, -48, 4, 12, 6, 4, 32, 48, 64, 0, 8, 3};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", 1, result.signum());
+    }
+
+    /**
+     * Test for a special case
+     */
+    public void testSpecialCase1() {
+        byte aBytes[] = {-1, -1, -1, -1};
+        byte bBytes[] = {5, -4, -3, -2};
+        int aSign = -1;
+        int bSign = -1;        
+        byte rBytes[] = {-1, 0, 0, 0, 0};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", -1, result.signum());
+    }
+
+    /**
+     * Test for a special case
+     */
+    public void testSpecialCase2() {
+        byte aBytes[] = {-51};
+        byte bBytes[] = {-52, -51, -50, -49, -48};
+        int aSign = -1;
+        int bSign = 1;        
+        byte rBytes[] = {0, -52, -51, -50, -49, 16};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.and(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", 1, result.signum());
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerAndTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerCompareTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerCompareTest.java?view=diff&rev=446491&r1=446490&r2=446491
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerCompareTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerCompareTest.java Thu Sep 14 20:08:07 2006
@@ -1,535 +1,535 @@
-/*
- *  Copyright 2005 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.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-/**
- * @author Elena Semukhina
- * @version $Revision$
- */
-
-package org.apache.harmony.tests.java.math;
-
-import junit.framework.TestCase;
-import java.math.BigInteger;
-
-/**
- * Class:   java.math.BigInteger
- * Methods: abs, compareTo, equals, max, min, negate, signum
- */
-public class BigIntegerCompareTest extends TestCase {
-    /**
-     * abs() for a positive number
-     */
-    public void testAbsPositive() {
-        byte aBytes[] = {1, 2, 3, 4, 5, 6, 7};
-        int aSign = 1;
-        byte rBytes[] = {1, 2, 3, 4, 5, 6, 7};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger result = aNumber.abs();
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", 1, result.signum());
-    }
-
-    /**
-     * abs() for a negative number
-     */
-    public void testAbsNegative() {
-        byte aBytes[] = {1, 2, 3, 4, 5, 6, 7};
-        int aSign = -1;
-        byte rBytes[] = {1, 2, 3, 4, 5, 6, 7};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger result = aNumber.abs();
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }
-        assertEquals("incorrect sign", 1, result.signum());
-    }
-
-    /**
-     * compareTo(BigInteger a).
-     * Compare two positive numbers.
-     * The first is greater.
-     */
-    public void testCompareToPosPos1() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        byte bBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
-        int aSign = 1;
-        int bSign = 1;        
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        assertEquals(1, aNumber.compareTo(bNumber));
-    }
-    
-    /**
-     * compareTo(BigInteger a).
-     * Compare two positive numbers.
-     * The first is less.
-     */
-    public void testCompareToPosPos2() {
-        byte aBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
-        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = 1;
-        int bSign = 1;        
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        int result = aNumber.compareTo(bNumber);
-        assertEquals(-1, aNumber.compareTo(bNumber));
-    }
-
-    /**
-     * compareTo(BigInteger a).
-     * Compare two equal positive numbers.
-     */
-    public void testCompareToEqualPos() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = 1;
-        int bSign = 1;        
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        assertEquals(0, aNumber.compareTo(bNumber));
-    }
-    
-    /**
-     * compareTo(BigInteger a).
-     * Compare two negative numbers.
-     * The first is greater in absolute value.
-     */
-    public void testCompareToNegNeg1() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        byte bBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
-        int aSign = -1;
-        int bSign = -1;        
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        assertEquals(-1, aNumber.compareTo(bNumber));
-    }
-    
-    /**
-     * compareTo(BigInteger a).
-     * Compare two negative numbers.
-     * The first is less  in absolute value.
-     */
-    public void testCompareNegNeg2() {
-        byte aBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
-        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = -1;
-        int bSign = -1;        
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        assertEquals(1, aNumber.compareTo(bNumber));
-    }
-
-    /**
-     * compareTo(BigInteger a).
-     * Compare two equal negative numbers.
-     */
-    public void testCompareToEqualNeg() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = -1;
-        int bSign = -1;        
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        assertEquals(0, aNumber.compareTo(bNumber));
-    }
-    
-    /**
-     * compareTo(BigInteger a).
-     * Compare two numbers of different signs.
-     * The first is positive.
-     */
-    public void testCompareToDiffSigns1() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        byte bBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
-        int aSign = 1;
-        int bSign = -1;        
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        assertEquals(1, aNumber.compareTo(bNumber));
-    }
-
-    /**
-     * compareTo(BigInteger a).
-     * Compare two numbers of different signs.
-     * The first is negative.
-     */
-    public void testCompareToDiffSigns2() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        byte bBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
-        int aSign = -1;
-        int bSign = 1;        
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        assertEquals(-1, aNumber.compareTo(bNumber));
-    }
-    
-    /**
-     * compareTo(BigInteger a).
-     * Compare a positive number to ZERO.
-     */
-    public void testCompareToPosZero() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = 1;
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = BigInteger.ZERO;
-        int result = aNumber.compareTo(bNumber);
-        assertEquals(1, aNumber.compareTo(bNumber));
-    }
-
-    /**
-     * compareTo(BigInteger a).
-     * Compare ZERO to a positive number.
-     */
-    public void testCompareToZeroPos() {
-        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        int bSign = 1;
-        BigInteger aNumber = BigInteger.ZERO;
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        assertEquals(-1, aNumber.compareTo(bNumber));
-    }
-
-    /**
-     * compareTo(BigInteger a).
-     * Compare a negative number to ZERO.
-     */
-    public void testCompareToNegZero() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = -1;
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = BigInteger.ZERO;
-        assertEquals(-1, aNumber.compareTo(bNumber));
-    }
-
-    /**
-     * compareTo(BigInteger a).
-     * Compare ZERO to a negative number.
-     */
-    public void testCompareToZeroNeg() {
-        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        int bSign = -1;
-        BigInteger aNumber = BigInteger.ZERO;
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        assertEquals(1, aNumber.compareTo(bNumber));
-    }
-
-    /**
-     * compareTo(BigInteger a).
-     * Compare ZERO to ZERO.
-     */
-    public void testCompareToZeroZero() {
-        BigInteger aNumber = BigInteger.ZERO;
-        BigInteger bNumber = BigInteger.ZERO;
-        assertEquals(0, aNumber.compareTo(bNumber));
-    }
-
-    /**
-     * equals(Object obj).
-     * obj is not a BigInteger
-     */
-    public void testEqualsObject() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = 1;
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        Object obj = new Object();
-        assertFalse(aNumber.equals(obj));
-    }
-
-    /**
-     * equals(null).
-     */
-    public void testEqualsNull() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = 1;
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        assertFalse(aNumber.equals(null));
-    }
-
-    /**
-     * equals(Object obj).
-     * obj is a BigInteger.
-     * numbers are equal.
-     */
-    public void testEqualsBigIntegerTrue() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = 1;
-        int bSign = 1;        
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        Object bNumber = (Object)new BigInteger(bSign, bBytes);
-        assertTrue(aNumber.equals(bNumber));
-    }
-
-    /**
-     * equals(Object obj).
-     * obj is a BigInteger.
-     * numbers are not equal.
-     */
-    public void testEqualsBigIntegerFalse() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        byte bBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = 1;
-        int bSign = 1;        
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        Object bNumber = (Object)new BigInteger(bSign, bBytes);
-        assertFalse(aNumber.equals(bNumber));
-    }
-
-    /**
-     * max(BigInteger val).
-     * the first is greater.
-     */
-    public void testMaxGreater() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        byte bBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = 1;
-        int bSign = 1;        
-        byte rBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.max(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }    
-        assertTrue("incorrect sign", result.signum() == 1);
-    }
-
-    /**
-     * max(BigInteger val).
-     * the first is less.
-     */
-    public void testMaxLess() {
-        byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
-        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = 1;
-        int bSign = 1;        
-        byte rBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.max(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }    
-        assertTrue("incorrect sign", result.signum() == 1);
-    }
-
-    /**
-     * max(BigInteger val).
-     * numbers are equal.
-     */
-    public void testMaxEqual() {
-        byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
-        byte bBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = 1;
-        int bSign = 1;        
-        byte rBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.max(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }    
-        assertEquals("incorrect sign", 1, result.signum());
-    }
-
-    /**
-     * max(BigInteger val).
-     * max of negative and ZERO.
-     */
-    public void testMaxNegZero() {
-        byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = -1;
-        byte rBytes[] = {0};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = BigInteger.ZERO;
-        BigInteger result = aNumber.max(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }    
-        assertTrue("incorrect sign", result.signum() == 0);
-    }
-
-    /**
-     * min(BigInteger val).
-     * the first is greater.
-     */
-    public void testMinGreater() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        byte bBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = 1;
-        int bSign = 1;        
-        byte rBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.min(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }    
-        assertEquals("incorrect sign", 1, result.signum());
-    }
-
-    /**
-     * min(BigInteger val).
-     * the first is less.
-     */
-    public void testMinLess() {
-        byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
-        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = 1;
-        int bSign = 1;        
-        byte rBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.min(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }    
-        assertEquals("incorrect sign", 1, result.signum());
-    }
-
-    /**
-     * min(BigInteger val).
-     * numbers are equal.
-     */
-    public void testMinEqual() {
-        byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
-        byte bBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = 1;
-        int bSign = 1;        
-        byte rBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = new BigInteger(bSign, bBytes);
-        BigInteger result = aNumber.min(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }    
-        assertTrue("incorrect sign", result.signum() == 1);
-    }
-
-    /**
-     * max(BigInteger val).
-     * min of positive and ZERO.
-     */
-    public void testMinPosZero() {
-        byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = 1;
-        byte rBytes[] = {0};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger bNumber = BigInteger.ZERO;
-        BigInteger result = aNumber.min(bNumber);
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }    
-        assertTrue("incorrect sign", result.signum() == 0);
-    }
-    
-    /**
-     * negate() a positive number.
-     */
-    public void testNegatePositive() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = 1;
-        byte rBytes[] = {-13, -57, -101, 1, 75, -90, -46, -92, -4, 14, -36, -27, -4, -91};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger result = aNumber.negate();
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }    
-        assertTrue("incorrect sign", result.signum() == -1);
-    }
-
-    /**
-     * negate() a negative number.
-     */
-    public void testNegateNegative() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = -1;
-        byte rBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        BigInteger result = aNumber.negate();
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }    
-        assertTrue("incorrect sign", result.signum() == 1);
-    }
-
-    /**
-     * negate() ZERO.
-     */
-    public void testNegateZero() {
-        byte rBytes[] = {0};
-        BigInteger aNumber = BigInteger.ZERO;
-        BigInteger result = aNumber.negate();
-        byte resBytes[] = new byte[rBytes.length];
-        resBytes = result.toByteArray();
-        for(int i = 0; i < resBytes.length; i++) {
-            assertTrue(resBytes[i] == rBytes[i]);
-        }    
-        assertEquals("incorrect sign", 0, result.signum());
-    }
-
-    /**
-     * signum() of a positive number.
-     */
-    public void testSignumPositive() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = 1;
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        assertEquals("incorrect sign", 1, aNumber.signum());
-    }
-    
-    /**
-     * signum() of a negative number.
-     */
-    public void testSignumNegative() {
-        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
-        int aSign = -1;
-        BigInteger aNumber = new BigInteger(aSign, aBytes);
-        assertEquals("incorrect sign", -1, aNumber.signum());
-    }
-    
-    /**
-     * signum() of ZERO.
-     */
-    public void testSignumZero() {
-        BigInteger aNumber = BigInteger.ZERO;
-        assertEquals("incorrect sign", 0, aNumber.signum());
-    }
-}
+/*
+ *  Copyright 2005 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.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Elena Semukhina
+ * @version $Revision$
+ */
+
+package org.apache.harmony.tests.java.math;
+
+import junit.framework.TestCase;
+import java.math.BigInteger;
+
+/**
+ * Class:   java.math.BigInteger
+ * Methods: abs, compareTo, equals, max, min, negate, signum
+ */
+public class BigIntegerCompareTest extends TestCase {
+    /**
+     * abs() for a positive number
+     */
+    public void testAbsPositive() {
+        byte aBytes[] = {1, 2, 3, 4, 5, 6, 7};
+        int aSign = 1;
+        byte rBytes[] = {1, 2, 3, 4, 5, 6, 7};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger result = aNumber.abs();
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", 1, result.signum());
+    }
+
+    /**
+     * abs() for a negative number
+     */
+    public void testAbsNegative() {
+        byte aBytes[] = {1, 2, 3, 4, 5, 6, 7};
+        int aSign = -1;
+        byte rBytes[] = {1, 2, 3, 4, 5, 6, 7};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger result = aNumber.abs();
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }
+        assertEquals("incorrect sign", 1, result.signum());
+    }
+
+    /**
+     * compareTo(BigInteger a).
+     * Compare two positive numbers.
+     * The first is greater.
+     */
+    public void testCompareToPosPos1() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        byte bBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
+        int aSign = 1;
+        int bSign = 1;        
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        assertEquals(1, aNumber.compareTo(bNumber));
+    }
+    
+    /**
+     * compareTo(BigInteger a).
+     * Compare two positive numbers.
+     * The first is less.
+     */
+    public void testCompareToPosPos2() {
+        byte aBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
+        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = 1;
+        int bSign = 1;        
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        int result = aNumber.compareTo(bNumber);
+        assertEquals(-1, aNumber.compareTo(bNumber));
+    }
+
+    /**
+     * compareTo(BigInteger a).
+     * Compare two equal positive numbers.
+     */
+    public void testCompareToEqualPos() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = 1;
+        int bSign = 1;        
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        assertEquals(0, aNumber.compareTo(bNumber));
+    }
+    
+    /**
+     * compareTo(BigInteger a).
+     * Compare two negative numbers.
+     * The first is greater in absolute value.
+     */
+    public void testCompareToNegNeg1() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        byte bBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
+        int aSign = -1;
+        int bSign = -1;        
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        assertEquals(-1, aNumber.compareTo(bNumber));
+    }
+    
+    /**
+     * compareTo(BigInteger a).
+     * Compare two negative numbers.
+     * The first is less  in absolute value.
+     */
+    public void testCompareNegNeg2() {
+        byte aBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
+        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = -1;
+        int bSign = -1;        
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        assertEquals(1, aNumber.compareTo(bNumber));
+    }
+
+    /**
+     * compareTo(BigInteger a).
+     * Compare two equal negative numbers.
+     */
+    public void testCompareToEqualNeg() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = -1;
+        int bSign = -1;        
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        assertEquals(0, aNumber.compareTo(bNumber));
+    }
+    
+    /**
+     * compareTo(BigInteger a).
+     * Compare two numbers of different signs.
+     * The first is positive.
+     */
+    public void testCompareToDiffSigns1() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        byte bBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
+        int aSign = 1;
+        int bSign = -1;        
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        assertEquals(1, aNumber.compareTo(bNumber));
+    }
+
+    /**
+     * compareTo(BigInteger a).
+     * Compare two numbers of different signs.
+     * The first is negative.
+     */
+    public void testCompareToDiffSigns2() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        byte bBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
+        int aSign = -1;
+        int bSign = 1;        
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        assertEquals(-1, aNumber.compareTo(bNumber));
+    }
+    
+    /**
+     * compareTo(BigInteger a).
+     * Compare a positive number to ZERO.
+     */
+    public void testCompareToPosZero() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = 1;
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = BigInteger.ZERO;
+        int result = aNumber.compareTo(bNumber);
+        assertEquals(1, aNumber.compareTo(bNumber));
+    }
+
+    /**
+     * compareTo(BigInteger a).
+     * Compare ZERO to a positive number.
+     */
+    public void testCompareToZeroPos() {
+        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        int bSign = 1;
+        BigInteger aNumber = BigInteger.ZERO;
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        assertEquals(-1, aNumber.compareTo(bNumber));
+    }
+
+    /**
+     * compareTo(BigInteger a).
+     * Compare a negative number to ZERO.
+     */
+    public void testCompareToNegZero() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = -1;
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = BigInteger.ZERO;
+        assertEquals(-1, aNumber.compareTo(bNumber));
+    }
+
+    /**
+     * compareTo(BigInteger a).
+     * Compare ZERO to a negative number.
+     */
+    public void testCompareToZeroNeg() {
+        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        int bSign = -1;
+        BigInteger aNumber = BigInteger.ZERO;
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        assertEquals(1, aNumber.compareTo(bNumber));
+    }
+
+    /**
+     * compareTo(BigInteger a).
+     * Compare ZERO to ZERO.
+     */
+    public void testCompareToZeroZero() {
+        BigInteger aNumber = BigInteger.ZERO;
+        BigInteger bNumber = BigInteger.ZERO;
+        assertEquals(0, aNumber.compareTo(bNumber));
+    }
+
+    /**
+     * equals(Object obj).
+     * obj is not a BigInteger
+     */
+    public void testEqualsObject() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = 1;
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        Object obj = new Object();
+        assertFalse(aNumber.equals(obj));
+    }
+
+    /**
+     * equals(null).
+     */
+    public void testEqualsNull() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = 1;
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        assertFalse(aNumber.equals(null));
+    }
+
+    /**
+     * equals(Object obj).
+     * obj is a BigInteger.
+     * numbers are equal.
+     */
+    public void testEqualsBigIntegerTrue() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = 1;
+        int bSign = 1;        
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        Object bNumber = (Object)new BigInteger(bSign, bBytes);
+        assertTrue(aNumber.equals(bNumber));
+    }
+
+    /**
+     * equals(Object obj).
+     * obj is a BigInteger.
+     * numbers are not equal.
+     */
+    public void testEqualsBigIntegerFalse() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        byte bBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = 1;
+        int bSign = 1;        
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        Object bNumber = (Object)new BigInteger(bSign, bBytes);
+        assertFalse(aNumber.equals(bNumber));
+    }
+
+    /**
+     * max(BigInteger val).
+     * the first is greater.
+     */
+    public void testMaxGreater() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        byte bBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = 1;
+        int bSign = 1;        
+        byte rBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.max(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }    
+        assertTrue("incorrect sign", result.signum() == 1);
+    }
+
+    /**
+     * max(BigInteger val).
+     * the first is less.
+     */
+    public void testMaxLess() {
+        byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
+        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = 1;
+        int bSign = 1;        
+        byte rBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.max(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }    
+        assertTrue("incorrect sign", result.signum() == 1);
+    }
+
+    /**
+     * max(BigInteger val).
+     * numbers are equal.
+     */
+    public void testMaxEqual() {
+        byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
+        byte bBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = 1;
+        int bSign = 1;        
+        byte rBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.max(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }    
+        assertEquals("incorrect sign", 1, result.signum());
+    }
+
+    /**
+     * max(BigInteger val).
+     * max of negative and ZERO.
+     */
+    public void testMaxNegZero() {
+        byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = -1;
+        byte rBytes[] = {0};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = BigInteger.ZERO;
+        BigInteger result = aNumber.max(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }    
+        assertTrue("incorrect sign", result.signum() == 0);
+    }
+
+    /**
+     * min(BigInteger val).
+     * the first is greater.
+     */
+    public void testMinGreater() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        byte bBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = 1;
+        int bSign = 1;        
+        byte rBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.min(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }    
+        assertEquals("incorrect sign", 1, result.signum());
+    }
+
+    /**
+     * min(BigInteger val).
+     * the first is less.
+     */
+    public void testMinLess() {
+        byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
+        byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = 1;
+        int bSign = 1;        
+        byte rBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.min(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }    
+        assertEquals("incorrect sign", 1, result.signum());
+    }
+
+    /**
+     * min(BigInteger val).
+     * numbers are equal.
+     */
+    public void testMinEqual() {
+        byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
+        byte bBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = 1;
+        int bSign = 1;        
+        byte rBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = new BigInteger(bSign, bBytes);
+        BigInteger result = aNumber.min(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }    
+        assertTrue("incorrect sign", result.signum() == 1);
+    }
+
+    /**
+     * max(BigInteger val).
+     * min of positive and ZERO.
+     */
+    public void testMinPosZero() {
+        byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = 1;
+        byte rBytes[] = {0};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger bNumber = BigInteger.ZERO;
+        BigInteger result = aNumber.min(bNumber);
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }    
+        assertTrue("incorrect sign", result.signum() == 0);
+    }
+    
+    /**
+     * negate() a positive number.
+     */
+    public void testNegatePositive() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = 1;
+        byte rBytes[] = {-13, -57, -101, 1, 75, -90, -46, -92, -4, 14, -36, -27, -4, -91};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger result = aNumber.negate();
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }    
+        assertTrue("incorrect sign", result.signum() == -1);
+    }
+
+    /**
+     * negate() a negative number.
+     */
+    public void testNegateNegative() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = -1;
+        byte rBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        BigInteger result = aNumber.negate();
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }    
+        assertTrue("incorrect sign", result.signum() == 1);
+    }
+
+    /**
+     * negate() ZERO.
+     */
+    public void testNegateZero() {
+        byte rBytes[] = {0};
+        BigInteger aNumber = BigInteger.ZERO;
+        BigInteger result = aNumber.negate();
+        byte resBytes[] = new byte[rBytes.length];
+        resBytes = result.toByteArray();
+        for(int i = 0; i < resBytes.length; i++) {
+            assertTrue(resBytes[i] == rBytes[i]);
+        }    
+        assertEquals("incorrect sign", 0, result.signum());
+    }
+
+    /**
+     * signum() of a positive number.
+     */
+    public void testSignumPositive() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = 1;
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        assertEquals("incorrect sign", 1, aNumber.signum());
+    }
+    
+    /**
+     * signum() of a negative number.
+     */
+    public void testSignumNegative() {
+        byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
+        int aSign = -1;
+        BigInteger aNumber = new BigInteger(aSign, aBytes);
+        assertEquals("incorrect sign", -1, aNumber.signum());
+    }
+    
+    /**
+     * signum() of ZERO.
+     */
+    public void testSignumZero() {
+        BigInteger aNumber = BigInteger.ZERO;
+        assertEquals("incorrect sign", 0, aNumber.signum());
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerCompareTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message