Exemple #1
0
 def test_find_all_indexes_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_all_indexes('abc', 'z') == []  # remember to test other letters
     assert find_all_indexes('abc', 'ac') == []  # important to test close cases
     assert find_all_indexes('abc', 'az') == []  # first letter, but not last
     assert find_all_indexes('abc', 'abz') == []  # first 2 letters, but not last
     assert find_all_indexes('abcabcabcabc','ac') == []
Exemple #2
0
 def test_find_all_indexes_with_matching_patterns(self):
     # Positive test cases (examples) with matching patterns
     assert find_all_indexes('abc', '') == [0, 1, 2]  # all strings contain empty string
     assert find_all_indexes('abc', 'a') == [0]  # single letters are easy
     assert find_all_indexes('abc', 'b') == [1]
     assert find_all_indexes('abc', 'c') == [2]
     assert find_all_indexes('abc', 'ab') == [0]  # multiple letters are harder
     assert find_all_indexes('abc', 'bc') == [1]
     assert find_all_indexes('abc', 'abc') == [0]  # all strings contain themselves
     assert find_all_indexes('aaa', 'a') == [0, 1, 2]  # multiple occurrences
     assert find_all_indexes('aaa', 'aa') == [0, 1]  # overlapping pattern
     assert find_all_indexes('bbbbbb', 'bbb') == [0, 3]
 def test_find_all_indexes_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_all_indexes('abc',
                             'z') == []  # remember to test other letters
     assert find_all_indexes('abc',
                             'ac') == []  # important to test close cases
     assert find_all_indexes('abc',
                             'az') == []  # first letter, but not last
     assert find_all_indexes('abc',
                             'abz') == []  # first 2 letters, but not last
     # TODO: Write more negative test cases with assert equal list statements
     assert find_all_indexes('rat a tat cat', 'aa') == []
 def test_find_all_indexes_with_complex_patterns(self):
     # Difficult test cases (examples) with complex patterns
     assert find_all_indexes('ababc', 'abc') == [2]  # overlapping prefix
     assert find_all_indexes('bananas', 'nas') == [4]  # overlapping prefix
     assert find_all_indexes('abcabcabc', 'abc') == [0, 3, 6]  # multiple occurrences
     assert find_all_indexes('abcabcab', 'abc') == [0, 3]  # multiple occurrences
     assert find_all_indexes('abcabcdef', 'abcd') == [3]  # overlapping prefix
     assert find_all_indexes('abcabcdef', 'abcdef') == [3]  # overlapping prefix
     assert find_all_indexes('abcabcdabcde', 'abcde') == [7]  # overlapping prefix
     assert find_all_indexes('abcabcdabcde', 'abcd') == [3, 7]  # multiple occurrences, overlapping prefix
     assert find_all_indexes('abra cadabra', 'abra') == [0, 8]  # multiple occurrences
     assert find_all_indexes('abra cadabra', 'adab') == [6]  # overlapping prefix
Exemple #5
0
    def test_find_all_indexes_with_non_matching_patterns(self):
        # Negative test cases (counterexamples) with non-matching patterns
        assert find_all_indexes('abc', 'z') == []  # remember to test other letters
        assert find_all_indexes('abc', 'ac') == []  # important to test close cases
        assert find_all_indexes('abc', 'az') == []  # first letter, but not last
        assert find_all_indexes('abc', 'abz') == []  # first 2 letters, but not last

        assert find_all_indexes('hello there', 'their') == []
        assert find_all_indexes('hello there', 'low') == []
        assert find_all_indexes('hello there', 'help') == []

        assert find_all_indexes('axx', 'xz') == []  # sending characters
        assert find_all_indexes('asd', 'asdasd') == []  # longer pattern
        assert find_all_indexes('abc', '') == [
            0, 1, 2]  # all indexes in string if char is empty
Exemple #6
0
 def test_find_all_indexes_with_matching_patterns(self):
     # Positive test cases (examples) with matching patterns
     assert find_all_indexes('abc',
                             '') == [0, 1,
                                     2]  # all strings contain empty string
     assert find_all_indexes('abc', 'a') == [0]  # single letters are easy
     assert find_all_indexes('abc', 'b') == [1]
     assert find_all_indexes('abc', 'c') == [2]
     assert find_all_indexes('abc',
                             'ab') == [0]  # multiple letters are harder
     assert find_all_indexes('abc', 'bc') == [1]
     assert find_all_indexes('abc',
                             'abc') == [0]  # all strings contain themselves
     assert find_all_indexes('aaa', 'a') == [0, 1,
                                             2]  # multiple occurrences
     assert find_all_indexes('aaa', 'aa') == [0, 1]  # overlapping pattern
     # TODO: Write more positive test cases with assert equal list statements
     assert find_all_indexes('kevin is not evin', 'evin') == [1, 10]
