Skip to content
Snippets Groups Projects
Commit cf751ea5 authored by Gemma Guest's avatar Gemma Guest
Browse files

Re #18215 Remove duplication

parent 6c9e8126
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,22 @@ private: ...@@ -35,6 +35,22 @@ private:
algo.setProperty("LRef", lref); algo.setProperty("LRef", lref);
} }
// Run the algorithm and do some basic checks. Returns the output workspace.
MatrixWorkspace_const_sptr runAlgorithm(UnwrapMonitor &algo,
const MatrixWorkspace_sptr inWS) {
// run the algorithm
TS_ASSERT(algo.execute());
TS_ASSERT(algo.isExecuted());
// verify the output workspace
const MatrixWorkspace_const_sptr outWS =
algo.getProperty("OutputWorkspace");
TS_ASSERT_EQUALS(inWS->getNumberHistograms(),
outWS->getNumberHistograms()); // shouldn't drop histograms
return outWS;
}
public: public:
// This pair of boilerplate methods prevent the suite being created statically // This pair of boilerplate methods prevent the suite being created statically
// This means the constructor isn't called when running other tests // This means the constructor isn't called when running other tests
...@@ -42,28 +58,18 @@ public: ...@@ -42,28 +58,18 @@ public:
static void destroySuite(UnwrapMonitorTest *suite) { delete suite; } static void destroySuite(UnwrapMonitorTest *suite) { delete suite; }
void testLrefLessThanLd() { void testLrefLessThanLd() {
// setup // setup and run the algorithm (includes basic checks)
MatrixWorkspace_sptr inWS = this->makeFakeWorkspace(); MatrixWorkspace_sptr inWS = this->makeFakeWorkspace();
UnwrapMonitor algo; UnwrapMonitor algo;
setupAlgorithm(algo, inWS, 11.0); setupAlgorithm(algo, inWS, 11.0);
MatrixWorkspace_const_sptr outWS = runAlgorithm(algo, inWS);
// run the algorithm // specific checks
TS_ASSERT(algo.execute());
TS_ASSERT(algo.isExecuted());
// verify the output workspace
const MatrixWorkspace_const_sptr outWS =
algo.getProperty("OutputWorkspace");
TS_ASSERT_EQUALS(inWS->getNumberHistograms(),
outWS->getNumberHistograms()); // shouldn't drop histograms
// Check some x values
const Mantid::MantidVec outX = outWS->readX(0); const Mantid::MantidVec outX = outWS->readX(0);
TS_ASSERT_EQUALS(outX.size(), 23); TS_ASSERT_EQUALS(outX.size(), 23);
TS_ASSERT_DELTA(outX.front(), 0.0, 1e-6); TS_ASSERT_DELTA(outX.front(), 0.0, 1e-6);
TS_ASSERT_DELTA(outX.back(), 0.017982, 1e-6); TS_ASSERT_DELTA(outX.back(), 0.017982, 1e-6);
// Check some y values
const Mantid::MantidVec outY = outWS->readY(0); const Mantid::MantidVec outY = outWS->readY(0);
TS_ASSERT_EQUALS(outY.size(), 22); TS_ASSERT_EQUALS(outY.size(), 22);
TS_ASSERT_DELTA(outY[3], 0.0, 1e-6); TS_ASSERT_DELTA(outY[3], 0.0, 1e-6);
...@@ -77,21 +83,13 @@ public: ...@@ -77,21 +83,13 @@ public:
} }
void testLrefGreaterThanLd() { void testLrefGreaterThanLd() {
// setup // setup and run the algorithm (includes basic checks)
const MatrixWorkspace_sptr inWS = this->makeFakeWorkspace(); const MatrixWorkspace_sptr inWS = this->makeFakeWorkspace();
UnwrapMonitor algo; UnwrapMonitor algo;
setupAlgorithm(algo, inWS, 17.0); setupAlgorithm(algo, inWS, 17.0);
const MatrixWorkspace_const_sptr outWS = runAlgorithm(algo, inWS);
// run the algorithm // specific checks
TS_ASSERT(algo.execute());
TS_ASSERT(algo.isExecuted());
// verify the output workspace
const MatrixWorkspace_const_sptr outWS =
algo.getProperty("OutputWorkspace");
TS_ASSERT_EQUALS(inWS->getNumberHistograms(),
outWS->getNumberHistograms()); // shouldn't drop histograms
const Mantid::MantidVec outY = outWS->readY(0); const Mantid::MantidVec outY = outWS->readY(0);
TS_ASSERT_EQUALS(outY.size(), 44); TS_ASSERT_EQUALS(outY.size(), 44);
...@@ -100,21 +98,13 @@ public: ...@@ -100,21 +98,13 @@ public:
} }
void testLrefEqualsLd() { void testLrefEqualsLd() {
// setup // setup and run the algorithm (includes basic checks)
const MatrixWorkspace_sptr inWS = this->makeFakeWorkspace(); const MatrixWorkspace_sptr inWS = this->makeFakeWorkspace();
UnwrapMonitor algo; UnwrapMonitor algo;
setupAlgorithm(algo, inWS, 15.0); setupAlgorithm(algo, inWS, 15.0);
const MatrixWorkspace_const_sptr outWS = runAlgorithm(algo, inWS);
// run the algorithm // specific checks
TS_ASSERT(algo.execute());
TS_ASSERT(algo.isExecuted());
// verify the output workspace
const MatrixWorkspace_const_sptr outWS =
algo.getProperty("OutputWorkspace");
TS_ASSERT_EQUALS(inWS->getNumberHistograms(),
outWS->getNumberHistograms()); // shouldn't drop histograms
const Mantid::MantidVec outY = outWS->readY(0); const Mantid::MantidVec outY = outWS->readY(0);
TS_ASSERT_EQUALS(outY.size(), 49); TS_ASSERT_EQUALS(outY.size(), 49);
...@@ -123,21 +113,13 @@ public: ...@@ -123,21 +113,13 @@ public:
} }
void testMinPossibleLref() { void testMinPossibleLref() {
// setup // setup and run the algorithm (includes basic checks)
const MatrixWorkspace_sptr inWS = this->makeFakeWorkspace(); const MatrixWorkspace_sptr inWS = this->makeFakeWorkspace();
UnwrapMonitor algo; UnwrapMonitor algo;
setupAlgorithm(algo, inWS, 0.01); setupAlgorithm(algo, inWS, 0.01);
const MatrixWorkspace_const_sptr outWS = runAlgorithm(algo, inWS);
// run the algorithm // specific checks
TS_ASSERT(algo.execute());
TS_ASSERT(algo.isExecuted());
// verify the output workspace
const MatrixWorkspace_const_sptr outWS =
algo.getProperty("OutputWorkspace");
TS_ASSERT_EQUALS(inWS->getNumberHistograms(),
outWS->getNumberHistograms()); // shouldn't drop histograms
const Mantid::MantidVec outY = outWS->readY(0); const Mantid::MantidVec outY = outWS->readY(0);
TS_ASSERT_EQUALS(outY.size(), 50); TS_ASSERT_EQUALS(outY.size(), 50);
TS_ASSERT_DELTA(outY[0], 100.0, 1e-6); TS_ASSERT_DELTA(outY[0], 100.0, 1e-6);
...@@ -148,21 +130,13 @@ public: ...@@ -148,21 +130,13 @@ public:
} }
void testLargeLref() { void testLargeLref() {
// setup // setup and run the algorithm (includes basic checks)
const MatrixWorkspace_sptr inWS = this->makeFakeWorkspace(); const MatrixWorkspace_sptr inWS = this->makeFakeWorkspace();
UnwrapMonitor algo; UnwrapMonitor algo;
setupAlgorithm(algo, inWS, 100.0); setupAlgorithm(algo, inWS, 100.0);
const MatrixWorkspace_const_sptr outWS = runAlgorithm(algo, inWS);
// run the algorithm // specific checks
TS_ASSERT(algo.execute());
TS_ASSERT(algo.isExecuted());
// verify the output workspace
const MatrixWorkspace_const_sptr outWS =
algo.getProperty("OutputWorkspace");
TS_ASSERT_EQUALS(inWS->getNumberHistograms(),
outWS->getNumberHistograms()); // shouldn't drop histograms
const Mantid::MantidVec outY = outWS->readY(0); const Mantid::MantidVec outY = outWS->readY(0);
TS_ASSERT_EQUALS(outY.size(), 10); TS_ASSERT_EQUALS(outY.size(), 10);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment