Question: Need help!! Create a test suite for the badcalc.cpp demo code that achieves full line coverage, and generates coverage report. #include #include #include using namespace

Need help!! Create a test suite for the badcalc.cpp demo code that achieves full line coverage, and generates coverage report.
#include
#include
#include
using namespace std;
int main(int argc, char * argv[]){
ifstream in(argv[1]);
string opd1;
string opr;
string opd2;
std::getline(in, opd1,'');
std::getline(in, opr, '');
std::getline(in, opd2,'');
int opd1int = atoi(opd1.c_str());
int opd2int = atoi(opd2.c_str());
if (opr =="*"){
cout << opd1int * opd2int <<"
";
} else if (opr =="/"){
if (opd2int ==0){
cerr << "divide by 0
";
} else {
cout << opd1int / opd2int <<"
";
}
} else if (opr =="-"){
cout << opd1int - opd2int <<"
";
} else if (opr =="+"){
cout << opd1int + opd2int <<"
";
} else {
cerr << "bad opr "<< opr <<"
";
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!