Changeset 1242


Ignore:
Timestamp:
Mar 16, 2008, 7:45:37 PM (13 years ago)
Author:
Peter
Message:

working on #223

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/nni_test.cc

    r1210 r1242  
    2424*/
    2525
     26#include "Suite.h"
     27
    2628#include "yat/utility/FileUtil.h"
    2729#include "yat/utility/Matrix.h"
     
    4446}
    4547
    46 int main(const int argc,const char* argv[])
     48int main(int argc, char* argv[])
    4749{
    48   bool print = (argc>1 && argv[1]==std::string("-p"));
    49   bool ok = true;
     50  test::Suite suite(argc, argv);
     51
    5052  uint neighbours=3;
    5153  std::string knni_data("data/knni_matrix.data");
     
    7678    for (unsigned int j=0; j<control.columns(); j++)
    7779      if (std::abs(control(i,j))>error_bound) {
    78         if (print)
    79           std::cerr << "kNNI FAILED, error on row " << i << " and "
     80        suite.err() << "kNNI FAILED, error on row " << i << " and "
    8081                    << "column " << j << " is " << std::abs(control(i,j))
    8182                    << ". Expected less than " << error_bound << std::endl;
    82         ok=false; // calculation result out of accepted error bounds
     83        suite.add(false); // calculation result out of accepted error bounds
    8384      }
    8485      else
    8586        if (!((control(i,j)==control(i,j)))) {
    86           if (print)
    87             std::cerr << "kNNI FAILED, nan (not a number) "
     87          suite.err() << "kNNI FAILED, nan (not a number) "
    8888                      << "encountered in test on row " << i
    8989                      << " and column " << j << std::endl;
    90           ok =false; // calucaltion error detected
     90          suite.add(false); // calucaltion error detected
    9191        }
    9292  control_stream.close();
     
    107107    for (unsigned int j=0; j<control.columns(); j++)
    108108      if (std::abs(control(i,j))>error_bound) {
    109         if (print)
    110           std::cerr << "WeNNI FAILED, error on row " << i << " and "
     109        suite.err() << "WeNNI FAILED, error on row " << i << " and "
    111110                    << "column " << j << " is " << std::abs(control(i,j))
    112111                    << ". Expected less than " << error_bound << std::endl;
    113         ok=false; // calculation result out of accepted error bounds
     112        suite.add(false); // calculation result out of accepted error bounds
    114113      }
    115114      else
    116115        if (!((control(i,j)==control(i,j)))) {
    117           if (print)
    118             std::cerr << "WeNNI FAILED, nan (not a number) "
     116          suite.err() << "WeNNI FAILED, nan (not a number) "
    119117                      << "encountered in test on row " << i
    120118                      << " and column " << j << std::endl;
    121           ok=false; // calucaltion error detected
     119          suite.add(false); // calucaltion error detected
    122120        }
    123121  control_stream.close();
     
    138136    for (unsigned int j=0; j<control.columns(); j++)
    139137      if (std::abs(control(i,j))>error_bound) {
    140         if (print)
    141           std::cerr << "WeNNI binary weight test FAILED.\nError on row " << i
     138        suite.err() << "WeNNI binary weight test FAILED.\nError on row " << i
    142139                    << " and column " << j << " is " << std::abs(control(i,j))
    143140                    << ". Expected less than " << error_bound << std::endl;
    144         ok=false; // calculation result out of accepted error bounds
     141        suite.add(false); // calculation result out of accepted error bounds
    145142      }
    146143      else
    147144        if (!((control(i,j)==control(i,j)))) {
    148           if (print)
    149             std::cerr << "WeNNI binary wieght test FAILED.\n"
     145          suite.err() << "WeNNI binary wieght test FAILED.\n"
    150146                      << "nan (not a number) encountered in test on row " << i
    151147                      << " and column " << j << std::endl;
    152           ok=false; // calucaltion error detected
     148          suite.add(false); // calucaltion error detected
    153149        }
    154150  control_stream.close();
     
    156152  weight_stream.close();
    157153
    158   return (ok ? 0 : -1);
     154  return suite.return_value();
    159155}
Note: See TracChangeset for help on using the changeset viewer.