Home | History | Annotate | Download | only in math
      1 /*
      2  *  Licensed to the Apache Software Foundation (ASF) under one or more
      3  *  contributor license agreements.  See the NOTICE file distributed with
      4  *  this work for additional information regarding copyright ownership.
      5  *  The ASF licenses this file to You under the Apache License, Version 2.0
      6  *  (the "License"); you may not use this file except in compliance with
      7  *  the License.  You may obtain a copy of the License at
      8  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  */
     17 /**
     18  * @author Elena Semukhina
     19  * @version $Revision$
     20  */
     21 
     22 package org.apache.harmony.math.tests.java.math;
     23 
     24 import dalvik.annotation.TestTargetClass;
     25 import dalvik.annotation.TestTargets;
     26 import dalvik.annotation.TestLevel;
     27 import dalvik.annotation.TestTargetNew;
     28 
     29 import java.math.BigInteger;
     30 
     31 import junit.framework.TestCase;
     32 @TestTargetClass(BigInteger.class)
     33 /**
     34  * Class:   java.math.BigInteger
     35  * Methods: abs, compareTo, equals, max, min, negate, signum
     36  */
     37 public class BigIntegerCompareTest extends TestCase {
     38     /**
     39      * abs() for a positive number
     40      */
     41     @TestTargetNew(
     42         level = TestLevel.PARTIAL_COMPLETE,
     43         notes = "This is a complete subset of tests for abs method.",
     44         method = "abs",
     45         args = {}
     46     )
     47     public void testAbsPositive() {
     48         byte aBytes[] = {1, 2, 3, 4, 5, 6, 7};
     49         int aSign = 1;
     50         byte rBytes[] = {1, 2, 3, 4, 5, 6, 7};
     51         BigInteger aNumber = new BigInteger(aSign, aBytes);
     52         BigInteger result = aNumber.abs();
     53         byte resBytes[] = new byte[rBytes.length];
     54         resBytes = result.toByteArray();
     55         for(int i = 0; i < resBytes.length; i++) {
     56             assertTrue(resBytes[i] == rBytes[i]);
     57         }
     58         assertEquals("incorrect sign", 1, result.signum());
     59     }
     60 
     61     /**
     62      * abs() for a negative number
     63      */
     64     @TestTargetNew(
     65         level = TestLevel.PARTIAL_COMPLETE,
     66         notes = "This is a complete subset of tests for abs method.",
     67         method = "abs",
     68         args = {}
     69     )
     70     public void testAbsNegative() {
     71         byte aBytes[] = {1, 2, 3, 4, 5, 6, 7};
     72         int aSign = -1;
     73         byte rBytes[] = {1, 2, 3, 4, 5, 6, 7};
     74         BigInteger aNumber = new BigInteger(aSign, aBytes);
     75         BigInteger result = aNumber.abs();
     76         byte resBytes[] = new byte[rBytes.length];
     77         resBytes = result.toByteArray();
     78         for(int i = 0; i < resBytes.length; i++) {
     79             assertTrue(resBytes[i] == rBytes[i]);
     80         }
     81         assertEquals("incorrect sign", 1, result.signum());
     82     }
     83 
     84     /**
     85      * compareTo(BigInteger a).
     86      * Compare two positive numbers.
     87      * The first is greater.
     88      */
     89     @TestTargetNew(
     90         level = TestLevel.PARTIAL_COMPLETE,
     91         notes = "This is a complete subset of tests for compareTo method.",
     92         method = "compareTo",
     93         args = {java.math.BigInteger.class}
     94     )
     95     public void testCompareToPosPos1() {
     96         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
     97         byte bBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
     98         int aSign = 1;
     99         int bSign = 1;
    100         BigInteger aNumber = new BigInteger(aSign, aBytes);
    101         BigInteger bNumber = new BigInteger(bSign, bBytes);
    102         assertEquals(1, aNumber.compareTo(bNumber));
    103     }
    104 
    105     /**
    106      * compareTo(BigInteger a).
    107      * Compare two positive numbers.
    108      * The first is less.
    109      */
    110     @TestTargetNew(
    111         level = TestLevel.PARTIAL_COMPLETE,
    112         notes = "This is a complete subset of tests for compareTo method.",
    113         method = "compareTo",
    114         args = {java.math.BigInteger.class}
    115     )
    116     public void testCompareToPosPos2() {
    117         byte aBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
    118         byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    119         int aSign = 1;
    120         int bSign = 1;
    121         BigInteger aNumber = new BigInteger(aSign, aBytes);
    122         BigInteger bNumber = new BigInteger(bSign, bBytes);
    123         assertEquals(-1, aNumber.compareTo(bNumber));
    124     }
    125 
    126     /**
    127      * compareTo(BigInteger a).
    128      * Compare two equal positive numbers.
    129      */
    130     @TestTargetNew(
    131         level = TestLevel.PARTIAL_COMPLETE,
    132         notes = "This is a complete subset of tests for compareTo method.",
    133         method = "compareTo",
    134         args = {java.math.BigInteger.class}
    135     )
    136     public void testCompareToEqualPos() {
    137         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    138         byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    139         int aSign = 1;
    140         int bSign = 1;
    141         BigInteger aNumber = new BigInteger(aSign, aBytes);
    142         BigInteger bNumber = new BigInteger(bSign, bBytes);
    143         assertEquals(0, aNumber.compareTo(bNumber));
    144     }
    145 
    146     /**
    147      * compareTo(BigInteger a).
    148      * Compare two negative numbers.
    149      * The first is greater in absolute value.
    150      */
    151     @TestTargetNew(
    152         level = TestLevel.PARTIAL_COMPLETE,
    153         notes = "This is a complete subset of tests for compareTo method.",
    154         method = "compareTo",
    155         args = {java.math.BigInteger.class}
    156     )
    157     public void testCompareToNegNeg1() {
    158         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    159         byte bBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
    160         int aSign = -1;
    161         int bSign = -1;
    162         BigInteger aNumber = new BigInteger(aSign, aBytes);
    163         BigInteger bNumber = new BigInteger(bSign, bBytes);
    164         assertEquals(-1, aNumber.compareTo(bNumber));
    165     }
    166 
    167     /**
    168      * compareTo(BigInteger a).
    169      * Compare two negative numbers.
    170      * The first is less  in absolute value.
    171      */
    172     @TestTargetNew(
    173         level = TestLevel.PARTIAL_COMPLETE,
    174         notes = "This is a complete subset of tests for compareTo method.",
    175         method = "compareTo",
    176         args = {java.math.BigInteger.class}
    177     )
    178     public void testCompareNegNeg2() {
    179         byte aBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
    180         byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    181         int aSign = -1;
    182         int bSign = -1;
    183         BigInteger aNumber = new BigInteger(aSign, aBytes);
    184         BigInteger bNumber = new BigInteger(bSign, bBytes);
    185         assertEquals(1, aNumber.compareTo(bNumber));
    186     }
    187 
    188     /**
    189      * compareTo(BigInteger a).
    190      * Compare two equal negative numbers.
    191      */
    192     @TestTargetNew(
    193         level = TestLevel.PARTIAL_COMPLETE,
    194         notes = "This is a complete subset of tests for compareTo method.",
    195         method = "compareTo",
    196         args = {java.math.BigInteger.class}
    197     )
    198     public void testCompareToEqualNeg() {
    199         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    200         byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    201         int aSign = -1;
    202         int bSign = -1;
    203         BigInteger aNumber = new BigInteger(aSign, aBytes);
    204         BigInteger bNumber = new BigInteger(bSign, bBytes);
    205         assertEquals(0, aNumber.compareTo(bNumber));
    206     }
    207 
    208     /**
    209      * compareTo(BigInteger a).
    210      * Compare two numbers of different signs.
    211      * The first is positive.
    212      */
    213     @TestTargetNew(
    214         level = TestLevel.PARTIAL_COMPLETE,
    215         notes = "This is a complete subset of tests for compareTo method.",
    216         method = "compareTo",
    217         args = {java.math.BigInteger.class}
    218     )
    219     public void testCompareToDiffSigns1() {
    220         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    221         byte bBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
    222         int aSign = 1;
    223         int bSign = -1;
    224         BigInteger aNumber = new BigInteger(aSign, aBytes);
    225         BigInteger bNumber = new BigInteger(bSign, bBytes);
    226         assertEquals(1, aNumber.compareTo(bNumber));
    227     }
    228 
    229     /**
    230      * compareTo(BigInteger a).
    231      * Compare two numbers of different signs.
    232      * The first is negative.
    233      */
    234     @TestTargetNew(
    235         level = TestLevel.PARTIAL_COMPLETE,
    236         notes = "This is a complete subset of tests for compareTo method.",
    237         method = "compareTo",
    238         args = {java.math.BigInteger.class}
    239     )
    240     public void testCompareToDiffSigns2() {
    241         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    242         byte bBytes[] = {10, 20, 30, 40, 50, 60, 70, 10, 20, 30};
    243         int aSign = -1;
    244         int bSign = 1;
    245         BigInteger aNumber = new BigInteger(aSign, aBytes);
    246         BigInteger bNumber = new BigInteger(bSign, bBytes);
    247         assertEquals(-1, aNumber.compareTo(bNumber));
    248     }
    249 
    250     /**
    251      * compareTo(BigInteger a).
    252      * Compare a positive number to ZERO.
    253      */
    254     @TestTargetNew(
    255         level = TestLevel.PARTIAL_COMPLETE,
    256         notes = "This is a complete subset of tests for compareTo method.",
    257         method = "compareTo",
    258         args = {java.math.BigInteger.class}
    259     )
    260     public void testCompareToPosZero() {
    261         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    262         int aSign = 1;
    263         BigInteger aNumber = new BigInteger(aSign, aBytes);
    264         BigInteger bNumber = BigInteger.ZERO;
    265         assertEquals(1, aNumber.compareTo(bNumber));
    266     }
    267 
    268     /**
    269      * compareTo(BigInteger a).
    270      * Compare ZERO to a positive number.
    271      */
    272     @TestTargetNew(
    273         level = TestLevel.PARTIAL_COMPLETE,
    274         notes = "This is a complete subset of tests for compareTo method.",
    275         method = "compareTo",
    276         args = {java.math.BigInteger.class}
    277     )
    278     public void testCompareToZeroPos() {
    279         byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    280         int bSign = 1;
    281         BigInteger aNumber = BigInteger.ZERO;
    282         BigInteger bNumber = new BigInteger(bSign, bBytes);
    283         assertEquals(-1, aNumber.compareTo(bNumber));
    284     }
    285 
    286     /**
    287      * compareTo(BigInteger a).
    288      * Compare a negative number to ZERO.
    289      */
    290     @TestTargetNew(
    291         level = TestLevel.PARTIAL_COMPLETE,
    292         notes = "This is a complete subset of tests for compareTo method.",
    293         method = "compareTo",
    294         args = {java.math.BigInteger.class}
    295     )
    296     public void testCompareToNegZero() {
    297         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    298         int aSign = -1;
    299         BigInteger aNumber = new BigInteger(aSign, aBytes);
    300         BigInteger bNumber = BigInteger.ZERO;
    301         assertEquals(-1, aNumber.compareTo(bNumber));
    302     }
    303 
    304     /**
    305      * compareTo(BigInteger a).
    306      * Compare ZERO to a negative number.
    307      */
    308     @TestTargetNew(
    309         level = TestLevel.PARTIAL_COMPLETE,
    310         notes = "This is a complete subset of tests for compareTo method.",
    311         method = "compareTo",
    312         args = {java.math.BigInteger.class}
    313     )
    314     public void testCompareToZeroNeg() {
    315         byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    316         int bSign = -1;
    317         BigInteger aNumber = BigInteger.ZERO;
    318         BigInteger bNumber = new BigInteger(bSign, bBytes);
    319         assertEquals(1, aNumber.compareTo(bNumber));
    320     }
    321 
    322     /**
    323      * compareTo(BigInteger a).
    324      * Compare ZERO to ZERO.
    325      */
    326     @TestTargetNew(
    327         level = TestLevel.PARTIAL_COMPLETE,
    328         notes = "This is a complete subset of tests for compareTo method.",
    329         method = "compareTo",
    330         args = {java.math.BigInteger.class}
    331     )
    332     public void testCompareToZeroZero() {
    333         BigInteger aNumber = BigInteger.ZERO;
    334         BigInteger bNumber = BigInteger.ZERO;
    335         assertEquals(0, aNumber.compareTo(bNumber));
    336     }
    337 
    338     /**
    339      * equals(Object obj).
    340      * obj is not a BigInteger
    341      */
    342     @TestTargetNew(
    343         level = TestLevel.PARTIAL_COMPLETE,
    344         notes = "This is a complete subset of tests for equals method.",
    345         method = "equals",
    346         args = {java.lang.Object.class}
    347     )
    348     public void testEqualsObject() {
    349         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    350         int aSign = 1;
    351         BigInteger aNumber = new BigInteger(aSign, aBytes);
    352         Object obj = new Object();
    353         assertFalse(aNumber.equals(obj));
    354     }
    355 
    356     /**
    357      * equals(null).
    358      */
    359     @TestTargetNew(
    360         level = TestLevel.PARTIAL_COMPLETE,
    361         notes = "This is a complete subset of tests for equals method.",
    362         method = "equals",
    363         args = {java.lang.Object.class}
    364     )
    365     public void testEqualsNull() {
    366         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    367         int aSign = 1;
    368         BigInteger aNumber = new BigInteger(aSign, aBytes);
    369         assertFalse(aNumber.equals(null));
    370     }
    371 
    372     /**
    373      * equals(Object obj).
    374      * obj is a BigInteger.
    375      * numbers are equal.
    376      */
    377     @TestTargetNew(
    378         level = TestLevel.PARTIAL_COMPLETE,
    379         notes = "This is a complete subset of tests for equals method.",
    380         method = "equals",
    381         args = {java.lang.Object.class}
    382     )
    383     public void testEqualsBigIntegerTrue() {
    384         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    385         byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    386         int aSign = 1;
    387         int bSign = 1;
    388         BigInteger aNumber = new BigInteger(aSign, aBytes);
    389         Object bNumber = new BigInteger(bSign, bBytes);
    390         assertTrue(aNumber.equals(bNumber));
    391     }
    392 
    393     /**
    394      * equals(Object obj).
    395      * obj is a BigInteger.
    396      * numbers are not equal.
    397      */
    398     @TestTargetNew(
    399         level = TestLevel.PARTIAL_COMPLETE,
    400         notes = "This is a complete subset of tests for equals method.",
    401         method = "equals",
    402         args = {java.lang.Object.class}
    403     )
    404     public void testEqualsBigIntegerFalse() {
    405         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    406         byte bBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
    407         int aSign = 1;
    408         int bSign = 1;
    409         BigInteger aNumber = new BigInteger(aSign, aBytes);
    410         Object bNumber = new BigInteger(bSign, bBytes);
    411         assertFalse(aNumber.equals(bNumber));
    412     }
    413 
    414     /**
    415      * max(BigInteger val).
    416      * the first is greater.
    417      */
    418     @TestTargetNew(
    419         level = TestLevel.PARTIAL_COMPLETE,
    420         notes = "This is a complete subset of tests for max method.",
    421         method = "max",
    422         args = {java.math.BigInteger.class}
    423     )
    424     public void testMaxGreater() {
    425         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    426         byte bBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
    427         int aSign = 1;
    428         int bSign = 1;
    429         byte rBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    430         BigInteger aNumber = new BigInteger(aSign, aBytes);
    431         BigInteger bNumber = new BigInteger(bSign, bBytes);
    432         BigInteger result = aNumber.max(bNumber);
    433         byte resBytes[] = new byte[rBytes.length];
    434         resBytes = result.toByteArray();
    435         for(int i = 0; i < resBytes.length; i++) {
    436             assertTrue(resBytes[i] == rBytes[i]);
    437         }
    438         assertTrue("incorrect sign", result.signum() == 1);
    439     }
    440 
    441     /**
    442      * max(BigInteger val).
    443      * the first is less.
    444      */
    445     @TestTargetNew(
    446         level = TestLevel.PARTIAL_COMPLETE,
    447         notes = "This is a complete subset of tests for max method.",
    448         method = "max",
    449         args = {java.math.BigInteger.class}
    450     )
    451     public void testMaxLess() {
    452         byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
    453         byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    454         int aSign = 1;
    455         int bSign = 1;
    456         byte rBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    457         BigInteger aNumber = new BigInteger(aSign, aBytes);
    458         BigInteger bNumber = new BigInteger(bSign, bBytes);
    459         BigInteger result = aNumber.max(bNumber);
    460         byte resBytes[] = new byte[rBytes.length];
    461         resBytes = result.toByteArray();
    462         for(int i = 0; i < resBytes.length; i++) {
    463             assertTrue(resBytes[i] == rBytes[i]);
    464         }
    465         assertTrue("incorrect sign", result.signum() == 1);
    466     }
    467 
    468     /**
    469      * max(BigInteger val).
    470      * numbers are equal.
    471      */
    472     @TestTargetNew(
    473         level = TestLevel.PARTIAL_COMPLETE,
    474         notes = "This is a complete subset of tests for max method.",
    475         method = "max",
    476         args = {java.math.BigInteger.class}
    477     )
    478     public void testMaxEqual() {
    479         byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
    480         byte bBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
    481         int aSign = 1;
    482         int bSign = 1;
    483         byte rBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
    484         BigInteger aNumber = new BigInteger(aSign, aBytes);
    485         BigInteger bNumber = new BigInteger(bSign, bBytes);
    486         BigInteger result = aNumber.max(bNumber);
    487         byte resBytes[] = new byte[rBytes.length];
    488         resBytes = result.toByteArray();
    489         for(int i = 0; i < resBytes.length; i++) {
    490             assertTrue(resBytes[i] == rBytes[i]);
    491         }
    492         assertEquals("incorrect sign", 1, result.signum());
    493     }
    494 
    495     /**
    496      * max(BigInteger val).
    497      * max of negative and ZERO.
    498      */
    499     @TestTargetNew(
    500         level = TestLevel.PARTIAL_COMPLETE,
    501         notes = "This is a complete subset of tests for max method.",
    502         method = "max",
    503         args = {java.math.BigInteger.class}
    504     )
    505     public void testMaxNegZero() {
    506         byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
    507         int aSign = -1;
    508         byte rBytes[] = {0};
    509         BigInteger aNumber = new BigInteger(aSign, aBytes);
    510         BigInteger bNumber = BigInteger.ZERO;
    511         BigInteger result = aNumber.max(bNumber);
    512         byte resBytes[] = new byte[rBytes.length];
    513         resBytes = result.toByteArray();
    514         for(int i = 0; i < resBytes.length; i++) {
    515             assertTrue(resBytes[i] == rBytes[i]);
    516         }
    517         assertTrue("incorrect sign", result.signum() == 0);
    518     }
    519 
    520     /**
    521      * min(BigInteger val).
    522      * the first is greater.
    523      */
    524     @TestTargetNew(
    525         level = TestLevel.PARTIAL_COMPLETE,
    526         notes = "This is a complete subset of tests for mix method.",
    527         method = "min",
    528         args = {java.math.BigInteger.class}
    529     )
    530     public void testMinGreater() {
    531         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    532         byte bBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
    533         int aSign = 1;
    534         int bSign = 1;
    535         byte rBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
    536         BigInteger aNumber = new BigInteger(aSign, aBytes);
    537         BigInteger bNumber = new BigInteger(bSign, bBytes);
    538         BigInteger result = aNumber.min(bNumber);
    539         byte resBytes[] = new byte[rBytes.length];
    540         resBytes = result.toByteArray();
    541         for(int i = 0; i < resBytes.length; i++) {
    542             assertTrue(resBytes[i] == rBytes[i]);
    543         }
    544         assertEquals("incorrect sign", 1, result.signum());
    545     }
    546 
    547     /**
    548      * min(BigInteger val).
    549      * the first is less.
    550      */
    551     @TestTargetNew(
    552         level = TestLevel.PARTIAL_COMPLETE,
    553         notes = "This is a complete subset of tests for mix method.",
    554         method = "min",
    555         args = {java.math.BigInteger.class}
    556     )
    557     public void testMinLess() {
    558         byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
    559         byte bBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    560         int aSign = 1;
    561         int bSign = 1;
    562         byte rBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
    563         BigInteger aNumber = new BigInteger(aSign, aBytes);
    564         BigInteger bNumber = new BigInteger(bSign, bBytes);
    565         BigInteger result = aNumber.min(bNumber);
    566         byte resBytes[] = new byte[rBytes.length];
    567         resBytes = result.toByteArray();
    568         for(int i = 0; i < resBytes.length; i++) {
    569             assertTrue(resBytes[i] == rBytes[i]);
    570         }
    571         assertEquals("incorrect sign", 1, result.signum());
    572     }
    573 
    574     /**
    575      * min(BigInteger val).
    576      * numbers are equal.
    577      */
    578     @TestTargetNew(
    579         level = TestLevel.PARTIAL_COMPLETE,
    580         notes = "This is a complete subset of tests for mix method.",
    581         method = "min",
    582         args = {java.math.BigInteger.class}
    583     )
    584     public void testMinEqual() {
    585         byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
    586         byte bBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
    587         int aSign = 1;
    588         int bSign = 1;
    589         byte rBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
    590         BigInteger aNumber = new BigInteger(aSign, aBytes);
    591         BigInteger bNumber = new BigInteger(bSign, bBytes);
    592         BigInteger result = aNumber.min(bNumber);
    593         byte resBytes[] = new byte[rBytes.length];
    594         resBytes = result.toByteArray();
    595         for(int i = 0; i < resBytes.length; i++) {
    596             assertTrue(resBytes[i] == rBytes[i]);
    597         }
    598         assertTrue("incorrect sign", result.signum() == 1);
    599     }
    600 
    601     /**
    602      * max(BigInteger val).
    603      * min of positive and ZERO.
    604      */
    605     @TestTargetNew(
    606         level = TestLevel.PARTIAL_COMPLETE,
    607         notes = "This is a complete subset of tests for mix method.",
    608         method = "min",
    609         args = {java.math.BigInteger.class}
    610     )
    611     public void testMinPosZero() {
    612         byte aBytes[] = {45, 91, 3, -15, 35, 26, 3, 91};
    613         int aSign = 1;
    614         byte rBytes[] = {0};
    615         BigInteger aNumber = new BigInteger(aSign, aBytes);
    616         BigInteger bNumber = BigInteger.ZERO;
    617         BigInteger result = aNumber.min(bNumber);
    618         byte resBytes[] = new byte[rBytes.length];
    619         resBytes = result.toByteArray();
    620         for(int i = 0; i < resBytes.length; i++) {
    621             assertTrue(resBytes[i] == rBytes[i]);
    622         }
    623         assertTrue("incorrect sign", result.signum() == 0);
    624     }
    625 
    626     /**
    627      * negate() a positive number.
    628      */
    629     @TestTargetNew(
    630         level = TestLevel.PARTIAL_COMPLETE,
    631         notes = "This is a complete subset of tests for negate method.",
    632         method = "negate",
    633         args = {}
    634     )
    635     public void testNegatePositive() {
    636         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    637         int aSign = 1;
    638         byte rBytes[] = {-13, -57, -101, 1, 75, -90, -46, -92, -4, 14, -36, -27, -4, -91};
    639         BigInteger aNumber = new BigInteger(aSign, aBytes);
    640         BigInteger result = aNumber.negate();
    641         byte resBytes[] = new byte[rBytes.length];
    642         resBytes = result.toByteArray();
    643         for(int i = 0; i < resBytes.length; i++) {
    644             assertTrue(resBytes[i] == rBytes[i]);
    645         }
    646         assertTrue("incorrect sign", result.signum() == -1);
    647     }
    648 
    649     /**
    650      * negate() a negative number.
    651      */
    652     @TestTargetNew(
    653         level = TestLevel.PARTIAL_COMPLETE,
    654         notes = "This is a complete subset of tests for negate method.",
    655         method = "negate",
    656         args = {}
    657     )
    658     public void testNegateNegative() {
    659         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    660         int aSign = -1;
    661         byte rBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    662         BigInteger aNumber = new BigInteger(aSign, aBytes);
    663         BigInteger result = aNumber.negate();
    664         byte resBytes[] = new byte[rBytes.length];
    665         resBytes = result.toByteArray();
    666         for(int i = 0; i < resBytes.length; i++) {
    667             assertTrue(resBytes[i] == rBytes[i]);
    668         }
    669         assertTrue("incorrect sign", result.signum() == 1);
    670     }
    671 
    672     /**
    673      * negate() ZERO.
    674      */
    675     @TestTargetNew(
    676         level = TestLevel.PARTIAL_COMPLETE,
    677         notes = "This is a complete subset of tests for negate method.",
    678         method = "negate",
    679         args = {}
    680     )
    681     public void testNegateZero() {
    682         byte rBytes[] = {0};
    683         BigInteger aNumber = BigInteger.ZERO;
    684         BigInteger result = aNumber.negate();
    685         byte resBytes[] = new byte[rBytes.length];
    686         resBytes = result.toByteArray();
    687         for(int i = 0; i < resBytes.length; i++) {
    688             assertTrue(resBytes[i] == rBytes[i]);
    689         }
    690         assertEquals("incorrect sign", 0, result.signum());
    691     }
    692 
    693     /**
    694      * signum() of a positive number.
    695      */
    696     @TestTargetNew(
    697         level = TestLevel.PARTIAL_COMPLETE,
    698         notes = "This is a complete subset of tests for signum method.",
    699         method = "signum",
    700         args = {}
    701     )
    702     public void testSignumPositive() {
    703         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    704         int aSign = 1;
    705         BigInteger aNumber = new BigInteger(aSign, aBytes);
    706         assertEquals("incorrect sign", 1, aNumber.signum());
    707     }
    708 
    709     /**
    710      * signum() of a negative number.
    711      */
    712     @TestTargetNew(
    713         level = TestLevel.PARTIAL_COMPLETE,
    714         notes = "This is a complete subset of tests for signum method.",
    715         method = "signum",
    716         args = {}
    717     )
    718     public void testSignumNegative() {
    719         byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91};
    720         int aSign = -1;
    721         BigInteger aNumber = new BigInteger(aSign, aBytes);
    722         assertEquals("incorrect sign", -1, aNumber.signum());
    723     }
    724 
    725     /**
    726      * signum() of ZERO.
    727      */
    728     @TestTargetNew(
    729         level = TestLevel.PARTIAL_COMPLETE,
    730         notes = "This is a complete subset of tests for signum method.",
    731         method = "signum",
    732         args = {}
    733     )
    734     public void testSignumZero() {
    735         BigInteger aNumber = BigInteger.ZERO;
    736         assertEquals("incorrect sign", 0, aNumber.signum());
    737     }
    738 }
    739