Skip to content

Commit

Permalink
Added loadbby unit test. re #9394
Browse files Browse the repository at this point in the history
And renamed property "Hdf Reference" to "HdfReference" to satisfy http://builds.mantidproject.org/job/develop_systemtests_rhel6/lastCompletedBuild/testReport/SystemTests/CodeConventions/Algorithms/
(tx to martyn for spotting this)
  • Loading branch information
Anders-Markvardsen committed Jun 24, 2014
1 parent 172575f commit 8f8a1eb
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 2 deletions.
1 change: 1 addition & 0 deletions Code/Mantid/Framework/DataHandling/CMakeLists.txt
Expand Up @@ -298,6 +298,7 @@ set ( TEST_FILES
InstrumentRayTracerTest.h
LoadAscii2Test.h
LoadAsciiTest.h
LoadBBYTest.h
LoadCalFileTest.h
LoadCanSAS1dTest.h
LoadDaveGrpTest.h
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/DataHandling/src/LoadBBY.cpp
Expand Up @@ -255,7 +255,7 @@ namespace Mantid
exts.clear();
exts.push_back(".hdf");
declareProperty(
new API::FileProperty("Hdf Reference", "", API::FileProperty::OptionalLoad, exts),
new API::FileProperty("HdfReference", "", API::FileProperty::OptionalLoad, exts),
"The input filename of the stored data");

declareProperty(
Expand Down Expand Up @@ -300,7 +300,7 @@ namespace Mantid

// Get the name of the file.
std::string filenameBin = getPropertyValue("Filename");
std::string filenameHdf = getPropertyValue("Hdf Reference");
std::string filenameHdf = getPropertyValue("HdfReference");

size_t nBins = 1;
double tofMinBoundary = getProperty("FilterByTofMin");
Expand Down
71 changes: 71 additions & 0 deletions Code/Mantid/Framework/DataHandling/test/LoadBBYTest.h
@@ -0,0 +1,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_*/

0 comments on commit 8f8a1eb

Please sign in to comment.