Пример #1
0
def test_LinkedListRemoveSecondValue():
    linkedList = LinkedList()
    linkedList.append(1)
    linkedList.append(2)
    linkedList.remove(2)
    assert linkedList.head.value == 1
    assert linkedList.head.value == linkedList.tail.value
Пример #2
0
def test_LinkedListWithTwoNode():
    linkedList = LinkedList()
    linkedList.append(1)
    linkedList.append(2)

    assert linkedList.head.value == 1
    assert linkedList.tail.value == 2
Пример #3
0
def test_searchValueLinkedList():
    linkedList = LinkedList()
    linkedList.append(1)
    linkedList.append(2)
    assert linkedList.search(1).value == 1
    assert linkedList.search(2).value == 2
    assert linkedList.search(1).next.value == 2
    assert linkedList.search(3) == None
Пример #4
0
def test_iteration():
    linkedList = LinkedList()
    linkedList.append(1)
    linkedList.append(2)
    linkedList.append(3)
    counter = 1
    for node in linkedList:
        assert node.value == counter
        counter += 1
Пример #5
0
class Vertex:
    def __init__(self, value):
        if value == None:
            raise AttributeError('Problem with value: value is empty')
        self.value = value
        self.edges = LinkedList()

    def addEdge(self, edge):
        self.edges.append(edge)
        return self
Пример #6
0
def test_reverseLinkedList():
    linkedList = LinkedList()
    linkedList.append(1)
    linkedList.append(2)
    linkedList.append(3)
    linkedList.reverse()
    counter = 3
    for node in linkedList:
        assert node.value == counter
        counter -= 1
Пример #7
0
def test_LinkedListWithTwoValues():
    linkedList = LinkedList()
    linkedList.append(1)
    linkedList.append(2)
    assert linkedList.size() == 2
Пример #8
0
def test_linkedListWithOneNode():
    linkedList = LinkedList()
    linkedList.append(1)

    assert linkedList.head.value == 1
Пример #9
0
def test_LinkedListRemoveFirstNode():
    linkedList = LinkedList()
    linkedList.append(1)
    assert linkedList.head.value == 1
    linkedList.remove(1)
    assert linkedList.head == None