// returns the number of comparisons completed, throws on failure. Size Tester::compareResults(const ResultSet& leftResultSet, const ResultSet& rightResultSet, const boost::property_tree::ptree& pt) // will throw on failure { Size comparisonsDone = 0; writeDiagnostics("Comparing results with: \nleft result:\n" + toString(leftResultSet) + "right result:\n" + toString(rightResultSet) + "and property tree:\n" + toString(pt), high, "Tester::compareResults"); boost::property_tree::ptree::const_iterator iter = pt.begin(); while(iter != pt.end()) { if(iter->first == "comparison") { std::string categoryStr = pt_get<std::string>(iter->second, "category"); ResultCategory category = stringToResultCategory(categoryStr); Real leftVal = leftResultSet.getValue(category); std::string comparison = pt_get<std::string>(iter->second, "comparison_type"); Real tol = pt_get<Real> (iter->second, "tolerance"); std::string rightSource = pt_get<std::string>(iter->second, "right_source"); Real rightVal; if(rightSource == "right_leg") rightVal = rightResultSet.getValue(category); else if( rightSource == "constant") rightVal = pt_get<Real>(iter->second, "constant"); else QL_FAIL("'right_source' must be either 'right_leg' or 'constant'. Here it is: " << rightSource); std::string msg = m_currentTestID + "\ncategory: " + categoryStr; // used when exception is thrown doComparison(leftVal, rightVal, comparison, tol, msg); // throws on failure comparisonsDone++; } iter++; } // when there are no comparisons done, i.e. comparisonsDone == 0, // there may have been a problem readin the xml // so we will use a diagnostic level of 'low' // making it more likely the message will be shown to the user. writeDiagnostics("For test: " + m_currentTestID + ",\nthe number of comparisons done was: " + toString(comparisonsDone)+ "\n", comparisonsDone > 0 ? high : low, "Tester::compareResults"); return comparisonsDone; }