def test_compact(self): ''' Test that the bit array is compacted correctly ''' array = BitArray() array.flip(127) self.assertEqual(128, array.length_of_bits) array.flip(127) self.assertEqual(0, array.length_of_bits)
def test_flip(self): ''' Test that the flip bit operation is correct ''' barray = BitArray(array=[0xEC]) for pos in [0, 1, 4]: barray.flip(pos) self.assertEqual([0xFF], barray.to_byte_list()) barray = BitArray(array=[0xFF]) for pos in [0, 1, 4]: barray.flip(pos) self.assertEqual([0xEC], barray.to_byte_list())