forked from mjpieters/rtfunicode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
35 lines (25 loc) · 1.04 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import string
import unittest
class RTFUnicodeTests(unittest.TestCase):
def setUp(self):
import rtfunicode # auto-registers
rtfunicode # pyflakes needn't worry
def _compare(self, in_, out):
self.assertEqual(in_.encode('rtfunicode'), out)
def testPlainASCII(self):
ascii = string.ascii_letters + string.digits
self._compare(ascii, ascii.encode())
def testRTFControlCodes(self):
self._compare('\\{}', b'\\u92?\\u123?\\u125?')
def testLatin1(self):
self._compare('\xe0\xeb', b'\\u224?\\u235?')
def testBMP(self):
self._compare('\u0123\u8123', b'\\u291?\\u-32477?')
def testBeyondBMP(self):
# RTF 1.9.1 (Word 2007), page 115 states that surrogate pairs are
# supported in math text-run groups; experimentation with Word shows
# they can exist outside of these too.
testChar = '\U00010196'
self._compare(testChar, b'\\u-10240?\\u-8810?')
def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__)