10c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi#!/usr/bin/env python
20c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi#
30c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi# test_codecmaps_jp.py
40c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi#   Codec mapping tests for Japanese encodings
50c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi#
60c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi
70c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yifrom test import test_support
80c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yifrom test import test_multibytecodec_support
90c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yiimport unittest
100c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi
110c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yiclass TestCP932Map(test_multibytecodec_support.TestBase_Mapping,
120c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi                   unittest.TestCase):
130c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    encoding = 'cp932'
140c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/' \
150c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi                 'WINDOWS/CP932.TXT'
160c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    supmaps = [
170c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi        ('\x80', u'\u0080'),
180c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi        ('\xa0', u'\uf8f0'),
190c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi        ('\xfd', u'\uf8f1'),
200c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi        ('\xfe', u'\uf8f2'),
210c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi        ('\xff', u'\uf8f3'),
220c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    ]
230c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    for i in range(0xa1, 0xe0):
240c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi        supmaps.append((chr(i), unichr(i+0xfec0)))
250c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi
260c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi
270c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yiclass TestEUCJPCOMPATMap(test_multibytecodec_support.TestBase_Mapping,
280c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi                         unittest.TestCase):
290c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    encoding = 'euc_jp'
300c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    mapfilename = 'EUC-JP.TXT'
310c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-JP.TXT'
320c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi
330c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi
340c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yiclass TestSJISCOMPATMap(test_multibytecodec_support.TestBase_Mapping,
350c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi                        unittest.TestCase):
360c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    encoding = 'shift_jis'
370c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    mapfilename = 'SHIFTJIS.TXT'
380c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/OBSOLETE' \
390c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi                 '/EASTASIA/JIS/SHIFTJIS.TXT'
400c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    pass_enctest = [
410c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi        ('\x81_', u'\\'),
420c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    ]
430c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    pass_dectest = [
440c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi        ('\\', u'\xa5'),
450c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi        ('~', u'\u203e'),
460c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi        ('\x81_', u'\\'),
470c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    ]
480c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi
490c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yiclass TestEUCJISX0213Map(test_multibytecodec_support.TestBase_Mapping,
500c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi                         unittest.TestCase):
510c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    encoding = 'euc_jisx0213'
520c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    mapfilename = 'EUC-JISX0213.TXT'
530c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-JISX0213.TXT'
540c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi
550c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi
560c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yiclass TestSJISX0213Map(test_multibytecodec_support.TestBase_Mapping,
570c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi                       unittest.TestCase):
580c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    encoding = 'shift_jisx0213'
590c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    mapfilename = 'SHIFT_JISX0213.TXT'
600c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    mapfileurl = 'http://people.freebsd.org/~perky/i18n/SHIFT_JISX0213.TXT'
610c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi
620c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi
630c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yidef test_main():
640c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    test_support.run_unittest(__name__)
650c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi
660c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yiif __name__ == "__main__":
670c5958b1636c47ed7c284f859c8e805fd06a0e6Bill Yi    test_main()
68