Beispiel #1
0
    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)
Beispiel #2
0
    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))
Beispiel #3
0
    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)
Beispiel #4
0
    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)
Beispiel #5
0
    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 )