Ejemplo n.º 1
0
 def test_del_mass_void_all(self):
     s_list = LinkedList()
     s_list.delete(1, True)
     ht = s_list.get_head_tail()
     data = ht + s_list.list_all_nodes()
     res = [None, None]
     self.assertEqual(data, res)
Ejemplo n.º 2
0
 def test_clean_void(self):
     s_list = LinkedList()
     s_list.clean()
     ht = s_list.get_head_tail()
     data = ht + s_list.list_all_nodes()
     res = [None, None]
     self.assertEqual(data, res)
Ejemplo n.º 3
0
 def test_insert_void(self):
     n1 = Node(1)
     s_list = LinkedList()
     s_list.insert(None, n1)
     ht = s_list.get_head_tail()
     data = ht + s_list.list_all_nodes()
     res = [n1, n1, 1]
     self.assertEqual(data, res)
Ejemplo n.º 4
0
 def test_del_mass_first_1_all(self):
     n1 = Node(1)
     s_list = LinkedList()
     s_list.add_in_tail(n1)
     s_list.delete(1, True)
     ht = s_list.get_head_tail()
     data = ht + s_list.list_all_nodes()
     res = [None, None]
     self.assertEqual(data, res)
Ejemplo n.º 5
0
 def test_clean_one(self):
     n1 = Node(1)
     s_list = LinkedList()
     s_list.add_in_tail(n1)
     s_list.clean()
     ht = s_list.get_head_tail()
     data = ht + s_list.list_all_nodes()
     res = [None, None]
     self.assertEqual(data, res)
Ejemplo n.º 6
0
 def test_insert_end_2(self):
     n1 = Node(1)
     n2 = Node(2)
     s_list = LinkedList()
     s_list.add_in_tail(n1)
     s_list.insert(n1, n2)
     ht = s_list.get_head_tail()
     data = ht + s_list.list_all_nodes()
     res = [n1, n2, 1, 2]
     self.assertEqual(data, res)
Ejemplo n.º 7
0
 def test_del_one_last_2(self):
     n1 = Node(1)
     n2 = Node(2)
     s_list = LinkedList()
     s_list.add_in_tail(n1)
     s_list.add_in_tail(n2)
     s_list.delete(2)
     ht = s_list.get_head_tail()
     data = ht + s_list.list_all_nodes()
     res = [n1, n1, 1]
     self.assertEqual(data, res)
Ejemplo n.º 8
0
 def test_insert_middle(self):
     n1 = Node(1)
     n2 = Node(2)
     n3 = Node(3)
     s_list = LinkedList()
     s_list.add_in_tail(n1)
     s_list.add_in_tail(n3)
     s_list.insert(n1, n2)
     ht = s_list.get_head_tail()
     data = ht + s_list.list_all_nodes()
     res = [n1, n3, 1, 2, 3]
     self.assertEqual(data, res)
Ejemplo n.º 9
0
 def test_del_one_first_3(self):
     n1 = Node(1)
     n2 = Node(2)
     n3 = Node(3)
     s_list = LinkedList()
     s_list.add_in_tail(n1)
     s_list.add_in_tail(n2)
     s_list.add_in_tail(n3)
     s_list.delete(1)
     ht = s_list.get_head_tail()
     data = ht + s_list.list_all_nodes()
     res = [n2, n3, 2, 3]
     self.assertEqual(data, res)
Ejemplo n.º 10
0
 def test_del_mass_no_element(self):
     n1 = Node(1)
     n2 = Node(1)
     n3 = Node(3)
     s_list = LinkedList()
     s_list.add_in_tail(n1)
     s_list.add_in_tail(n2)
     s_list.add_in_tail(n3)
     s_list.delete(4, True)
     ht = s_list.get_head_tail()
     data = ht + s_list.list_all_nodes()
     res = [n1, n3, 1, 1, 3]
     self.assertEqual(data, res)
Ejemplo n.º 11
0
from main import Node, LinkedList


def sum_list(list_1, list_2):
    if list_1.len() == list_2.len():
        super_list = LinkedList()
        node_1, node_2 = list_1.head, list_2.head
        while node_1 != None:
            super_node = Node(node_1.value + node_2.value)
            super_list.add_in_tail(super_node)
            node_1 = node_1.next
            node_2 = node_2.next
        return super_list


n1 = Node(1)
s_list = LinkedList()
s_list.add_in_tail(n1)
print(s_list.get_head_tail())