Skip to content
Snippets Groups Projects
Commit f57191d8 authored by Verena Reimund's avatar Verena Reimund
Browse files

Initial tests for join & merge

Refs #23947
parent 7bf32a63
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,7 @@ class MANTID_ALGORITHMS_DLL SampleLogsBehaviour { ...@@ -23,6 +23,7 @@ class MANTID_ALGORITHMS_DLL SampleLogsBehaviour {
public: public:
enum class MergeLogType { Sum, TimeSeries, List, Warn, Fail }; enum class MergeLogType { Sum, TimeSeries, List, Warn, Fail };
// names of parameters in IPF
const std::string SUM_MERGE; const std::string SUM_MERGE;
const std::string TIME_SERIES_MERGE; const std::string TIME_SERIES_MERGE;
const std::string LIST_MERGE; const std::string LIST_MERGE;
......
...@@ -24,12 +24,18 @@ ...@@ -24,12 +24,18 @@
#include "MantidKernel/make_cow.h" #include "MantidKernel/make_cow.h"
#include "MantidTestHelpers/WorkspaceCreationHelper.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h"
#include "MantidDataHandling/LoadParameterFile.h"
#include "MantidGeometry/Instrument.h"
#include "MantidGeometry/Instrument/ParameterMap.h"
using Mantid::Algorithms::CreateSampleWorkspace; using Mantid::Algorithms::CreateSampleWorkspace;
using Mantid::Algorithms::GroupWorkspaces; using Mantid::Algorithms::GroupWorkspaces;
using Mantid::Algorithms::SampleLogsBehaviour; using Mantid::Algorithms::SampleLogsBehaviour;
using namespace Mantid::API; using namespace Mantid::API;
using namespace Mantid::DataHandling;
using namespace Mantid::DataObjects; using namespace Mantid::DataObjects;
using namespace Mantid::HistogramData; using namespace Mantid::HistogramData;
using namespace Mantid::Geometry;
using namespace Mantid::Kernel; using namespace Mantid::Kernel;
using namespace WorkspaceCreationHelper; using namespace WorkspaceCreationHelper;
...@@ -42,9 +48,65 @@ public: ...@@ -42,9 +48,65 @@ public:
} }
static void destroySuite(SampleLogsBehaviourTest *suite) { delete suite; } static void destroySuite(SampleLogsBehaviourTest *suite) { delete suite; }
// Please note that many tests are currently present in MergeRunsTest.
private: void testMergeRunsIPFNames() {
// Using default values of the constructor
Logger log("testLog");
MatrixWorkspace_sptr ws = create2DWorkspaceWithFullInstrument(
3, 3, true, false, true, "INSTRUMENT");
// Add sample logs
ws->mutableRun().addLogData(new PropertyWithValue<double>("A", 2.65));
ws->mutableRun().addLogData(new PropertyWithValue<double>("B", 1.56));
ws->mutableRun().addLogData(new PropertyWithValue<double>("C", 8.55));
// Load test parameter file
LoadParameterFile paramLoader;
paramLoader.initialize();
paramLoader.setPropertyValue(
"Filename", "IDFs_for_UNIT_TESTING/SampleLogsBehaviour_Parameters.xml");
paramLoader.setProperty("Workspace", ws);
paramLoader.execute();
SampleLogsBehaviour sbh = SampleLogsBehaviour(ws, log);
sbh.mergeSampleLogs(ws, ws);
const std::string A = ws->run().getLogData("A")->value();
const std::string B = ws->run().getLogData("B")->value();
const std::string C = ws->run().getLogData("C")->value();
TS_ASSERT_EQUALS(A, "2.6499999999999999")
TS_ASSERT_EQUALS(B, "1.5600000000000001")
TS_ASSERT_EQUALS(C, "8.5500000000000007")
}
void testConjoinXRunsIPFNames() {
// Using suffix conjoin_ + default value names for constructing
Logger log("testLog");
MatrixWorkspace_sptr ws = create2DWorkspaceWithFullInstrument(
3, 3, true, false, true, "INSTRUMENT");
// Add sample logs
ws->mutableRun().addLogData(new PropertyWithValue<double>("A", 2.65));
ws->mutableRun().addLogData(new PropertyWithValue<double>("B", 1.56));
ws->mutableRun().addLogData(new PropertyWithValue<double>("C", 8.55));
// Load test parameter file
LoadParameterFile paramLoader;
paramLoader.initialize();
paramLoader.setPropertyValue(
"Filename", "IDFs_for_UNIT_TESTING/SampleLogsBehaviour_Parameters.xml");
paramLoader.setProperty("Workspace", ws);
paramLoader.execute();
SampleLogsBehaviour sbh = SampleLogsBehaviour(
ws, log, "", "", "", "", "", "", "", "conjoin_sample_logs_sum",
"conjoin_sample_logs_time_series", "conjoin_sample_logs_list",
"conjoin_sample_logs_warn", "conjoin_sample_logs_warn_tolerances",
"conjoin_sample_logs_fail", "conjoin_sample_logs_fail_tolerances");
sbh.mergeSampleLogs(ws, ws);
const std::string A = ws->run().getLogData("A")->value();
const std::string B = ws->run().getLogData("B")->value();
const std::string C = ws->run().getLogData("C")->value();
TS_ASSERT_EQUALS(A, "2.6499999999999999")
TS_ASSERT_EQUALS(B, "1.5600000000000001")
TS_ASSERT_EQUALS(C, "8.5500000000000007")
}
private:
}; };
#endif /* MANTID_ALGORITHMS_SAMPLELOGSBEHAVIOURTEST_H_ */ #endif /* MANTID_ALGORITHMS_SAMPLELOGSBEHAVIOURTEST_H_ */
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