[KoCo-CVS] [Commit] KoreanCodecs/test test_cp949.py
Brought to you by:
perky
From: Hye-Shik C. <pe...@us...> - 2003-01-09 22:07:25
|
perky 03/01/09 14:07:24 Modified: test test_cp949.py Log: Add mapping test for cp949 Revision Changes Path 1.7 +22 -1 KoreanCodecs/test/test_cp949.py Index: test_cp949.py =================================================================== RCS file: /cvsroot/koco/KoreanCodecs/test/test_cp949.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- test_cp949.py 9 Jan 2003 21:41:37 -0000 1.6 +++ test_cp949.py 9 Jan 2003 22:07:23 -0000 1.7 @@ -16,7 +16,7 @@ # along with KoreanCodecs; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# $Id: test_cp949.py,v 1.6 2003/01/09 21:41:37 perky Exp $ +# $Id: test_cp949.py,v 1.7 2003/01/09 22:07:23 perky Exp $ # import CodecTestBase @@ -33,6 +33,27 @@ ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\uc894\ufffd"), ("abc\x80\x80\xc1\xc4", "ignore", u"abc\uc894"), ) + + def test_mapping(self): + for line in open('mappings/cp949.txt'): + if not line: + break + data = line.split('#')[0].strip().split() + if len(data) != 2: + continue + + cp949val, unival = map(eval, data) + + if cp949val <= 0x7F: + cp949ch = chr(cp949val & 0xff) + elif cp949val >= 0x100: + cp949ch = chr(cp949val >> 8) + chr(cp949val & 0xff) + else: + continue + unich = unichr(unival) + + self.assertEqual(unich.encode('cp949'), cp949ch) + self.assertEqual(unicode(cp949ch, 'cp949'), unich) class TestCP949_CExtension(Shield.TestCP949Base): encoding = 'korean.c.cp949' |