Changeset 3162


Ignore:
Timestamp:
Jan 15, 2014, 9:01:08 AM (9 years ago)
Author:
Peter
Message:

refs #778. samwrite returns -1 if file is closed, so correct code to detect when this happens.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/bam.cc

    r3160 r3162  
    210210
    211211
     212void test_write(test::Suite& suite, const BamHeader& header)
     213{
     214  OutBamFile out;
     215  BamRead read;
     216  try {
     217    // trying to write to a file not open
     218    out.write(read);
     219    suite.add(false);
     220    suite.err() << "write(BamRead): did not throw\n";
     221  }
     222  catch (utility::runtime_error& e) {
     223    suite.err() << "expected exception: " << e.what() << "\n";
     224  }
     225}
     226
     227
    212228void test1(test::Suite& suite)
    213229{
     
    258274  test_name(suite, bam);
    259275  test_open3(suite, in.header());
    260 }
    261 #endif
     276  test_write(suite, in.header());
     277}
     278#endif
  • trunk/yat/omic/BamFile.cc

    r3160 r3162  
    162162  void OutBamFile::write(const BamRead& read)
    163163  {
    164     if (!samwrite(sf_, read.bam_)) {
     164    if (samwrite(sf_, read.bam_)<=0) {
    165165      // FIXME if wanted perhaps we should throw an OutBamFile::error
    166166      // instead that can hold \a read
Note: See TracChangeset for help on using the changeset viewer.