/*
 * Created on May 12, 2004
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */

package org.codehaus.activemq.util;
import junit.framework.TestCase;

/**
 * BitArrayBinTest
 */
public class BitArrayBinTest extends TestCase {
    public static void main(String[] args) {
    }

    /*
     * @see TestCase#setUp()
     */
    protected void setUp() throws Exception {
        super.setUp();
    }

    /*
     * @see TestCase#tearDown()
     */
    protected void tearDown() throws Exception {
        super.tearDown();
    }

    /**
     * Constructor for BitArrayBinTest.
     * 
     * @param arg0
     */
    public BitArrayBinTest(String arg0) {
        super(arg0);
    }

    public void testSetBitGetBitInRange() {
        int count = 100;
        BitArrayBin ba = new BitArrayBin(100);
        for (long i = 0;i < count;i++) {
            if (i % 2 == 0) {
                assertTrue(!ba.setBit(i, true));
            }
        }
        for (int i = 0;i < count;i++) {
            boolean flag = i % 2 == 0;
            assertTrue(ba.getBit(i) == flag);
        }
    }

    public void testSetBitGetBit() {
        long count = 10000;
        long start = Integer.MAX_VALUE;
        BitArrayBin ba = new BitArrayBin(10);
        for (long i = start;i < count;i++) {
            assertTrue(!ba.setBit(i, true));
        }
        for (long i = Integer.MAX_VALUE - 10;i < count;i++) {
            assertTrue(ba.getBit(i));
        }
    }
}
