예제 #1
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])
예제 #2
0
 def test_unshift(self):
     test_list = DoubleLinkedList()
     test_list.unshift(1)
     test_list.unshift("test")
     test_list.unshift(3.2)
     self.assertEqual(test_list.len(), 3)
     self.assertEqual(test_list.show(), [3.2, "test", 1])
예제 #3
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)
예제 #4
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)
예제 #5
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)
예제 #6
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)
예제 #7
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)
예제 #8
0
 def test_shift_empty(self):
     test_list = DoubleLinkedList()
     self.assertEqual(test_list.shift(), "list is empty")
예제 #9
0
 def test_unshift_shift(self):
     test_list = DoubleLinkedList()
     test_list.unshift(5)
     self.assertEqual(test_list.len(), 1)
     self.assertEqual(test_list.shift(), 5)
예제 #10
0
 def test_len(self):
     list_1 = DoubleLinkedList()
     list_1.push(1)
     list_1.unshift(2)
     self.assertEqual(list_1.len(), 1)
예제 #11
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)
예제 #12
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)
예제 #13
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)
예제 #14
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)
예제 #15
0
 def test_len(self):
     test_list = DoubleLinkedList()
     for i in range(10):
         test_list.push(i)
     self.assertEqual(test_list.len(), 10)
예제 #16
0
 def test_pop_empty(self):
     test_list = DoubleLinkedList()
     self.assertEqual(test_list.pop(), "list is empty")
예제 #17
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)
예제 #18
0
 def test_delete_empty(self):
     test_list = DoubleLinkedList()
     self.assertEqual(test_list.delete("test"), "no such element")
예제 #19
0
 def test_push(self):
     list_1 = DoubleLinkedList()
     list_1.push(1)
     self.assertEqual(list_1.last.elem, 1)
예제 #20
0
 def test_emptyList(self):
     list_1 = DoubleLinkedList()
     self.assertEqual(list_1.first, None)
예제 #21
0
 def test_len_empty(self):
     test_list = DoubleLinkedList()
     self.assertEqual(test_list.len(), 0)
예제 #22
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)
예제 #23
0
 def test_contains_empty(self):
     test_list = DoubleLinkedList()
     self.assertEqual(test_list.contains("test"), 0)
예제 #24
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)
예제 #25
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)
예제 #26
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)
예제 #27
0
 def test_last_only(self):
     test_list = DoubleLinkedList()
     test_list.push("test")
     self.assertEqual(test_list.last(), "test")
예제 #28
0
 def test_pop(self):
     list_1 = DoubleLinkedList()
     list_1.push(1)
     list_1.pop()
     self.assertEqual(list_1.len(), 0)