Skip to content

Commit

Permalink
Fixed some errors in unit tests. Refs #9358.
Browse files Browse the repository at this point in the history
  • Loading branch information
wdzhou committed May 28, 2014
1 parent 8527250 commit fb76197
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
8 changes: 7 additions & 1 deletion Code/Mantid/Framework/Algorithms/src/GeneratePeaks.cpp
Expand Up @@ -251,6 +251,7 @@ namespace Algorithms
{
// Function parameters
std::string paramwsname = getPropertyValue("PeakParametersWorkspace");
g_log.notice() << "[DB]" << " Input parameter workpace name: " << paramwsname << ".\n";
if (paramwsname.size() > 0)
{
// Using parameter table workspace has a higher priority
Expand Down Expand Up @@ -426,7 +427,12 @@ namespace Algorithms
// Set up and clone peak function
size_t numpeakparams = m_peakFunction->nParams();
if (m_vecPeakParamValues.size() != numpeakparams)
throw std::runtime_error("Number of peak parameters' value is not correct. ");
{
std::stringstream errss;
errss << "Number of input peak parameters' value (" << numpeakparams << ") is not correct (should be "
<< m_vecPeakParamValues.size() << " for peak of type " << m_peakFunction->name() << "). ";
throw std::runtime_error(errss.str());
}
else
{
for (size_t i = 0; i < numpeakparams; ++i)
Expand Down
17 changes: 10 additions & 7 deletions Code/Mantid/Framework/Algorithms/test/GeneratePeaksTest.h
Expand Up @@ -37,7 +37,7 @@ class GeneratePeaksTest : public CxxTest::TestSuite
FrameworkManager::Instance();
}

void Ptest_Init()
void test_Init()
{
GeneratePeaks alg;
TS_ASSERT_THROWS_NOTHING(alg.initialize());
Expand All @@ -63,6 +63,7 @@ class GeneratePeaksTest : public CxxTest::TestSuite
{
// Create input parameter table workspace
DataObjects::TableWorkspace_sptr peakparmsws = createTestPeakParameters();
AnalysisDataService::Instance().addOrReplace("TestPeakParameterTable", peakparmsws);

// Initialize algorithm GenertePeaks
GeneratePeaks alg;
Expand Down Expand Up @@ -124,10 +125,11 @@ class GeneratePeaksTest : public CxxTest::TestSuite
//----------------------------------------------------------------------------------------------
/** Test algorithm by using an existing input workspace as X-values
*/
void Xtest_FromInputWorkspace()
void test_FromInputWorkspace()
{
// Create input
DataObjects::TableWorkspace_sptr peakparmsws = createTestPeakParameters2();
AnalysisDataService::Instance().addOrReplace("TestParameterTable2", peakparmsws);
API::MatrixWorkspace_sptr inputws = createTestInputWorkspace();

// Initialize algorithm class
Expand All @@ -136,8 +138,8 @@ class GeneratePeaksTest : public CxxTest::TestSuite

// Set value
TS_ASSERT_THROWS_NOTHING(alg.setProperty("PeakParametersWorkspace", peakparmsws));
TS_ASSERT_THROWS_NOTHING(alg.setProperty("PeakFunction", "Gaussian"));
TS_ASSERT_THROWS_NOTHING(alg.setProperty("BackgroundFunction", "Quadratic"));
TS_ASSERT_THROWS_NOTHING(alg.setProperty("PeakType", "Gaussian"));
TS_ASSERT_THROWS_NOTHING(alg.setProperty("BackgroundType", "Quadratic"));
TS_ASSERT_THROWS_NOTHING(alg.setProperty("InputWorkspace", inputws));
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("BinningParameters", "0.0, 0.01, 10.0"));
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", "Test02WS"));
Expand Down Expand Up @@ -189,18 +191,19 @@ class GeneratePeaksTest : public CxxTest::TestSuite
//----------------------------------------------------------------------------------------------
/** Test to use user-provided binning parameters
*/
void Xtest_Background()
void test_Background()
{
// 1. Create input
DataObjects::TableWorkspace_sptr peakparmsws = createTestPeakParameters3();
AnalysisDataService::Instance().addOrReplace("TestParameterTable3", peakparmsws);

GeneratePeaks alg;
alg.initialize();

// 3. Set value
TS_ASSERT_THROWS_NOTHING(alg.setProperty("PeakParametersWorkspace", peakparmsws));
TS_ASSERT_THROWS_NOTHING(alg.setProperty("PeakFunction", "Gaussian"));
TS_ASSERT_THROWS_NOTHING(alg.setProperty("BackgroundFunction", "Auto"));
TS_ASSERT_THROWS_NOTHING(alg.setProperty("PeakType", "Gaussian"));
TS_ASSERT_THROWS_NOTHING(alg.setProperty("BackgroundType", "Auto"));
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("BinningParameters", "0.0, 0.01, 10.0"));
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", "Test01WS"));
TS_ASSERT_THROWS_NOTHING(alg.setProperty("GenerateBackground", true));
Expand Down

0 comments on commit fb76197

Please sign in to comment.