Exemple #7
0
 def test_find_all_indexes_with_duplicates(self):
     assert find_all_indexes('bbbb', 'bb') == [0, 1, 2]
     assert find_all_indexes('bbbbbb', 'bbb') == [0, 1, 2, 3]
     assert find_all_indexes('bbbbbbbb', 'bb') == [0, 1, 2, 3, 4, 5, 6]
     assert find_all_indexes('bbabbabb', 'bbabb') == [0, 3]
     assert find_all_indexes('bbbabbbabbb', 'bbbabbb') == [0, 4]
     assert find_all_indexes('bbbbabbbbabbbbabbbb',
                             'bbbbabbbb') == [0, 5, 10]
 def test_find_all_indexes_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_all_indexes('abc',
                             'z') == []  # remember to test other letters
     assert find_all_indexes('abc',
                             'ac') == []  # important to test close cases
     assert find_all_indexes('abc',
                             'az') == []  # first letter, but not last
     assert find_all_indexes('abc',
                             'abz') == []  # first 2 letters, but not last
     # Write more negative test cases with assert equal list statements
     assert find_all_indexes('abcd', 'abcr') == []
     assert find_all_indexes('asdf', 'fdsa') == []
     assert find_all_indexes('sdaf', 'sdfa') == []
     assert find_all_indexes('pinepirepink', 'pile') == []
Exemple #9
0
 def test_find_all_indexes_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_all_indexes('abc',
                             'z') == []  # remember to test other letters
     assert find_all_indexes('abc',
                             'ac') == []  # important to test close cases
     assert find_all_indexes('abc',
                             'az') == []  # first letter, but not last
     assert find_all_indexes('abc',
                             'abz') == []  # first 2 letters, but not last
     # TODO: Write more negative test cases with assert equal list statements
     assert find_all_indexes('defeat', 'w') == []
     assert find_all_indexes('110011010', '1997') == []
     assert find_all_indexes('____---____---', 'hey') == []
     assert find_all_indexes('boom bam bop bada bop boump pow',
                             'drums') == []
Exemple #10
0
 def test_find_all_indexes_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_all_indexes('abc',
                             'z') == []  # remember to test other letters
     assert find_all_indexes('abc',
                             'ac') == []  # important to test close cases
     assert find_all_indexes('abc',
                             'az') == []  # first letter, but not last
     assert find_all_indexes('abc',
                             'abz') == []  # first 2 letters, but not last
     assert find_all_indexes('farfignugenfarfig', 'fart') == []
     assert find_all_indexes('boobajonga', 'bob') == []
     assert find_all_indexes('vroomvroom', 'roomy') == []
 def test_find_all_indexes_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     # remember to test other letters
     assert find_all_indexes('abc', 'z') == []
     # important to test close cases
     assert find_all_indexes('abc', 'ac') == []
     # first letter, but not last
     assert find_all_indexes('abc', 'az') == []
     # first 2 letters, but not last
     assert find_all_indexes('abc', 'abz') == []
     assert find_all_indexes('sjklqjk2lnqw', 'ajsk2') == []
     assert find_all_indexes('2kl;as1kl;', 'asd') == []
     assert find_all_indexes('askqk', 'askql') == []
 def test_find_all_indexes_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_all_indexes('abc',
                             'z') == []  # remember to test other letters
     assert find_all_indexes('abc',
                             'ac') == []  # important to test close cases
     assert find_all_indexes('abc',
                             'az') == []  # first letter, but not last
     assert find_all_indexes('abc',
                             'abz') == []  # first 2 letters, but not last
     assert find_all_indexes('pepperoni', 'sausage') == []  # not even close
     assert find_all_indexes('etcetera', 'cera') == []
     assert find_all_indexes('abc', 'bbc') == []
    def test_find_all_indexes_with_non_matching_patterns(self):
        # remember to test other letters
        assert find_all_indexes('abc', 'z') == []
        # important to test close cases
        assert find_all_indexes('abc', 'ac') == []
        # first letter, but not last
        assert find_all_indexes('abc', 'az') == []
        # first 2 letters, but not last
        assert find_all_indexes('abc', 'abz') == []

        self.assertEqual(find_all_indexes('avv', 'vg'), [])
        self.assertEqual(find_all_indexes('ygd', 'z'), [])
        self.assertEqual(find_all_indexes('math rocks', 'cs rocks'), [])
