diff --git a/Framework/Crystal/test/SortPeaksWorkspaceTest.h b/Framework/Crystal/test/SortPeaksWorkspaceTest.h index 9bf9820de16e99cb0dca58a03fdf0fafa3c47864..d889eff22256dad0058cd005f259dbccb19d064c 100644 --- a/Framework/Crystal/test/SortPeaksWorkspaceTest.h +++ b/Framework/Crystal/test/SortPeaksWorkspaceTest.h @@ -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); + } };