Ignore:
Timestamp:
Apr 16, 2015, 2:22:24 AM (8 years ago)
Author:
Peter
Message:

Implement functions to get/set free text in BamHeader?. As setting the
header text modifies underlying data, copy and assignment are now
implemented as hard copy (rather than the implicit pointer copy as
before). It also means that the bam_hdr_t* is no longer owned by
InBamFile?, but is now owned by BamHeader? and destroyed in its
destructor.

refs #817

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/bam_header.cc

    r3210 r3408  
    7979  suite.out() << hdr.target_length(0) << "\n";
    8080  suite.add(hdr.target_length(0)==249250621);
     81
     82  std::string str = hdr.text();
     83  std::string str1(str);
     84  str1 += "@PG\tID:prog\tVN:1.0\n";
     85  omic::BamHeader hdr2(hdr);
     86  hdr.text(str1);
     87  std::string str2 = hdr.text();
     88  if (str2.substr(0, str.size()) != str) {
     89    suite.add(false);
     90    suite.err() << "incorrect text:\n" << str2 << "\nexpected:\n"
     91                << str1 << "\n";
     92  }
     93  else if (str2 != str1) {
     94    suite.add(false);
     95    suite.err() << "error: line was not added to header\n";
     96  }
     97  if (hdr2.text() != str) {
     98    suite.add(false);
     99    suite.err() << "function text(1) affects copies\n";
     100  }
     101
    81102#endif
    82103}
Note: See TracChangeset for help on using the changeset viewer.