def test_find_index_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_index('abc', 'z') is None  # remember to test other letters
     assert find_index('abc', 'ac') is None  # important to test close cases
     assert find_index('abc', 'az') is None  # first letter, but not last
     assert find_index('abc', 'abz') is None  # first 2 letters, but not last
     assert find_index('abc', 'bcc') is None
     assert find_index('abc', 'abcde') is None
     assert find_index('abc', 'cab') is None
示例#2
0
 def test_find_index_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_index("abc", "z") is None  # remember to test other letters
     assert find_index("abc", "ac") is None  # important to test close cases
     assert find_index("abc", "az") is None  # first letter, but not last
     assert find_index("abc", "abz") is None  # first 2 letters, but not last
     assert find_index("yaaaaaayeeeeetyaaaaYEEET", "yeet") is None
     assert find_index("WHO Peed oN THE floor BROOM?", "peeed") is None
     assert find_index("YEAAAAAH IM GONNA TAKE MY HORSE...", "I'm") is None
示例#3
0
 def test_find_index_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_index('abc', 'z') is None  # remember to test other letters
     assert find_index('abc', 'ac') is None  # important to test close cases
     assert find_index('abc', 'az') is None  # first letter, but not last
     assert find_index('abc',
                       'abz') is None  # first 2 letters, but not last
     # TODO: Write more negative test cases with assert is None statements
     # ...
     assert find_index('the bible', 'PICKLE RIIIIIICK') is None
     assert find_index(
         'your honor that is wonderful',
         'your honor with all due respect that is bogus') is None
     assert find_index('meow', 'me_irl') is None
     assert find_index('dangerous gateway properties', 'trees') is None
     assert find_index('safest way to have fun!', 'crack') is None
     assert find_index(
         'these are not supposed to be jokes its just easier to make them not match when i put in absurd things',
         'dont you like playing volleyball when its negative 10 degrees and you left your favorite coat in Korea'
     ) is None
示例#4
0
 def test_find_index_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_index('abc', 'z') is None  # remember to test other letters
     assert find_index('abc', 'ac') is None  # important to test close cases
     assert find_index('abc', 'az') is None  # first letter, but not last
     assert find_index('abc', 'abz') is None  # first 2 letters, but not last
     # My test cases
     assert find_index('test!!!', 'testing') is None
     assert find_index('idk idk plea idk idk', 'please') is None
     assert find_index('oh man', 'ohman') is None
 def test_find_index_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_index('abc', 'z') is None  # remember to test other letters
     assert find_index('abc', 'ac') is None  # important to test close cases
     assert find_index('abc', 'az') is None  # first letter, but not last
     assert find_index('abc', 'abz') is None  # first 2 letters, but not last
     # TODO: Write more negative test cases with assert is None statements
     assert find_index('kaichi', 'ik') is None
     assert find_index('kaichi', 'kao') is None
     assert find_index('kaichi', 'kaicho') is None
 def test_find_index_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_index('abc', 'z') is None  # remember to test other letters
     assert find_index('abc', 'ac') is None  # important to test close cases
     assert find_index('abc', 'az') is None  # first letter, but not last
     assert find_index('abc',
                       'abz') is None  # first 2 letters, but not last
     # TODO: Write more negative test cases with assert is None statements
     assert find_index("sweet pox", "sweeta") is None
     assert find_index("castor", "castoroil") is None
     assert find_index("Where's Spot", "Wheres") is None
 def test_find_index_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_index('abc', 'z') is None  # remember to test other letters
     assert find_index('abc', 'ac') is None  # important to test close cases
     assert find_index('abc', 'az') is None  # first letter, but not last
     assert find_index('abc', 'abz') is None  # first 2, not last letter
     self.assertIs(find_index('Mecca', 'Makkah'), None)
     self.assertIs(find_index('GoogleMePlease', 'Google me'), None)
示例#8
0
 def test_find_index_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_index('abc', 'z') is None  # remember to test other letters
     assert find_index('abc', 'ac') is None  # important to test close cases
     assert find_index('abc', 'az') is None  # first letter, but not last
     assert find_index('abc',
                       'abz') is None  # first 2 letters, but not last
     # TODO: Write more negative test cases with assert is None statements
     # ...
     assert find_index('gopher', 'gob') is None
     assert find_index('rabbit', 'rat') is None
     assert find_index('raccoon', 'con') is None
