document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import unittest
  2. from node import Node
  3. from dlinkedlist import DLinkedList
  4.  
  5. class testNode(unittest.TestCase):
  6.     def test_init(self):
  7.         a = Node(3)
  8.         self.assertEqual(a.get_data(), 3)
  9.        
  10. class testDLinkedList(unittest.TestCase):
  11.     def test_init(self):
  12.         x = DLinkedList()
  13.         x.add(1)
  14.         x.add(2)
  15.         x.add(3)
  16.         self.assertFalse(x.is_empty())
  17.    
  18.     def test_search(self):
  19.         x = DLinkedList()
  20.         x.add(1)
  21.         x.add(2)
  22.         x.add(3)
  23.         self.assertTrue(x.search(2))
  24.    
  25.     def test_get_last(self):
  26.         x = DLinkedList()
  27.         x.add(1)
  28.         x.add(2)
  29.         x.add(3)
  30.         self.assertEqual(x.get_last().get_data(), 1)
  31.        
  32.     def test_append(self):
  33.         x = DLinkedList()
  34.         x.add(1)
  35.         x.add(2)
  36.         x.add(3)
  37.         x.append(4)
  38.         self.assertEqual(str(x), "[3, 2, 1, 4]")
  39.    
  40.     def test_insert(self):
  41.         x = DLinkedList()
  42.         x.add(1)
  43.         x.add(2)
  44.         x.add(3)
  45.         x.insert(10,1)
  46.         self.assertEqual(str(x), "[3, 10, 2, 1]")
  47.        
  48.     def test_pop(self):
  49.         x = DLinkedList()
  50.         x.add(1)
  51.         x.add(2)
  52.         x.add(3)
  53.         self.assertEqual(x.pop(), 1)
  54.         self.assertEqual(str(x), "[3, 2]")
  55.              
  56. if __name__ == "__main__":
  57.     unittest.main()
');