Ignore:
Timestamp:
Dec 26, 2012, 2:32:57 AM (9 years ago)
Author:
Peter
Message:

add EXIT_SKIP macro. make test compile also --without-samtools

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/0.10-stable/test/bam_iterator.cc

    r2895 r2929  
    2020#include "Suite.h"
    2121
     22#ifdef HAVE_LIBBAM
    2223#include "yat/omic/BamFile.h"
    2324#include "yat/omic/BamRead.h"
    2425#include "yat/omic/BamReadIterator.h"
    2526#include "yat/omic/BamWriteIterator.h"
     27#endif
    2628
    2729#include <algorithm>
    2830#include <cassert>
    2931#include <fstream>
    30 #include <iostream>
    3132#include <string>
    3233
    3334using namespace theplu::yat;
     35
     36void test1(test::Suite& suite);
     37
     38int main(int argc, char* argv[])
     39{
     40  test::Suite suite(argc, argv);
     41#ifndef HAVE_LIBBAM
     42  suite.out() << "no libbam\n";
     43  return EXIT_SKIP;
     44#endif
     45#ifndef HAVE_SAMTOOLS
     46  suite.out() << "no samtools\n";
     47  return EXIT_SKIP;
     48#endif
     49  test1(suite);
     50  return suite.return_value();
     51}
     52
     53#ifdef HAVE_LIBBAM
    3454using namespace omic;
    3555
     
    7999};
    80100
    81 int main(int argc, char* argv[])
     101
     102void test1(test::Suite& suite)
    82103{
    83 #ifndef HAVE_SAMTOOLS
    84   return EXIT_SKIP;
    85 #endif
    86   test::Suite suite(argc, argv);
    87 
    88104  std::string file = "../../data/foo.sorted.bam";
    89105
     
    99115  in.open(file);
    100116  size_t n1 = std::distance(BamReadIterator(in), BamReadIterator());
    101   std::cout << "entries in " << file << ": " << n1 << "\n";
     117  suite.out() << "entries in " << file << ": " << n1 << "\n";
    102118  in.close();
    103119
     
    105121  size_t n2 = std::distance(BamReadIterator(copy), BamReadIterator());
    106122  copy.close();
    107   std::cout << "entries in " << outname << ": " << n2 << "\n";
     123  suite.out() << "entries in " << outname << ": " << n2 << "\n";
    108124  if (n1!=n2) {
    109     std::cout << "error: not same number of entries in copy\n";
    110     exit(1);
     125    suite.out() << "error: not same number of entries in copy\n";
     126    suite.add(false);
    111127  }
    112128
     
    115131  if (!std::equal(BamReadIterator(in), BamReadIterator(),
    116132                  BamReadIterator(copy), BamReadEqual())) {
    117     std::cout << "error: " << file << " and " << outname << " not equal\n";
    118     exit(1);
     133    suite.out() << "error: " << file << " and " << outname << " not equal\n";
     134    suite.add(false);
    119135  }
    120136  copy.close();
    121137  in.close();
    122138  unlink(outname.c_str());
    123   std::cout << "OK\n";
    124   return 0;
    125139}
     140#endif
Note: See TracChangeset for help on using the changeset viewer.