From ee3d53384dbf91c429ffc8020be6b1b0e7adcece Mon Sep 17 00:00:00 2001
From: Samuel Jones <samjones714@gmail.com>
Date: Fri, 3 Aug 2018 15:48:56 +0100
Subject: [PATCH] Re #22515 Start Unit test in cpp and rename files

---
 Framework/Algorithms/CMakeLists.txt           |  4 +-
 .../{SortXAxis2.h => SortXAxis.h}             |  0
 .../src/{SortXAxis2.cpp => SortXAxis.cpp}     |  4 +-
 Framework/Algorithms/test/SortXAxisTest.h     | 67 +++++++++++++++++++
 4 files changed, 71 insertions(+), 4 deletions(-)
 rename Framework/Algorithms/inc/MantidAlgorithms/{SortXAxis2.h => SortXAxis.h} (100%)
 rename Framework/Algorithms/src/{SortXAxis2.cpp => SortXAxis.cpp} (99%)
 create mode 100644 Framework/Algorithms/test/SortXAxisTest.h

diff --git a/Framework/Algorithms/CMakeLists.txt b/Framework/Algorithms/CMakeLists.txt
index 542362879e6..ec251747d76 100644
--- a/Framework/Algorithms/CMakeLists.txt
+++ b/Framework/Algorithms/CMakeLists.txt
@@ -280,7 +280,7 @@ set ( SRC_FILES
 	src/SofQWPolygon.cpp
 	src/SolidAngle.cpp
 	src/SortEvents.cpp
-	src/SortXAxis2.cpp
+	src/SortXAxis.cpp
 	src/SpatialGrouping.cpp
 	src/SpectrumAlgorithm.cpp
 	src/SpecularReflectionAlgorithm.cpp
@@ -610,7 +610,7 @@ set ( INC_FILES
 	inc/MantidAlgorithms/SofQWPolygon.h
 	inc/MantidAlgorithms/SolidAngle.h
 	inc/MantidAlgorithms/SortEvents.h
-	inc/MantidAlgorithms/SortXAxis2.h
+	inc/MantidAlgorithms/SortXAxis.h
 	inc/MantidAlgorithms/SpatialGrouping.h
 	inc/MantidAlgorithms/SpectrumAlgorithm.h
 	inc/MantidAlgorithms/SpecularReflectionAlgorithm.h
diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SortXAxis2.h b/Framework/Algorithms/inc/MantidAlgorithms/SortXAxis.h
similarity index 100%
rename from Framework/Algorithms/inc/MantidAlgorithms/SortXAxis2.h
rename to Framework/Algorithms/inc/MantidAlgorithms/SortXAxis.h
diff --git a/Framework/Algorithms/src/SortXAxis2.cpp b/Framework/Algorithms/src/SortXAxis.cpp
similarity index 99%
rename from Framework/Algorithms/src/SortXAxis2.cpp
rename to Framework/Algorithms/src/SortXAxis.cpp
index 6dd81d7afd3..49c436c7cf7 100644
--- a/Framework/Algorithms/src/SortXAxis2.cpp
+++ b/Framework/Algorithms/src/SortXAxis.cpp
@@ -1,4 +1,4 @@
-#include "MantidAlgorithms/SortXAxis2.h"
+#include "MantidAlgorithms/SortXAxis.h"
 #include "MantidAPI/Algorithm.h"
 #include "MantidAPI/MatrixWorkspace.h"
 #include "MantidAPI/WorkspaceProperty.h"
@@ -16,7 +16,7 @@ DECLARE_ALGORITHM(SortXAxis)
 
 const std::string SortXAxis::name() const { return "SortXAxis"; }
 
-int SortXAxis::version() const { return 2; }
+int SortXAxis::version() const { return 1; }
 
 const std::string SortXAxis::category() const {
   return "Transforms\\Axes;Utility\\Sorting";
diff --git a/Framework/Algorithms/test/SortXAxisTest.h b/Framework/Algorithms/test/SortXAxisTest.h
new file mode 100644
index 00000000000..f4bd883c12b
--- /dev/null
+++ b/Framework/Algorithms/test/SortXAxisTest.h
@@ -0,0 +1,67 @@
+#ifndef MANTID_ALGORITHMS_SORTXAXISTEST_H_
+#define MANTID_ALGORITHMS_SORTXAXISTEST_H_
+
+#include "MantidAlgorithms/SortXAxis.h"
+#include "MantidAPI/MatrixWorkspace.h"
+#include "MantidKernel/Workspace.h"
+#include <cxxtest/TestSuite.h>
+
+namespace {
+MatrixWorkspace_sptr createWorkspace(const HistogramX &xData,
+                                     const HistogramY &yData,
+                                     const HistogramE &eData,
+                                     const int nSpec = 1) {
+
+  Workspace2D_sptr outWS = boost::make_shared<Workspace2D>();
+  outWS->initialize(nSpec, xData.size(), yData.size());
+  for (int i = 0; i < nSpec; ++i) {
+    outWS->mutableY(i) = yData;
+    outWS->mutableE(i) = eData;
+    outWS->mutableX(i) = xData;
+  }
+
+  outWS->getAxis(0)->unit() = UnitFactory::Instance().create("Wavelength");
+
+  return outWS;
+}
+
+class SortXAxisTest : public CxxTest::TestSuite {
+    // This pair of boilerplate methods prevent the suite being created statically
+  // This means the constructor isn't called when running other tests
+  static SortXAxisTest *createSuite() { return new SortXAxisTest(); }
+  static void destroySuite(SortXAxisTest *suite) { delete suite; }
+
+  void testXAscending(){
+    std::vector<double> xData = {1,2,3};
+    std::vector<double> yData = {1,2,3};
+    std::vector<double> eData = {1,2,3};
+
+    MatrixWorkspace_sptr unsortedws = createWorkspace(xData, yData, eData);
+
+    SortXAxis alg;
+    alg.setProperty("InputWorkspacd", "unsortedws");
+    alg.setProperty("OutputWorkspace", "sortedws");
+    alg.execute();
+    MatrixWorkspace_sptr sortedws = 
+
+  }
+
+  void testXDescending(){}
+
+  void testOnMultipleSpectrum(){}
+
+  void testSortsXHistogramAscending(){}
+
+  void testSortsXHistogramDescending(){}
+
+  void testSortXWorksChild(){}
+
+  void testDxMultipleSpectrum(){}
+
+  void testDxHistogramAscending(){}
+
+  void testSortDescending(){}
+};
+
+
+#endif /*MANTID_ALGORITHMS_SORTXAXISTEST_H_*/
-- 
GitLab