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

M.-A. Lemburg lemburg@users.sourceforge.net
Tue, 16 Jan 2001 03:54:14 -0800


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

Modified Files:
	string_tests.py test_unicode.py 
Log Message:
Added checks to prevent PyUnicode_Count() from dumping core
in case the parameters are out of bounds and fixes error handling
for .count(), .startswith() and .endswith() for the case of
mixed string/Unicode objects.

This patch adds Python style index semantics to PyUnicode_Count()
indices (including the special handling of negative indices).

The patch is an extended version of patch #103249 submitted
by Michael Hudson (mwh) on SF. It also includes new test cases.     
        



Index: string_tests.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** string_tests.py	2000/07/11 20:55:38	1.3
--- string_tests.py	2001/01/16 11:54:11	1.4
***************
*** 54,57 ****
--- 54,61 ----
      test('capitalize', ' hello ', ' hello ')
      test('capitalize', 'hello ', 'Hello ')
+ 
+     test('count', 'aaa', 3, 'a')
+     test('count', 'aaa', 0, 'b')
+     
      test('find', 'abcdefghiabc', 0, 'abc')
      test('find', 'abcdefghiabc', 9, 'abc', 1)

Index: test_unicode.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -r1.25 -r1.26
*** test_unicode.py	2001/01/03 21:29:14	1.25
--- test_unicode.py	2001/01/16 11:54:11	1.26
***************
*** 33,36 ****
--- 33,43 ----
  test('capitalize', u'hello ', u'Hello ')
  
+ test('count', u'aaa', 3, u'a')
+ test('count', u'aaa', 0, u'b')
+ test('count', 'aaa', 3, u'a')
+ test('count', 'aaa', 0, u'b')
+ test('count', u'aaa', 3, 'a')
+ test('count', u'aaa', 0, 'b')
+ 
  test('title', u' hello ', u' Hello ')
  test('title', u'hello ', u'Hello ')