@@ -0,0 +1,857 @@
+# -*- encoding: utf-8 -*-%0Afrom datetime import datetime%0Afrom decimal import Decimal%0Atry:%0A    import unittest2 as unittest%0Aexcept ImportError:%0A    import unittest%0A%0Afrom pamqp import encode, decode%0Afrom pamqp import PYTHON3%0A%0Aif PYTHON3:%0A    long = int%0A%0A%0Adef to_bytes(value):%0A    if isinstance(value, bytes):%0A        return bytes%0A    if PYTHON3:%0A        return bytes(value, 'utf-8')%0A    return bytes(value)%0A%0A%0Aclass EncodeDecodeTests(unittest.TestCase):%0A%0A    def test_encode_decode_field_table_long_keys(self):%0A        %22%22%22 Encoding and decoding a field_table with too long keys.%0A        %22%22%22%0A        # second key is 126 A's + %5CN%7BPILE OF POO%7D%0A        data = %7B'A' * 256: 1,%0A                (b'A' * 126) + b'%5Cxf0%5Cx9f%5Cx92%5Cxa9': 2%7D%0A        encoded = encode.field_table(data)%0A        decoded = decode.field_table(encoded)%5B1%5D%0A        self.assertIn(b'A' * 128, decoded)%0A

test encode - decode of truncated utf-8 data