Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / lib / python2.4 / test / test_codecencodings_cn.py
CommitLineData
920dae64
AT
1#!/usr/bin/env python
2#
3# test_codecencodings_cn.py
4# Codec encoding tests for PRC encodings.
5#
6# $CJKCodecs: test_codecencodings_cn.py,v 1.2 2004/06/19 06:09:55 perky Exp $
7
8from test import test_support
9from test import test_multibytecodec_support
10import unittest
11
12class Test_GB2312(test_multibytecodec_support.TestBase, unittest.TestCase):
13 encoding = 'gb2312'
14 tstring = test_multibytecodec_support.load_teststring('gb2312')
15 codectests = (
16 # invalid bytes
17 ("abc\x81\x81\xc1\xc4", "strict", None),
18 ("abc\xc8", "strict", None),
19 ("abc\x81\x81\xc1\xc4", "replace", u"abc\ufffd\u804a"),
20 ("abc\x81\x81\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"),
21 ("abc\x81\x81\xc1\xc4", "ignore", u"abc\u804a"),
22 ("\xc1\x64", "strict", None),
23 )
24
25class Test_GBK(test_multibytecodec_support.TestBase, unittest.TestCase):
26 encoding = 'gbk'
27 tstring = test_multibytecodec_support.load_teststring('gbk')
28 codectests = (
29 # invalid bytes
30 ("abc\x80\x80\xc1\xc4", "strict", None),
31 ("abc\xc8", "strict", None),
32 ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\u804a"),
33 ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"),
34 ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u804a"),
35 ("\x83\x34\x83\x31", "strict", None),
36 )
37
38class Test_GB18030(test_multibytecodec_support.TestBase, unittest.TestCase):
39 encoding = 'gb18030'
40 tstring = test_multibytecodec_support.load_teststring('gb18030')
41 codectests = (
42 # invalid bytes
43 ("abc\x80\x80\xc1\xc4", "strict", None),
44 ("abc\xc8", "strict", None),
45 ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\u804a"),
46 ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"),
47 ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u804a"),
48 ("abc\x84\x39\x84\x39\xc1\xc4", "replace", u"abc\ufffd\u804a"),
49 )
50 has_iso10646 = True
51
52def test_main():
53 suite = unittest.TestSuite()
54 suite.addTest(unittest.makeSuite(Test_GB2312))
55 suite.addTest(unittest.makeSuite(Test_GBK))
56 suite.addTest(unittest.makeSuite(Test_GB18030))
57 test_support.run_suite(suite)
58
59if __name__ == "__main__":
60 test_main()