Question: 1. Please write a CPPUnit Light test in the follwing format for the c++ program below. 2. Please show all output. _______________________________________________________________________________ CPPUnit Light test
1. Please write a CPPUnit Light test in the follwing format for the c++ program below.
2. Please show all output.
_______________________________________________________________________________
CPPUnit Light test format:
// Define a simple class class IntValue { public: IntValue() : myValue(10) { } int getValue() { return myValue; } void setValue(int value) { myValue = value; } private: int myValue; }; TEST(DataMembers, SimpleClass) { // Declare two instances of the class IntValue inst0; IntValue inst1; // Change the data member in one of them inst1.setValue(20); CHECK_EQUAL(10, inst0.getValue()); CHECK_EQUAL(20, inst1.getValue()); }
____________________________________________________________________
Program the CPPUnit Light test is written for:
#include
using namespace std;
const int ARRAY_SIZE = 500;
//function definition
void pigLatin( char *pointer )
{
int length = strlen( pointer );
for (int i = 1; i < length; ++i )
cout << *( pointer + i );
cout << *pointer << "ay";
} int main() { //declaring character char input_Sentence[ ARRAY_SIZE ], *pointer; //input sentence cout << "Enter a sentence: "; cin.getline( input_Sentence, ARRAY_SIZE ); //tokenize each word
cout << " The sentence in Pig Latin is: ";
pointer = strtok( input_Sentence, " .,;" );
//to convert each word to pig latin form
while ( pointer )
{
pigLatin( pointer );
pointer = strtok( 0, " .,;" );
if ( pointer )
cout << ' ';
}
cout << '.' << endl;
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
