Skip to content
Snippets Groups Projects
Commit e600990e authored by Roman Tolchenov's avatar Roman Tolchenov
Browse files

Re #11738. Unit test for the fix.

parent 7af9c977
No related branches found
No related tags found
No related merge requests found
......@@ -4,12 +4,11 @@
#include "cxxtest/TestSuite.h"
#include "MantidDataHandling/LoadGSS.h"
#include "MantidAPI/AlgorithmManager.h"
//#include "MantidAPI/AnalysisDataService.h"
//#include <Poco/File.h>
//#include <fstream>
#include "MantidTestHelpers/ScopedFileHelper.h"
using namespace Mantid;
using Mantid::DataHandling::LoadGSS;
using ScopedFileHelper::ScopedFile;
class LoadGSSTest : public CxxTest::TestSuite
{
......@@ -24,13 +23,54 @@ public:
TS_ASSERT_EQUALS( loader.version(), 1 )
}
void test_load_gss_txt()
{
void test_load_gss_txt() {
API::IAlgorithm_sptr loader = createAlgorithm();
loader->setPropertyValue("Filename","gss.txt");
TS_ASSERT( loader->execute() )
loader->setPropertyValue("Filename", "gss.txt");
TS_ASSERT(loader->execute())
API::MatrixWorkspace_const_sptr ws = loader->getProperty("OutputWorkspace");
// Check a few things in the workspace
checkWorkspace( loader->getProperty("OutputWorkspace"), 8, 816);
checkWorkspace(ws, 8, 816);
auto x1 = ws->readX(0)[99];
auto x2 = ws->readX(0)[100];
auto y = ws->readY(0)[99];
TS_ASSERT_DELTA((x1 + x2)/2, 40844.0625, 1e-6);
TS_ASSERT_DELTA(y, 145304004.625, 1e-6);
}
void test_large_x_values() {
std::string gss =
"LuBaCo4O7 HR BS P=2GPa Tcryo=130.0K "
" \n"
"# 1 Histograms\n"
"# File generated by Mantid:\n"
"# Instrument: WISH\n"
"# From workspace named : w21552-2foc\n"
"# with Y multiplied by the bin widths.\n"
"# Primary flight path 40m \n"
"# Total flight path 42.2222m, tth 58.308deg, DIFC 10398.8\n"
"# Data for spectrum :0\n"
"BANK 1 4399 4399 RALF 166409 124 166409 0.00074 FXYE\n"
" 115202.20029 123456.00000002 0.00000000\n"
" 115206.06310 1234567.00000003 0.00000000\n"
" 115209.92877 12345678.00000004 0.00000000\n"
" 115213.79731123456789.00000005 0.00000000\n"
" 115217.66873234567890.00000006 0.00000000";
ScopedFile file(gss,"gss_large_x.txt");
API::IAlgorithm_sptr loader = createAlgorithm();
loader->setPropertyValue("Filename", file.getFileName());
TS_ASSERT(loader->execute())
API::MatrixWorkspace_const_sptr ws = loader->getProperty("OutputWorkspace");
auto x1 = ws->readX(0)[0];
auto x2 = ws->readX(0)[1];
auto dx = x2 - x1;
auto y = ws->readY(0)[0] * dx;
TS_ASSERT_DELTA((x1 + x2)/2, 115202.20029, 1e-6);
TS_ASSERT_DELTA(y, 123456.00000002, 1e-10);
x1 = ws->readX(0)[3];
x2 = ws->readX(0)[4];
dx = x2 - x1;
y = ws->readY(0)[3] * dx;
TS_ASSERT_DELTA(y, 123456789.00000005, 1e-10);
}
void test_load_gss_ExtendedHeader_gsa()
......
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