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

Guido van Rossum python-dev@python.org
Fri, 24 Mar 2000 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') == 'h\000e\000l\000l\000o\000'
+ assert u'hello'.encode('utf-16-be') == '\000h\000e\000l\000l\000o'
+ 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.'