1   package com.generationjava.lang;
2   
3   import junit.framework.Test;
4   import junit.framework.TestCase;
5   import junit.framework.TestSuite;
6   import junit.textui.TestRunner;
7   
8   import java.math.BigInteger;
9   
10  public class BigIntegerUtilsTest extends TestCase {
11  
12      public BigIntegerUtilsTest(String name) {
13          super(name);
14      }
15  
16      //-----------------------------------------------------------------------
17      private BigInteger bi = BigInteger.valueOf(25L);   // 11001
18  
19      // need to test extractInt extractBoolean extractFloat
20      public void testExtractInt() {
21          assertEquals("11001[2,4]=2 failure", 2, BigIntegerUtils.extractInt(bi, 2, 4) );
22      }
23  
24      public void testExtractFloat() {
25          assertEquals("11001[0,4:2.2]= failure", 2.1F, BigIntegerUtils.extractFloat(bi, 0, 4, 2), 0 );
26      }
27  
28      public void testExtractBoolean() {
29          assertEquals("11001[0]=true failure", true, BigIntegerUtils.extractBoolean(bi, 0) );
30          assertEquals("11001[1]=false failure", false, BigIntegerUtils.extractBoolean(bi, 1) );
31          assertEquals("11001[2]=false failure", false, BigIntegerUtils.extractBoolean(bi, 2) );
32          assertEquals("11001[3]=true failure", true, BigIntegerUtils.extractBoolean(bi, 3) );
33          assertEquals("11001[4]=true failure", true, BigIntegerUtils.extractBoolean(bi, 4) );
34      }
35  
36  }