Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please write these problems in C++ format 6. Write a test harness that tests a f

ID: 3626509 • Letter: P

Question

Please write these problems in C++ format
6. Write a test harness that tests a function named reverse. This must be a complete
program, including all necessary include directives and using statements. However, you are NOT implementing the reverse function, only testing it.
To get all 20 points for this question, your test harness (main function) must be thorough. This test harness must be capable of finding ALL potential errors in the logic of the function: void reverse( vector<double> &v );
If you do not include all specific test values in your actual code, then you must state (in English is fine) what values you will enter for each test. I should be able to run your program (entering the values you state, if applicable) and tell by the output if the function has a logic or runtime error.
The reverse function reverses the order of all elements in a vector of strings passed in as a parameter to the function. For example, when the function is called, if the vector argument stores the values, "a", "cat", "ball", "at", "zed", "to"
in this order, then when the function returns, the argument should store those same values but now in the following order: "to", "zed", "at", "ball", "cat", "a"
You are NOT implementing the reverse function. You are only writing the test harness
that will thoroughly test the reverse function.

Hypothetical Rubric:
2 pts: Complete program with no major syntax errors.
1 pt: Correctly declares and initializes vector with at least 1 set of test values.
2 pts: Correctly calls function and correctly uses reversed vector in at least 1 valid test.
5 pts: Main function is capable of running ALL tests without restarting the program.
10 pts: Thoroughness of test cases. To get these 10 points your program must either
actually run these tests or be capable of having the user input values to run ALL
of the tests you describe in English. Only tests that can by run by your code will
be counted in this part.

Explanation / Answer

#include<iostream>
#include<vector>
using namespace std;
void reverse(vector<string>& v)
{
int k=v.size()-1;
for(int i=0; i<v.size()/2; i++)
{
string temp = v[i];
v[i] = v[k];
v[k]=temp;
k--;
}
}
int main()
{
string a[]={"a", "cat", "ball", "at", "zed", "to"};
vector<string> v(a,a+6);
cout << "before reverse" <<endl;
for(int i=0; i<v.size(); i++)
cout<<v[i]<<" ";
reverse(v);
cout << " after reverse" <<endl;
for(int i=0; i<v.size(); i++)
cout<<v[i]<<" ";

return 0;
}