mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
Add tests for issue #7458: str.rfind() would crash when called with an invalid
start value. The offending code itself was removed as part of #7462. This patch by Victor Stinner.
This commit is contained in:
parent
b56fb12b74
commit
83f86e8e98
1 changed files with 6 additions and 0 deletions
|
@ -185,6 +185,9 @@ class CommonTest(unittest.TestCase):
|
||||||
self.checkequal(-1, '', 'find', 'xx', 1, 1)
|
self.checkequal(-1, '', 'find', 'xx', 1, 1)
|
||||||
self.checkequal(-1, '', 'find', 'xx', sys.maxint, 0)
|
self.checkequal(-1, '', 'find', 'xx', sys.maxint, 0)
|
||||||
|
|
||||||
|
# issue 7458
|
||||||
|
self.checkequal(-1, 'ab', 'find', 'xxx', sys.maxsize + 1, 0)
|
||||||
|
|
||||||
# For a variety of combinations,
|
# For a variety of combinations,
|
||||||
# verify that str.find() matches __contains__
|
# verify that str.find() matches __contains__
|
||||||
# and that the found substring is really at that location
|
# and that the found substring is really at that location
|
||||||
|
@ -255,6 +258,9 @@ class CommonTest(unittest.TestCase):
|
||||||
if loc != -1:
|
if loc != -1:
|
||||||
self.assertEqual(i[loc:loc+len(j)], j)
|
self.assertEqual(i[loc:loc+len(j)], j)
|
||||||
|
|
||||||
|
# issue 7458
|
||||||
|
self.checkequal(-1, 'ab', 'rfind', 'xxx', sys.maxsize + 1, 0)
|
||||||
|
|
||||||
def test_index(self):
|
def test_index(self):
|
||||||
self.checkequal(0, 'abcdefghiabc', 'index', '')
|
self.checkequal(0, 'abcdefghiabc', 'index', '')
|
||||||
self.checkequal(3, 'abcdefghiabc', 'index', 'def')
|
self.checkequal(3, 'abcdefghiabc', 'index', 'def')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue