Ignore:
Timestamp:
Dec 1, 2008, 7:41:08 PM (14 years ago)
Author:
Peter Johansson
Message:

fixed so test can be run outside 'make check'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/base1/se.lu.thep.wenni/trunk/test/wenni_test.cc

    r836 r846  
    4040bool compare(const std::string&, const std::string&, double error_bound=1e-20);
    4141bool diff(const std::string&, const std::string&);
     42std::string get_srcdir(void);
    4243bool rm(const std::string& filename);
    43 
    4444
    4545int main(const int argc,const char* argv[])
     
    5050  teststatus|=check_default_results();
    5151
    52   char* buf=std::getenv("srcdir");
    53   assert(buf);
    54   std::string srcdir(buf);
     52  std::string srcdir=get_srcdir();
    5553  std::stringstream system_call;
    5654  system_call << "./nni -data default_results/wenni_logratio.data"
     
    8280bool check_default_results(void)
    8381{
    84   char* buf=std::getenv("srcdir");
    85   assert(buf);
    86   std::string srcdir(buf);
     82  std::string srcdir=get_srcdir();
    8783
    8884  bool teststatus=false;
     
    113109bool check_knni_results(void)
    114110{
    115   char* buf=std::getenv("srcdir");
    116   assert(buf);
    117   std::string srcdir(buf);
     111  std::string srcdir=get_srcdir();
    118112  bool teststatus=false;
    119113  teststatus|=diff("knni_imputed.data",srcdir+"/../data/knni_imputed.data");
     
    126120bool check_raw_results(void)
    127121{
    128   char* buf=std::getenv("srcdir");
    129   assert(buf);
    130   std::string srcdir(buf);
     122  std::string srcdir=get_srcdir();
    131123
    132124  bool teststatus=false;
     
    161153{
    162154  bool teststatus=false;
    163   char* buf=std::getenv("srcdir");
    164   assert(buf);
    165   std::string srcdir(buf);
     155  std::string srcdir=get_srcdir();
    166156  teststatus|=compare("wenni_imputed.data",srcdir+"/../data/wenni_imputed.data",
    167157                      1.1e-11);
     
    235225
    236226
     227std::string get_srcdir(void)
     228{
     229  char* buf=std::getenv("srcdir");
     230  if (buf)
     231    return buf;
     232  return ".";
     233 
     234}
     235
     236
    237237bool rm(const std::string& filename) {
    238238  if (unlink(filename.c_str())) {
Note: See TracChangeset for help on using the changeset viewer.