Skip to content
Snippets Groups Projects
Commit d5bf805e authored by Zhang, Chen's avatar Zhang, Chen
Browse files

add new unit test for sort LeanElasticPWS

parent 7dd4e753
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@
#include "MantidAPI/TableRow.h"
#include "MantidCrystal/SortPeaksWorkspace.h"
#include "MantidDataObjects/LeanElasticPeaksWorkspace.h"
#include "MantidDataObjects/PeaksWorkspace.h"
#include "MantidTestHelpers/WorkspaceCreationHelper.h"
#include <algorithm>
......@@ -209,4 +210,34 @@ public:
"workspaces should be the same.",
outWS, inWS);
}
void test_leanPeakWorkspace_sort_inplace() {
// generate a lean elastic peak workspace with two peaks
auto lpws = std::make_shared<LeanElasticPeaksWorkspace>();
// add peaks
LeanElasticPeak pk1(Mantid::Kernel::V3D(0.0, 0.0, 6.28319), 2.0);
LeanElasticPeak pk2(Mantid::Kernel::V3D(6.28319, 0.0, 6.28319), 1.0);
lpws->addPeak(pk1);
lpws->addPeak(pk2);
IPeaksWorkspace_sptr inWS =
std::dynamic_pointer_cast<IPeaksWorkspace>(lpws);
SortPeaksWorkspace alg;
alg.setChild(true);
alg.setRethrows(true);
TS_ASSERT_THROWS_NOTHING(alg.initialize())
TS_ASSERT(alg.isInitialized())
TS_ASSERT_THROWS_NOTHING(alg.setProperty("InputWorkspace", inWS));
alg.setPropertyValue("OutputWorkspace", "OutName");
TS_ASSERT_THROWS_NOTHING(alg.setProperty("OutputWorkspace", inWS));
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("ColumnNameToSortBy", "h"));
TS_ASSERT_THROWS_NOTHING(alg.execute());
TS_ASSERT(alg.isExecuted());
IPeaksWorkspace_sptr outWS = alg.getProperty("OutputWorkspace");
TSM_ASSERT_EQUALS("Sorting should have happened in place. Output and input "
"workspaces should be the same.",
outWS, inWS);
}
};
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