From e600990ef78763aaeb5ab154b51af4d9994181ac Mon Sep 17 00:00:00 2001
From: Roman Tolchenov <roman.tolchenov@stfc.ac.uk>
Date: Tue, 12 May 2015 11:05:01 +0100
Subject: [PATCH] Re #11738. Unit test for the fix.

---
 .../Framework/DataHandling/test/LoadGSSTest.h | 56 ++++++++++++++++---
 1 file changed, 48 insertions(+), 8 deletions(-)

diff --git a/Code/Mantid/Framework/DataHandling/test/LoadGSSTest.h b/Code/Mantid/Framework/DataHandling/test/LoadGSSTest.h
index be74e753277..62457964d0c 100644
--- a/Code/Mantid/Framework/DataHandling/test/LoadGSSTest.h
+++ b/Code/Mantid/Framework/DataHandling/test/LoadGSSTest.h
@@ -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()
-- 
GitLab