30 #include "boost/thread/thread.hpp" 31 #include "boost/thread/barrier.hpp" 54 int numC, numH, numN, numO,
numS, num13C, num2H, num15N, num18O;
61 {
"C1H2N3O4S5", 1, 2, 3, 4, 5, 0, 0, 0, 0, 279.864884, 280.36928 },
62 {
"C1H 2N3O4 S5", 1, 2, 3, 4, 5, 0, 0, 0, 0, 279.864884, 280.36928 },
63 {
"H-42", 0, -42, 0, 0, 0, 0, 0, 0, 0, -42.328651, -42.333512 },
64 {
"N2C-1", -1, 0, 2, 0, 0, 0, 0, 0, 0, 28.006148 - 12, 28.013486 - 12.0107 },
65 {
"C39H67N11O10", 39, 67, 11, 10, 0, 0, 0, 0, 0, 849.507238, 850.01698 },
66 {
"C3H7N1O2Se1", 3, 7, 1, 2, 0, 0, 0, 0, 0, 168.9642, 168.0532 },
67 {
"_13C1_2H2_15N3_18O4", 0, 0, 0, 0, 0, 1, 2, 3, 4, 134.0285, 134.0285 },
68 {
"C-1 _13C1 _2H2 H-2 N-3 _15N3 _18O4 O-4", -1, -2, -3, -4, 0, 1, 2, 3, 4, 14.024, 13.984 },
69 {
"C-1_13C1_2H2H-2N-3_15N3_18O4O-4", -1, -2, -3, -4, 0, 1, 2, 3, 4, 14.024, 13.984 },
81 const double EPSILON = 0.001;
88 if (
os_) *
os_ << formula <<
" " << formula.monoisotopicMass() <<
" " << formula.molecularWeight() << endl;
98 if (
os_) *
os_ <<
"formula: " << formula << endl;
99 if (
os_) *
os_ <<
"formula2: " << formula2 << endl;
105 if (
os_) *
os_ <<
"formula: " << formula << endl;
106 if (
os_) *
os_ <<
"formula2: " << formula2 << endl;
107 unit_assert_equal(formula.monoisotopicMass(), formula2.monoisotopicMass(), EPSILON);
126 for (Formula::Map::iterator it=data.begin(), end=data.end(); it!=end; ++it)
127 *
os_ << it->first << it->second <<
" ";
136 using namespace Element;
153 if (
os_) *
os_ <<
"water: " << a-water << endl;
175 "[chemistry::text2enum()] Error translating symbol foo");
191 Formula formula(
"Si6C12H36O6");
195 *
os_ <<
"polysiloxane:\n" 221 cerr <<
"Exception in worker thread: " << e.what() << endl;
225 cerr <<
"Unhandled exception in worker thread." << endl;
232 boost::barrier testBarrier(testThreadCount);
233 boost::thread_group testThreadGroup;
234 vector<int> results(testThreadCount, 0);
235 for (
int i=0; i < testThreadCount; ++i)
236 testThreadGroup.add_thread(
new boost::thread(&
testThreadSafetyWorker, &testBarrier, boost::ref(results[i])));
237 testThreadGroup.join_all();
239 int failedThreads = std::accumulate(results.begin(), results.end(), 0);
240 if (failedThreads > 0)
241 throw runtime_error(lexical_cast<string>(failedThreads) +
" thread failed");
245 int main(
int argc,
char* argv[])
249 if (argc>1 && !strcmp(argv[1],
"-v"))
os_ = &cout;
250 if (
os_) *
os_ <<
"ChemistryTest\n" << setprecision(12);
#define unit_assert_throws_what(x, exception, whatStr)
const TestFormula testFormulaData[]
PWIZ_API_DECL const Record & record(Type type)
returns the amino acid's Record by type
void testFormulaOperations()
#define unit_assert_equal(x, y, epsilon)
const int testFormulaDataSize
void testThreadSafetyWorker(boost::barrier *testBarrier, int &result)
int main(int argc, char *argv[])
double mz(double neutralMass, int protonDelta, int electronDelta=0, int neutronDelta=0)
void testThreadSafety(const int &testThreadCount)
#define TEST_PROLOG(argc, argv)
pwiz::chemistry::Element::Type Type
struct for holding isotope information