Example #1
0
 def test_extend_iterable_object(self):
     items = 100
     first = LinkedList()
     second = list(range(items))
     assert first.is_empty()
     assert first.extend(second) is None
     assert isinstance(first.head, Node)
     assert isinstance(first.tail, Node)
     assert first.head is not first.tail
     assert first.size == len(second)
     match = 0
     for node in first:
         assert node.data == match
         match += 1
Example #2
0
 def test_extend_another_linked_list_from_empty(self):
     first = LinkedList()
     second = LinkedList()
     items = 100
     for i in range(items):
         assert second.append(i) is None
     assert first.is_empty()
     assert second.size == items
     assert first.extend(second) is None
     assert isinstance(first.head, Node)
     assert isinstance(first.tail, Node)
     assert first.head is not second.head
     assert first.tail is not second.tail
     assert first.size == second.size
     match = 0
     for node in first:
         assert node.data == match
         match += 1
Example #3
0
 def test_extend_non_iterable_object_error(self):
     dll = LinkedList()
     with pytest.raises(TypeError):
         dll.extend(None)