示例#1
0
    def test_encode_string_literal(self):
        encoded = ed.encode_string_literal("test")
        self.assertEqual(encoded, b'\x04test')

        longstring = 'a'*4096
        encoded = ed.encode_string_literal(longstring)
        self.assertEqual(encoded, b'\x7f\x81\x1f' + longstring.encode('ascii'))
示例#2
0
    def test_encode_string_literal_huffman(self):
        encoded = ed.encode_string_literal("test", True)
        self.assertEqual(encoded, b'\x83\x49\x50\x9f')

        longstring = 'a'*4096
        longstring_encoded = b'\x18\xc6\x31\x8c\x63' * (4096//8)
        encoded = ed.encode_string_literal(longstring, True)
        self.assertEqual(encoded, b'\xff\x81\x13' + longstring_encoded)