Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 1 | # |
| 2 | # test_codecencodings_kr.py |
| 3 | # Codec encoding tests for ROK encodings. |
| 4 | # |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 5 | |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 6 | from test import support |
R David Murray | 75d9aca | 2012-04-09 09:37:52 -0400 | [diff] [blame] | 7 | from test import multibytecodec_support |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 8 | import unittest |
| 9 | |
R David Murray | 75d9aca | 2012-04-09 09:37:52 -0400 | [diff] [blame] | 10 | class Test_CP949(multibytecodec_support.TestBase, unittest.TestCase): |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 11 | encoding = 'cp949' |
R David Murray | 75d9aca | 2012-04-09 09:37:52 -0400 | [diff] [blame] | 12 | tstring = multibytecodec_support.load_teststring('cp949') |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 13 | codectests = ( |
| 14 | # invalid bytes |
Guido van Rossum | 024da5c | 2007-05-17 23:59:11 +0000 | [diff] [blame] | 15 | (b"abc\x80\x80\xc1\xc4", "strict", None), |
| 16 | (b"abc\xc8", "strict", None), |
Victor Stinner | 2cded9c | 2011-07-08 01:45:13 +0200 | [diff] [blame] | 17 | (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\ufffd\uc894"), |
| 18 | (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\ufffd\uc894\ufffd"), |
Guido van Rossum | 024da5c | 2007-05-17 23:59:11 +0000 | [diff] [blame] | 19 | (b"abc\x80\x80\xc1\xc4", "ignore", "abc\uc894"), |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 20 | ) |
| 21 | |
R David Murray | 75d9aca | 2012-04-09 09:37:52 -0400 | [diff] [blame] | 22 | class Test_EUCKR(multibytecodec_support.TestBase, unittest.TestCase): |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 23 | encoding = 'euc_kr' |
R David Murray | 75d9aca | 2012-04-09 09:37:52 -0400 | [diff] [blame] | 24 | tstring = multibytecodec_support.load_teststring('euc_kr') |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 25 | codectests = ( |
| 26 | # invalid bytes |
Guido van Rossum | 024da5c | 2007-05-17 23:59:11 +0000 | [diff] [blame] | 27 | (b"abc\x80\x80\xc1\xc4", "strict", None), |
| 28 | (b"abc\xc8", "strict", None), |
Victor Stinner | 2cded9c | 2011-07-08 01:45:13 +0200 | [diff] [blame] | 29 | (b"abc\x80\x80\xc1\xc4", "replace", 'abc\ufffd\ufffd\uc894'), |
| 30 | (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\ufffd\uc894\ufffd"), |
Guido van Rossum | 024da5c | 2007-05-17 23:59:11 +0000 | [diff] [blame] | 31 | (b"abc\x80\x80\xc1\xc4", "ignore", "abc\uc894"), |
Guido van Rossum | 61e21b5 | 2007-08-20 19:06:03 +0000 | [diff] [blame] | 32 | |
| 33 | # composed make-up sequence errors |
| 34 | (b"\xa4\xd4", "strict", None), |
| 35 | (b"\xa4\xd4\xa4", "strict", None), |
| 36 | (b"\xa4\xd4\xa4\xb6", "strict", None), |
| 37 | (b"\xa4\xd4\xa4\xb6\xa4", "strict", None), |
| 38 | (b"\xa4\xd4\xa4\xb6\xa4\xd0", "strict", None), |
| 39 | (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa4", "strict", None), |
| 40 | (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xd4", "strict", "\uc4d4"), |
| 41 | (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xd4x", "strict", "\uc4d4x"), |
Victor Stinner | 2cded9c | 2011-07-08 01:45:13 +0200 | [diff] [blame] | 42 | (b"a\xa4\xd4\xa4\xb6\xa4", "replace", 'a\ufffd'), |
Guido van Rossum | 61e21b5 | 2007-08-20 19:06:03 +0000 | [diff] [blame] | 43 | (b"\xa4\xd4\xa3\xb6\xa4\xd0\xa4\xd4", "strict", None), |
| 44 | (b"\xa4\xd4\xa4\xb6\xa3\xd0\xa4\xd4", "strict", None), |
| 45 | (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa3\xd4", "strict", None), |
Victor Stinner | 2cded9c | 2011-07-08 01:45:13 +0200 | [diff] [blame] | 46 | (b"\xa4\xd4\xa4\xff\xa4\xd0\xa4\xd4", "replace", '\ufffd\u6e21\ufffd\u3160\ufffd'), |
| 47 | (b"\xa4\xd4\xa4\xb6\xa4\xff\xa4\xd4", "replace", '\ufffd\u6e21\ub544\ufffd\ufffd'), |
| 48 | (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xff", "replace", '\ufffd\u6e21\ub544\u572d\ufffd'), |
| 49 | (b"\xa4\xd4\xff\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xd4", "replace", '\ufffd\ufffd\ufffd\uc4d4'), |
Guido van Rossum | 61e21b5 | 2007-08-20 19:06:03 +0000 | [diff] [blame] | 50 | (b"\xc1\xc4", "strict", "\uc894"), |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 51 | ) |
| 52 | |
R David Murray | 75d9aca | 2012-04-09 09:37:52 -0400 | [diff] [blame] | 53 | class Test_JOHAB(multibytecodec_support.TestBase, unittest.TestCase): |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 54 | encoding = 'johab' |
R David Murray | 75d9aca | 2012-04-09 09:37:52 -0400 | [diff] [blame] | 55 | tstring = multibytecodec_support.load_teststring('johab') |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 56 | codectests = ( |
| 57 | # invalid bytes |
Guido van Rossum | 024da5c | 2007-05-17 23:59:11 +0000 | [diff] [blame] | 58 | (b"abc\x80\x80\xc1\xc4", "strict", None), |
| 59 | (b"abc\xc8", "strict", None), |
Victor Stinner | 2cded9c | 2011-07-08 01:45:13 +0200 | [diff] [blame] | 60 | (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\ufffd\ucd27"), |
| 61 | (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\ufffd\ucd27\ufffd"), |
Guido van Rossum | 024da5c | 2007-05-17 23:59:11 +0000 | [diff] [blame] | 62 | (b"abc\x80\x80\xc1\xc4", "ignore", "abc\ucd27"), |
Victor Stinner | 2cded9c | 2011-07-08 01:45:13 +0200 | [diff] [blame] | 63 | (b"\xD8abc", "replace", "\uFFFDabc"), |
| 64 | (b"\xD8\xFFabc", "replace", "\uFFFD\uFFFDabc"), |
| 65 | (b"\x84bxy", "replace", "\uFFFDbxy"), |
| 66 | (b"\x8CBxy", "replace", "\uFFFDBxy"), |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 67 | ) |
| 68 | |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 69 | if __name__ == "__main__": |
Zachary Ware | 38c707e | 2015-04-13 15:00:43 -0500 | [diff] [blame] | 70 | unittest.main() |