def test_insert_when_more_than_one_element_in_myarray(self): # Arrange myarray = MyArray('i', 1, 2, 3, 4, 5) # Act myarray.insert(2, 99) # Assert self.assertEqual(6, myarray.size()) # (expected, actual) self.assertEqual(99, myarray.get(2))
def test_insert_when_single_item_myarray(self): # Arrange myarray = MyArray('i', 1) # Act myarray.insert(0, 99) # Assert self.assertEqual(2, myarray.size()) # (expected, actual) self.assertEqual(99, myarray.get(0))
def test_insert_when_empty_myarray(self): # Arrange myarray = MyArray('i') # Act myarray.insert(0, 99) # Assert self.assertEqual(1, myarray.size()) self.assertEqual(99, myarray.get(0))
def test_insert_when_single_element_in_myarray(self): # Arrange myarray = MyArray('i', 100) # Act myarray.insert(1, 200) # Assert self.assertEqual(2, myarray.size()) self.assertEqual(100, myarray.get(0)) self.assertEqual(200, myarray.get(1))
def test_insert_when_more_than_one_element_in_myarray(self): # Arrange myarray = MyArray('i', 100, 200) # Act myarray.insert(2, 300) # Assert self.assertEqual(3, myarray.size()) self.assertEqual(100, myarray.get(0)) self.assertEqual(200, myarray.get(1)) self.assertEqual(300, myarray.get(2))