File tree 1 file changed +11
-3
lines changed 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -327,11 +327,12 @@ def reference_find(p, s):
327
327
for i in range (len (s )):
328
328
if s .startswith (p , i ):
329
329
return i
330
+ if p == '' and s == '' :
331
+ return 0
330
332
return - 1
331
333
332
- rr = random .randrange
333
- choices = random .choices
334
- for _ in range (1000 ):
334
+ def check_pattern (rr ):
335
+ choices = random .choices
335
336
p0 = '' .join (choices ('abcde' , k = rr (10 ))) * rr (10 , 20 )
336
337
p = p0 [:len (p0 ) - rr (10 )] # pop off some characters
337
338
left = '' .join (choices ('abcdef' , k = rr (2000 )))
@@ -341,6 +342,13 @@ def reference_find(p, s):
341
342
self .checkequal (reference_find (p , text ),
342
343
text , 'find' , p )
343
344
345
+ rr = random .randrange
346
+ for _ in range (1000 ):
347
+ check_pattern (rr )
348
+
349
+ # Test that empty string always work:
350
+ check_pattern (lambda * args : 0 )
351
+
344
352
def test_find_shift_table_overflow (self ):
345
353
"""When the table of 8-bit shifts overflows."""
346
354
N = 2 ** 8 + 100
You can’t perform that action at this time.
0 commit comments