29 #include "boost/thread/thread.hpp" 30 #include "boost/thread/barrier.hpp" 49 serializer.
write(oss, pd, NULL);
51 if (
os_) *
os_ <<
"oss:\n" << oss.str() << endl;
53 shared_ptr<istringstream> iss(
new istringstream(oss.str()));
55 serializer.
read(iss, pd2);
58 if (
os_ && diff) *
os_ << diff << endl;
65 if (
os_) *
os_ <<
"testWriteRead() MemoryIndex" << endl;
69 if (
os_) *
os_ <<
"testWriteRead() BinaryIndexStream" << endl;
70 shared_ptr<stringstream> indexStringStream(
new stringstream);
84 for (
int i=0; i < 3; ++i)
86 for (
size_t j=0; j < args->second->proteinListPtr->size(); ++j)
87 unit_assert(args->second->proteinListPtr->protein(j)->index == j);
92 cerr <<
"Exception in worker thread: " << e.what() << endl;
96 cerr <<
"Unhandled exception in worker thread." << endl;
105 boost::barrier testBarrier(testThreadCount);
106 boost::thread_group testThreadGroup;
107 for (
int i=0; i < testThreadCount; ++i)
108 testThreadGroup.add_thread(
new boost::thread(&
testThreadSafetyWorker,
new pair<boost::barrier*, ProteomeData*>(&testBarrier, &pd)));
109 testThreadGroup.join_all();
120 proteinListPtr->proteins.push_back(
ProteinPtr(
new Protein(
"ABC123", 0,
"One two three.",
"ELVISLIVES")));
121 proteinListPtr->proteins.push_back(
ProteinPtr(
new Protein(
"ZEBRA", 1,
"Has stripes:",
"BLACKANDWHITE")));
122 proteinListPtr->proteins.push_back(
ProteinPtr(
new Protein(
"DEFCON42", 2,
"",
"DNTPANIC")));
123 proteinListPtr->proteins.push_back(
ProteinPtr(
new Protein(
"ZEBRA", 1,
"Black and white",
"STRIPES")));
128 serializer.
write(oss, pd, NULL);
130 if (
os_) *
os_ <<
"oss:\n" << oss.str() << endl;
132 shared_ptr<istringstream> iss(
new istringstream(oss.str()));
136 "[ProteinList_FASTA::createIndex] duplicate protein id \"ZEBRA\"");
140 int main(
int argc,
char* argv[])
146 if (argc>1 && !strcmp(argv[1],
"-v"))
os_ = &cout;
void write(std::ostream &os, const ProteomeData &pd, const pwiz::util::IterationListenerRegistry *iterationListenerRegistry) const
write ProteomeData object to ostream as FASTA
#define unit_assert_throws_what(x, exception, whatStr)
int main(int argc, char *argv[])
void testThreadSafetyWorker(pair< boost::barrier *, ProteomeData *> *args)
Calculate diffs of objects in a ProteoWizard data model hierarchy.
void testWriteRead(const Serializer_FASTA::Config &config)
void diff(const string &filename1, const string &filename2)
index implementation in a stream (intended for fstreams but any iostream works); find(string id) is O...
Serializer_FASTA configuration.
void testThreadSafety(const int &testThreadCount)
void read(boost::shared_ptr< std::istream > is, ProteomeData &pd) const
read in ProteomeData object from a FASTA istream
ProteinListPtr proteinListPtr
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
#define TEST_PROLOG(argc, argv)
boost::shared_ptr< Protein > ProteinPtr
ProteomeData <-> FASTA stream serialization.