示例#9
0
 def test_find_index_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_index('abc', 'z') is None  # remember to test other letters
     assert find_index('abc', 'ac') is None  # important to test close cases
     assert find_index('abc', 'az') is None  # first letter, but not last
     assert find_index('abc', 'abz') is None  # first 2 letters, but not last
     # Added: more negative test cases with assert is None statements
     assert find_index('aargraargra', 'grab') is None
     assert find_index('aargooglrabyargra', 'google') is None
示例#10
0
 def test_find_index_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_index('abc', 'z') is None  # remember to test other letters
     assert find_index('abc', 'ac') is None  # important to test close cases
     assert find_index('abc', 'az') is None  # first letter, but not last
     assert find_index('abc',
                       'abz') is None  # first 2 letters, but not last
     # TODO: Write more negative test cases with assert is None statements
     assert find_index("WHHyYYWEHYhwYYWHEY", "why") is None
     assert find_index('I WANNA SLEEEEP', 'sleep') is None
 def test_find_index_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_index('abc', 'z') is None  # remember to test other letters
     assert find_index('abc', 'ac') is None  # important to test close cases
     assert find_index('abc', 'az') is None  # first letter, but not last
     assert find_index('abc',
                       'abz') is None  # first 2 letters, but not last
     # more negative test cases with assert is None statements
     assert find_index('Duis aute irure dolor', '.') is None
     assert find_index('eiusmod tempor incididunt', 'a') is None
示例#12
0
 def test_find_index_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_index('abc', 'z') is None  # remember to test other letters
     assert find_index('abc', 'ac') is None  # important to test close cases
     assert find_index('abc', 'az') is None  # first letter, but not last
     assert find_index('abc',
                       'abz') is None  # first 2 letters, but not last
     # Write more negative test cases with assert is None statements
     assert find_index('crazy', 'zy ') is None  # with space at end
     assert find_index('test', ' ') is None  # there is no space in string
 def test_contains_with_matching_patterns(self):
     # Positive test cases (examples) with matching patterns
     assert contains('abc', '') is True  # all strings contain empty string
     assert contains('abc', 'a') is True  # single letters are easy
     assert contains('abc', 'b') is True
     assert contains('abc', 'c') is True
     assert contains('abc', 'ab') is True  # multiple letters are harder
     assert contains('abc', 'bc') is True
     assert contains('abc', 'abc') is True  # all strings contain themselves
     assert contains('aaa', 'a') is True  # multiple occurrences
     assert contains('aaa', 'aa') is True  # overlapping pattern
     # TODO: Write more positive test cases with assert is True statements
     assert contains('andrewbandrew', 'and') is True
     assert contains('booooooo', 'boo') is True
     assert contains('booooooo', 'oooo') is True
     assert contains('aaaaab', 'aaab') is True  # overlapping prefix
     assert find_index('aaaaab', 'aaab') == 2  # overlapping prefix
示例#14
0
 def test_find_index_with_complex_patterns(self):
     # Difficult test cases (examples) with complex patterns
     assert find_index('ababc', 'abc') == 2  # overlapping prefix
     assert find_index('bananas', 'nas') == 4  # overlapping prefix
     assert find_index('abcabcabc', 'abc') == 0  # multiple occurrences
     assert find_index('abcabcab', 'abc') == 0  # multiple occurrences
     assert find_index('abcabcdef', 'abcd') == 3  # overlapping prefix
     assert find_index('abcabcdef', 'abcdef') == 3  # overlapping prefix
     assert find_index('abcabcdabcde', 'abcde') == 7  # overlapping prefix
     assert find_index(
         'abcabcdabcde',
         'abcd') == 3  # multiple occurrences, overlapping prefix
     assert find_index('abra cadabra', 'abra') == 0  # multiple occurrences
     assert find_index('abra cadabra', 'adab') == 6  # overlapping prefix
     # TODO: Write more test cases that check complex patterns or edge cases
     assert find_index('taco cat', 'o c') == 3
     assert find_index('new york city', 'ew') == 1
