Skip to content

Commit

Permalink
refs #6852 Unit test which checks that EI saved and loaded from NeXus
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Apr 22, 2013
1 parent e32e05b commit 6df695b
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Code/Mantid/Framework/API/test/ExperimentInfoTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "MantidKernel/DateAndTime.h"
#include "MantidKernel/NexusTestHelper.h"
#include "MantidKernel/SingletonHolder.h"
#include "MantidKernel/Matrix.h"


#include "MantidTestHelpers/ComponentCreationHelper.h"
Expand Down Expand Up @@ -628,6 +629,43 @@ class ExperimentInfoTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS( parameterStr, "" );
}

void testNexus_W_matrix()
{
NexusTestHelper th(true);
th.createFile("ExperimentInfoWMatrixTest.nxs");
ExperimentInfo ei;

DblMatrix WTransf(3,3,true);
// let's add some tricky stuff to w-transf
WTransf[0][1]=0.5;
WTransf[0][2]=2.5;
WTransf[1][0]=10.5;
WTransf[1][2]=12.5;
WTransf[2][0]=20.5;
WTransf[2][1]=21.5;

auto wTrVector = WTransf.getVector();

// this occurs in ConvertToMD, copy methadata
ei.mutableRun().addProperty("W_MATRIX",wTrVector,true);

TS_ASSERT_THROWS_NOTHING(ei.saveExperimentInfoNexus(th.file));

th.reopenFile();

ExperimentInfo other;
std::string InstrParameters;
TS_ASSERT_THROWS_NOTHING(other.loadExperimentInfoNexus(th.file,InstrParameters));

std::vector<double> wMatrRestored=other.run().getPropertyValueAsType<std::vector<double> >("W_MATRIX");

for(int i=0;i<9;i++)
{
TS_ASSERT_DELTA(wTrVector[i],wMatrRestored[i],1.e-9);
}

}

private:

void addInstrumentWithParameter(ExperimentInfo & expt, const std::string & name, const std::string & value)
Expand Down

0 comments on commit 6df695b

Please sign in to comment.