Ejemplo n.º 1
0
    def test_generate_path_leaves(self):
        data = open(DATA, 'rb').read()
        nodes, bits = PathTree._unpack_data(data)
        ret = PathTree._generate_path_leaves(GhettoBitStream(bits))

        self.assertEqual(len(ret), 4)
        for node in ret:
            self.assertTrue(isinstance(node, HuffmanNode))
Ejemplo n.º 2
0
    def test_generate_path_leaves(self):
        data = open(DATA).read()
        nodes, bits = PathTree._unpack_data(data)
        ret = PathTree._generate_path_leaves(GhettoBitStream(bits))

        self.assertEqual(len(ret), 4)
        for node in ret:
            self.assertTrue(isinstance(node, HuffmanNode))
Ejemplo n.º 3
0
 def test_unpack_data(self):
     data = open(DATA, 'rb').read()
     nodes, bits = PathTree._unpack_data(data)
     self.assertEqual(len(nodes), 6)
     # first node always gets weight of 1
     self.assertEqual(nodes[0].weight, 1)
     self.assertEqual(nodes[0].value, 'never')
     self.assertEqual(nodes[5].weight, 6)
     self.assertEqual(nodes[5].value, '')
     self.assertEqual(len(bits), 6)
Ejemplo n.º 4
0
 def test_unpack_data(self):
     data = open(DATA).read()
     nodes, bits = PathTree._unpack_data(data)
     self.assertEqual(len(nodes), 6)
     # first node always gets weight of 1
     self.assertEqual(nodes[0].weight, 1)
     self.assertEqual(nodes[0].value, 'never')
     self.assertEqual(nodes[5].weight, 6)
     self.assertEqual(nodes[5].value, '')
     self.assertEqual(len(bits), 6)