// file: $isip/util/diagnostics/diagnose_class/diagnose_class.cc
// version: $Id: diagnose_class.cc 6034 2000-12-20 23:08:33Z hamaker $

// isip include files 
//
#include "diagnose_class.h"

//-----------------------------------------------------------------------------//
// program: diagnose_class
//
//  synopsis: DIAG_CLASS.exe [-debug DETAILED] [3]
//    DIAG_CLASS denotes the class to be diagnosed
//    [] denotes the optional arguments
//      [-debug DETAILED] -- the debug level, default BRIEF
//      [3] -- the diagnose times, default 1
//
//   this is the utility for diagnosing the isip classes
// 
//-----------------------------------------------------------------------------
int main(int argc, char **argv) {
  
  // set default values
  //
  Integral::DEBUG debug_level = Integral::BRIEF;
  long iterations = 1;
  
  // have the error handler display file and line number information
  //
  Error::setDebug(Integral::ALL);

  // parse the command line parameters
  //
  readCmdline(argc, argv, debug_level, iterations);

  // output the start testing information
  //
  SysString output(L"testing class ");
  output.concat(DIAG_CLASS_NAME::name());
  output.concat(L"\n");
  Console::put(output);
  
  // diagnose the class
  //
  boolean status = true;
  
  for (long count = 0; count < iterations; count++) {
    Console::increaseIndention();
    status &= DIAG_CLASS_NAME::diagnose(debug_level);
    Console::decreaseIndention();
    
    // output the iteration count if there is more than 1 iteration
    //
    if (iterations > 1) {
      SysString iteration_str(L"iteration ");
      SysString count_str;
      count_str.assign(count);
      iteration_str.concat(count_str);
      iteration_str.concat(L": passed");
      Console::put(iteration_str);
    }
  }

  // output the end testing information
  //
  output.clear();
  if (status == true) {
    output.assign(L"tests passed for class ");
  }
  else {
    output.assign(L"tests failed for class ");
  }
  output.concat(DIAG_CLASS_NAME::name());
  output.concat(L"\n");
  Console::put(output);
  
  // exit gracefully
  //
  return Integral::exit();
}
