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 {
"CH2N3O4S5", 1, 2, 3, 4, 5, 0, 0, 0, 0, 279.864884, 280.36928 },
63 {
"H2N3O4S5C", 1, 2, 3, 4, 5, 0, 0, 0, 0, 279.864884, 280.36928 },
64 {
"C H2N3O4S5", 1, 2, 3, 4, 5, 0, 0, 0, 0, 279.864884, 280.36928 },
65 {
"H2N3O4S5C ", 1, 2, 3, 4, 5, 0, 0, 0, 0, 279.864884, 280.36928 },
66 {
"H2N3O4S5 C ", 1, 2, 3, 4, 5, 0, 0, 0, 0, 279.864884, 280.36928 },
67 {
"C1H 2N3O4 S5", 1, 2, 3, 4, 5, 0, 0, 0, 0, 279.864884, 280.36928 },
68 {
"H-42", 0, -42, 0, 0, 0, 0, 0, 0, 0, -42.328651, -42.333512 },
69 {
"N2C-1", -1, 0, 2, 0, 0, 0, 0, 0, 0, 28.006148 - 12, 28.013486 - 12.0107 },
70 {
"C39H67N11O10", 39, 67, 11, 10, 0, 0, 0, 0, 0, 849.507238, 850.01698 },
71 {
"C3H7N1O2Se1", 3, 7, 1, 2, 0, 0, 0, 0, 0, 168.9642, 168.0532 },
72 {
"_13C1_2H2_15N3_18O4", 0, 0, 0, 0, 0, 1, 2, 3, 4, 134.0285, 134.0285 },
73 {
"_13C1D2_15N3_18O4", 0, 0, 0, 0, 0, 1, 2, 3, 4, 134.0285, 134.0285 },
74 {
"_13C1_3H2_15N3_18O4", 0, 0, 0, 0, 0, 1, 2, 3, 4, 136.0324, 136.0324 },
75 {
"_13C_3H2_15N3_18O4", 0, 0, 0, 0, 0, 1, 2, 3, 4, 136.0324, 136.0324 },
76 {
"_3H2_15N3_18O4_13C", 0, 0, 0, 0, 0, 1, 2, 3, 4, 136.0324, 136.0324 },
77 {
"_13C1T2_15N3_18O4", 0, 0, 0, 0, 0, 1, 2, 3, 4, 136.0324, 136.0324 },
78 {
"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 },
79 {
"C-1_13C1_2H2H-2N-3_15N3_18O4O-4", -1, -2, -3, -4, 0, 1, 2, 3, 4, 14.024, 13.984 },
91 const double EPSILON = 0.001;
108 if (
os_) *
os_ <<
"formula: " << formula << endl;
109 if (
os_) *
os_ <<
"formula2: " << formula2 << endl;
115 if (
os_) *
os_ <<
"formula: " << formula << endl;
116 if (
os_) *
os_ <<
"formula2: " << formula2 << endl;
136 for (Formula::Map::iterator it=data.begin(), end=data.end(); it!=end; ++it)
137 *
os_ << it->first << it->second <<
" ";
146 using namespace Element;
163 if (
os_) *
os_ <<
"water: " << a-water << endl;
185 "[chemistry::text2enum()] Error translating symbol foo");
201 Formula formula(
"Si6C12H36O6");
205 *
os_ <<
"polysiloxane:\n"
231 cerr <<
"Exception in worker thread: " << e.what() << endl;
235 cerr <<
"Unhandled exception in worker thread." << endl;
242 boost::barrier testBarrier(testThreadCount);
243 boost::thread_group testThreadGroup;
244 vector<int> results(testThreadCount, 0);
245 for (
int i=0; i < testThreadCount; ++i)
246 testThreadGroup.add_thread(
new boost::thread(&
testThreadSafetyWorker, &testBarrier, boost::ref(results[i])));
247 testThreadGroup.join_all();
249 int failedThreads = std::accumulate(results.begin(), results.end(), 0);
250 if (failedThreads > 0)
251 throw runtime_error(lexical_cast<string>(failedThreads) +
" thread failed");
255 int main(
int argc,
char* argv[])
259 if (argc>1 && !strcmp(argv[1],
"-v"))
os_ = &cout;
260 if (
os_) *
os_ <<
"ChemistryTest\n" << setprecision(12);