Please use c code and also the code must use assertions and

Please use c++ code and also the code must use assertions and when it runs it should display \"All tests passed\"
obile GitHub, Inc. on. Exercise 1: Finding the maximum value (10 points) int maximum(int a, int numberOfElements); Provide an implementation of the maximum function whose declaration is shown above. The first argument of the function is an array of int and the second argument is the number of ints that are in the array. The function returns the largest int that is in the array. Write test code that thoroughly tests the function. The test code should use assertions.

Solution

class MaxTestSuite : public Test::Suite
{
public:
MaxTestSuite()
{
TEST_MAX(ExampleTestSuite::myfirst_test)
}
   int maximum(int a[], int numberOfElements ) {
       int max = 0;
       for(int i=0;i<numberOfElements;i++){
           if(a[i] > max){
               max = a[i];
           }
       }
       return max;
   }
  
private:
void myfirst_test();
};

void MaxTestSuite::myfirst_test(){
   int arr[5] = {1,2,3,4,8};
   TEST_AASERT(maximum(arr, 5) == 8);
}

Please use c++ code and also the code must use assertions and when it runs it should display \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site