Beispiel #1
0
 def test_bitset_count_unset_bits(self):
     b = BitSet(65535)
     b.bitset_set(1000)
     assert b.bitset_count_set_bits() == 1
     assert b.bitset_count_unset_bits() == 65534
     b.bitset_set_range(start=65000, end=65100)
     assert b.bitset_count_set_bits() == 102
     assert b.bitset_count_unset_bits() == 65433
Beispiel #2
0
    def test_bitset_set_unset_and_if_bitset_set(self):
        b = BitSet(8)
        b.bitset_set(1)
        b.bitset_set(7)
        assert b.bitset_as_string() == "A"
        b.bitset_set(6)
        assert b.bitset_as_string() == "C"

        assert b.bitset_is_set(6) is True
        b.bitset_unset(6)
        assert b.bitset_as_string() == "A"

        assert b.bitset_is_set(6) is False
        assert b.bitset_is_set(2) is False
Beispiel #3
0
 def test_bitset_valid_initialization(self):
     b = BitSet(255)
     assert b.size() == 255
     bs = b.bitset_as_string()
     # ugly mangling to get to byte_size and not recalculate
     assert bs == (chr(0) * b._BitSet__byte_size)
Beispiel #4
0
 def test_bitset_unset_out_of_bounds(self):
     b = BitSet(1)
     b.bitset_unset(2)
Beispiel #5
0
 def inner(instance):
     b = BitSet(len(initString) * 8)
     # ugly mangling to get set the "private" member.
     b._BitSet__bitset = bytearray(initString)
     func(instance, b)