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