Ejemplo n.º 1
0
 def test_GetBits4(self):
     bb = BitBucket()
     inp = [0xd, 0xd, 0xd, 0xd]
     for offset in xrange(16):
         bb.Clear()
         StoreBitsFromString(bb, "1" * offset + "|11011101|11011101 [0]")
         for i in xrange(offset):
             bb.GetBit()
         for i in xrange(len(inp)):
             assert bb.GetBits4() == inp[i]
Ejemplo n.º 2
0
 def test_GetBits8(self):
     bb = BitBucket()
     inp = [0xdd, 0xee, 0xaa, 0xdd]
     bitstr = "|11011101|11101110|10101010|11011101 [0]"
     for offset in xrange(16):
         bb.Clear()
         StoreBitsFromString(bb, ("1" * offset) + bitstr)
         for i in xrange(offset):
             bb.GetBit()
         for i in xrange(len(inp)):
             assert bb.GetBits8() == inp[i]
Ejemplo n.º 3
0
 def test_AdvanceReadPtrToByteBoundary(self):
     bb = BitBucket()
     for offset in xrange(16):
         bb.Clear()
         StoreBitsFromString(bb, "1" * 32)
         for i in xrange(offset):
             bb.GetBit()
         old_idx_byte = bb.idx_byte
         old_idx_boff = bb.idx_boff
         assert bb.idx_byte == offset / 8
         assert bb.idx_boff == offset % 8
         bb.AdvanceReadPtrToByteBoundary()
         if old_idx_boff == 0:
             assert bb.idx_boff == old_idx_boff
             assert bb.idx_byte == old_idx_byte
         else:
             assert bb.idx_boff == 0
             assert bb.idx_byte == (old_idx_byte + 1)