// Purpose: Provide outline of a typical test driver for GCS // Status: Not complete at all, outline only // Date: Sept. 19, 2002 // Proposed changes: ... // Warning: THIS HAS NOT BEEN COMPILED. IT PROBABLY HAS LOTS OF ERRORS! // It is provided to illustrate the concept only! // Programmer: cmo #include #include using namespace std; #include "/home/cs350/term.projects/include.files/external.h" #include "/home/cs350/term.projects/include.files/guidance_state.h" #include "/home/cs350/term.projects/include.files/run_parameters.h" #include "/home/cs350/term.projects/include.files/sensor_output.h" extern void arsp(); struct guidance_state gs; struct external ex; struct run_parameters rp; struct sensor_output so; int main( int argc, char *argv[] ) { struct guidance_state local_gs; struct sensor_output local_so; bool summary; // if summary, produce statistics only. No details ... int inct, DiffCt, MatchCt, TestCaseCt = 0, Totinct = 0, TotDiffCt = 0, TotMatchCt = 0; bool FoundOne; // Read all inputs into global vars // Read & echo ar_altitude for ( int i=0; i<4; i++ ) { so.ar_altitude[ i ] = get_next_num(); inct++; } // Read & echo ar_counter ... // call arsp. arsp(); // Check outputs if ( !summary ) cout << " Checking ar_altitude" << endl; FoundOne = false; // Check ar_altitude for ( int i=0; i<3; i++ ) { if ( differ( local_so.ar_altitude[i], so.ar_altitude[i]) ) { FoundOne = true; DiffCt++; if ( !summary ) { cout << " ar_altitude[" << i+1 << "] differ." << endl; cout << " Actual: " << so.ar_altitude[i] << endl; cout << " Expected: " << local_so.ar_altitude[i] << endl; } else MatchCt++; } if ( !FoundOne && !summary ) cout << " All values matched."; if ( !summary ) cout << endl; // Check ar_status ... // Print run summary if ( summary ) { cout << "Test Case Count: " << cout.width(4); cout << TestCaseCt << endl; cout << "Match Count: " << cout.width(8); cout << MatchCt << endl; cout << "Difference Count: " << cout.width(8); cout << DiffCt << endl; } else { if ( !FoundOne ) cout << " All values matched."; cout << endl; cout.width(5); cout << inct << " test values read." << endl; cout.width(5); cout << MatchCt << " values matched." << endl; cout.width(5); cout << DiffCt << " differences detected." << endl << endl; cout << "--------------------------------------------------------------" << endl; } // Report cout << "Run Summary:" << endl; cout.width(5); cout << TestCaseCt << " test cases read." << endl; cout.width(5); cout << TotInct << " test values read." << endl; cout.width(5); cout << TotMatchCt << " values matched." << endl; cout.width(5); cout << TotDiffCt << " differences detected." << endl; }