[Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.3,1.4

Guido van Rossum python-dev@python.org
2000年3月24日 17:14:20 -0500 (EST)


Update of /projects/cvsroot/python/dist/src/Lib/test
In directory eric:/home/guido/hp/mal/py-patched/Lib/test
Modified Files:
	test_unicode.py 
Log Message:
Marc-Andre Lemburg:
Attached you find the latest update of the Unicode implementation.
The patch is against the current CVS version.
It includes the fix I posted yesterday for the core dump problem
in codecs.c (was introduced by my previous patch set -- sorry),
adds more tests for the codecs and two new parser markers
"es" and "es#".
Index: test_unicode.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/test/test_unicode.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** test_unicode.py	2000年03月20日 16:36:31	1.3
--- test_unicode.py	2000年03月24日 22:14:18	1.4
***************
*** 294,295 ****
--- 294,325 ----
 
 print 'done.'
+ 
+ # Test builtin codecs
+ print 'Testing builtin codecs...',
+ 
+ assert unicode('hello','ascii') == u'hello'
+ assert unicode('hello','utf-8') == u'hello'
+ assert unicode('hello','utf8') == u'hello'
+ assert unicode('hello','latin-1') == u'hello'
+ 
+ assert u'hello'.encode('ascii') == 'hello'
+ assert u'hello'.encode('utf-8') == 'hello'
+ assert u'hello'.encode('utf8') == 'hello'
+ assert u'hello'.encode('utf-16-le') == 'h000円e000円l000円l000円o000円'
+ assert u'hello'.encode('utf-16-be') == '000円h000円e000円l000円l000円o'
+ assert u'hello'.encode('latin-1') == 'hello'
+ 
+ u = u''.join(map(unichr, range(1024)))
+ for encoding in ('utf-8', 'utf-16', 'utf-16-le', 'utf-16-be',
+ 'raw_unicode_escape', 'unicode_escape', 'unicode_internal'):
+ assert unicode(u.encode(encoding),encoding) == u
+ 
+ u = u''.join(map(unichr, range(256)))
+ for encoding in ('latin-1',):
+ assert unicode(u.encode(encoding),encoding) == u
+ 
+ u = u''.join(map(unichr, range(128)))
+ for encoding in ('ascii',):
+ assert unicode(u.encode(encoding),encoding) == u
+ 
+ print 'done.'

AltStyle によって変換されたページ (->オリジナル) /