def test_find_basic():
    """
    Test find function.
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14

    assert find("xxxatcg","atcg",2,10) == 3
def test_find_basic():
    """
    Test find function.
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14
    assert find("This is an ex-parrot", "parrot", 14, 20) == 14
    assert find("Who lives in a pineapple under the sea", "sea", 0, 38) == 35
def test_find_basic():
    """
     Test find function.
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14
    assert find("Hello Toronto!", "may", 0, 20) == -1
    assert find("jshdushd", "hd", 30, 100) == -1
    assert find("45637902341", "902", 0, 200) == 5
def test_find_basic():
    """
    Test find function.
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14
    assert find("Hello, are you my mummy?", "my", 0, 23) == 15
    assert find("You are my sunshine", "moonlight", 0, 18) == -1
    assert find("abcdefghijklmnop", "abd", 0, 16) == -1
def test_find_not_present():
    """
    Test find function when substring is not present in input_string, or outside index range.
    """
    assert find("This is an ex-parrot", "parrot", 0, 19) == -1
    assert find("This is an ex-parrot", "parrot", 15, 20) == -1
    assert find("Who lives in a pineapple under the sea", "sea", 0, 30) == -1
    assert find("", "parrot", 0, 0) == -1
def test_find_basic():
    """
    Test find function.
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14
    assert find("Hello, are you my mummy?", "my", 0, 23) == 15
    assert find("You are my sunshine", "moonlight", 0, 18) == -1
    assert find("abcdefghijklmnop", "abd", 0, 16) == -1
def test_find_basic():
    """
    Test find function.
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14
    assert find("This is an ex-parrot", "an", 0, 20) == 8
    assert find("This is an ex-parrot", "This", 0, 20) == 0
    assert find("This is an ex-parrot", "this", 0, 20) == -1
    assert find("This is an ex-parrot", "THIS", 0, 20) == -1
def test_find_basic():
    """
    Test find function: find the index of "parrot" in the string with the start of 0 and end of 20.
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14
    assert find("This is an ex-rat", "parrot", 100, 150) == -1
    assert find("abcdefg", "cd", 0, 100) == 2
    assert find("123456789", "7", 3, 100) == 6
    assert find("The weather is nice today", "7", 0, 1000) == -1
def test_find_basic():
    """
    Test find function.
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14

    assert find("You are powerful, young padowan", "padowan", 0, 31) == 24

    assert find("My name is Inigo", "Montoya", 0, 16) == -1
def test_find_more():
    """
    Establish other function to test more scenarios of find_basic
    """

    assert find("This is an ex-parrot", "parrot", 0, 25) == 14
    assert find("This is an ex-parrot", "parrot", 16, -5) == -1
    assert find("This is an 3x-parrot", "parrot", 0, 20) == 14
    assert find(" T his i s an par rot", "parrot", 0, 20) == -1
Esempio n. 11
0
def test_find_basic():
    """
	Test find function.
	"""
    #tests whether our code actually works
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14
    assert find("This is an ex-parrot", "Arthur", 0, 20) == -1
    assert find("I am Arthur, King of the Britons", "King", 0, 30) == 13
    assert find("I am Arthur, King of the Britons", "Who?", 0, 30) == -1
def test_find_invalid_substring():

    #Test if the substring is not in the input_string

    assert find("homogeneous", "bob", 0, 12) == -1

    assert find("identification", "low", 0, 22) == -1

    assert find("service_department", "man", 0, 12) == -1

    assert find("fire_work", "ide", 0, 10) == -1
def test_find_basic():
    """
    Test find function.
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14
    assert find("Where is the cookie", "the", 3, 15) == 9
    assert find("ABCDEFFGABCDEFF", "FF", 8, 11) == -1
    try:
        find(239239081, "integers", 0, 20)
    except TypeError:
        assert True
def test_find_basic():
    """
    Test find function.
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14

    # Test using integers
    assert find(411926345, 11, 0, 9) == 1

    # Test using special characters
    assert find("!@#$ $#@& %$#@ ^%$#", "^", 0, 19) == 15
