Code example for BigInteger

Methods: intValue, toString

0
    /** 
     * @tests java.math.BigInteger#BigInteger(java.lang.String) 
     */ 
    public void test_ConstrString1() { 
        String s = "0";
        BigInteger bi_s = new BigInteger(s);
        assertTrue("the BigInteger value is not initialized properly", bi_s.intValue() == 0);
        assertEquals("the BigInteger value is not initialized properly", bi_s.toString(), s);
    } 
 
    /** 
     * @tests java.math.BigInteger#BigInteger(java.lang.String) 
     */ 
    public void test_ConstrString2() { 
        String s = "-2147483648";
        BigInteger bi_s = new BigInteger(s);
        assertTrue("the BigInteger value is not initialized properly",
                bi_s.intValue() == Integer.MIN_VALUE);
        assertEquals("the BigInteger value is not initialized properly", bi_s.toString(), s);
    }