[Python-checkins] python/dist/src/Lib/test string_tests.py,1.17,1.18
nnorwitz@users.sourceforge.net
nnorwitz@users.sourceforge.net
Thu, 13 Jun 2002 17:50:44 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv11051/Lib/test
Modified Files:
string_tests.py
Log Message:
SF bug # 493951 string.{starts,ends}with vs slices
Handle negative indices similar to slices.
Index: string_tests.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** string_tests.py 23 May 2002 15:15:30 -0000 1.17
--- string_tests.py 14 Jun 2002 00:50:42 -0000 1.18
***************
*** 224,227 ****
--- 224,239 ----
test('startswith', 'helloworld', 0, 'lowo', 3, 6)
+ # test negative indices in startswith
+ test('startswith', 'hello', 1, 'he', 0, -1)
+ test('startswith', 'hello', 1, 'he', -53, -1)
+ test('startswith', 'hello', 0, 'hello', 0, -1)
+ test('startswith', 'hello', 0, 'hello world', -1, -10)
+ test('startswith', 'hello', 0, 'ello', -5)
+ test('startswith', 'hello', 1, 'ello', -4)
+ test('startswith', 'hello', 0, 'o', -2)
+ test('startswith', 'hello', 1, 'o', -1)
+ test('startswith', 'hello', 1, '', -3, -3)
+ test('startswith', 'hello', 0, 'lo', -9)
+
test('endswith', 'hello', 1, 'lo')
test('endswith', 'hello', 0, 'he')
***************
*** 238,241 ****
--- 250,268 ----
test('endswith', 'ab', 0, 'ab', 0, 1)
test('endswith', 'ab', 0, 'ab', 0, 0)
+
+ # test negative indices in endswith
+ test('endswith', 'hello', 1, 'lo', -2)
+ test('endswith', 'hello', 0, 'he', -2)
+ test('endswith', 'hello', 1, '', -3, -3)
+ test('endswith', 'hello', 0, 'hello world', -10, -2)
+ test('endswith', 'helloworld', 0, 'worl', -6)
+ test('endswith', 'helloworld', 1, 'worl', -5, -1)
+ test('endswith', 'helloworld', 1, 'worl', -5, 9)
+ test('endswith', 'helloworld', 1, 'world', -7, 12)
+ test('endswith', 'helloworld', 1, 'lowo', -99, -3)
+ test('endswith', 'helloworld', 1, 'lowo', -8, -3)
+ test('endswith', 'helloworld', 1, 'lowo', -7, -3)
+ test('endswith', 'helloworld', 0, 'lowo', 3, -4)
+ test('endswith', 'helloworld', 0, 'lowo', -8, -2)
test('zfill', '123', '123', 2)