Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef LOADMCSTASTEST_H_
#define LOADMCSTASTEST_H_
#include <fstream>
#include <cxxtest/TestSuite.h>
#include "MantidAPI/FrameworkManager.h"
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidDataHandling/LoadBBY.h"
#include "MantidDataObjects/WorkspaceSingleValue.h"
#include "MantidDataHandling/LoadInstrument.h"
#include <Poco/Path.h>
#include <Poco/TemporaryFile.h>
using namespace Mantid::API;
using namespace Mantid::Kernel;
using namespace Mantid::DataHandling;
using namespace Mantid::DataObjects;
class LoadBBYTest : public CxxTest::TestSuite
{
public:
void testInit()
{
TS_ASSERT_THROWS_NOTHING(algToBeTested.initialize());
TS_ASSERT( algToBeTested.isInitialized() );
}
// test loading of bilby dataset
void testExec()
{
if ( !algToBeTested.isInitialized() ) algToBeTested.initialize();
outputSpace="LoadBBYTest";
algToBeTested.setPropertyValue("OutputWorkspace", outputSpace);
// Should fail because mandatory parameter has not been set
TS_ASSERT_THROWS(algToBeTested.execute(),std::runtime_error);
inputFile = "Bilby_EOS.bin";
algToBeTested.setPropertyValue("Filename", inputFile);
TS_ASSERT_THROWS_NOTHING(algToBeTested.execute());
TS_ASSERT( algToBeTested.isExecuted() );
// get workspace generated
MatrixWorkspace_sptr output = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(outputSpace);
// test it is as expected
TS_ASSERT_EQUALS( output->getNumberHistograms(), 61440);
double sum = 0.0;
for (size_t i = 0; i < output->getNumberHistograms(); i++)
sum += output->readY(i)[0];
sum *= 1.0e22;
TS_ASSERT_DELTA(sum / 1.0E27,0.9639,0.0001);
}
private:
LoadBBY algToBeTested;
std::string inputFile;
std::string outputSpace;
};
#endif /*LoadBBYTEST_H_*/