BitArrayBinTest xref

    1   /*
    2    * Created on May 12, 2004
    3    *
    4    * To change the template for this generated file go to
    5    * Window - Preferences - Java - Code Generation - Code and Comments
    6    */
    7
    8   package org.codehaus.activemq.util;
    9   import junit.framework.TestCase;
    10
    11  /***
    12   * BitArrayBinTest
    13   */
    14  public class BitArrayBinTest extends TestCase {
    15      public static void main(String[] args) {
    16      }
    17
    18      /*
    19       * @see TestCase#setUp()
    20       */
    21      protected void setUp() throws Exception {
    22          super.setUp();
    23      }
    24
    25      /*
    26       * @see TestCase#tearDown()
    27       */
    28      protected void tearDown() throws Exception {
    29          super.tearDown();
    30      }
    31
    32      /***
    33       * Constructor for BitArrayBinTest.
    34       *
    35       * @param arg0
    36       */
    37      public BitArrayBinTest(String arg0) {
    38          super(arg0);
    39      }
    40
    41      public void testSetBitGetBitInRange() {
    42          int count = 100;
    43          BitArrayBin ba = new BitArrayBin(100);
    44          for (long i = 0;i < count;i++) {
    45              if (i % 2 == 0) {
    46                  assertTrue(!ba.setBit(i, true));
    47              }
    48          }
    49          for (int i = 0;i < count;i++) {
    50              boolean flag = i % 2 == 0;
    51              assertTrue(ba.getBit(i) == flag);
    52          }
    53      }
    54
    55      public void testSetBitGetBit() {
    56          long count = 10000;
    57          long start = Integer.MAX_VALUE;
    58          BitArrayBin ba = new BitArrayBin(10);
    59          for (long i = start;i < count;i++) {
    60              assertTrue(!ba.setBit(i, true));
    61          }
    62          for (long i = Integer.MAX_VALUE - 10;i < count;i++) {
    63              assertTrue(ba.getBit(i));
    64          }
    65      }
    66  }