Skip to content

Commit

Permalink
refs #5016. Additional tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed May 29, 2012
1 parent 6f129ab commit 2f9d001
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ namespace MDEvents
checkExtents(extents);
checkIncidentTheta(incidentTheta);
checkCustomThetaInputs(bUseOwnIncidentTheta, incidentTheta);
checkOutputDimensionalityChoice(outputDimensions);

// Extract the incient theta angle from the logs if a user provided one is not given.
if(!bUseOwnIncidentTheta)
Expand Down
63 changes: 53 additions & 10 deletions Code/Mantid/Framework/MDEvents/test/ConvertToReflectometryQTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "MantidMDEvents/ConvertToReflectometryQ.h"
#include "MantidAPI/IMDHistoWorkspace.h"
#include "MantidAPI/NumericAxis.h"
#include "MantidAPI/FrameworkManager.h"

using namespace Mantid;
using namespace Mantid::MDEvents;
Expand Down Expand Up @@ -64,6 +65,10 @@ class ConvertToReflectometryQTest : public CxxTest::TestSuite
static ConvertToReflectometryQTest *createSuite() { return new ConvertToReflectometryQTest(); }
static void destroySuite( ConvertToReflectometryQTest *suite ) { delete suite; }

void setUp()
{
Mantid::API::FrameworkManager::Instance();
}

void test_Init()
{
Expand All @@ -73,40 +78,78 @@ class ConvertToReflectometryQTest : public CxxTest::TestSuite
TS_ASSERT( alg.isInitialized() )
}

void test_theta_initial_negative()
void test_theta_initial_negative_throws()
{
auto alg = make_standard_algorithm();
alg->setProperty("OverrideIncidentTheta", true);
alg->setProperty("IncidentTheta", -0.0001);
TSM_ASSERT_THROWS("Incident theta is negative, should throw", alg->execute(), std::logic_error);
}

void test_theta_initial_too_large()
void test_theta_initial_too_large_throws()
{
auto alg = make_standard_algorithm();
alg->setProperty("OverrideIncidentTheta", true);
alg->setProperty("IncidentTheta", 90.001);
TSM_ASSERT_THROWS("Incident theta is too large, should throw", alg->execute(), std::logic_error);
}

void test_invalid_theta_axis()
void test_wrong_number_of_extents_throws()
{
auto alg = make_standard_algorithm();
alg->setProperty("Extents", "-1");
TSM_ASSERT_THROWS("Should only accept 4 extents", alg->execute(), std::runtime_error);
}

//Characterisation test for the current state of the algorithm
void test_only_support_q_conversion()
void test_extents_with_qxmin_equals_qxmax_throws()
{
auto alg = make_standard_algorithm();
alg->setProperty("OutputDimensions", "P (lab frame)");
TSM_ASSERT_THROWS("Should throw as this mode is not supported yet", alg->execute(), std::runtime_error);
alg->setProperty("Extents", "-1,-1,-1,1");
TS_ASSERT_THROWS(alg->execute(), std::runtime_error);
}

void test_extents_with_qxmin_more_than_qxmax_throws()
{
auto alg = make_standard_algorithm();
alg->setProperty("Extents", "-1,-1.01,-1,1");
TS_ASSERT_THROWS(alg->execute(), std::runtime_error);
}

void test_extents_with_qxmin_less_than_qxmax()
{
auto alg = make_standard_algorithm();
alg->setProperty("Extents", "-1,-0.999,-1,1");
TS_ASSERT_THROWS_NOTHING(alg->execute(), std::runtime_error);
}

void test_check_shouldnt_be_working()
void test_extents_with_qzmin_equals_qzmax_throws()
{
std::string outWSName("ConvertToReflectometryQTest_OutputWS");
doExecute(outWSName);
auto alg = make_standard_algorithm();
alg->setProperty("Extents", "-1,1,-1,-1");
TS_ASSERT_THROWS(alg->execute(), std::runtime_error);
}

void test_extents_with_qzmin_more_than_qzmax_throws()
{
auto alg = make_standard_algorithm();
alg->setProperty("Extents", "-1,1,-1,-1.01");
TS_ASSERT_THROWS(alg->execute(), std::runtime_error);
}

void test_extents_with_qzmin_less_than_qzmax()
{
auto alg = make_standard_algorithm();
alg->setProperty("Extents", "-1,1,0.999,1");
TS_ASSERT_THROWS_NOTHING(alg->execute(), std::runtime_error);
}

//Characterisation test for the current state of the algorithm
void test_only_support_q_conversion()
{
auto alg = make_standard_algorithm();
alg->setProperty("OutputDimensions", "P (lab frame)");
TSM_ASSERT_THROWS("Should throw as this mode is not supported yet", alg->execute(), std::runtime_error);
}


};
Expand Down

0 comments on commit 2f9d001

Please sign in to comment.