def test_should_tolerate_varying_space_in_haystack_and_needle(self): haystack = 'Smith ,J .A .' needle = 'Smith, J. A.' assert fuzzy_search_index_range(haystack, needle, 0.5) == (0, 13)
def test_should_find_longer_needle(self): haystack = 'PO Box 12345' needle = 'P.O. Box 12345' # Note: ideally it would match (0, 12) assert fuzzy_search_index_range(haystack, needle, 0.8) == (3, 12)
def test_should_find_exact_match_containing_dot(self): haystack = 'abc.' needle = 'abc.' assert fuzzy_search_index_range(haystack, needle, 0.8) == (0, 4)
def test_should_tolerate_space_in_haystack(self): haystack = 'abc .' needle = 'abc.' assert fuzzy_search_index_range(haystack, needle, 0.9) == (0, 5)
def test_should_find_exact_match_surrounded_by_line_feed(self): haystack = '\nabc\n' needle = 'abc' assert fuzzy_search_index_range(haystack, needle, 0.8) == (1, 4)
def test_should_find_exact_match_surrounded_by_dot(self): haystack = '.abc.' needle = 'abc' assert fuzzy_search_index_range(haystack, needle, 0.8) == (1, 4)
def test_should_find_exact_match_surrounded_by_square_brackets(self): haystack = '[abc]' needle = 'abc' assert fuzzy_search_index_range(haystack, needle, 0.8) == (1, 4)
def test_should_find_exact_match_inside(self): haystack = 'xyz abc 123' needle = 'abc' assert fuzzy_search_index_range(haystack, needle, 0.8) == (4, 7)
def test_should_find_exact_complete_match(self): haystack = 'abc' needle = 'abc' assert fuzzy_search_index_range(haystack, needle, 0.8) == (0, 3)