示例#15
0
 def test_find_index_with_matching_patterns(self):
     # Positive test cases (examples) with matching patterns
     assert find_index('abc', '') == 0  # all strings contain empty string
     assert find_index('abc', 'a') == 0  # single letters are easy
     assert find_index('abc', 'b') == 1
     assert find_index('abc', 'c') == 2
     assert find_index('abc', 'ab') == 0  # multiple letters are harder
     assert find_index('abc', 'bc') == 1
     assert find_index('abc', 'abc') == 0  # all strings contain themselves
     assert find_index('aaa', 'a') == 0  # multiple occurrences
     assert find_index('aaa', 'aa') == 0  # overlapping pattern
     # TODO: Write more positive test cases with assert equal int statements
     assert find_index('mississippi', 'sis') == 3
     assert find_index('chelseaanne', 'a') == 6
 def test_find_index_with_complex_patterns(self):
     # Difficult test cases (examples) with complex patterns
     assert find_index('ababc', 'abc') == 2  # overlapping prefix
     assert find_index('bananas', 'nas') == 4  # overlapping prefix
     assert find_index('abcabcabc', 'abc') == 0  # multiple occurrences
     assert find_index('abcabcab', 'abc') == 0  # multiple occurrences
     assert find_index('abcabcdef', 'abcd') == 3  # overlapping prefix
     assert find_index('abcabcdef', 'abcdef') == 3  # overlapping prefix
     assert find_index('abcabcdabcde', 'abcde') == 7  # overlapping prefix
     # multiple occurrences, overlapping prefix
     assert find_index('abcabcdabcde', 'abcd') == 3
     assert find_index('abra cadabra', 'abra') == 0  # multiple occurrences
     assert find_index('abra cadabra', 'adab') == 6  # overlapping prefix
     # TODO: Write more test cases that check complex patterns or edge cases
     assert find_index('algorithm', 'rithm') == 4
     assert find_index('computer', 'er') == 6
     assert find_index('conscience', 'science') == 3
示例#17
0
    def test_find_index_with_complex_patterns(self):
        # Difficult test cases (examples) with complex patterns
        assert find_index('ababc', 'abc') == 2  # overlapping prefix
        assert find_index('bananas', 'nas') == 4  # overlapping prefix
        assert find_index('abcabcabc', 'abc') == 0  # multiple occurrences
        assert find_index('abcabcab', 'abc') == 0  # multiple occurrences
        assert find_index('abcabcdef', 'abcd') == 3  # overlapping prefix
        assert find_index('abcabcdef', 'abcdef') == 3  # overlapping prefix
        assert find_index('abcabcdabcde', 'abcde') == 7  # overlapping prefix
        assert find_index(
            'abcabcdabcde',
            'abcd') == 3  # multiple occurrences, overlapping prefix
        assert find_index('abra cadabra', 'abra') == 0  # multiple occurrences
        assert find_index('abra cadabra', 'adab') == 6  # overlapping prefix

        # TODO: Write more test cases that check complex patterns or edge cases
        # You'll need a lot more than this to test your algorithm's robustness
        # ...
        assert find_index('abra cadabra', '') == 0  #empty string
        assert find_index('asd83 4fg o3 -hjkl', '83 4fg') == 3  #spaces
示例#18
0
    def test_find_index_with_matching_patterns(self):
        # Positive test cases (examples) with matching patterns
        assert find_index('abc', '') == 0  # all strings contain empty string
        assert find_index('abc', 'a') == 0  # single letters are easy
        assert find_index('abc', 'b') == 1
        assert find_index('abc', 'c') == 2
        assert find_index('abc', 'ab') == 0  # multiple letters are harder
        assert find_index('abc', 'bc') == 1
        assert find_index('abc', 'abc') == 0  # all strings contain themselves
        assert find_index('aaa', 'a') == 0  # multiple occurrences
        assert find_index('aaa', 'aa') == 0  # overlapping pattern

        # TODO: Write more positive test cases with assert equal int statements
        assert find_index('aaa', 'aa') == 0
        assert find_index('!@#$%^&*()', '#') == 2  # Special chars
        assert find_index('!@#$%^&*()', '()') == 8  # 2 Special chars
