コード例 #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)