Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # test_codecencodings_kr.py |
| 4 | # Codec encoding tests for ROK encodings. |
| 5 | # |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 6 | |
| 7 | from test import test_support |
| 8 | from test import test_multibytecodec_support |
| 9 | import unittest |
| 10 | |
| 11 | class Test_CP949(test_multibytecodec_support.TestBase, unittest.TestCase): |
| 12 | encoding = 'cp949' |
| 13 | tstring = test_multibytecodec_support.load_teststring('cp949') |
| 14 | codectests = ( |
| 15 | # invalid bytes |
| 16 | ("abc\x80\x80\xc1\xc4", "strict", None), |
| 17 | ("abc\xc8", "strict", None), |
| 18 | ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\uc894"), |
| 19 | ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\uc894\ufffd"), |
| 20 | ("abc\x80\x80\xc1\xc4", "ignore", u"abc\uc894"), |
| 21 | ) |
| 22 | |
| 23 | class Test_EUCKR(test_multibytecodec_support.TestBase, unittest.TestCase): |
| 24 | encoding = 'euc_kr' |
| 25 | tstring = test_multibytecodec_support.load_teststring('euc_kr') |
| 26 | codectests = ( |
| 27 | # invalid bytes |
| 28 | ("abc\x80\x80\xc1\xc4", "strict", None), |
| 29 | ("abc\xc8", "strict", None), |
| 30 | ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\uc894"), |
| 31 | ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\uc894\ufffd"), |
| 32 | ("abc\x80\x80\xc1\xc4", "ignore", u"abc\uc894"), |
Hye-Shik Chang | 2390104 | 2007-08-20 06:49:18 +0000 | [diff] [blame] | 33 | |
| 34 | # composed make-up sequence errors |
| 35 | ("\xa4\xd4", "strict", None), |
| 36 | ("\xa4\xd4\xa4", "strict", None), |
| 37 | ("\xa4\xd4\xa4\xb6", "strict", None), |
| 38 | ("\xa4\xd4\xa4\xb6\xa4", "strict", None), |
| 39 | ("\xa4\xd4\xa4\xb6\xa4\xd0", "strict", None), |
| 40 | ("\xa4\xd4\xa4\xb6\xa4\xd0\xa4", "strict", None), |
| 41 | ("\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xd4", "strict", u"\uc4d4"), |
| 42 | ("\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xd4x", "strict", u"\uc4d4x"), |
| 43 | ("a\xa4\xd4\xa4\xb6\xa4", "replace", u"a\ufffd"), |
| 44 | ("\xa4\xd4\xa3\xb6\xa4\xd0\xa4\xd4", "strict", None), |
| 45 | ("\xa4\xd4\xa4\xb6\xa3\xd0\xa4\xd4", "strict", None), |
| 46 | ("\xa4\xd4\xa4\xb6\xa4\xd0\xa3\xd4", "strict", None), |
| 47 | ("\xa4\xd4\xa4\xff\xa4\xd0\xa4\xd4", "replace", u"\ufffd"), |
| 48 | ("\xa4\xd4\xa4\xb6\xa4\xff\xa4\xd4", "replace", u"\ufffd"), |
| 49 | ("\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xff", "replace", u"\ufffd"), |
| 50 | ("\xc1\xc4", "strict", u"\uc894"), |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 51 | ) |
| 52 | |
| 53 | class Test_JOHAB(test_multibytecodec_support.TestBase, unittest.TestCase): |
| 54 | encoding = 'johab' |
| 55 | tstring = test_multibytecodec_support.load_teststring('johab') |
| 56 | codectests = ( |
| 57 | # invalid bytes |
| 58 | ("abc\x80\x80\xc1\xc4", "strict", None), |
| 59 | ("abc\xc8", "strict", None), |
| 60 | ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\ucd27"), |
| 61 | ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\ucd27\ufffd"), |
| 62 | ("abc\x80\x80\xc1\xc4", "ignore", u"abc\ucd27"), |
| 63 | ) |
| 64 | |
| 65 | def test_main(): |
Collin Winter | c2898c5 | 2007-04-25 17:29:52 +0000 | [diff] [blame] | 66 | test_support.run_unittest(__name__) |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 67 | |
| 68 | if __name__ == "__main__": |
| 69 | test_main() |