Exemple #1
0
    def test_hello_world(self):
        plain_text = 'hello, world'

        encoding_table = get_tunstall_table(plain_text, 5)
        code = encode(plain_text, encoding_table)
        restored = decode(code, encoding_table)

        self.assertEqual(restored, plain_text)
Exemple #2
0
    def test_hello_world(self):
        plain_text = "hello world"

        table = get_huffman_table(plain_text)
        code = ''.join(list(encode(plain_text, table)))
        restored = decode(code, table)

        self.assertEqual(plain_text, restored)
    def test_hello_world(self):
        plain_text = "hello world"

        encoding_table = get_shannon_fano_table(plain_text)
        code = ''.join(list(encode(plain_text, encoding_table)))
        restored = decode(code, encoding_table)

        self.assertEqual(plain_text, restored)
Exemple #4
0
    def test_data_driven(self, plain_text):
        encoding_table = get_tunstall_table(plain_text, 3)
        code = encode(plain_text, encoding_table)
        restored = decode(code, encoding_table)

        self.assertEqual(plain_text, restored)
Exemple #5
0
    def test_data_driven(self, plain_text):
        encoding_table = get_huffman_table(plain_text)
        code = ''.join(list(encode(plain_text, encoding_table)))
        restored = decode(code, encoding_table)

        self.assertEqual(plain_text, restored)