Benjamin Peterson | 90f5ba5 | 2010-03-11 22:53:45 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 2 | # |
| 3 | # test_codecmaps_jp.py |
| 4 | # Codec mapping tests for Japanese encodings |
| 5 | # |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 6 | |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 7 | from test import support |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 8 | from test import test_multibytecodec_support |
| 9 | import unittest |
| 10 | |
| 11 | class TestCP932Map(test_multibytecodec_support.TestBase_Mapping, |
| 12 | unittest.TestCase): |
| 13 | encoding = 'cp932' |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 14 | mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/' \ |
| 15 | 'WINDOWS/CP932.TXT' |
| 16 | supmaps = [ |
Guido van Rossum | 005ebb1 | 2007-07-23 18:06:59 +0000 | [diff] [blame] | 17 | (b'\x80', '\u0080'), |
| 18 | (b'\xa0', '\uf8f0'), |
| 19 | (b'\xfd', '\uf8f1'), |
| 20 | (b'\xfe', '\uf8f2'), |
| 21 | (b'\xff', '\uf8f3'), |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 22 | ] |
| 23 | for i in range(0xa1, 0xe0): |
Guido van Rossum | 005ebb1 | 2007-07-23 18:06:59 +0000 | [diff] [blame] | 24 | supmaps.append((bytes([i]), chr(i+0xfec0))) |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 25 | |
| 26 | |
| 27 | class TestEUCJPCOMPATMap(test_multibytecodec_support.TestBase_Mapping, |
| 28 | unittest.TestCase): |
| 29 | encoding = 'euc_jp' |
| 30 | mapfilename = 'EUC-JP.TXT' |
| 31 | mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-JP.TXT' |
| 32 | |
| 33 | |
| 34 | class TestSJISCOMPATMap(test_multibytecodec_support.TestBase_Mapping, |
| 35 | unittest.TestCase): |
| 36 | encoding = 'shift_jis' |
| 37 | mapfilename = 'SHIFTJIS.TXT' |
| 38 | mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/OBSOLETE' \ |
| 39 | '/EASTASIA/JIS/SHIFTJIS.TXT' |
| 40 | pass_enctest = [ |
Guido van Rossum | 005ebb1 | 2007-07-23 18:06:59 +0000 | [diff] [blame] | 41 | (b'\x81_', '\\'), |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 42 | ] |
| 43 | pass_dectest = [ |
Guido van Rossum | 005ebb1 | 2007-07-23 18:06:59 +0000 | [diff] [blame] | 44 | (b'\\', '\xa5'), |
| 45 | (b'~', '\u203e'), |
| 46 | (b'\x81_', '\\'), |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 47 | ] |
| 48 | |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 49 | class TestEUCJISX0213Map(test_multibytecodec_support.TestBase_Mapping, |
| 50 | unittest.TestCase): |
| 51 | encoding = 'euc_jisx0213' |
| 52 | mapfilename = 'EUC-JISX0213.TXT' |
| 53 | mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-JISX0213.TXT' |
| 54 | |
| 55 | |
| 56 | class TestSJISX0213Map(test_multibytecodec_support.TestBase_Mapping, |
| 57 | unittest.TestCase): |
| 58 | encoding = 'shift_jisx0213' |
| 59 | mapfilename = 'SHIFT_JISX0213.TXT' |
| 60 | mapfileurl = 'http://people.freebsd.org/~perky/i18n/SHIFT_JISX0213.TXT' |
| 61 | |
| 62 | |
| 63 | def test_main(): |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 64 | support.run_unittest(__name__) |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 65 | |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 66 | if __name__ == "__main__": |
| 67 | test_main() |