Changeset 290


Ignore:
Timestamp:
Apr 22, 2005, 12:19:59 AM (16 years ago)
Author:
Peter
Message:

modified to be able to print when fail

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/test_nni.cc

    r285 r290  
    2121int main(const int argc,const char* argv[])
    2222{
     23  bool print=false;
     24  if (argc>1 && argv[1]==std::string("-p"))
     25    print=true;
    2326
     27  bool ok = true;
    2428  uint neighbours=3;
    2529  std::string knni_data("data/knni_matrix.data");
     
    5054      // hardcoded number below should be changed.
    5155      if (fabs(control(i,j))>5e-13) {
    52         //std::cerr << "test_nni: kNNI FAILED, cannot reproduce test result\n";
    53         exit(-1); // calculation result out of accepted error bounds
     56        if (print)
     57          std::cerr << "test_nni: kNNI FAILED, cannot reproduce test result\n";
     58        ok=false; // calculation result out of accepted error bounds
    5459      }
    5560      else
    5661        if (!((control(i,j)==control(i,j)))) {
    57           //std::cerr << "test_nni: kNNI FAILED, nan (not a number) encountered in test\n";
    58           exit(-1); // calucaltion error detected
     62          if (print){
     63            std::cerr << "test_nni: kNNI FAILED, nan (not a number) "
     64                      << "encountered in test\n";
     65          }
     66          ok =false; // calucaltion error detected
    5967        }
    6068  control_stream.close();
     
    7684      // hardcoded number below should be changed.
    7785      if (fabs(control(i,j))>5e-13) {
    78         //std::cerr << "test_nni: WeNNI FAILED, cannot reproduce test result\n";
    79         exit(-1); // calculation result out of accepted error bounds
     86        if (print)
     87          std::cerr << "test_nni: WeNNI FAILED, cannot reproduce test result\n";
     88        ok=false; // calculation result out of accepted error bounds
    8089      }
    8190      else
    8291        if (!((control(i,j)==control(i,j)))) {
    83           //std::cerr << "test_nni: WeNNI FAILED, nan (not a number) encountered in test\n";
    84           exit(-1); // calucaltion error detected
     92          if (print) {
     93            std::cerr << "test_nni: WeNNI FAILED, nan (not a number) "
     94                      << "encountered in test\n";
     95          }
     96          ok=false; // calucaltion error detected
    8597        }
    86 
    87   //std::cout << "test_nni: SUCCESS, reproducing test result\n";
    88   exit(0);        // normal exit
     98  if(ok)
     99    return 0;
     100  return -1;
    89101}
Note: See TracChangeset for help on using the changeset viewer.