示例#19
0
 def test_find_index_with_complex_patterns(self):
     # Difficult test cases (examples) with complex patterns
     assert find_index('ababc', 'abc') == 2  # overlapping prefix
     assert find_index('bananas', 'nas') == 4  # overlapping prefix
     assert find_index('abcabcabc', 'abc') == 0  # multiple occurrences
     assert find_index('abcabcab', 'abc') == 0  # multiple occurrences
     assert find_index('abcabcdef', 'abcd') == 3  # overlapping prefix
     assert find_index('abcabcdef', 'abcdef') == 3  # overlapping prefix
     assert find_index('abcabcdabcde', 'abcde') == 7  # overlapping prefix
     assert find_index(
         'abcabcdabcde',
         'abcd') == 3  # multiple occurrences, overlapping prefix
     assert find_index('abra cadabra', 'abra') == 0  # multiple occurrences
     assert find_index('abra cadabra', 'adab') == 6  # overlapping prefix
     with self.assertRaises(AssertionError,
                            msg='pattern is not a string: abra'):
         find_index('aaaaaaa', 1)
 def test_find_index_with_matching_patterns(self):
     # Positive test cases (examples) with matching patterns
     assert find_index('abc', '') == 0  # all strings contain empty string
     assert find_index('abc', 'a') == 0  # single letters are easy
     assert find_index('abc', 'b') == 1
     assert find_index('abc', 'c') == 2
     assert find_index('abc', 'ab') == 0  # multiple letters are harder
     assert find_index('abc', 'bc') == 1
     assert find_index('abc', 'abc') == 0  # all strings contain themselves
     assert find_index('aaa', 'a') == 0  # multiple occurrences
     assert find_index('aaa', 'aa') == 0  # overlapping pattern
     assert find_index('bananas', 'ana') == 1
     assert find_index('ashe', 'she') == 1
     assert find_index('slack', 'k') == 4
 def test_find_index_with_complex_patterns(self):
     # Difficult test cases (examples) with complex patterns
     assert find_index('ababc', 'abc') == 2  # overlapping prefix
     assert find_index('bananas', 'nas') == 4  # overlapping prefix
     assert find_index('abcabcabc', 'abc') == 0  # multiple occurrences
     assert find_index('abcabcab', 'abc') == 0  # multiple occurrences
     assert find_index('abcabcdef', 'abcd') == 3  # overlapping prefix
     assert find_index('abcabcdef', 'abcdef') == 3  # overlapping prefix
     assert find_index('abcabcdabcde', 'abcde') == 7  # overlapping prefix
     assert find_index('abcabcdabcde', 'abcd') == 3  # multiple occurrences, overlapping prefix
     assert find_index('abra cadabra', 'abra') == 0  # multiple occurrences
     assert find_index('abra cadabra', 'adab') == 6  # overlapping prefix
     # TODO: Write more test cases that check complex patterns or edge cases
     # You'll need a lot more than this to test your algorithm's robustness
     assert find_index('jfkjf', 'jf') == 0  # multiple occurrences
     assert find_index('mammonommam', 'am') == 1  # multiple occurrences
     assert find_index('kakaka', 'aka') == 1  # overlapping prefix
     assert find_index('kongkongs', 'kongs') == 4  # overlapping prefix
示例#22
0
    def test_find_index_with_matching_patterns(self):
        # Positive test cases (examples) with matching patterns
        assert find_index('abc', '') == 0  # all strings contain empty string
        assert find_index('abc', 'a') == 0  # single letters are easy
        assert find_index('abc', 'b') == 1
        assert find_index('abc', 'c') == 2
        assert find_index('abc', 'ab') == 0  # multiple letters are harder
        assert find_index('abc', 'bc') == 1
        assert find_index('abc', 'abc') == 0  # all strings contain themselves
        assert find_index('aaa', 'a') == 0  # multiple occurrences
        assert find_index('aaa', 'aa') == 0  # overlapping pattern

        assert find_index('hello there', '') == 0
        assert find_index('hello there', ' ') == 5
        assert find_index('hello there', 'h') == 0
        assert find_index('hello there', 'e') == 1
        assert find_index('hello there', 'he') == 0
        assert find_index('General Kenobi', 'Kenobi') == 8
        assert find_index('General Kenobi', 'en') == 1
        assert find_index('General Kenobi', 'obi') == 11
        assert find_index('General Kenobi', 'l K') == 6

        assert find_index('oooooooooh', 'oooh') == 6
        assert find_index('oooooh', 'oooh') == 2
 def test_find_index_with_matching_patterns(self):
     # Positive test cases (examples) with matching patterns
     assert find_index('abc', '') == 0  # all strings contain empty string
     assert find_index('abc', 'a') == 0  # single letters are easy
     assert find_index('abc', 'b') == 1
     assert find_index('abc', 'c') == 2
     assert find_index('abc', 'ab') == 0  # multiple letters are harder
     assert find_index('abc', 'bc') == 1
     assert find_index('abc', 'abc') == 0  # all strings contain themselves
     assert find_index('aaa', 'a') == 0  # multiple occurrences
     assert find_index('aaa', 'aa') == 0  # overlapping pattern
     # TODO: Write more positive test cases with assert equal int statements
     assert find_index('kaichi', 'ichi') == 2
     assert find_index('make school', 'ake') == 1
     assert find_index('algorithm', 'ithm') == 5
     assert find_index('aaaaab', 'aaab') == 2
