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 7. Write a test harness that tests a f

ID: 3626510 • Letter: P

Question

Please write these problems in C++ format
7. Write a test harness that tests a function named merge. This must be a complete program, including all necessary include directives and using statements. You are NOT implementing the merge 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 merge( vector<double> &v,
const vector<double> &a,
const vector<double> &b );
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 merge function passes in 3 vectors of doubles. The first parameter should be passed in empty and then the function merges the 2nd and 3rd vector parameters into the 1st vector.

For example, if the 2nd vector argument passed in has values in the order:
15 8 9 17 and the 3rd vector argument passed in has values in the order:
100 200 300 400 500 600 then when the function returns the 1st vector argument will have values in the order:
15 100 8 200 9 300 17 400 500 600
and the 2nd and 3rd arguments will be unchanged.
Notice that the 2nd and 3rd arguments may not have the same number of values.
You are NOT implementing the merge function. You are only writing the test harness that will thoroughly test the merge 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 return value(s) 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 merge(vector<int>& v,const vector<int>& v1,const vector<int>& v2)
{
int max=v1.size()>v2.size()?v1.size():v2.size();
for(int i=0; i<max; i++)
{
if(i<v1.size()) v.push_back(v1[i]);
if(i<v2.size()) v.push_back(v2[i]);
}
}
int main()
{
int a[] = {15, 8, 9 ,17};
int b[] = {100, 200, 300, 400, 500, 600};
vector<int> v;
vector<int> v1(a,a+4);
vector<int> v2(b,b+6);
merge(v,v1,v2);
for(int i=0; i<v.size(); i++)
cout<<v[i]<<" ";
return 0;