def test_eq(self):
     dll = DoublyLinkedList(range(10))
     dll2 = DoublyLinkedList()
     for i in xrange(10 - 1):
         dll2.addToTail(i)
         self.assertFalse(dll == dll2)
     dll2.addToTail(i + 1)
     self.assertTrue(dll == dll2)
	def test_eq(self):
		dll = DoublyLinkedList(range(10))
		dll2 = DoublyLinkedList()
		for i in xrange(10-1):
			dll2.addToTail(i)
			self.assertFalse(dll == dll2)
		dll2.addToTail(i+1)
		self.assertTrue(dll == dll2)
    def test_moveToHead(self):
        l = DoublyLinkedList()
        sanity = []
        for i in xrange(8):
            if i % 2 == 0:
                l.addToHead(i)
                sanity = [i] + sanity
            else:
                l.addToTail(i)
                sanity.append(i)
            self.assertEqual(list(l), sanity)

            original_dll = l.copy()
            original_sanity = sanity[::]
            for j in xrange(i):
                #Move each item to the head once
                l.moveToHead(l.getNodeByIndex(j))
                list_move_to_head(sanity, j)
                try:
                    self.assertEqual(list(l), sanity)
                except:
                    import code
                    code.interact(local=locals())
            l = original_dll
            sanity = original_sanity

        l = DoublyLinkedList()
        sanity = []
        for i in xrange(8):
            if i % 2 == 1:
                l.addToHead(i)
                sanity = [i] + sanity
            else:
                l.addToTail(i)
                sanity.append(i)
            self.assertEqual(list(l), sanity)

            original_dll = l.copy()
            original_sanity = sanity[::]
            for j in xrange(i):
                #Move each item to the head once
                l.moveToHead(l.getNodeByIndex(j))
                list_move_to_head(sanity, j)
                self.assertEqual(list(l), sanity)
            l = original_dll
            sanity = original_sanity
	def test_moveToHead(self):
		l = DoublyLinkedList()
		sanity = []
		for i in xrange(8):
			if i % 2 == 0:
				l.addToHead(i)
				sanity = [i] + sanity
			else:
				l.addToTail(i)
				sanity.append(i)
			self.assertEqual(list(l), sanity)
			
			original_dll = l.copy()
			original_sanity = sanity[::]
			for j in xrange(i):
				#Move each item to the head once
				l.moveToHead(l.getNodeByIndex(j))
				list_move_to_head(sanity, j)
				try:
					self.assertEqual(list(l), sanity)
				except:
					import code; code.interact(local=locals())
			l = original_dll
			sanity = original_sanity
		
		l = DoublyLinkedList()
		sanity = []
		for i in xrange(8):
			if i % 2 == 1:
				l.addToHead(i)
				sanity = [i] + sanity
			else:
				l.addToTail(i)
				sanity.append(i)
			self.assertEqual(list(l), sanity)
			
			original_dll = l.copy()
			original_sanity = sanity[::]
			for j in xrange(i):
				#Move each item to the head once
				l.moveToHead(l.getNodeByIndex(j))
				list_move_to_head(sanity, j)
				self.assertEqual(list(l), sanity)
			l = original_dll
			sanity = original_sanity
    def test_AddToHead_and_addToTail(self):
        l = DoublyLinkedList()
        sanity = []
        for i in xrange(8):
            if i % 2 == 0:
                l.addToHead(i)
                sanity = [i] + sanity
            else:
                l.addToTail(i)
                sanity.append(i)
            self.assertEqual(list(l), sanity)

        l = DoublyLinkedList()
        sanity = []
        for i in xrange(8):
            if i % 2 == 1:
                l.addToHead(i)
                sanity = [i] + sanity
            else:
                l.addToTail(i)
                sanity.append(i)
            self.assertEqual(list(l), sanity)
	def test_AddToHead_and_addToTail(self):
		l = DoublyLinkedList()
		sanity = []
		for i in xrange(8):
			if i % 2 == 0:
				l.addToHead(i)
				sanity = [i] + sanity
			else:
				l.addToTail(i)
				sanity.append(i)
			self.assertEqual(list(l), sanity)
		
		l = DoublyLinkedList()
		sanity = []
		for i in xrange(8):
			if i % 2 == 1:
				l.addToHead(i)
				sanity = [i] + sanity
			else:
				l.addToTail(i)
				sanity.append(i)
			self.assertEqual(list(l), sanity)
 def test_addToTail(self):
     l = DoublyLinkedList()
     for i in xrange(4):
         self.assertIs(l.size, i)
         l.addToTail(i)
         self.assertEqual(list(l), range(0, i + 1))
	def test_addToTail(self):
		l = DoublyLinkedList()
		for i in xrange(4):
			self.assertIs(l.size, i)
			l.addToTail(i)
			self.assertEqual(list(l), range(0, i+1))