1 | n/a | # |
---|
2 | n/a | # test_codecencodings_kr.py |
---|
3 | n/a | # Codec encoding tests for ROK encodings. |
---|
4 | n/a | # |
---|
5 | n/a | |
---|
6 | n/a | from test import multibytecodec_support |
---|
7 | n/a | import unittest |
---|
8 | n/a | |
---|
9 | n/a | class Test_CP949(multibytecodec_support.TestBase, unittest.TestCase): |
---|
10 | n/a | encoding = 'cp949' |
---|
11 | n/a | tstring = multibytecodec_support.load_teststring('cp949') |
---|
12 | n/a | codectests = ( |
---|
13 | n/a | # invalid bytes |
---|
14 | n/a | (b"abc\x80\x80\xc1\xc4", "strict", None), |
---|
15 | n/a | (b"abc\xc8", "strict", None), |
---|
16 | n/a | (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\ufffd\uc894"), |
---|
17 | n/a | (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\ufffd\uc894\ufffd"), |
---|
18 | n/a | (b"abc\x80\x80\xc1\xc4", "ignore", "abc\uc894"), |
---|
19 | n/a | ) |
---|
20 | n/a | |
---|
21 | n/a | class Test_EUCKR(multibytecodec_support.TestBase, unittest.TestCase): |
---|
22 | n/a | encoding = 'euc_kr' |
---|
23 | n/a | tstring = multibytecodec_support.load_teststring('euc_kr') |
---|
24 | n/a | codectests = ( |
---|
25 | n/a | # invalid bytes |
---|
26 | n/a | (b"abc\x80\x80\xc1\xc4", "strict", None), |
---|
27 | n/a | (b"abc\xc8", "strict", None), |
---|
28 | n/a | (b"abc\x80\x80\xc1\xc4", "replace", 'abc\ufffd\ufffd\uc894'), |
---|
29 | n/a | (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\ufffd\uc894\ufffd"), |
---|
30 | n/a | (b"abc\x80\x80\xc1\xc4", "ignore", "abc\uc894"), |
---|
31 | n/a | |
---|
32 | n/a | # composed make-up sequence errors |
---|
33 | n/a | (b"\xa4\xd4", "strict", None), |
---|
34 | n/a | (b"\xa4\xd4\xa4", "strict", None), |
---|
35 | n/a | (b"\xa4\xd4\xa4\xb6", "strict", None), |
---|
36 | n/a | (b"\xa4\xd4\xa4\xb6\xa4", "strict", None), |
---|
37 | n/a | (b"\xa4\xd4\xa4\xb6\xa4\xd0", "strict", None), |
---|
38 | n/a | (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa4", "strict", None), |
---|
39 | n/a | (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xd4", "strict", "\uc4d4"), |
---|
40 | n/a | (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xd4x", "strict", "\uc4d4x"), |
---|
41 | n/a | (b"a\xa4\xd4\xa4\xb6\xa4", "replace", 'a\ufffd'), |
---|
42 | n/a | (b"\xa4\xd4\xa3\xb6\xa4\xd0\xa4\xd4", "strict", None), |
---|
43 | n/a | (b"\xa4\xd4\xa4\xb6\xa3\xd0\xa4\xd4", "strict", None), |
---|
44 | n/a | (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa3\xd4", "strict", None), |
---|
45 | n/a | (b"\xa4\xd4\xa4\xff\xa4\xd0\xa4\xd4", "replace", '\ufffd\u6e21\ufffd\u3160\ufffd'), |
---|
46 | n/a | (b"\xa4\xd4\xa4\xb6\xa4\xff\xa4\xd4", "replace", '\ufffd\u6e21\ub544\ufffd\ufffd'), |
---|
47 | n/a | (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xff", "replace", '\ufffd\u6e21\ub544\u572d\ufffd'), |
---|
48 | n/a | (b"\xa4\xd4\xff\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xd4", "replace", '\ufffd\ufffd\ufffd\uc4d4'), |
---|
49 | n/a | (b"\xc1\xc4", "strict", "\uc894"), |
---|
50 | n/a | ) |
---|
51 | n/a | |
---|
52 | n/a | class Test_JOHAB(multibytecodec_support.TestBase, unittest.TestCase): |
---|
53 | n/a | encoding = 'johab' |
---|
54 | n/a | tstring = multibytecodec_support.load_teststring('johab') |
---|
55 | n/a | codectests = ( |
---|
56 | n/a | # invalid bytes |
---|
57 | n/a | (b"abc\x80\x80\xc1\xc4", "strict", None), |
---|
58 | n/a | (b"abc\xc8", "strict", None), |
---|
59 | n/a | (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\ufffd\ucd27"), |
---|
60 | n/a | (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\ufffd\ucd27\ufffd"), |
---|
61 | n/a | (b"abc\x80\x80\xc1\xc4", "ignore", "abc\ucd27"), |
---|
62 | n/a | (b"\xD8abc", "replace", "\uFFFDabc"), |
---|
63 | n/a | (b"\xD8\xFFabc", "replace", "\uFFFD\uFFFDabc"), |
---|
64 | n/a | (b"\x84bxy", "replace", "\uFFFDbxy"), |
---|
65 | n/a | (b"\x8CBxy", "replace", "\uFFFDBxy"), |
---|
66 | n/a | ) |
---|
67 | n/a | |
---|
68 | n/a | if __name__ == "__main__": |
---|
69 | n/a | unittest.main() |
---|