source: trunk/test/bam_header2.cc @ 3144

Last change on this file since 3144 was 3144, checked in by Peter, 8 years ago

merge patch release 0.11.1 into trunk

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1// $Id: bam_header2.cc 3144 2013-12-18 08:18:48Z peter $
2//
3// Copyright (C) 2013 Peter Johansson
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful, but
11// WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13// General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18#include <config.h>
19
20#include "Suite.h"
21
22#ifdef HAVE_LIBBAM
23#include "yat/omic/BamFile.h"
24#include "yat/omic/BamHeader.h"
25#endif
26
27using namespace theplu::yat;
28
29#ifdef SKIP_BAM_TEST
30void do_main(test::Suite& suite) {}
31#else
32void do_main(test::Suite& suite);
33#endif
34
35int main(int argc, char* argv[])
36{
37#ifdef SKIP_BAM_TEST
38  return EXIT_SKIP;
39#endif
40  test::Suite suite(argc, argv);
41  try {
42    do_main(suite);
43  }
44  catch (std::runtime_error& e) {
45    suite.err() << "what: " << e.what() << "\n";
46    suite.add(false);
47  }
48
49  return suite.return_value();
50}
51
52#ifdef HAVE_LIBBAM
53void do_main(test::Suite& suite)
54{
55  using namespace omic;
56  std::string file = "../../data/foo.sorted.bam";
57
58  InBamFile bam_stream(file);
59  BamHeader hdr = bam_stream.header();
60  int32_t tid1 = hdr.tid("2");
61  if (tid1 != 1) {
62    suite.add(false);
63    suite.err() << "incorrect tid1: " << tid1 << " expected: 1\n";
64  }
65  int32_t tid2 = hdr.tid("2");
66  if (tid1 != tid2) {
67    suite.add(false);
68    suite.err() << "error: tid1: " << tid1 << " != tid2: " << tid2 << "\n";
69  }
70}
71#endif
Note: See TracBrowser for help on using the repository browser.