Commit f1bdd9e0 authored by Zhou, Wenduo's avatar Zhou, Wenduo
Browse files

Add more unit tests. Refs #6746.

parent aa9baa39
......@@ -229,9 +229,15 @@ namespace Mantid
if (obsI.size() != calI.size() || obsI.size() != obsE.size())
{
std::stringstream errss;
errss << "GetRFactor() Input Error! Observed Intensity, Calculated Intensity and Observed Error have different number of elements.";
errss << "GetRFactor() Input Error! Observed Intensity (" << obsI.size()
<< "), Calculated Intensity (" << calI.size() << ") and Observed Error ("
<< obsE.size() << ") have different number of elements.";
throw std::runtime_error(errss.str());
}
if (obsI.size() == 0)
{
throw std::runtime_error("getRFactor(): the input arrays are empty.");
}
double sumnom = 0;
double sumdenom = 0;
......
......@@ -143,8 +143,45 @@ public:
double rwp = getRFactor(obsY, calY, obsE);
TS_ASSERT_DELTA(rwp, 0.1582, 0.0001);
}
/** Test throw exception
*/
void testRwpException1()
{
vector<double> obsY(4);
vector<double> calY(4);
vector<double> obsE(3);
obsY[0] = 1.0;
calY[0] = 1.1;
obsE[0] = 1.0;
obsY[1] = 2.0;
calY[1] = 2.1;
obsE[1] = 1.2;
obsY[2] = 3.0;
calY[2] = 3.5;
obsE[2] = 1.4;
obsY[3] = 1.0;
calY[3] = 1.3;
TS_ASSERT_THROWS_ANYTHING(getRFactor(obsY, calY, obsE));
}
/** Test throw exception on empty array
*/
void testRwpException2()
{
vector<double> obsY;
vector<double> calY;
vector<double> obsE;
TS_ASSERT_THROWS_ANYTHING(getRFactor(obsY, calY, obsE));
}
};
#endif // STATISTICSTEST_H_
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment