Skip to content

Commit

Permalink
refs #4201 More unit tests
Browse files Browse the repository at this point in the history
Committed rather to check CRLF issue then to do any useful work.
  • Loading branch information
abuts committed Jan 11, 2012
1 parent d94f809 commit bd86f21
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
1 change: 1 addition & 0 deletions Code/Mantid/Framework/MDAlgorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ set ( TEST_FILES
test/ConvertToMDEventsUnitsConvTest.h
test/ConvertToMDEventsCoordTransfTest.h
test/ConvertEventsToMDEventsTest.h
test/ConvertToMDEventsMethodsTest.h
test/DivideMDTest.h
test/EqualToMDTest.h
test/ExponentialMDTest.h
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#ifndef CONVERT2_MDEVENTS_METHODS_TEST_H_
#define CONVERT2_MDEVENTS_METHODS_TEST_H_

#include <cxxtest/TestSuite.h>
#include "MantidMDAlgorithms/ConvertToMDEventsUnitsConv.h"
#include "MantidMDAlgorithms/ConvertToMDEventsDetInfo.h"
#include "MantidMDAlgorithms/ConvertToMDEvents.h"
#include "MantidTestHelpers/WorkspaceCreationHelper.h"
#include "MantidAPI/Progress.h"
#include "MantidMDAlgorithms/ConvertToMDEventsHistoWS.h"
#include "MantidMDAlgorithms/ConvertToMDEventsEventWS.h"



using namespace Mantid;
using namespace Mantid::MDAlgorithms;
using namespace Mantid::API;
using namespace Mantid::Geometry;



class ConvertToMDEventsMethodsTest : public CxxTest::TestSuite, public ConvertToMDEvents
{
Mantid::API::MatrixWorkspace_sptr ws2D;

std::auto_ptr<API::Progress > pProg;
PreprocessedDetectors det_loc;

public:
static ConvertToMDEventsMethodsTest *createSuite() {
return new ConvertToMDEventsMethodsTest();
//g_log = Kernel::Logger::get("MD-Algorithms-Tests");
}
static void destroySuite(ConvertToMDEventsMethodsTest * suite) { delete suite; }

void test_TwoTransfMethods()
{

ConvertToMDEvensHistoWS<Q3D,Direct,ConvertNo> HistoConv;

MDEvents::MDWSDescription TestWS(4);

TestWS.Ei = *(dynamic_cast<Kernel::PropertyWithValue<double> *>(ws2D->run().getProperty("Ei")));
TestWS.emode= MDAlgorithms::Direct;
TestWS.dim_min.assign(4,-3);
TestWS.dim_max.assign(4,3);
TestWS.dim_names.assign(4,"Momentum");
TestWS.dim_names[3]="DeltaE";
TestWS.rotMatrix.assign(9,0);
TestWS.rotMatrix[0]=1;
TestWS.rotMatrix[4]=1;
TestWS.rotMatrix[8]=1;

boost::shared_ptr<MDEvents::MDEventWSWrapper> pOutMDWSWrapper = boost::shared_ptr<MDEvents::MDEventWSWrapper>(new MDEvents::MDEventWSWrapper());
pOutMDWSWrapper->createEmptyMDWS(TestWS);


TS_ASSERT_THROWS_NOTHING(HistoConv.setUPConversion(ws2D,det_loc,TestWS,pOutMDWSWrapper));

pProg = std::auto_ptr<API::Progress >(new API::Progress(dynamic_cast<ConvertToMDEvents *>(this),0.0,1.0,4));

}



ConvertToMDEventsMethodsTest (){

std::vector<double> L2(5,5);
std::vector<double> polar(5,(30./180.)*3.1415926);
polar[0]=0;
std::vector<double> azimutal(5,0);
azimutal[1]=(45./180.)*3.1415936;
azimutal[2]=(90./180.)*3.1415936;
azimutal[3]=(135./180.)*3.1415936;
azimutal[4]=(180./180.)*3.1415936;

int numBins=10;
ws2D =WorkspaceCreationHelper::createProcessedInelasticWS(L2, polar, azimutal,numBins,-1,3,3);

Kernel::UnitFactory::Instance().create("TOF");
Kernel::UnitFactory::Instance().create("Energy");
Kernel::UnitFactory::Instance().create("DeltaE");
Kernel::UnitFactory::Instance().create("Momentum");

// set up workpspaces and preprocess detectors
pProg = std::auto_ptr<API::Progress >(new API::Progress(dynamic_cast<ConvertToMDEvents *>(this),0.0,1.0,4));

processDetectorsPositions(ws2D,det_loc,ConvertToMDEvents::getLogger(),pProg.get());
//pConvMethods = std::auto_ptr<ConvertToMDEventsCoordTestHelper>(new ConvertToMDEventsCoordTestHelper());
//pConvMethods->setUPConversion(ws2D,det_loc);


}

};



#endif

0 comments on commit bd86f21

Please sign in to comment.