Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #9009. For starters - need a test suite.
No test coverage for existing functionality. This is required first.
- Loading branch information
1 parent
840415e
commit 028b22a
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
Code/Mantid/Framework/Algorithms/test/ConvertMDHistoToMatrixWorkspaceTest.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* ConvertMDHistoToMatrixWorkspaceTest.h | ||
* | ||
* Created on: Feb 13, 2014 | ||
* Author: spu92482 | ||
*/ | ||
|
||
#ifndef CONVERTMDHISTOTOMATRIXWORKSPACETEST_H_ | ||
#define CONVERTMDHISTOTOMATRIXWORKSPACETEST_H_ | ||
|
||
#include <cxxtest/TestSuite.h> | ||
#include "MantidAlgorithms/ConvertMDHistoToMatrixWorkspace.h" | ||
#include "MantidMDEvents/MDHistoWorkspace.h" | ||
#include "MantidTestHelpers/MDEventsTestHelper.h" | ||
#include "MantidTestHelpers/WorkspaceCreationHelper.h" | ||
|
||
using namespace Mantid; | ||
using namespace Mantid::API; | ||
using namespace Mantid::Kernel; | ||
using namespace Mantid::Algorithms; | ||
using namespace Mantid::MDEvents; | ||
|
||
class ConvertMDHistoToMatrixWorkspaceTest : public CxxTest::TestSuite | ||
{ | ||
public: | ||
|
||
MatrixWorkspace_sptr do_execute(const size_t n_dims, const double signal, const double error_sq, size_t* nbins, coord_t* min, coord_t* max) | ||
{ | ||
IMDHistoWorkspace_sptr inWS = MDEventsTestHelper::makeFakeMDHistoWorkspaceGeneral(n_dims, signal, | ||
error_sq, nbins, min, max); | ||
|
||
ConvertMDHistoToMatrixWorkspace alg; | ||
alg.setChild(true); | ||
alg.setRethrows(true); | ||
alg.initialize(); | ||
alg.setProperty("InputWorkspace", inWS); | ||
alg.setPropertyValue("OutputWorkspace", "_"); | ||
|
||
alg.execute(); | ||
MatrixWorkspace_sptr outWS = alg.getProperty("OutputWorkspace"); | ||
return outWS; | ||
} | ||
|
||
void test_input_workspace_must_be_imdhisto() | ||
{ | ||
MatrixWorkspace_sptr ws = WorkspaceCreationHelper::Create1DWorkspaceConstant(1,1,0); | ||
ConvertMDHistoToMatrixWorkspace alg; | ||
alg.setRethrows(true); | ||
alg.initialize(); | ||
TS_ASSERT_THROWS(alg.setProperty("InputWorkspace", ws), std::invalid_argument&) ; | ||
} | ||
|
||
void test_conversion() | ||
{ | ||
const size_t n_dims = 1; | ||
const double signal = 1; | ||
const double error_sq = 0; | ||
size_t nbins[1] = {1}; | ||
coord_t min[1] = {-1}; | ||
coord_t max[1] = {1}; | ||
|
||
MatrixWorkspace_sptr outWS = do_execute(n_dims, signal, error_sq, nbins, min, max); | ||
} | ||
|
||
}; | ||
|
||
|
||
#endif /* CONVERTMDHISTOTOMATRIXWORKSPACETEST_H_ */ |