Пример #1
0
    def test_delete_1(self):
        linked_list = LinkedList()
        linked_list.add_in_tail(self.n1)

        linked_list.delete(12)
        self.assertEqual(linked_list.head, None)
        self.assertEqual(linked_list.tail, None)
Пример #2
0
 def test_add_in_head_2(self):
     linked_list = LinkedList()
     linked_list.add_in_tail(self.n1)
     
     linked_list.add_in_head(self.n6)
     self.assertEqual(linked_list.head, self.n6)
     self.assertEqual(linked_list.tail, self.n1)
     self.assertEqual(self.n1.prev, self.n6)
     self.assertEqual(self.n6.next, self.n1)
Пример #3
0
    def test_delete_3(self):
        linked_list = LinkedList()
        linked_list.add_in_tail(self.n1)
        linked_list.add_in_tail(self.n2)

        linked_list.delete(12)
        self.assertEqual(linked_list.head, self.n2)
        self.assertEqual(linked_list.tail, self.n2)
        self.assertEqual(linked_list.head.prev, None)
        self.assertEqual(linked_list.head.next, None)
Пример #4
0
    def test_insert_2(self):
        linked_list = LinkedList()
        linked_list.add_in_tail(self.n1)
        linked_list.add_in_tail(self.n3)

        linked_list.insert(self.n3, self.n6)
        self.assertEqual(linked_list.head, self.n1)
        self.assertEqual(linked_list.tail, self.n6)
        self.assertEqual(self.n3.next, self.n6)
        self.assertEqual(self.n6.next, None)
        self.assertEqual(self.n6.prev, self.n3)
Пример #5
0
    def test_find_all_2(self):
        linked_list = LinkedList()
        linked_list.add_in_tail(self.n1)
        linked_list.add_in_tail(self.n2)
        linked_list.add_in_tail(self.n3)
        linked_list.add_in_tail(self.n6)
        linked_list.add_in_tail(self.n7)

        self.assertEqual(linked_list.find_all(12), [self.n1, self.n2, self.n7])
Пример #6
0
    def test_delete_all_3(self):
        linked_list = LinkedList()
        linked_list.add_in_tail(self.n1)
        linked_list.add_in_tail(self.n2)
        linked_list.add_in_tail(self.n7)
        linked_list.add_in_tail(self.n8)

        linked_list.delete(12, True)
        self.assertEqual(linked_list.head, None)
        self.assertEqual(linked_list.tail, None)
Пример #7
0
    def test_delete_all_1(self):
        linked_list = LinkedList()
        linked_list.add_in_tail(self.n1)
        linked_list.add_in_tail(self.n2)
        linked_list.add_in_tail(self.n3)

        linked_list.delete(12, True)
        self.assertEqual(linked_list.head, self.n3)
        self.assertEqual(linked_list.tail, self.n3)
        self.assertEqual(linked_list.head.prev, None)
Пример #8
0
    def test_find_2(self):
        linked_list = LinkedList()
        linked_list.add_in_tail(self.n3)
        linked_list.add_in_tail(self.n1)
        linked_list.add_in_tail(self.n2)

        self.assertEqual(linked_list.find(12), self.n1)
Пример #9
0
    def test_delete_4(self):
        linked_list = LinkedList()
        linked_list.add_in_tail(self.n3)
        linked_list.add_in_tail(self.n1)
        linked_list.add_in_tail(self.n2)
        linked_list.add_in_tail(self.n6)

        linked_list.delete(12)
        self.assertEqual(linked_list.head, self.n3)
        self.assertEqual(linked_list.tail, self.n6)
        self.assertEqual(self.n3.next, self.n2)
        self.assertEqual(self.n2.prev, self.n3)
Пример #10
0
    def test_find_4(self):
        linked_list = LinkedList()
        linked_list.add_in_tail(self.n3)

        self.assertEqual(linked_list.find_all(12), [])
Пример #11
0
    def test_find_all(self):
        linked_list = LinkedList()

        self.assertEqual(linked_list.find_all(12), [])
Пример #12
0
    def test_find_3(self):
        linked_list = LinkedList()
        linked_list.add_in_tail(self.n3)

        self.assertEqual(linked_list.find(12), None)
Пример #13
0
    def test_add_in_head(self):
        linked_list = LinkedList()

        linked_list.add_in_head(self.n6)
        self.assertEqual(linked_list.head, self.n6)
        self.assertEqual(linked_list.tail, self.n6)
Пример #14
0
    def test_insert_1(self):
        linked_list = LinkedList()

        linked_list.insert(None, self.n6)
        self.assertEqual(linked_list.head, self.n6)
        self.assertEqual(linked_list.tail, self.n6)
Пример #15
0
    def test_delete_all_2(self):
        linked_list = LinkedList()
        linked_list.add_in_tail(self.n1)
        linked_list.add_in_tail(self.n2)
        linked_list.add_in_tail(self.n3)
        linked_list.add_in_tail(self.n4)
        linked_list.add_in_tail(self.n5)
        linked_list.add_in_tail(self.n6)
        linked_list.add_in_tail(self.n7)
        linked_list.add_in_tail(self.n8)

        linked_list.delete(12, True)
        self.assertEqual(linked_list.head, self.n3)
        self.assertEqual(linked_list.tail, self.n6)
        self.assertEqual(self.n6.prev, self.n3)
        self.assertEqual(self.n6.next, None)
        self.assertEqual(self.n3.prev, None)
        self.assertEqual(self.n3.next, self.n6)
Пример #16
0
    def test_find(self):
        linked_list = LinkedList()

        self.assertEqual(linked_list.find(12), None)