示例#24
0
    def test_find_index_with_complex_patterns(self):
        # Difficult test cases (examples) with complex patterns
        assert find_index('ababc', 'abc') == 2  # overlapping prefix
        assert find_index('bananas', 'nas') == 4  # overlapping prefix
        assert find_index('abcabcabc', 'abc') == 0  # multiple occurrences
        assert find_index('abcabcab', 'abc') == 0  # multiple occurrences
        assert find_index('abcabcdef', 'abcd') == 3  # overlapping prefix
        assert find_index('abcabcdef', 'abcdef') == 3  # overlapping prefix
        assert find_index('abcabcdabcde', 'abcde') == 7  # overlapping prefix
        assert find_index('abcabcdabcde', 'abcd') == 3  # multiple occurrences, overlapping prefix
        assert find_index('abra cadabra', 'abra') == 0  # multiple occurrences
        assert find_index('abra cadabra', 'adab') == 6  # overlapping prefix

        assert find_index('heyheymommasaidthewayyoumove', 'ymom') == 5
        assert find_index("if there's a will, there's a way", "there's a way") == 19
        assert find_index('arrrrrrrg', 'rg') == 7
        assert find_index('arrrrrrrg', 'rrr') == 1
        assert find_index('arrrrrrrg', 'rrrrg') == 4
        assert find_index('arrrrrrrg', 'rrrrrrg') == 2

        assert find_index('asdfasvazasdf', '') == 0  # empty pattern
        # repeating patterns
        assert find_index('uuummummmuuummmm', 'uuummm') == 9
        assert find_index('ooo', 'oo') == 0  # sorta strange pattern
 def test_find_index_with_complex_patterns(self):
     # Difficult test cases (examples) with complex patterns
     assert find_index('ababc', 'abc') == 2  # overlapping prefix
     assert find_index('bananas', 'nas') == 4  # overlapping prefix
     assert find_index('abcabcabc', 'abc') == 0  # multiple occurrences
     assert find_index('abcabcab', 'abc') == 0  # multiple occurrences
     assert find_index('abcabcdef', 'abcd') == 3  # overlapping prefix
     assert find_index('abcabcdef', 'abcdef') == 3  # overlapping prefix
     assert find_index('abcabcdabcde', 'abcde') == 7  # overlapping prefix
     assert find_index(
         'abcabcdabcde',
         'abcd') == 3  # multiple occurrences, overlapping prefix
     assert find_index('abra cadabra', 'abra') == 0  # multiple occurrences
     assert find_index('abra cadabra', 'adab') == 6  # overlapping prefix
     # TODO: Write more test cases that check complex patterns or edge cases
     assert find_index('yzxyzxyz', 'xyz') == 2
     assert find_index('facebook', 'book') == 4
     assert find_index('laptop', 'top') == 3
     assert find_index('interesting', 'rest') == 4
示例#26
0
 def test_find_index_with_matching_patterns(self):
     # Positive test cases (examples) with matching patterns
     assert find_index('abc', '') == 0  # all strings contain empty string
     assert find_index('abc', 'a') == 0  # single letters are easy
     assert find_index('abc', 'b') == 1
     assert find_index('abc', 'c') == 2
     assert find_index('abc', 'ab') == 0  # multiple letters are harder
     assert find_index('abc', 'bc') == 1
     assert find_index('abc', 'abc') == 0  # all strings contain themselves
     assert find_index('aaa', 'a') == 0  # multiple occurrences
     assert find_index('aaa', 'aa') == 0  # overlapping pattern
     assert find_index('medi', 'di') == 2
     assert find_index('medi', 'edi') == 1
     assert find_index('aaaaaag', 'aaag') == 3  # Aakash killer test case
