Code example for BitSet

Methods: clear, toString

0
     * @tests java.util.BitSet#toString() 
     */ 
    public void test_toString() { 
        // Test for method java.lang.String java.util.BitSet.toString() 
        assertEquals("Returned incorrect string representation",
                     "{0, 1, 2, 3, 4, 5, 6, 7}", eightbs.toString());
        eightbs.clear(2);
        assertEquals("Returned incorrect string representation",
                     "{0, 1, 3, 4, 5, 6, 7}", eightbs.toString());
    } 
 
    /** 
     * @tests java.util.BitSet#length() 
     */ 
    public void test_length() { 
        BitSet bs = new BitSet();
        assertEquals("BitSet returned wrong length", 0, bs.length());
        bs.set(5);
        assertEquals("BitSet returned wrong length", 6, bs.length());
        bs.set(10);
        assertEquals("BitSet returned wrong length", 11, bs.length());