def test_find_basic():
    """
    Test find function.
    """
    # Positive Cases
    # Basic strings
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14

    # DNA sequence matching
    assert find("TCGATCGAACTG", "ACTG", 0, 12) == 8

    # Numbers
    assert find("0123456789", "456", 0, 10) == 4

    # Phrases
    assert find(pangram, "quick brown fox", 0, 71) == 4

    # Returns the lowest index only
    long_string = "This is the first ACTG string. This ACTG string should not be returned."
    assert find(long_string, "ACTG", 0, 71) == 18


    # Errors
    # Returns -1 for failures
    assert find(pangram, "cat", 0, 44) == -1

    # Empty entry
    assert find("", "cat", 0, 0) == -1

    # 'start' param beyond first index occurrence leads to failure
    assert find(pangram, "quick", 20, 71) == -1
Esempio n. 16
0
def test_find_basic():
    """
    Test find function.
    """
    # Positive Cases
    # Basic strings
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14

    # DNA sequence matching
    assert find("TCGATCGAACTG", "ACTG", 0, 12) == 8

    # Numbers
    assert find("0123456789", "456", 0, 10) == 4

    # Phrases
    assert find(pangram, "quick brown fox", 0, 71) == 4

    # Returns the lowest index only
    long_string = "This is the first ACTG string. This ACTG string should not be returned."
    assert find(long_string, "ACTG", 0, 71) == 18

    # Errors
    # Returns -1 for failures
    assert find(pangram, "cat", 0, 44) == -1

    # Empty entry
    assert find("", "cat", 0, 0) == -1

    # 'start' param beyond first index occurrence leads to failure
    assert find(pangram, "quick", 20, 71) == -1
Esempio n. 17
0
def test_find_basic():
    """
    Test find function.
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14
    assert find("This is an ex-parrot", "is", 0, 20) == 2
    assert find("This is an ex-parrot", "parbot", 0, 20) == -1
    assert find("And now for something completely different", "completely", 0, 42) == 22
    assert find("And now for something completely different", "om", 0, 42) == 13
    assert find("And now for something completely different", "lumberjack", 0, 42) == -1
    assert find("I'm a lumberjack and I'm OK", "OK", 0, 26) == 25
    assert find("I'm a lumberjack and I'm OK", "I'm", 0, 26) == 0
    assert find("I'm a lumberjack and I'm OK", "parrot", 0, 26) == -1
def test_find_basic():
    """
    Test find function.
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14

    # test substring search
    assert find("Testing a string", "est", 0, 15) == 1

    # test with substring not found
    assert find("Testing a string again", "ask", 0, 20) == -1

    # test for a whitespace (single space) search in string
    assert find("Testing a string once more", " ", 0, 25) == 7

    # test for number as string in string with different characters
    assert find("abc 123 $!@", "2", 0, 10) == 5
def test_find_basic():
    """
    Test find function.
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14

    # If the substring is not found it returns -1.

    assert find("This is an ex-parrot", "orange", 0, 20) == -1

    # Test case to find a substring

    assert find ("Humpty dumpty sat on the wall", "wall", 0, 30) == 25

    # Test case to find special characters.

    assert find ("what does the # do?", "#", 0, 20) ==  14
def test_find_bad_start_end():
    """
    Test find function with substring that is longer than tested
    """
    try:
        assert find("h", "help", 0, 1)
    except AssertionError:
        return True
def test_too_many_variables():
    """
    Tests for more variables than are accepted.
    """
    try:
        assert find("asdf", "qwerty", 0, 20, 20) == 10
    except TypeError:
        return True
Esempio n. 22
0
def test_find_bad_start_end():
    """
    Test find function with substring that is longer than tested
    """
    try:
        assert find("h", "help", 0, 1)
    except AssertionError:
        return True
Esempio n. 23
0
def test_too_many_variables():
    """
    Tests for more variables than are accepted.
    """
    try:
        assert find("asdf", "qwerty", 0, 20, 20) == 10
    except TypeError:
        return True
def test_advanced_find_basic():
    """
    Test the find function with more extraordinary situation
    """
    assert find("characteristic", "ara", 0, 14) == 2

    # A special situation where the end index is negative number
    assert find("dominating", "min", 0, -1) == 2

    # A special situation where substring is identical as input_string

    assert find("homework", "homework", 0, 8) == 0

    # Test when only ranging the portion of the input_string

    assert find("honeyhoneyhoney", "ney", 0, 5) == 2

    # Test when the end index is out of range

    assert find("honey", "ney", 0, 15) == 2
def test_find_basic():
    """
    Test find function.
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14
    # Test cases added that also check for wrong input and output
    assert find("Hello World", "Wo", 0, 14) == 6
    assert find("hello", "hello", 0, 14) == 0
    assert find("hhellhellohello", "hel", 0, 8) == 1
    # Test case shows when substring not found, -1 returned
    assert find("Welcome to Python", "help", 0, 18) == -1
    assert find("This is an ex-parrot", "parrot", 20, 30) == -1
