Skip to content

Commit

Permalink
Refs #5350 Added numerical test after algorithm execution
Browse files Browse the repository at this point in the history
modified:   ../Framework/DataHandling/test/LoadSassenaTest.h
  • Loading branch information
jmborr committed May 22, 2012
1 parent 639561c commit 765b4e1
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions Code/Mantid/Framework/DataHandling/test/LoadSassenaTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

#include <cxxtest/TestSuite.h>
#include "MantidDataHandling/LoadSassena.h"
#include "MantidAPI/AnalysisDataService.h"

using namespace Mantid;

class LoadSassenaTest : public CxxTest::TestSuite
{
Expand All @@ -15,20 +18,20 @@ class LoadSassenaTest : public CxxTest::TestSuite
m_inputFile = "outputSassena_1.4.1.h5";
}

void testInit()
void test_init()
{
TS_ASSERT_THROWS_NOTHING( m_alg.initialize() )
TS_ASSERT( m_alg.isInitialized() )
}

void testFileCheck()
void test_fileCheck()
{
if( !m_alg.isInitialized() ) m_alg.initialize();
m_alg.setPropertyValue( "Filename", m_inputFile );
TS_ASSERT_EQUALS(m_alg.fileCheck(m_alg.getPropertyValue("Filename")), 99);
}

void testExec()
void test_exec()
{
std::string result;
if( !m_alg.isInitialized() ) m_alg.initialize();
Expand All @@ -43,6 +46,36 @@ class LoadSassenaTest : public CxxTest::TestSuite
TS_ASSERT_THROWS_NOTHING( m_alg.execute() );
TS_ASSERT( m_alg.isExecuted() );

//Test the last stored value for each of the workspaces
API::WorkspaceGroup_sptr gws = API::AnalysisDataService::Instance().retrieveWS<API::WorkspaceGroup>("outGWS");

//Test qvectors
DataObjects::Workspace2D_sptr ws = boost::dynamic_pointer_cast<DataObjects::Workspace2D>( gws->getItem("outGWS_qvectors") );
TS_ASSERT_DELTA( ws->readY(4)[0], 0.02402402, 1e-08 );

//Test fq
ws = boost::dynamic_pointer_cast<DataObjects::Workspace2D>( gws->getItem("outGWS_fq") );
TS_ASSERT_DELTA( ws->readY(0)[4], 1070.7009, 1e-04 );
TS_ASSERT_DELTA( ws->readY(1)[4], 674.67703, 1e-05 );

//Test fq0
ws = boost::dynamic_pointer_cast<DataObjects::Workspace2D>( gws->getItem("outGWS_fq0") );
TS_ASSERT_DELTA( ws->readY(0)[4], 1094.1314, 1e-04 );
TS_ASSERT_DELTA( ws->readY(1)[4], 652.75902, 1e-05 );

//Test fq2
ws = boost::dynamic_pointer_cast<DataObjects::Workspace2D>( gws->getItem("outGWS_fq2") );
TS_ASSERT_DELTA( ws->readY(0)[4], 358926.16, 1e-02 );
TS_ASSERT_EQUALS( ws->readY(1)[4], 0.0);

//Test fq Real part
ws = boost::dynamic_pointer_cast<DataObjects::Workspace2D>( gws->getItem("outGWS_fqt.Re") );
TS_ASSERT_DELTA( ws->readY(4)[7], 1918.2156, 1e-04 );

//Test fq Imaginary part
ws = boost::dynamic_pointer_cast<DataObjects::Workspace2D>( gws->getItem("outGWS_fqt.Im") );
TS_ASSERT_DELTA( ws->readY(4)[7], 656.82368, 1e-05 );

} // end of testExec

private:
Expand Down

0 comments on commit 765b4e1

Please sign in to comment.