From b7780f7bfb4e6bb922e25fd2334dcc6ba9cd71b9 Mon Sep 17 00:00:00 2001 From: Alvin Wong Date: Sat, 20 Mar 2021 15:37:19 +0800 Subject: [PATCH] Add font encoding test --- Translations/make_translation_test.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Translations/make_translation_test.py diff --git a/Translations/make_translation_test.py b/Translations/make_translation_test.py new file mode 100644 index 00000000..5cae449a --- /dev/null +++ b/Translations/make_translation_test.py @@ -0,0 +1,21 @@ +import unittest + + +class TestMakeTranslation(unittest.TestCase): + def test_getCharsFromFontIndex(self): + from make_translation import getCharsFromFontIndex + self.assertEqual(getCharsFromFontIndex(2), "\\x02") + self.assertEqual(getCharsFromFontIndex(239), "\\xEF") + self.assertEqual(getCharsFromFontIndex(240), "\\xF0") + self.assertEqual(getCharsFromFontIndex(241), "\\xF1\\x01") + self.assertEqual(getCharsFromFontIndex(495), "\\xF1\\xFF") + self.assertEqual(getCharsFromFontIndex(496), "\\xF2\\x01") + self.assertEqual(getCharsFromFontIndex(750), "\\xF2\\xFF") + self.assertEqual(getCharsFromFontIndex(751), "\\xF3\\x01") + self.assertEqual(getCharsFromFontIndex(0x10 * 0xFF - 15), "\\xFF\\xFF") + with self.assertRaises(AssertionError): + getCharsFromFontIndex(0x10 * 0xFF - 14) + + +if __name__ == '__main__': + unittest.main()