diff --git a/Framework/Algorithms/test/CropToComponentTest.h b/Framework/Algorithms/test/CropToComponentTest.h index 94602eee74ae3fb4ae1f96c159e3a566c6b56a95..41e9d29f21beab2d8c7f0996522e5cb5d6343fb7 100644 --- a/Framework/Algorithms/test/CropToComponentTest.h +++ b/Framework/Algorithms/test/CropToComponentTest.h @@ -5,6 +5,7 @@ #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/SpectrumInfo.h" +#include "MantidAlgorithms/CreateSampleWorkspace.h" #include "MantidAlgorithms/CropToComponent.h" #include "MantidDataHandling/LoadRaw3.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" @@ -201,6 +202,34 @@ public: } } + void test_scanning_workspace() { + + // Create a sample scanning workspace + Mantid::Algorithms::CreateSampleWorkspace creator; + creator.setChild(true); + creator.initialize(); + creator.setProperty("NumBanks", 2); + creator.setProperty("NumScanPoints", 5); + creator.setProperty("OutputWorkspace", "__unused_for_child"); + creator.execute(); + Mantid::API::MatrixWorkspace_sptr workspace = + creator.getProperty("OutputWorkspace"); + + // Act + Mantid::Algorithms::CropToComponent crop; + crop.setChild(true); + crop.initialize(); + crop.setRethrows(true); + crop.setProperty("InputWorkspace", workspace); + crop.setProperty("OutputWorkspace", "__cropped"); + crop.setProperty("ComponentNames", "bank1"); + TS_ASSERT_THROWS_NOTHING(crop.execute()) + TS_ASSERT(crop.isExecuted()) + Mantid::API::MatrixWorkspace_sptr cropped = + crop.getProperty("OutputWorkspace"); + TS_ASSERT(cropped) + } + private: Mantid::API::MatrixWorkspace_sptr getSampleWorkspace(int numberOfBanks, int numbersOfPixelPerBank) { diff --git a/Framework/Indexing/test/IndexInfoTest.h b/Framework/Indexing/test/IndexInfoTest.h index 5725246bdf0dec4f5487b2bb81b271ccfe386785..23b0a5ee44d5d659967636072b516e0b67bcb44c 100644 --- a/Framework/Indexing/test/IndexInfoTest.h +++ b/Framework/Indexing/test/IndexInfoTest.h @@ -333,17 +333,25 @@ public: "Some of the requested detectors do not have a corresponding spectrum"); } - void test_globalSpectrumIndicesFromDetectorIndices_scanning() { + void + test_globalSpectrumIndicesFromDetectorIndices_scanning_different_time_indices() { IndexInfo info(3); std::vector<size_t> detectorIndices{6, 8}; std::vector<SpectrumDefinition> specDefs(3); - // Two indices map to same detector; typical for time-indexed workspaces. - specDefs[0].add(6); - specDefs[1].add(6); - specDefs[2].add(8); + // Two indices map to the same detector at different time indices; typical + // for time-indexed workspaces. + specDefs[0].add(6, 1); + specDefs[1].add(6, 2); + specDefs[2].add(8, 1); info.setSpectrumDefinitions(specDefs); TS_ASSERT_THROWS_NOTHING( info.globalSpectrumIndicesFromDetectorIndices(detectorIndices)); + const auto &indices = + info.globalSpectrumIndicesFromDetectorIndices(detectorIndices); + TS_ASSERT_EQUALS(indices.size(), 3); + TS_ASSERT_EQUALS(indices[0], 0); + TS_ASSERT_EQUALS(indices[1], 1); + TS_ASSERT_EQUALS(indices[2], 2); } void test_globalSpectrumIndicesFromDetectorIndices_fails_conflict_miss() { @@ -351,8 +359,8 @@ public: std::vector<size_t> detectorIndices{6, 8}; std::vector<SpectrumDefinition> specDefs(3); // Two indices map to same detector, but additionally one is missing. - specDefs[0].add(6); - specDefs[1].add(6); + specDefs[0].add(6, 1); + specDefs[1].add(6, 2); info.setSpectrumDefinitions(specDefs); TS_ASSERT_THROWS_EQUALS( info.globalSpectrumIndicesFromDetectorIndices(detectorIndices),