Please send questions to
st10@humboldt.edu .
#include <iostream>
#include <string>
#include "FUNCT.h"
// and any other files needed by FUNCT or what it calls
using namespace std;
/*--------------------------------------------------
Contract: main : void -> int
Purpose: perform unit tests for function/class FUNCT
and permit further tests to be run as
desired (until the user types in n to say
they want to do no further testing), prompting
the user for the needed arguments for each
additional test.
Examples: not really applicable --- this will
perform and display to the screen the
results of FUNCT's examples, and
will then allow the user to enter arguments
for additional calls of FUNCT until
they enter n when asked if they'd like to
continue.
Compile using:
g++ -o testFUNCT testFUNCT.cpp FUNCT.o <any other needed.o>
-----------------------------------------------------*/
int main()
{
// local variables - IF necessary
string answer;
FUNCTreturn_type result;
return_type FUNCT_arg1;
return_type FUNCT_arg2;
...
// FIRST: test FUNCT's examples
// (type/edit in hard-coded tests from FUNCT's
// Examples section ---
// OR, for a class, test its constructors,
// accessors, and mutators, as demonstrated
// also in the example testProf.cpp
// IF these can be expressed as == conditions,
// THEN use:
cout << "Each 1 below indicates a PASSED test; " << endl;
cout << " (each 0 indicates a FAILED test) " << endl;
cout << "--------------------------------------" << endl;
cout << (FUNCT(arg1, arg2...) == val)
<< endl;
// IF these CANNOT be expressed as == conditions,
// THEN use:
cout << "expected value/result of test: " << "(descr or value)";
cout << "actual value/result of test: ";
result = FUNCT(arg1, arg2...);
cout << result << endl;
// OR, for a class without a string depiction,
// call the accessors for a resulting class
// instance and print their results
// PART 2 -- allow user to loop and test alphaForm further,
// until they type q to quit
// (this may be OMITTED for a simple class ---
// or perhaps you'd ask for new values for
// certain member variables, change them
// accordingly, and show using the accessors
// that the change has been made...)
cout << endl;
cout << "Would you like to test FUNCT further?" << endl;
cout << "(type n for no, anything else for yes)" << endl;
cout << endl;
cout << "your answer: ";
cin >> answer;
while (answer != "n")
{
// for each argument... ask for a value
cout << "Enter a FUNCT_arg1: ";
cin >> FUNCT_arg1;
cout << Enter a FUNCT_arg2: ";
cin >> FUNCT_arg2;
...
result = FUNCT(FUNCT_arg1, FUNCT_arg2, ...);
cout << "returns: " << result << endl;
cout << endl;
cout << "Would you like to test FUNCT further?" << endl;
cout << "(type n for no, anything else for yes)" << endl;
cout << endl;
cout << "your answer: ";
cin >> answer;
}
return 0;
}