Changeset 2592 in Sophya for trunk/SophyaProg/Tests/tcmd.cc


Ignore:
Timestamp:
Aug 9, 2004, 11:38:58 AM (21 years ago)
Author:
ansari
Message:

amelioaration programme tcmd (Test Commander/CExpEvaluator/RPNEvaluator) - Reza 9 Aout 2004

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaProg/Tests/tcmd.cc

    r2513 r2592  
    5858
    5959  if (narg < 2) {
    60     cout << " Usage: tcmd commander/cexptst/rpntst \n "
    61          << "  - commander: Commader class test \n"
    62          << "  - cexptst: CExpressionEvaluator class test \n"
    63          << "  - rpntst: RPNExpressionEvaluator class test \n" << endl;
     60    cout << " Usage: tcmd S=commander/cexptst/rpntst \n"
     61         << "  S= commander: Commader class test \n"
     62         << "  S= cexptst: CExpressionEvaluator class test \n"
     63         << "  S= rpntst: RPNExpressionEvaluator class test \n" << endl;
    6464    return 0;
    6565  }
     
    6868  InitTim();
    6969  int rc = 0;
     70  cout << " ---- tcmd S= " << opt << " (commander/evaluator test) " << endl;
    7071  try {
    7172    if (opt == "commander") {
     
    7576    }
    7677    else if (opt == "cexptst") rc = tst_cexpreval();
    77     else rc = tst_rpneval();
    78   }
     78    else if (opt == "rpntst")   rc = tst_rpneval();
     79    else {
     80      cout << " tcmd/error: Unknown select option: " << opt << endl;
     81      rc = 9;
     82    }
     83  }
    7984 
    8085  catch (PThrowable & exc) {
     
    8287         << " - Msg= " << exc.Msg() << endl;
    8388  }
     89  catch (exception & e) {
     90    cerr << " exception catched : e.what()= " << e.what() << endl;
     91  }
    8492  catch (...) {
    8593    cerr << " some other exception was caught ! " << endl;
     
    8795
    8896  PrtTim(" End of tcmd ");
     97  PrtTim("--Fin tcmd ");
    8998  return(rc);
    9099}
     
    135144    try {
    136145      num++;
     146      CExpressionEvaluator cex("4.e-1");
     147      cout << "CExpr=" << cex;
     148      cout << " -> cex.Value() = " << cex.Value() << " =? " << ( res=4.e-1 ) << endl;
     149      if (fabs(cex.Value()-res) > 1.e-9) {
     150        cout << " ERREUR CALCUL " << cex << endl;
     151        nerr++;
     152      }
     153      else nok++;
     154    }
     155    catch (CExprException& err) {
     156      nerrparse++;
     157      cout << "Exp[" << num << "]  Exception: " << err.Msg() << endl;
     158    }
     159    cout << "  [" << num << "] CExprBase::NbCreate() = " << CExprBase::NbCreate()
     160         << "CExprBase::NbDelete()=" <<  CExprBase::NbDelete() << endl;
     161
     162    try {
     163      num++;
    137164      CExpressionEvaluator cex("4*3+8");
    138165      cout << "CExpr=" << cex;
     
    266293
    267294    // Expression avec erreur de syntaxe
     295   cout << " >>>>> Expression avec erreur <<<<<< " << endl;
    268296   try {
    269297      num++;   
     
    313341  cout << "-------- CExprBase::NbCreate() = " << CExprBase::NbCreate() << " CExprBase::NbDelete()=" <<  CExprBase::NbDelete() << endl;
    314342  cout << "--- NExpr= " << num << " NOk= " <<  nok << " NErr=" << nerr << " NErrParse=" << nerrparse << endl;
    315   return 0;
     343  if ( (nok == 8) && (nerr == 0) && (nerrparse == 3) ) return 0;
     344  else return 99;
    316345}
    317346
Note: See TracChangeset for help on using the changeset viewer.