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

M.-A. Lemburg lemburg@users.sourceforge.net
Wed, 06 Feb 2002 10:09:04 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv6841/Lib/test

Modified Files:
	test_unicode.py 
Log Message:
Fix for the UTF-8 memory allocation bug and the UTF-8 encoding
bug related to lone high surrogates.



Index: test_unicode.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** test_unicode.py	2001/12/10 20:57:34	1.47
--- test_unicode.py	2002/02/06 18:09:02	1.48
***************
*** 496,512 ****
  
  # UTF-8 specific encoding tests:
! verify(u'\u20ac'.encode('utf-8') == \
!        ''.join((chr(0xe2), chr(0x82), chr(0xac))) )
! verify(u'\ud800\udc02'.encode('utf-8') == \
!        ''.join((chr(0xf0), chr(0x90), chr(0x80), chr(0x82))) )
! verify(u'\ud84d\udc56'.encode('utf-8') == \
!        ''.join((chr(0xf0), chr(0xa3), chr(0x91), chr(0x96))) )
  # UTF-8 specific decoding tests
! verify(unicode(''.join((chr(0xf0), chr(0xa3), chr(0x91), chr(0x96))),
!                'utf-8') == u'\U00023456' )
! verify(unicode(''.join((chr(0xf0), chr(0x90), chr(0x80), chr(0x82))),
!                'utf-8') == u'\U00010002' )
! verify(unicode(''.join((chr(0xe2), chr(0x82), chr(0xac))),
!                'utf-8') == u'\u20ac' )
  
  # Other possible utf-8 test cases:
--- 496,511 ----
  
  # UTF-8 specific encoding tests:
! verify(u'\u20ac'.encode('utf-8') == '\xe2\x82\xac')
! verify(u'\ud800\udc02'.encode('utf-8') == '\xf0\x90\x80\x82')
! verify(u'\ud84d\udc56'.encode('utf-8') == '\xf0\xa3\x91\x96')
! verify(u'\ud800'.encode('utf-8') == '\xed\xa0\x80')
! verify(u'\udc00'.encode('utf-8') == '\xed\xb0\x80')
! verify((u'\ud800\udc02'*1000).encode('utf-8') ==
!        '\xf0\x90\x80\x82'*1000)
! 
  # UTF-8 specific decoding tests
! verify(unicode('\xf0\xa3\x91\x96', 'utf-8') == u'\U00023456' )
! verify(unicode('\xf0\x90\x80\x82', 'utf-8') == u'\U00010002' )
! verify(unicode('\xe2\x82\xac', 'utf-8') == u'\u20ac' )
  
  # Other possible utf-8 test cases: