Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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])
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #10
0
    def test_find_4(self):
        linked_list = LinkedList()
        linked_list.add_in_tail(self.n3)

        self.assertEqual(linked_list.find_all(12), [])
Beispiel #11
0
    def test_find_all(self):
        linked_list = LinkedList()

        self.assertEqual(linked_list.find_all(12), [])
Beispiel #12
0
    def test_find_3(self):
        linked_list = LinkedList()
        linked_list.add_in_tail(self.n3)

        self.assertEqual(linked_list.find(12), None)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #16
0
    def test_find(self):
        linked_list = LinkedList()

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