Esempio n. 26
0
def test_find_additional():
    """
    Test find function with a variety of arguments.
    """
    # Test with numbers.
    assert find("0123456789", "89", 0, 10) == 8

    # Test with letters.
    assert find("EGG", "G", 0, 3) == 1

    # Test with string having multiple instances of substring.
    assert find("DuckDuckDuckGoose", "Duck", 0, 16) == 0

    # Test with string having no instances of substring.
    assert find("Joe", "Z", 0, 2) == -1

    # Test with string having instances of substring outside of passed index range.
    assert find("012345", "5", 0, 4) == -1

    # Test with index beyond the length of the string.
    assert find("012345", "5", 0, 44) == 5
Esempio n. 27
0
def test_find_additional():
    """
    Test find function with a variety of arguments.
    """
    # Test with numbers.
    assert find("0123456789", "89", 0, 10) == 8

    # Test with letters.
    assert find("EGG", "G", 0, 3) == 1

    # Test with string having multiple instances of substring.
    assert find("DuckDuckDuckGoose", "Duck", 0, 16) == 0

    # Test with string having no instances of substring.
    assert find("Joe", "Z", 0, 2) == -1

    # Test with string having instances of substring outside of passed index range.
    assert find("012345", "5", 0, 4) == -1

    # Test with index beyond the length of the string.
    assert find("012345", "5", 0, 44) == 5
def test_find_nothing():
    assert find("Ni! Ni! Ni! Ni!", "Hi", 0, 20) == "No Match Found"
def test_find_none():
    """
    Test find function with substring that does not exist
    """
    assert find("This is an ex-parrot", "help", 0, 20) == -1
def test_find_basic():
    """
    Test find function.
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14
def test_not_in_scope():
    assert find("I am starving now.", "now", 0, 8) == -1
    assert find("Class is warmer than my home.", "my", 0, -29) == -1
    assert find("We need coffee.", "coffee", -1, -15) == -1
def test_find_substring_larger_than_input_string():
    """
    Test find function with an empty substring.
    """
    assert find("parrot", "", 0, 0) == -1
    assert find("", "", 0, 0) == -1
def test_find_out_of_string():
    assert find("This is an ex-parrot", "parrot", 21, 20) == -1
    assert find("This is an ex-parrot", "parrot", 0, 25) == 14
def test_find_all():
    """
    Test find function with substring contained multiple times
    """
    assert find("helphelphelphelp", "help", 0, 16) == 0
    assert find("     ", "      ", 0, 10) == -1
Esempio n. 35
0
def test_find_bad_different_characters():
    """
    Test find function with strings that contain weird characters 
    """
    assert find("@#@#!#@#$%^@&*", "^@&*", 0, 14) == 10
def test_find_basic():
    """
    Test find function with substring that exist
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14
Esempio n. 37
0
def test_find_all():
    """
    Test find function with substring contained multiple times
    """
    assert find("helphelphelphelp", "help", 0, 16) == 0
    assert find("     ", "      ", 0, 10) == -1
Esempio n. 38
0
def test_find_none():
    """
    Test find function with substring that does not exist
    """
    assert find("This is an ex-parrot", "help", 0, 20) == -1
Esempio n. 39
0
def test_find_basic():
    """
    Test find function with substring that exist
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14
def test_find_normal():
    assert find("I'm in class right now", "now", 0, 21) == 19
    assert find(THEME_SONG, "dimension", 0, 337) == 92
def test_find_basic():
    """
    Test find function.
    """
    assert find("This is an ex-parrot", "parrot", 0, 20) == 14
    assert find("This is an ex-parrot", "flamingo",0,20) == -1
def test_not_found_find():
    assert find("I'm busy", "Jackson", 0, 7) == -1
def test_find_bad_different_characters():
    """
    Test find function with strings that contain weird characters 
    """
    assert find("@#@#!#@#$%^@&*", "^@&*", 0, 14) == 10
def test_find_substring_larger_than_input_string():
    """
    Test find function with a substring length larger than the input string length.
    """
    assert find("parrot", "This is an ex-parrot", 0, 6) == -1
    assert find("", "parrot", 0, 0) == -1