re: Add test cases for end-before-start and negative values.

pull/14179/head
Jared Hancock 2024-03-28 09:17:18 -05:00
rodzic f72327165f
commit 5ad16c3678
1 zmienionych plików z 21 dodań i 2 usunięć

Wyświetl plik

@ -29,7 +29,8 @@ print_groups(m)
m = p.match("dog", 2)
print_groups(m)
m = p.match("dog", 3) # Past end of input
# No match past end of input
m = p.match("dog", 5)
print_groups(m)
m = p.match("dog", 0, 1)
@ -40,11 +41,22 @@ p = re.compile(r"^o")
m = p.match("dog", 1)
print_groups(m)
# End at begging means searching empty string
# End at beginning means searching empty string
p = re.compile(r"o")
m = p.match("dog", 1, 1)
print_groups(m)
# End before the beginning doesn't match anything
m = p.match("dog", 2, 1)
print_groups(m)
# Negative starting values don't crash
m = p.search("dog", -2)
print_groups(m)
m = p.search("dog", -2, -5)
print_groups(m)
# Search also works
print("--search")
@ -57,3 +69,10 @@ print_groups(m)
m = p.search("dog", 2)
print_groups(m)
# Negative starting values don't crash
m = p.search("dog", -2)
print_groups(m)
m = p.search("dog", -2, -5)
print_groups(m)