def test_return_centre_of_list_with_many_even_elements(self): singlyLinkedListObject = SinglyLinkedList() inputList = range(40000) singlyLinkedListObject.populate(inputList) centreIndex = (len(inputList)-1)/2 expectedCentre = inputList[centreIndex] actualCentre = singlyLinkedListObject.returnCentreOfTheLinkedList() self.assertTrue(expectedCentre == actualCentre.data, "Expected centre if linked list: %s, Got: %s" %(expectedCentre, actualCentre))
def test_return_centre_of_empty_list(self): singlyLinkedListObject = SinglyLinkedList() expectedCentre = None actualCentre = singlyLinkedListObject.returnCentreOfTheLinkedList() self.assertTrue(expectedCentre == actualCentre, "Expected centre if linked list: %s, Got: %s" %(expectedCentre, actualCentre))