import unittest
from HuffmanCoding.src.HuffmanCoding import HuffmanCoding
from HuffmanCoding.src.freq_dicts import freq_eng

class HuffmanCodingTest(unittest.TestCase):
    def test_A(self):
        hc = HuffmanCoding(default_freq_dict=freq_eng)
        encoded = hc.encode('AAABBBBBDDFFPPQQQWPPPQQQWWWWWWWWWWWWWWWKKKKKKJJGGGMMO')
        self.assertEqual(encoded, '010101111111111111111111111111110110111001100100010001111000111100011110001101100010001000111100011110001111000110111011101110111011101110111011101110111011101110111011101111101111101111101111101111101111101111100111110011001100110011110111000')

    def test_B(self):
        hc = HuffmanCoding(default_freq_dict=None)
        encoded = hc.encode('AAABBBBBDDFFPPQQQWPPPQQQWWWWWWWWWWWWWWWKKKKKKJJGGGMMO')
        self.assertEqual(encoded, '00010001000110111011101110111011010110101110100101000010011001001001100100100110010010011111111111111111111111111111101101101101101101110101101010100010001000000000001010')

    def test_C(self):
        hc = HuffmanCoding(default_freq_dict=None)
        encoded = hc.encode('sacra ignis Inquisitionis devorabit vos')
        self.assertEqual(encoded, '1001011001100110101100011101001110011110000000100110001010010111111001110111111110111001111000000011101000101011010110101100101111011100010101101100')

    def test_D(self):
        hc = HuffmanCoding(default_freq_dict=None)
        encoded = hc.encode('Лорем ипсум долор сит амет, харум медиоцритатем еа дуо, нобис хомеро аудиам не дуо.')
        self.assertEqual(encoded, '111111101010001110001110101100010011110100100111001110100000010101000110111101011011011010100011110011011111011000011101010001001001110001111001111011010000101100010110110101001101110001110111010101100111100101011111011000001010000000101111110110000110100011110100001011010101001011110111010001110000011110110011110010101111110')

if __name__ == '__main__':
    unittest.main()
