Esempio n. 1
0
 def test_create_code(self):
     freqlist = cnt_freq("test1.txt")
     hufftree = create_huff_tree(freqlist)
     codes = create_code(hufftree)
     self.assertEqual(codes[ord('d')], '1')
     self.assertEqual(codes[ord('a')], '0000')
     self.assertEqual(codes[ord('f')], '0001')
Esempio n. 2
0
 def test_create_code3(self):
     freqlist = cnt_freq("test3.txt")
     hufftree = create_huff_tree(freqlist)
     codes = create_code(hufftree)
     self.assertEqual(codes[ord('s')], '111')
     self.assertEqual(codes[ord('t')], '00')
     self.assertEqual(codes[ord('\n')], '10010')
     self.assertEqual(codes[ord(' ')], '101')
Esempio n. 3
0
 def test_create_code2(self):
     freqlist = cnt_freq("test2.txt")
     hufftree = create_huff_tree(freqlist)
     codes = create_code(hufftree)
     self.assertEqual(codes[ord('g')], '00')
     self.assertEqual(codes[ord('o')], '01')
     self.assertEqual(codes[ord('\n')], '1000')
     self.assertEqual(codes[ord(' ')], '101')
 def test_create_code3(self):
     freqlist = cnt_freq("file3.txt")
     hufftree = create_huff_tree(freqlist)
     codes = create_code(hufftree)
     print('s', codes[ord('s')])
     print('t', codes[ord('t')])
     print('a', codes[ord('a')])
     self.assertEqual(codes[ord('s')], '111')
     self.assertEqual(codes[ord('t')], '00')
     self.assertEqual(codes[ord('a')], '010')
 def test_create_code2(self):
     freqlist = cnt_freq("file2.txt")
     hufftree = create_huff_tree(freqlist)
     codes = create_code(hufftree)
     print('g', codes[ord('g')])
     print('o', codes[ord('o')])
     print(' ', codes[ord(' ')])
     self.assertEqual(codes[ord('g')], '00')
     self.assertEqual(codes[ord('o')], '01')
     self.assertEqual(codes[ord(' ')], '101')
 def test_create_code(self):
     freqlist = cnt_freq("file1.txt")
     hufftree = create_huff_tree(freqlist)
     codes = create_code(hufftree)
     print('d', codes[ord('d')])
     print('a', codes[ord('a')])
     print('f', codes[ord('f')])
     self.assertEqual(codes[ord('d')], '0')
     self.assertEqual(codes[ord('a')], '11111')
     self.assertEqual(codes[ord('f')], '1110')
Esempio n. 7
0
 def test_create_code_1(self):
     freq_list = cnt_freq("test1.txt")
     huff_tree = create_huff_tree(freq_list)
     code = create_code(huff_tree)
     print("d", code[ord("d")])
     print("s", code[ord("s")])
     print("l", code[ord("l")])
     self.assertEqual(code[ord('d')], '11011')
     self.assertEqual(code[ord('s')], '00')
     self.assertEqual(code[ord('l')], '1001')
Esempio n. 8
0
 def test_create_code3(self):
     freqlist = cnt_freq("test3.txt")
     hufftree = create_huff_tree(freqlist)
     codes = create_code(hufftree)