def test_insert_when_single_element_in_myarray(self): # Arrange myarray = MyArray('i', 20) # Act myarray.insert(0, 100) # Assert self.assertEqual(2, myarray.size()) self.assertEqual(100, myarray.get(0)) self.assertEqual(20, myarray.get(1))
def test_insert_when_empty_myarray(self): #Arrange myarray = MyArray('i') self.assertEqual(0, myarray.size()) # Act myarray.insert(0, 100) # Assert self.assertEqual(1, myarray.size()) self.assertEqual(100, myarray.get(0))
def test_insert_when_more_than_one_element_in_myarray(self): # Arrange myarray = MyArray('i', 20, 30) # Act myarray.insert(0, 100) # Assert self.assertEqual(3, myarray.size()) self.assertEqual(100, myarray.get(0)) self.assertEqual(20, myarray.get(1)) self.assertEqual(30, myarray.get(2))