ProteoWizard
Functions | Variables
TraDataFileTest.cpp File Reference
#include "TraDataFile.hpp"
#include "Diff.hpp"
#include "IO.hpp"
#include "examples.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Filesystem.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/copy.hpp>

Go to the source code of this file.

Functions

void hackInMemoryTraData (TraData &td)
void test ()
int main (int argc, char *argv[])

Variables

ostream * os_ = 0
string filenameBase_ = "temp.TraDataFileTest"

Function Documentation

void hackInMemoryTraData ( TraData td)

Definition at line 47 of file TraDataFileTest.cpp.

References pwiz::tradata::TraData::softwarePtrs.

Referenced by test().

{
// remove metadata ptrs appended on read
//vector<SourceFilePtr>& sfs = msd.fileDescription.sourceFilePtrs;
//if (!sfs.empty()) sfs.erase(sfs.end()-1);
vector<SoftwarePtr>& sws = td.softwarePtrs;
if (!sws.empty()) sws.erase(sws.end()-1);
}
void test ( )

Definition at line 56 of file TraDataFileTest.cpp.

References diff(), filename1, filenameBase_, hackInMemoryTraData(), pwiz::identdata::examples::initializeTiny(), os_, unit_assert, pwiz::tradata::TraDataFile::write(), and write().

{
if (os_) *os_ << "test()\n " << writeConfig << endl;
string filename1 = filenameBase_ + ".1";
string filename2 = filenameBase_ + ".2";
{
// create TraData object in memory
TraData tiny;
// write to file #1 (static)
TraDataFile::write(tiny, filename1, writeConfig);
// read back into an TraDataFile object
TraDataFile td1(filename1);
// compare
if (diff && os_) *os_ << diff << endl;
// write to file #2 (member)
td1.write(filename2, writeConfig);
// read back into another TraDataFile object
TraDataFile td2(filename2);
// compare
diff(tiny, td2);
if (diff && os_) *os_ << diff << endl;
// now give the gzip read a workout
bio::filtering_istream tinyGZ(bio::gzip_compressor() | bio::file_descriptor_source(filename1));
bio::copy(tinyGZ, bio::file_descriptor_sink(filename1+".gz", ios::out|ios::binary));
TraDataFile td3(filename1);
// compare
diff(tiny, td3);
if (diff && os_) *os_ << diff << endl;
}
// remove temp files
boost::filesystem::remove(filename1);
boost::filesystem::remove(filename2);
boost::filesystem::remove(filename1 + ".gz");
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 114 of file TraDataFileTest.cpp.

References e(), os_, test(), TEST_EPILOG, TEST_FAILED, and TEST_PROLOG.

{
TEST_PROLOG(argc, argv)
try
{
if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
test();
}
catch (exception& e)
{
TEST_FAILED(e.what())
}
catch (...)
{
TEST_FAILED("Caught unknown exception.")
}
}

Variable Documentation

ostream* os_ = 0

Definition at line 42 of file TraDataFileTest.cpp.

string filenameBase_ = "temp.TraDataFileTest"

Definition at line 45 of file TraDataFileTest.cpp.