Changeset 1119


Ignore:
Timestamp:
Feb 21, 2008, 11:27:48 PM (13 years ago)
Author:
Peter
Message:

add view_test into TESTS

Location:
trunk/test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/Makefile.am

    r1117 r1119  
    4040  statistics_test subset_generator_test svd_test svm_test target_test \
    4141  ttest_test \
    42   utility_test vector_test
     42  utility_test vector_test view_test
    4343
    4444check_PROGRAMS = $(TESTS)
    4545
    4646# tests that fail are only built not included in check
    47 check_PROGRAMS += view_test
     47#check_PROGRAMS +=
    4848
    4949LDADD = @top_builddir@/$(YAT_LIB_LOCATION)/$(YAT_LIB)
  • trunk/test/view_test.cc

    r1114 r1119  
    2828#include "yat/utility/VectorConstView.h"
    2929
     30#include <fstream>
    3031#include <iostream>
    3132#include <string>
    3233
    33 using namespace theplu::yat::utility;
    34 
    35 
    36 void f(const VectorBase& aa, VectorMutable& bb) {
    37   std::cout << "f aa: " << aa << std::endl;
    38   std::cout << "f bb: " << bb << std::endl;
    39 }
    40 
    4134int main(const int argc,const char* argv[])
    4235
     36  using namespace theplu::yat::utility;
     37  std::ostream* message;
     38  if (argc>1 && argv[1]==std::string("-v"))
     39    message = &std::cerr;
     40  else {
     41    message = new std::ofstream("/dev/null");
     42    if (argc>1)
     43      std::cout << "vector_test -v : for printing extra "  << "information\n";
     44  }
     45  *message << "testing vector" << std::endl;
     46  bool ok = true;
    4347
    4448  matrix data1;
     
    5357  VectorView b=data2.column_view(0);
    5458
    55   std::cout << "First\n";
    56   f(a,b);
     59  data1.column_const_view(0);
     60  if (b.size()!=3){
     61    ok =false;
     62    *message << "ERROR: expected size to be 3 - found " << b.size() << std::endl;
     63  }
     64  if ( !(b(0)==1 && b(1)==(1) && b(2)==1) )
     65    ok = false;
     66 
    5767
    58   std::cout << "Second\n";
    59   f(a,b);
     68  if (ok)
     69    *message << "test is ok" << std::endl;
     70  else
     71    *message << "view test failed" << std::endl;
    6072
    61   std::cout << "Third\n";
    62   f(data1.column_const_view(0),b);
     73  if (message!=&std::cerr)
     74    delete message;
    6375
    64   std::cout << "Fourth\n";
    65   f(a,b);
    66 
    67   std::cout << "data 2:\n" << data2 << std::endl;
     76  return (ok ? 0 : -1);
    6877}
    6978
Note: See TracChangeset for help on using the changeset viewer.