示例#27
0
 def test_find_index_with_matching_patterns(self):
     # Positive test cases (examples) with matching patterns
     assert find_index("abc", "") == 0  # all strings contain empty string
     assert find_index("abc", "a") == 0  # single letters are easy
     assert find_index("abc", "b") == 1
     assert find_index("abc", "c") == 2
     assert find_index("abc", "ab") == 0  # multiple letters are harder
     assert find_index("abc", "bc") == 1
     assert find_index("abc", "abc") == 0  # all strings contain themselves
     assert find_index("aaa", "a") == 0  # multiple occurrences
     assert find_index("aaa", "aa") == 0  # overlapping pattern
     assert find_index("yaaaaaaaaaYEETyaaaaaYEET", "yeet") == 10
     assert find_index("whome?aw hell nahhhhh", "aw") == 6
     assert find_index("I cant believe its not PYTHON", "python") == 23
 def test_find_index_with_matching_patterns(self):
     # Positive test cases (examples) with matching patterns
     assert find_index('abc', '') == 0  # all strings contain empty string
     assert find_index('abc', 'a') == 0  # single letters are easy
     assert find_index('abc', 'b') == 1
     assert find_index('abc', 'c') == 2
     assert find_index('abc', 'ab') == 0  # multiple letters are harder
     assert find_index('abc', 'bc') == 1
     assert find_index('abc', 'abc') == 0  # all strings contain themselves
     assert find_index('aaa', 'a') == 0  # multiple occurrences
     assert find_index('aaa', 'aa') == 0  # overlapping pattern
     # TODO: Write more positive test cases with assert equal int statements
     assert find_index('abcjdhiuadjow',
                       'jdhi') == 3  # all strings contain themselves
     assert find_index('iureyjaodja',
                       'jao') == 5  # all strings contain themselves
     assert find_index('gshgsagshgsxgetgets',
                       'gsx') == 9  # all strings contain themselves
     assert find_index('aaaaaaaab', 'aaaab') == 4  # not resetting pattern
示例#29
0
 def test_find_index_with_complex_patterns(self):
     # Difficult test cases (examples) with complex patterns
     assert find_index('ababc', 'abc') == 2  # overlapping prefix
     assert find_index('bananas', 'nas') == 4  # overlapping prefix
     assert find_index('abcabcabc', 'abc') == 0  # multiple occurrences
     assert find_index('abcabcab', 'abc') == 0  # multiple occurrences
     assert find_index('abcabcdef', 'abcd') == 3  # overlapping prefix
     assert find_index('abcabcdef', 'abcdef') == 3  # overlapping prefix
     assert find_index('abcabcdabcde', 'abcde') == 7  # overlapping prefix
     assert find_index(
         'abcabcdabcde',
         'abcd') == 3  # multiple occurrences, overlapping prefix
     assert find_index('abra cadabra', 'abra') == 0  # multiple occurrences
     assert find_index('abra cadabra', 'adab') == 6  # overlapping prefix
     assert find_index('medi is a boss', 'medi') == 0
示例#30
0
 def test_find_index_with_complex_patterns(
     self
 ):  # Difficult test cases (examples) with complex patterns
     assert find_index("ababc", "abc") == 2  # overlapping prefix
     assert find_index("bananas", "nas") == 4  # overlapping prefix
     assert find_index("abcabcabc", "abc") == 0  # multiple occurrences
     assert find_index("abcabcab", "abc") == 0  # multiple occurrences
     assert find_index("abcabcdef", "abcd") == 3  # overlapping prefix
     assert find_index("abcabcdef", "abcdef") == 3  # overlapping prefix
     assert find_index("abcabcdabcde", "abcde") == 7  # overlapping prefix
     assert (
         find_index("abcabcdabcde", "abcd") == 3
     )  # multiple occurrences, overlapping prefix
     assert find_index("abra cadabra", "abra") == 0  # multiple occurrences
     assert find_index("abra cadabra", "adab") == 6  # overlapping prefix
     assert find_index("robots die on roblox", "rob") == 0
     assert find_index("roxbots die on roblox", "rob") == 15
     assert find_index("bro plz lemme hit your juul, just two hits", "juu") == 23
     assert (
         find_index("I got the horses in the back, horse stock is attached", "horse")
         == 10
     )