Пример #1
0
def test_head_ll():

    anime = LinkedList()
    anime.insert("test head")
    expected = anime.head.data
    actual = 'test head'
    assert expected == actual
Пример #2
0
def test_insert_ll():
    """
    Can properly insert into the linked list ?
    """
    anime = LinkedList()
    anime.insert("Slam Dunk")
    expected = anime.head.data
    actual = 'Slam Dunk'
    assert expected == actual
def linked():
    item = LinkedList()
    item.insert('Rawan')
    item.insert('12')
    item.insert('so')
    item.insert('cool')
    item.insert('yes')

    return item
Пример #4
0
def test_insertAfter_lastnode():
    anime = LinkedList()
    anime.append("Slam dunk")
    anime.append("death note")
    anime.insertAfter("death note", "one puch man")
    assert anime.__str__(
    ) == '(Slam dunk) -> (death note) -> (one puch man) -> NULL'
Пример #5
0
def test_insertbefore_first_node():
    anime = LinkedList()
    anime.append("Slam dunk")
    anime.append("death note")
    anime.insertBefore("Slam dunk", "one puch man")
    assert anime.__str__(
    ) == '(one puch man) -> (Slam dunk) -> (death note) -> NULL'
Пример #6
0
def test_insert_multiple_nodes():
    anime = LinkedList()
    anime.insert("Abu")
    anime.insert("Rawan")
    expected = anime.__str__()
    actual = '(Rawan) -> (Abu) -> NULL'
    assert expected == actual
Пример #7
0
def test_kth_from_end_greater_than_length():
    anime = LinkedList()
    anime.append(1)
    anime.append(3)
    anime.append(8)
    anime.append(2)
    assert anime.kthFromEnd(5) == 'The Value Not Found'
Пример #8
0
def test_kth_from_end1_Happy_Path():
    anime = LinkedList()
    anime.append(1)
    anime.append(3)
    anime.append(8)
    anime.append(2)
    assert anime.kthFromEnd(3) == 1
    assert anime.kthFromEnd(1) == 8
Пример #9
0
def prepare_data():
    anime = LinkedList()
    node1 = anime.append("BLEACH")
    node2 = anime.append("God of high school")
    node3 = anime.append("Deat note")
    test1 = anime.includes("BLEACH")
    test2 = anime.includes("Conan")
    return {
        'anime': anime,
        "node1": node1,
        "node2": node2,
        "node3": node3,
        "test1": test1,
        "test2": test2
    }
Пример #10
0
def test_empty_ll():
    expected = LinkedList().__str__()
    actual = 'Your Linked List still empty'
    assert expected == actual
Пример #11
0
def test_kth_from_end_size1():
    anime = LinkedList()
    anime.append(3)
    assert anime.kthFromEnd(0) == 3
Пример #12
0
        temp = first
        first = second
        second = temp
        current_fll = first.head
        current_sll = second.head
    linked_first = first.head
    linked_second = second.head
    while linked_first and linked_second:
        first_next = linked_first.next_node
        second_next = linked_second.next_node
        linked_second.next_node = first_next
        linked_first.next_node = linked_second
        linked_first = first_next
        linked_second = second_next
        second.head = linked_second
    return first


myList = LinkedList()
myList.insert(5)
myList.insert(8)
myList.insert(12)
myList.append(3)

list = LinkedList()
myList.insert(1)
myList.insert(5)
myList.insert(88)
myList.append(4)

print(zipLists(myList, list))
def test_find_value_exists():
    myList = LinkedList()
    myList.insert('great')
    actual = myList.includes('great')
    expected = True
    assert actual == expected
def test_insert_multiple_nodes():
    expected = ['so', 'cool', 'yes']
    myList = LinkedList()
    actual = [myList.insert('so'), myList.insert('cool'), myList.insert('yes')]
    assert actual == expected
def test_empty_linked_list():
    expected = "Your Linked List still empty"
    actual = str(LinkedList())
    assert actual == expected
import pytest
from data_structure.data_structure.linked_list.linked_list import Node, LinkedList

myList = LinkedList()

# def test_import():
#     assert LinkedList

# def test_import():
#     assert Node


def test_empty_linked_list():
    expected = "Your Linked List still empty"
    actual = str(LinkedList())
    assert actual == expected


def test_insert_properly():
    actual = myList.insert("12")
    expected = "12"
    assert actual == expected


# def test_head_point_first_node(linked):
#     actual = str(linked.head)
#     expected = 'Rawan'
#     assert actual == expected


def test_insert_multiple_nodes():