def test_bitlab_bits(self): self.assertEqual( len(list(bitlab.bits(b'ABC'))), 24 ) bits = bitlab.bits(b'A') self.assertEqual( bitlab.cast(bits,5), 8) self.assertEqual( bitlab.cast(bits,3), 1)
def test_huff_tree(self): huff = huffman.HuffTree() book = huff.initCodeBook((3, 3, 3, 3, 3, 2, 4, 4)) huff.loadCodeBook(book) bits = bitlab.bits(b'\xef') syms = tuple(huff.iterHuffSyms(bits))
def test_bitlab_bits(self): self.assertEqual( len(list(bitlab.bits(b'ABC'))), 24 ) bits = bitlab.BitStream(b'A', order='big') self.assertEqual( bits.cast(5), 8) self.assertEqual( bits.cast(3), 1) bits = bitlab.BitStream(b'A', order='little') self.assertEqual( bits.cast(5), 16) self.assertEqual( bits.cast(3), 2)
def test_bitlab_bits(self): self.assertEqual(len(list(bitlab.bits(b'ABC'))), 24) bits = bitlab.BitStream(b'A', order='big') self.assertEqual(bits.cast(5), 8) self.assertEqual(bits.cast(3), 1) bits = bitlab.BitStream(b'A', order='little') self.assertEqual(bits.cast(5), 16) self.assertEqual(bits.cast(3), 2)
def test_huff_tree(self): huff = huffman.HuffTree() book = huff.initCodeBook( (3, 3, 3, 3, 3, 2, 4, 4) ) huff.loadCodeBook(book) bits = bitlab.bits( b'\xef' ) syms = tuple( huff.iterHuffSyms( bits ) ) # self.assertEqual( tuple(book), huffbook ) # self.assertEqual( tuple(syms), huffsyms )