Example #1
0
def test_two():
    drinks = LinkedList()
    drinks.append("Coffee")
    drinks.append("Ice_Tea")
    drinks.includes("Lemonade")
    expected = False
    actual = drinks.includes("Milk")
    assert expected == actual
Example #2
0
def test_one():
    drinks = LinkedList()
    drinks.append("Coffee")
    drinks.append("Ice_Tea")
    drinks.includes("Lemonade")
    expected = 'Coffee -> Ice_Tea -> Lemonade -> None'
    actual = drinks.__str__()
    assert expected == actual
Example #3
0
def test_four():
    drinks = LinkedList()
    drinks.append("Coffee")
    drinks.append("Ice_Tea")
    drinks.append('Lemonade')
    drinks.includes("Lemonade")
    drinks.insert('Milk')
    expected = 'Milk -> Coffee -> Ice_Tea -> Lemonade -> None'
    actual = drinks.__str__()
    assert expected == actual
Example #4
0
def test_includes():
    ll = LinkedList()
    ll.insert("apples")
    ll.insert("bananas")
    ll.insert("cherries")
    assert ll.includes("bananas")
    assert ll.includes("oranges") == False
def test_not_includes():
    cities = LinkedList()
    cities.insert("Beijing")
    cities.insert("Guangzhou")
    cities.insert("Chengdu")

    assert not cities.includes("Shanghai")
Example #6
0
def test_includes():
    ll = LinkedList()
    ll.insert(3)
    ll.insert(2)
    ll.insert(1)
    ll.insert(0)
    assert ll.includes(3) == True
    assert ll.includes(5) == False
Example #7
0
def test_includes():
    test = LinkedList()
    test.insert(0)
    test.insert(1)
    test.insert(2)
    test.insert(3)
    expected = True
    actual = test.includes(3)
    assert expected == actual
Example #8
0
def repeated_word(string):
    '''
    using linked list this function will search for the first repeated word in your inputed string:
        inp ---> only string
        out >>> the repeated word from your input
    '''
    container = LinkedList()
    word = ''
    for i in range(len(string)):
        if container.includes(word):
            # print(container.toString())
            return word
        elif string[i] == ',' or string[i] == ' ' or string[
                i] == '-' or string[i] == '.':
            if word != '':
                container.insert(word)
                word = ''
            continue
        else:
            word += string[i].lower()
    # print(container.toString())
    return 'there is no repeated word in your input!'
Example #9
0
def test_LinkedList_includes():
    test_LinkedList = LinkedList()
    test_LinkedList.insert(0)
    test_LinkedList.insert(1)
    assert test_LinkedList.includes(1) == True
    assert test_LinkedList.includes(100) == False