Exemple #14
0
 def test_my_own_cases(self):
     assert find_all_indexes('abababababababa',
                             'aba') == [0, 2, 4, 6, 8, 10, 12]
     assert find_all_indexes('levelevel', 'level') == [0, 4]
     # worst case senario
     assert find_all_indexes('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah',
                             'aaaaaaaaaaah') == [32]
     assert find_all_indexes('ooooo', 'oo') == [0, 1, 2, 3]
     assert find_all_indexes('topotopot', 'pot') == [2, 6]
     assert find_all_indexes('tap', 'tap') == [0]
Exemple #15
0
 def test_find_all_indexes_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_all_indexes("abc", "z") == []  # remember to test other letters
     assert find_all_indexes("abc", "ac") == []  # important to test close cases
     assert find_all_indexes("abc", "az") == []  # first letter, but not last
     assert find_all_indexes("abc", "abz") == []  # first 2 letters, but not last
     assert find_all_indexes("robots are invading robotland!", "roblox") == []
     assert (
         find_all_indexes(
             "I got the horxes in the back, horx stock is attached", "horse"
         )
         == []
     )
     assert find_all_indexes("yayeetyayeetyayeetyaaaa", "yeeet") == []
Exemple #16
0
 def test_find_all_indexes_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     # remember to test other letters
     assert find_all_indexes('abc', 'z') == []
     # important to test close cases
     assert find_all_indexes('abc', 'ac') == []
     # first letter, but not last
     assert find_all_indexes('abc', 'az') == []
     # first 2 letters, but not last
     assert find_all_indexes('abc', 'abz') == []
     # TODO: Write more negative test cases with assert equal list statements
     assert find_all_indexes(
         'baby baby i feel crazy',
         'i feel so sane this is a healthy relationship') == []
     assert find_all_indexes(
         'dear scammer clairvoyant will i marry my celebrity crush',
         'uhh no but im gonna tell you what you wanna hear') == []
     assert find_all_indexes('some canonical text',
                             'cherry-picked ideas') == []
     assert find_all_indexes('objective reality',
                             'innately biased lens') == []
     assert find_all_indexes('aaaaaaaaaaaaaaaaaa', 'zymnop') == []
Exemple #17
0
 def test_find_all_indexes_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_all_indexes('abc',
                             'z') == []  # remember to test other letters
     assert find_all_indexes('abc',
                             'ac') == []  # important to test close cases
     assert find_all_indexes('abc',
                             'az') == []  # first letter, but not last
     assert find_all_indexes('abc',
                             'abz') == []  # first 2 letters, but not last
     # TODO: Write more negative test cases with assert equal list statements
     assert find_all_indexes('!@#$%^&*()', '$^') == []  #special char
     assert find_all_indexes('I Like Wafflez', 'i like wafflez') == [
     ]  # case sensitivity is off
     assert find_all_indexes('abcde', 'sdw') == []
Exemple #18
0
 def test_find_all_indexes_with_non_matching_patterns(self):
     # Negative test cases (counterexamples) with non-matching patterns
     assert find_all_indexes('abc',
                             'z') == []  # remember to test other letters
     assert find_all_indexes('abc',
                             'ac') == []  # important to test close cases
     assert find_all_indexes('abc',
                             'az') == []  # first letter, but not last
     assert find_all_indexes('abc',
                             'abz') == []  # first 2 letters, but not last
     # TODO: Write more negative test cases with assert equal list statements
     assert find_all_indexes('heeeelp meeee', 'help') == []
     assert find_all_indexes(
         'im so tired but i wanna pass this submission pls', 'awake') == []
     assert find_all_indexes('im such a procrastinator',
                             'good student') == []
