Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 1 | # |
| 2 | # test_codecmaps_jp.py |
| 3 | # Codec mapping tests for Japanese 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 TestCP932Map(multibytecodec_support.TestBase_Mapping, |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 11 | unittest.TestCase): |
| 12 | encoding = 'cp932' |
Georg Brandl | 5a15508 | 2014-11-06 14:37:49 +0100 | [diff] [blame] | 13 | mapfileurl = 'http://www.pythontest.net/unicode/CP932.TXT' |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 14 | supmaps = [ |
Guido van Rossum | 005ebb1 | 2007-07-23 18:06:59 +0000 | [diff] [blame] | 15 | (b'\x80', '\u0080'), |
| 16 | (b'\xa0', '\uf8f0'), |
| 17 | (b'\xfd', '\uf8f1'), |
| 18 | (b'\xfe', '\uf8f2'), |
| 19 | (b'\xff', '\uf8f3'), |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 20 | ] |
| 21 | for i in range(0xa1, 0xe0): |
Guido van Rossum | 005ebb1 | 2007-07-23 18:06:59 +0000 | [diff] [blame] | 22 | supmaps.append((bytes([i]), chr(i+0xfec0))) |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 23 | |
| 24 | |
R David Murray | 75d9aca | 2012-04-09 09:37:52 -0400 | [diff] [blame] | 25 | class TestEUCJPCOMPATMap(multibytecodec_support.TestBase_Mapping, |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 26 | unittest.TestCase): |
| 27 | encoding = 'euc_jp' |
| 28 | mapfilename = 'EUC-JP.TXT' |
Georg Brandl | 5a15508 | 2014-11-06 14:37:49 +0100 | [diff] [blame] | 29 | mapfileurl = 'http://www.pythontest.net/unicode/EUC-JP.TXT' |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 30 | |
| 31 | |
R David Murray | 75d9aca | 2012-04-09 09:37:52 -0400 | [diff] [blame] | 32 | class TestSJISCOMPATMap(multibytecodec_support.TestBase_Mapping, |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 33 | unittest.TestCase): |
| 34 | encoding = 'shift_jis' |
| 35 | mapfilename = 'SHIFTJIS.TXT' |
Georg Brandl | 5a15508 | 2014-11-06 14:37:49 +0100 | [diff] [blame] | 36 | mapfileurl = 'http://www.pythontest.net/unicode/SHIFTJIS.TXT' |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 37 | pass_enctest = [ |
Guido van Rossum | 005ebb1 | 2007-07-23 18:06:59 +0000 | [diff] [blame] | 38 | (b'\x81_', '\\'), |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 39 | ] |
| 40 | pass_dectest = [ |
Guido van Rossum | 005ebb1 | 2007-07-23 18:06:59 +0000 | [diff] [blame] | 41 | (b'\\', '\xa5'), |
| 42 | (b'~', '\u203e'), |
| 43 | (b'\x81_', '\\'), |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 44 | ] |
| 45 | |
R David Murray | 75d9aca | 2012-04-09 09:37:52 -0400 | [diff] [blame] | 46 | class TestEUCJISX0213Map(multibytecodec_support.TestBase_Mapping, |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 47 | unittest.TestCase): |
| 48 | encoding = 'euc_jisx0213' |
| 49 | mapfilename = 'EUC-JISX0213.TXT' |
Georg Brandl | 5a15508 | 2014-11-06 14:37:49 +0100 | [diff] [blame] | 50 | mapfileurl = 'http://www.pythontest.net/unicode/EUC-JISX0213.TXT' |
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 TestSJISX0213Map(multibytecodec_support.TestBase_Mapping, |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 54 | unittest.TestCase): |
| 55 | encoding = 'shift_jisx0213' |
| 56 | mapfilename = 'SHIFT_JISX0213.TXT' |
Georg Brandl | 5a15508 | 2014-11-06 14:37:49 +0100 | [diff] [blame] | 57 | mapfileurl = 'http://www.pythontest.net/unicode/SHIFT_JISX0213.TXT' |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 58 | |
| 59 | |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 60 | if __name__ == "__main__": |
Zachary Ware | d9de794 | 2014-07-01 19:55:04 -0500 | [diff] [blame] | 61 | unittest.main() |