Skip to content
Snippets Groups Projects
Commit 7d679dbc authored by Russell Taylor's avatar Russell Taylor
Browse files

Re #8184. Add a test for loading a TableWorkspace.

Fails right now because of the extra whitespace at the end of entries
in the string column.
parent 81439d02
No related merge requests found
......@@ -10,6 +10,7 @@
#include "MantidGeometry/Instrument.h"
#include "MantidDataHandling/LoadNexusProcessed.h"
#include "MantidDataHandling/SaveNexusProcessed.h"
#include "MantidDataHandling/Load.h"
#include "SaveNexusProcessedTest.h"
#include <cxxtest/TestSuite.h>
#include <iostream>
......@@ -514,10 +515,39 @@ public:
// test to see if parameters are loaded
std::vector<boost::shared_ptr<const Mantid::Geometry::IComponent> > bankComp = ws->getInstrument()->getAllComponentsWithName("bank_bsk");
//std::cout << "kkkkkkkkkkkkkkkk " << bankComp.size() << " " << bankComp[0]->getParameterNames().size() << std::endl;
TS_ASSERT( bankComp[0]->getParameterNames().size() == 3 );
//TS_ASSERT_DELTA( bankComp->getNumberParameter("A")[0], 32.0, 0.0001);
}
void testTableWorkspace()
{
Load alg;
alg.initialize();
alg.setPropertyValue("Filename","SavedTableWorkspace.nxs");
const std::string wsName("SavedTableWorkspace");
alg.setPropertyValue("OutputWorkspace",wsName);
TS_ASSERT( alg.execute() );
TableWorkspace_const_sptr ws = AnalysisDataService::Instance().retrieveWS<TableWorkspace>(wsName);
TS_ASSERT_EQUALS( ws->columnCount(), 3 );
TS_ASSERT_EQUALS( ws->rowCount(), 4 );
Column_const_sptr column;
TS_ASSERT_THROWS_NOTHING( column = ws->getColumn("Name") );
TS_ASSERT_EQUALS( column->cell<std::string>(0), "Height" );
TS_ASSERT_EQUALS( column->cell<std::string>(1), "PeakCentre" );
TS_ASSERT_EQUALS( column->cell<std::string>(2), "Sigma" );
TS_ASSERT_EQUALS( column->cell<std::string>(3), "Cost function value" );
TS_ASSERT_THROWS_NOTHING( column = ws->getColumn("Value") );
TS_ASSERT_DELTA( column->cell<double>(0), 79.2315, 0.0001 );
TS_ASSERT_DELTA( column->cell<double>(1), 2.3979, 0.0001 );
TS_ASSERT_DELTA( column->cell<double>(2), 0.3495, 0.0001 );
TS_ASSERT_DELTA( column->cell<double>(3), 35.6841, 0.0001 );
TS_ASSERT_THROWS_NOTHING( column = ws->getColumn("Error") );
TS_ASSERT_DELTA( column->cell<double>(0), 0.814478, 0.0001);
TS_ASSERT_DELTA( column->cell<double>(1), 0.00348291, 0.000001 );
TS_ASSERT_DELTA( column->cell<double>(2), 0.00342847, 0.000001 );
TS_ASSERT_EQUALS( column->cell<double>(3), 0 );
AnalysisDataService::Instance().remove(wsName);
}
private:
......
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment