コード例 #1
0
 def test_doublyLinkedlist_remove(self):
     #we remove both the head and the tail here to see that it works
     L = DoubleLinkedlist()
     L.insertFirst(6, 5, 30, 50)
     L.remove(6)
     L.remove(50)
     self.assertEqual(L.toList(), [30,5])
コード例 #2
0
 def test_doublyLinkedlist_insert_last(self):
     
     P = DoubleLinkedlist()
     P.insertLast(5)
     P.insertLast(6)
     P.insertLast(30)
     P.insertLast(50)
     self.assertEqual(P.toList(), [5, 6, 30, 50] )
コード例 #3
0
 def test_doublyLinkedlist_search_forwards(self):
     L = DoubleLinkedlist()
     L.insertFirst(1, 2, 3, 4, 5)
     self.assertEqual(L.search_by_index(2).getData(), 2)
コード例 #4
0
 def test_doublyLinkedList_search_byValue(self):
     L = DoubleLinkedlist()
     L.insertFirst(6, 5, 30, 50)
     self.assertEqual(L.search(50).getData(), 50)
コード例 #5
0
 def test_doublyLinkedlist_insert_first(self):
     L = DoubleLinkedlist()
     L.insertFirst(5, 6, 30, 50, 60, 3)
     L.show()
     self.assertEqual(L.toList(), [3, 60, 50, 30, 6, 5] )
コード例 #6
0
 def test_doublyLinkedlist_fromList(self):
     l = [1,2,3,4]
     L= DoubleLinkedlist() 
     L.fromList(l)
     self.assertEqual(L.toList(), [4, 3, 2, 1])