Exemple #19
0
    def test_find_all_indexes_with_matching_patterns(self):
        # Positive test cases (examples) with matching patterns
        assert find_all_indexes('abc', '') == [0, 1, 2]  # all strings contain empty string
        assert find_all_indexes('abc', 'a') == [0]  # single letters are easy
        assert find_all_indexes('abc', 'b') == [1]
        assert find_all_indexes('abc', 'c') == [2]
        assert find_all_indexes('abc', 'ab') == [0]  # multiple letters are harder
        assert find_all_indexes('abc', 'bc') == [1]
        assert find_all_indexes('abc', 'abc') == [0]  # all strings contain themselves
        assert find_all_indexes('aaa', 'a') == [0, 1, 2]  # multiple occurrences
        assert find_all_indexes('aaa', 'aa') == [0, 1]  # overlapping pattern

        assert find_all_indexes('hello there', '') == [
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
        assert find_all_indexes('hello there', ' ') == [5]
        assert find_all_indexes('hello there', 'h') == [0, 7]
        assert find_all_indexes('hello there', 'e') == [1, 8, 10]
        assert find_all_indexes('General Kenobi', 'Kenobi') == [8]
        assert find_all_indexes('General Kenobi', 'obi') == [11]
        assert find_all_indexes('General Kenobi', 'l K') == [6]

        assert find_all_indexes('\nhi\n', '\n') == [0, 3]  # escape characters
        assert find_all_indexes('🥑 🥑', '🥑') == [0, 2]
Exemple #20
0
 def test_find_all_indexes_with_complex_patterns(self):
     # Difficult test cases (examples) with complex patterns
     assert find_all_indexes('ababc', 'abc') == [2]  # overlapping prefix
     assert find_all_indexes('bananas', 'nas') == [4]  # overlapping prefix
     assert find_all_indexes('abcabcabc',
                             'abc') == [0, 3, 6]  # multiple occurrences
     assert find_all_indexes('abcabcab',
                             'abc') == [0, 3]  # multiple occurrences
     assert find_all_indexes('abcabcdef',
                             'abcd') == [3]  # overlapping prefix
     assert find_all_indexes('abcabcdef',
                             'abcdef') == [3]  # overlapping prefix
     assert find_all_indexes('abcabcdabcde',
                             'abcde') == [7]  # overlapping prefix
     assert find_all_indexes(
         'abcabcdabcde',
         'abcd') == [3, 7]  # multiple occurrences, overlapping prefix
     assert find_all_indexes('abra cadabra',
                             'abra') == [0, 8]  # multiple occurrences
     assert find_all_indexes('abra cadabra',
                             'adab') == [6]  # overlapping prefix
     # TODO: Write more test cases that check complex patterns or edge cases
     assert find_all_indexes('cacio de pepe', 'pe') == [9, 11]
     assert find_all_indexes('mac ayres says hay', 'ay') == [4, 11, 16]
Exemple #21
0
 def test_what_im_doing_with_my_life(self):
     assert find_all_indexes('\\', '\\') == [0]
     assert find_all_indexes('t\\\\', '\\') == [1, 2]
     assert find_all_indexes('t\\\\', '\\\\') == [1]
     assert find_all_indexes('\n', '\n') == [0]
     assert find_all_indexes('\n\n', '\n') == [0, 1]
     assert find_all_indexes('\ttap', 'tap') == [1]
     assert find_all_indexes('\ntap', 'tap') == [1]
     assert find_all_indexes('\ttap', '\ttap') == [0]
     assert find_all_indexes('\ntap', '\ntap') == [0]
     assert find_all_indexes('t\nap', 't\nap') == [0]
     assert find_all_indexes('\n', '') == [0]
     assert find_all_indexes('\ntap', '\ntap\n') == []
     assert find_all_indexes('\"\"\"hello\"\"\"', 'hello') == [3]
 def test_find_all_indexes_with_complex_patterns(self):
     # Difficult test cases (examples) with complex patterns
     assert find_all_indexes('ababc', 'abc') == [2]  # overlapping prefix
     assert find_all_indexes('bananas', 'nas') == [4]  # overlapping prefix
     assert find_all_indexes('abcabcabc', 'abc') == [
         0, 3, 6]  # multiple occurrences
     assert find_all_indexes('abcabcab', 'abc') == [
         0, 3]  # multiple occurrences
     assert find_all_indexes('abcabcdef', 'abcd') == [
         3]  # overlapping prefix
     assert find_all_indexes('abcabcdef', 'abcdef') == [
         3]  # overlapping prefix
     assert find_all_indexes('abcabcdabcde', 'abcde') == [
         7]  # overlapping prefix
     # multiple occurrences, overlapping prefix
     assert find_all_indexes('abcabcdabcde', 'abcd') == [3, 7]
     assert find_all_indexes('abra cadabra', 'abra') == [
         0, 8]  # multiple occurrences
     assert find_all_indexes('abra cadabra', 'adab') == [
         6]  # overlapping prefix
     # TODO: Write more test cases that check complex patterns or edge cases
     
     assert find_all_indexes('aaaaaaaaaaaaaaa', 'aaaa') == [
         0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
     assert find_all_indexes('aaa', 'aa') == [0, 1]
Exemple #23
0
    def test_find_all_indexes_with_complex_patterns(self):
        # Difficult test cases (examples) with complex patterns
        assert find_all_indexes('ababc', 'abc') == [2]  # overlapping prefix
        assert find_all_indexes('bananas', 'nas') == [4]  # overlapping prefix
        assert find_all_indexes('abcabcabc',
                                'abc') == [0, 3, 6]  # multiple occurrences
        assert find_all_indexes('abcabcab',
                                'abc') == [0, 3]  # multiple occurrences
        assert find_all_indexes('abcabcdef',
                                'abcd') == [3]  # overlapping prefix
        assert find_all_indexes('abcabcdef',
                                'abcdef') == [3]  # overlapping prefix
        assert find_all_indexes('abcabcdabcde',
                                'abcde') == [7]  # overlapping prefix
        assert find_all_indexes(
            'abcabcdabcde',
            'abcd') == [3, 7]  # multiple occurrences, overlapping prefix
        assert find_all_indexes('abra cadabra',
                                'abra') == [0, 8]  # multiple occurrences
        assert find_all_indexes('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_all_indexes('abra cadabra', 'abra cad') == [0]
        assert find_all_indexes(
            'asddssdsd sad', 'sd') == [1, 5,
                                       7]  # multiple occurrences and overlaped
Exemple #24
0
 def test_find_all_indexes_with_complex_patterns(self):
     # Difficult test cases (examples) with complex patterns
     assert find_all_indexes('ababc', 'abc') == [2]  # overlapping prefix
     assert find_all_indexes('bananas', 'nas') == [4]  # overlapping prefix
     assert find_all_indexes('abcabcabc',
                             'abc') == [0, 3, 6]  # multiple occurrences
     assert find_all_indexes('abcabcab',
                             'abc') == [0, 3]  # multiple occurrences
     assert find_all_indexes('abcabcdef',
                             'abcd') == [3]  # overlapping prefix
     assert find_all_indexes('abcabcdef',
                             'abcdef') == [3]  # overlapping prefix
     assert find_all_indexes('abcabcdabcde',
                             'abcde') == [7]  # overlapping prefix
     assert find_all_indexes(
         'abcabcdabcde',
         'abcd') == [3, 7]  # multiple occurrences, overlapping prefix
     assert find_all_indexes('abra cadabra',
                             'abra') == [0, 8]  # multiple occurrences
     assert find_all_indexes('abra cadabra',
                             'adab') == [6]  # overlapping prefix
     # TODO: Write more test cases that check complex patterns or edge cases
     assert find_all_indexes('abc',
                             'abcd') == []  # pattern longer than text
     with self.assertRaises(AssertionError,
                            msg='pattern is not a string: abra'):
         find_all_indexes('aaaaaaa', 1)
Exemple #25
0
    def test_walk_the_gauntlet(self):
        # METAL AF
        assert find_all_indexes('99 Red Balloons', '99') == [0]
        assert find_all_indexes('99 Red Balloons', '99 RED BALLOONS') == []
        assert find_all_indexes('sidyuf87723yh4j23!@#(@!$HRJWEfekwf',
                                '@') == [18, 21]
        assert find_all_indexes('Marlene Dietrich', 'Backpfeifengesicht') == []
        assert find_all_indexes('anananananananananananananananananan',
                                'anana') == [
                                    0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22,
                                    24, 26, 28, 30
                                ]
        assert find_all_indexes('施氏食獅史', '食') == [2]
        assert find_all_indexes(
            '''
            Donald J. Trump
            @realDonaldTrump

            Despite the negative press covfefe

            Retweets Likes
            11,029 13,430
            12:06 AM - 31 May 2017
            ''', 'covfefe') == [98]
        assert find_all_indexes(
            '''
            To be fair, you have to have a very high IQ to understand Rick and Morty. 
            The humor is extremely subtle, and without a solid grasp of theoretical physics 
            most of the jokes will go over a typical viewer's head. There's also Rick's nihilistic 
            outlook, which is deftly woven into his characterisation - his personal philosophy 
            draws heavily from Narodnaya Volya literature, for instance. The fans understand this 
            stuff; they have the intellectual capacity to truly appreciate the depths of these jokes, 
            to realize that they're not just funny- they say something deep about LIFE. As a 
            consequence people who dislike Rick and Morty truly ARE idiots- of course they wouldn't 
            appreciate, for instance, the humour in Rick's existential catchphrase "Wubba Lubba Dub 
            Dub," which itself is a cryptic reference to Turgenev's Russian epic Fathers and Sons. 
            I'm smirking right now just imagining one of those addlepated simpletons scratching their 
            heads in confusion as Dan Harmon's genius unfolds itself on their television screens. 
            What fools... how I pity them. 😂 And yes by the way, I DO have a Rick and Morty tattoo. 
            And no, you cannot see it. It's for the ladies' eyes only- And even they have to 
            demonstrate that they're within 5 IQ points of my own (preferably lower) beforehand.
            ''', 'Morty') == [80, 725, 1263]
        assert find_all_indexes(
            '''
            T̜͔̱ọ̺̺̝̤ ̥̞̩͓̜i͔̪̖͔̭̯͟n͓̬̤̯̖v̤ͅo̡̤̺̙͇̳͈̭k͕̭e̪̬͍̭̰͝ͅ ̵̹t͓̣̞̲͞h͉̰̥͎͢e͎̳͇͡ ͈̰͈̭̹͕̥h͍̜̬i̞̯͚͔̼̯v̭͚͙̻̙͟e̡͍̩̩̗͉-̟͕̖͓͚͓́m̙ͅi̭̭̮̦͖̫n̪̭͇d̮̲̖̤͓͟ ҉͍̰̗̹̯r̼̪͕͡e͠pr̷e͉͉̲̖s͉͙é̠̗̰̹n̡̝͎t͖̼̯͖̱͉in͓͔̝͍̞͉͜g̬̬̣ ͎̳̦͔̹̟̟c͉̺̮h̫̞͈̘̯̀a̼o̷̟̟̣̪s̝̕.̴̝̣͉͉͎̺
            ̫̀I̝͖̣͎͇̲͠ͅn̲̪̦v̸̫̣̖̪̺̙o̸̠͙͍̩k̜i̜n̳̭̖̼ͅg̢ ̀t̰͙h̯͙͇̬͖̟e̟̭̘̱̟̦ ̩͉̗̱̰̝͡f͕̙̲̲͟ͅͅee̙̜͈͖l̵̙͙i̩͕̮̳͙̙̝n͕g̡̻̥̲̞̰̝̟ ̰o͖͎f̛ ͈̳c̩̟̱͈̦͘ͅh̝̮a̘̺͈o͚̲̯̞͕s̘̞̝̹̗͇͈͞.̡͓̪̮̪
            ͕̻͈̻͕͉̀W̼̗̺̫̞͖it̠̦͎̪͓̺̻́h̭̼̘͕͔͔ ͕͓̠̟̙͉̩o̪͇̲̯u̸̟͚̰̠̲ṯ̖̭ ̰̣̣o̫̣̤͖̫͚͞ͅr̻d͏̘̣͙͓̫̭̩e̴̹͙͎̟r̹.
            ̝̤̩́The ͉̜̟͈͍N̯̤̞͔e̦̹̯̠̥̹z̡͇̭p̪̱̳ę̟̙͙ŕ̦͓̤͉͙̗͈d̴̖̖̺̩̼i̷̼̩a̺̲̪̘n҉̲̣ ͎̩̜h̬̗͉̱͉͈i̻͉̘̹̕v̴͉̤̱̖è̝̭̯̣̘-͇̘͔̜̜̜͞ͅm̵̠̝̦i̠̣͔n͖͈d҉̲̺ ̡̖͇͍o͘f̵ ch̩̞̗̱̘̀a̵̗̤͈̟̭o҉s.̸ ̠̞̠̭͖̦Z͘a͕̣̪̫͇̙l̗͖̳g͎̟̻o͖͚̮̬͘.̴̩
            ͔̝̦͖̬̲̠H͚̝͡e̵͇̜̲̦͔ͅ ͎͚͇w͔̹̭̳h̟̙͝o̸̯̫̯ ̢̫̤͖̯͕W̤ͅͅḁ̟̻iț̛͍͍ͅs͇̮̗ ̹͕͙̭͎̰̺B͞e̥h̜i̲̹̠̳͡ͅn͚͓̝̹̞d̵̹̫̗̯̩ ͡T̗͕̹̣͚̘̗h͓e̡̮ ̖͉W͇͈̠̱͈͉̬a̯̱̩͉͔͟l̶̰̞̻͚̗l̰͈͕̲̭̙͈.̯͟
            ̮Z͏̠̩͚̥̺̻A̦͔̜͎ͅL̪͜G͉̳͍̀ͅO̭̠̞̲͈̟̭͡!̫̹̰̣
            ''', 'chaos') == []
        assert find_all_indexes(
            '''
            Head underwater
            And they tell me
            To breathe easy for a while
            Breathing gets harder, even I know that
            Made room for me It's too soon to see
            If I'm happy in your hands
            I'm unusually hard to hold on to

            Blank stares at blank pages
            No easy way to say this
            You mean well, but you make this hard on me

            I'm not gonna write you a love song
            'Cause you asked for it
            'Cause you need one, you see

            I'm not gonna write you a love song
            'Cause you tell me it's
            Make or breaking this
            If you're on your way

            I'm not gonna write you to stay
            If all you have is leavin'
            I'ma need a better reason
            To write you a love song
            Today, today, yeah

            I learned the hard way
            That they all say
            Things you want to hear

            My heavy heart sinks deep down under
            You and your twisted words
            Your help just hurts
            You are not what I thought you were
            Hello to high and dry

            Convince me to please you
            Make me think that I need this too
            I'm trying to let you hear me as I am

            I'm not gonna write you a love song
            'Cause you asked for it
            'Cause you need one, you see

            I'm not gonna write you alove song
            'Cause you tell me it's
            Make or breaking this
            If you're on your way

            I'm not gonna write you to stay
            If all you have is leavin'
            I'ma need a better reason
            To write you a love song
            Today

            Promise me you'll leave the light on
            To help me see
            With daylight, my guide, gone
            'Cause I believe there's a way
            You can love me because I say
            I'm not gonna write you a love song
            'Cause you asked for it
            'Cause you need one,
            You see

            I'm not gonna write you a love song
            'Cause you tell me it's
            Make or breaking this
            Is that why you wanted a love song?
            'Cause you asked for it
            'Cause you need one, you see

            I'm not gonna write you a love song
            'Cause you tell me it's
            Make or breaking this
            Or you're on your way
            I'm not gonna write you to stay

            If your heart is nowhere in it
            I don't want it for a minute
            Babe, I'll walk the seven seas when I believe that
            There's a reason to write you a love song
            Today, today
            ''', '\n') != []
        with self.assertRaises(AssertionError,
                               msg='text is not a string: {}'.format(599)):
            find_all_indexes(599, '420')
        with self.assertRaises(AssertionError,
                               msg='pattern is not a string: {}'.format(420)):
            find_all_indexes('599', 420)
 def test_find_all_indexes_with_complex_patterns(self):
     # Difficult test cases (examples) with complex patterns
     assert find_all_indexes('ababc', 'abc') == [2]  # overlapping prefix
     assert find_all_indexes('bananas', 'nas') == [4]  # overlapping prefix
     assert find_all_indexes('abcabcabc', 'abc') == [0, 3, 6]  # multiple occurrences
     assert find_all_indexes('abcabcab', 'abc') == [0, 3]  # multiple occurrences
     assert find_all_indexes('abcabcdef', 'abcd') == [3]  # overlapping prefix
     assert find_all_indexes('abcabcdef', 'abcdef') == [3]  # overlapping prefix
     assert find_all_indexes('abcabcdabcde', 'abcde') == [7]  # overlapping prefix
     assert find_all_indexes('abcabcdabcde', 'abcd') == [3, 7]  # multiple occurrences, overlapping prefix
     assert find_all_indexes('abra cadabra', 'abra') == [0, 8]  # multiple occurrences
     assert find_all_indexes('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_all_indexes('jf k jf', 'jf') == [0, 5]  # multiple occurrences
     assert find_all_indexes('mam mo nomm am', 'am') == [1, 12]  # multiple occurrences
     assert find_all_indexes('kakaka', 'aka') == [1, 3]  # overlapping prefix
     assert find_all_indexes('kongkongs', 'kongs') == [4]  # overlapping prefix
     assert find_all_indexes('aaaaab', 'aaab') == [2]
Exemple #27
0
 def test_find_all_indexes_with_complex(self):
     assert find_all_indexes('repeatnothingrepeat', 'repeat') == [0, 13]
     assert find_all_indexes('rlovecaser', 'r') == [0, 9]
     assert find_all_indexes('rampcampnone', 'a') == [1, 5]
     assert find_all_indexes('abccbd', 'repeat') == []
     assert find_all_indexes('finalisNone', 'repeat') == []
Exemple #28
0
 def test_find_all_indexes_with_matching_patterns(self):
     # Positive test cases (examples) with matching patterns
     assert find_all_indexes("abc", "") == [
         0,
         1,
         2,
     ]  # all strings contain empty string
     assert find_all_indexes("abc", "a") == [0]  # single letters are easy
     assert find_all_indexes("abc", "b") == [1]
     assert find_all_indexes("abc", "c") == [2]
     assert find_all_indexes("abc", "ab") == [0]  # multiple letters are harder
     assert find_all_indexes("abc", "bc") == [1]
     assert find_all_indexes("abc", "abc") == [0]  # all strings contain themselves
     assert find_all_indexes("aaa", "a") == [0, 1, 2]  # multiple occurrences
     assert find_all_indexes("aaa", "aa") == [0, 1]  # overlapping pattern
     assert find_all_indexes(
         "I got the horses in the back, horse stock is attached", "horse"
     ) == [10, 30]
     assert find_all_indexes("bro plz lemme hit your juul, just two hits", "ju") == [
         23,
         29,
     ]
     assert find_all_indexes("robots die on roblox and robloxians win", "rob") == [
         0,
         14,
         25,
     ]
Exemple #29
0
 def test_find_all_indexes_with_complex_patterns(self):
     # Difficult test cases (examples) with complex patterns
     assert find_all_indexes("ababc", "abc") == [2]  # overlapping prefix
     assert find_all_indexes("bananas", "nas") == [4]  # overlapping prefix
     assert find_all_indexes("abcabcabc", "abc") == [0, 3, 6]  # multiple occurrences
     assert find_all_indexes("abcabcab", "abc") == [0, 3]  # multiple occurrences
     assert find_all_indexes("abcabcdef", "abcd") == [3]  # overlapping prefix
     assert find_all_indexes("abcabcdef", "abcdef") == [3]  # overlapping prefix
     assert find_all_indexes("abcabcdabcde", "abcde") == [7]  # overlapping prefix
     assert find_all_indexes("abcabcdabcde", "abcd") == [
         3,
         7,
     ]  # multiple occurrences, overlapping prefix
     assert find_all_indexes("abra cadabra", "abra") == [
         0,
         8,
     ]  # multiple occurrences
     assert find_all_indexes("abra cadabra", "adab") == [6]  # overlapping prefix
     assert find_all_indexes("yeetyeeeetyeetyeeetyeet", "yeet") == [0, 10, 19]
     assert find_all_indexes("hmmm, is there a pattern here?", "er") == [11, 21, 26]
 def test_find_all_indexes_with_complex_patterns(self):
     # Difficult test cases (examples) with complex patterns
     assert find_all_indexes('ababc', 'abc') == [2]  # overlapping prefix
     assert find_all_indexes('bananas', 'nas') == [4]  # overlapping prefix
     assert find_all_indexes('abcabcabc',
                             'abc') == [0, 3, 6]  # multiple occurrences
     assert find_all_indexes('abcabcab',
                             'abc') == [0, 3]  # multiple occurrences
     assert find_all_indexes('abcabcdef',
                             'abcd') == [3]  # overlapping prefix
     assert find_all_indexes('abcabcdef',
                             'abcdef') == [3]  # overlapping prefix
     assert find_all_indexes('abcabcdabcde',
                             'abcde') == [7]  # overlapping prefix
     assert find_all_indexes(
         'abcabcdabcde',
         'abcd') == [3, 7]  # multiple occurrences, overlapping prefix
     assert find_all_indexes('abra cadabra',
                             'abra') == [0, 8]  # multiple occurrences
     assert find_all_indexes('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_all_indexes('mamamiya', 'ma') == [0, 2]
     assert find_all_indexes('hiccup', 'cup') == [3]
     assert find_all_indexes('fiftyfive', 'fi') == [0, 5]
     assert find_all_indexes('pencils', 'pen') == [0]