summaryrefslogtreecommitdiffstats
path: root/Lib/test/string_tests.py
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2006-05-30 17:11:48 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2006-05-30 17:11:48 (GMT)
commit93eff6fecd6563c04ab6a15c546f00852ef8e639 (patch)
treee61ea46401c978e927367439685fc996d351c9b5 /Lib/test/string_tests.py
parent9faa3eda6b767ddfae8ff2627d50edd6ad072490 (diff)
downloadcpython-93eff6fecd6563c04ab6a15c546f00852ef8e639.zip
cpython-93eff6fecd6563c04ab6a15c546f00852ef8e639.tar.gz
cpython-93eff6fecd6563c04ab6a15c546f00852ef8e639.tar.bz2
changed find/rfind to return -1 for matches outside the source string
Diffstat (limited to 'Lib/test/string_tests.py')
-rw-r--r--Lib/test/string_tests.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index 5fe9fb9..c2e0875 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -154,6 +154,10 @@ class CommonTest(unittest.TestCase):
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 @@ class CommonTest(unittest.TestCase):
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)