Exemplo n.º 1
0
 def test_contains_true(self):
     list_1 = DoubleLinkedList()
     list_1.push(1)
     list_1.push(2)
     list_1.push(3)
     list_1.push(4)
     self.assertEqual(list_1.contains(3), True)
Exemplo n.º 2
0
 def test_del(self):
     list_1 = DoubleLinkedList()
     list_1.push(1)
     list_1.push(2)
     list_1.push(2)
     list_1.delete(2)
     self.assertEqual(list_1.len(), 2)
Exemplo n.º 3
0
 def test_contains_multi_elem(self):
     test_list = DoubleLinkedList()
     for i in range(10):
         test_list.push(i)
     for i in range(3):
         test_list.push(5)
     self.assertEqual(test_list.len(), 13)
     self.assertEqual(test_list.contains(5), 4)
Exemplo n.º 4
0
 def test_delete_elem_only_multi(self):
     test_list = DoubleLinkedList()
     for i in range(5):
         test_list.push(2)
     self.assertEqual(test_list.len(), 5)
     self.assertEqual(test_list.contains(2), 5)
     test_list.delete(2)
     self.assertEqual(test_list.len(), 0)
     self.assertEqual(test_list.contains(2), 0)
Exemplo n.º 5
0
 def test_push(self):
     test_list = DoubleLinkedList()
     test_list.push(1)
     test_list.push("test")
     test_list.push(3.2)
     self.assertEqual(test_list.len(), 3)
     self.assertEqual(test_list.show(), [1, "test", 3.2])
Exemplo n.º 6
0
 def test_delete_elem_multi(self):
     test_list = DoubleLinkedList()
     for i in range(3):
         test_list.push(i)
     test_list.push(1)
     for i in range(3):
         test_list.push(i)
     self.assertEqual(test_list.len(), 7)
     self.assertEqual(test_list.contains(1), 3)
     test_list.delete(1)
     self.assertEqual(test_list.len(), 4)
     self.assertEqual(test_list.contains(1), 0)
Exemplo n.º 7
0
 def test_len(self):
     test_list = DoubleLinkedList()
     for i in range(10):
         test_list.push(i)
     self.assertEqual(test_list.len(), 10)
Exemplo n.º 8
0
 def test_push_pop(self):
     test_list = DoubleLinkedList()
     test_list.push(5)
     self.assertEqual(test_list.len(), 1)
     self.assertEqual(test_list.pop(), 5)
Exemplo n.º 9
0
 def test_shift(self):
     test_list = DoubleLinkedList()
     for i in range(5):
         test_list.push(i)
     for i in range(5):
         self.assertEqual(test_list.shift(), i)
Exemplo n.º 10
0
 def test_last_only(self):
     test_list = DoubleLinkedList()
     test_list.push("test")
     self.assertEqual(test_list.last(), "test")
Exemplo n.º 11
0
 def test_not_contains_elem(self):
     test_list = DoubleLinkedList()
     for i in range(10):
         test_list.push(i)
     self.assertEqual(test_list.len(), 10)
     self.assertEqual(test_list.contains(14), 0)
Exemplo n.º 12
0
 def test_delete_elem_only(self):
     test_list = DoubleLinkedList()
     test_list.push("test")
     self.assertEqual(test_list.len(), 1)
     test_list.delete("test")
     self.assertEqual(test_list.len(), 0)
Exemplo n.º 13
0
 def test_push(self):
     list_1 = DoubleLinkedList()
     list_1.push(1)
     self.assertEqual(list_1.last.elem, 1)
Exemplo n.º 14
0
 def test_contains_false(self):
     list_1 = DoubleLinkedList()
     list_1.push(1)
     list_1.push(2)
     list_1.push(3)
     self.assertEqual(list_1.contains(0), False)
Exemplo n.º 15
0
 def test_len(self):
     list_1 = DoubleLinkedList()
     list_1.push(1)
     list_1.unshift(2)
     self.assertEqual(list_1.len(), 1)
Exemplo n.º 16
0
 def test_contains_only_elem(self):
     test_list = DoubleLinkedList()
     test_list.push("test")
     self.assertEqual(test_list.len(), 1)
     self.assertEqual(test_list.contains("test"), 1)
Exemplo n.º 17
0
 def test_contains_only_multi_elem(self):
     test_list = DoubleLinkedList()
     for i in range(10):
         test_list.push(1)
     self.assertEqual(test_list.len(), 10)
     self.assertEqual(test_list.contains(1), 10)
Exemplo n.º 18
0
 def test_pop(self):
     test_list = DoubleLinkedList()
     for i in range(5):
         test_list.push(i)
     for i in range(5):
         self.assertEqual(test_list.pop(), 4 - i)
Exemplo n.º 19
0
 def test_last(self):
     test_list = DoubleLinkedList()
     for i in range(5):
         test_list.push(i)
     self.assertEqual(test_list.last(), 4)
     self.assertEqual(test_list.len(), 5)
Exemplo n.º 20
0
 def test_pop(self):
     list_1 = DoubleLinkedList()
     list_1.push(1)
     list_1.pop()
     self.assertEqual(list_1.len(), 0)