Beispiel #1
0
 def test_compression(self):
     """
     Test compression types compressed and uncompressed
     """
     data = '{\\rtf1\\ansi\\ansicpg1252\\pard hello world}\r\n'
     self.assertEqual(
         compress(data, compressed=True),
         '-\x00\x00\x00+\x00\x00\x00LZFu\xf1\xc5\xc7\xa7\x03\x00\n\x00'
         'rcpg125B2\n\xf3 hel\t\x00 bw\x05\xb0ld}\n\x80\x0f\xa0')
     # test uncompressed
     self.assertEqual(
         compress(data, compressed=False),
         '7\x00\x00\x00+\x00\x00\x00MELA\x03\xa3n}{\\rtf1\\ansi\\ansicpg'
         '1252\\pard hello world}\r\n')
Beispiel #2
0
 def test_compression(self):
     """
     Test compression types compressed and uncompressed
     """
     data = '{\\rtf1\\ansi\\ansicpg1252\\pard hello world}\r\n'
     self.assertEqual(
         compress(data, compressed=True),
         '-\x00\x00\x00+\x00\x00\x00LZFu\xf1\xc5\xc7\xa7\x03\x00\n\x00'
         'rcpg125B2\n\xf3 hel\t\x00 bw\x05\xb0ld}\n\x80\x0f\xa0')
     # test uncompressed
     self.assertEqual(
         compress(data, compressed=False),
         '7\x00\x00\x00+\x00\x00\x00MELA\x03\xa3n}{\\rtf1\\ansi\\ansicpg'
         '1252\\pard hello world}\r\n')
Beispiel #3
0
 def test_compression_repeated_tokens(self):
     """
     Test compression of data with repeated tokens, crossing write position
     """
     data = '{\\rtf1 WXYZWXYZWXYZWXYZWXYZ}'
     self.assertEqual(
         compress(data),
         '\x1a\x00\x00\x00\x1c\x00\x00\x00LZFu\xe2\xd4KQA\x00\x04 WXYZ\r'
         'n}\x01\x0e\xb0')
Beispiel #4
0
 def test_compression_repeated_tokens(self):
     """
     Test compression of data with repeated tokens, crossing write position
     """
     data = '{\\rtf1 WXYZWXYZWXYZWXYZWXYZ}'
     self.assertEqual(
         compress(data),
         '\x1a\x00\x00\x00\x1c\x00\x00\x00LZFu\xe2\xd4KQA\x00\x04 WXYZ\r'
         'n}\x01\x0e\xb0')
Beispiel #5
0
 def test_hither_and_thither_long(self):
     """
     Test decompression of compressed data larger than 4096
     """
     data = '{\\rtf1\\ansi\\ansicpg1252\\pard hello world'
     while len(data) < 4096:
         data += "testtest"
     data += "}"
     self.assertEqual(decompress(compress(data, compressed=True)), data)
Beispiel #6
0
 def test_hither_and_thither(self):
     """
     Test decompression of compressed data
     """
     data = '{\\rtf1\\ansi\\mac\\deff0\\deftab720'
     self.assertEqual(decompress(compress(data, compressed=True)), data)
Beispiel #7
0
 def test_hither_and_thither(self):
     """
     Test decompression of compressed data
     """
     data = '{\\rtf1\\ansi\\mac\\deff0\\deftab720'
     self.assertEqual(decompress(compress(data, compressed=True)), data)