mirror of
https://github.com/python/cpython.git
synced 2025-10-31 21:51:50 +00:00
changed find/rfind to return -1 for matches outside the source string
This commit is contained in:
parent
9faa3eda6b
commit
93eff6fecd
2 changed files with 19 additions and 10 deletions
|
|
@ -154,6 +154,10 @@ def test_find(self):
|
|||
self.checkequal(9, 'abcdefghiabc', 'find', 'abc', 1)
|
||||
self.checkequal(-1, 'abcdefghiabc', 'find', 'def', 4)
|
||||
|
||||
self.checkequal(0, 'abc', 'find', '', 0)
|
||||
self.checkequal(3, 'abc', 'find', '', 3)
|
||||
self.checkequal(-1, 'abc', 'find', '', 4)
|
||||
|
||||
self.checkraises(TypeError, 'hello', 'find')
|
||||
self.checkraises(TypeError, 'hello', 'find', 42)
|
||||
|
||||
|
|
@ -188,6 +192,10 @@ def test_rfind(self):
|
|||
self.checkequal(0, 'abcdefghiabc', 'rfind', 'abcd')
|
||||
self.checkequal(-1, 'abcdefghiabc', 'rfind', 'abcz')
|
||||
|
||||
self.checkequal(3, 'abc', 'rfind', '', 0)
|
||||
self.checkequal(3, 'abc', 'rfind', '', 3)
|
||||
self.checkequal(-1, 'abc', 'rfind', '', 4)
|
||||
|
||||
self.checkraises(TypeError, 'hello', 'rfind')
|
||||
self.checkraises(TypeError, 'hello', 'rfind', 42)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue