diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/__init__.py | 1 | ||||
-rw-r--r-- | tests/test_pdfstring.py | 37 |
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..218d892 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +# This file intentionally left blank. diff --git a/tests/test_pdfstring.py b/tests/test_pdfstring.py new file mode 100644 index 0000000..4dcd2df --- /dev/null +++ b/tests/test_pdfstring.py @@ -0,0 +1,37 @@ +''' +Run from the directory above like so: +python -m tests.test_pdfstring +''' + + +import pdfrw +import unittest + + +class TestEncoding(unittest.TestCase): + + @staticmethod + def decode(value): + return pdfrw.pdfobjects.PdfString(value).decode() + + @staticmethod + def encode(value): + return str(pdfrw.pdfobjects.PdfString.encode(value)) + + @classmethod + def encode_decode(cls, value): + return cls.decode(cls.encode(value)) + + def roundtrip(self, value): + self.assertEqual(value, self.encode_decode(value)) + + def test_doubleslash(self): + self.roundtrip('\\') + + +def main(): + unittest.main() + + +if __name__ == '__main__': + main() |