Commit 69f314f1 authored by Antti Soininen's avatar Antti Soininen
Browse files

Move MockRNG from several tests to its own file. Re #24636

parent bd792f30
...@@ -14,57 +14,28 @@ ...@@ -14,57 +14,28 @@
#include "MantidGeometry/Objects/ShapeFactory.h" #include "MantidGeometry/Objects/ShapeFactory.h"
#include "MantidGeometry/Objects/Track.h" #include "MantidGeometry/Objects/Track.h"
#include "MantidGeometry/Rendering/GeometryHandler.h" #include "MantidGeometry/Rendering/GeometryHandler.h"
#include "MantidGeometry/Rendering/ShapeInfo.h"
#include "MantidGeometry/Surfaces/Cylinder.h" #include "MantidGeometry/Surfaces/Cylinder.h"
#include "MantidGeometry/Surfaces/Plane.h" #include "MantidGeometry/Surfaces/Plane.h"
#include "MantidGeometry/Surfaces/Sphere.h" #include "MantidGeometry/Surfaces/Sphere.h"
#include "MantidGeometry/Surfaces/SurfaceFactory.h" #include "MantidGeometry/Surfaces/SurfaceFactory.h"
#include "MantidKernel/Material.h" #include "MantidKernel/Material.h"
#include "MantidKernel/MersenneTwister.h" #include "MantidKernel/MersenneTwister.h"
#include "MantidKernel/WarningSuppressions.h"
#include "MantidKernel/make_unique.h"
#include "MantidTestHelpers/ComponentCreationHelper.h" #include "MantidTestHelpers/ComponentCreationHelper.h"
#include "MockRNG.h"
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cxxtest/TestSuite.h> #include <cxxtest/TestSuite.h>
#include <ostream>
#include <vector>
#include "boost/make_shared.hpp" #include "boost/make_shared.hpp"
#include "boost/shared_ptr.hpp" #include "boost/shared_ptr.hpp"
#include <Poco/DOM/AutoPtr.h> #include <Poco/DOM/AutoPtr.h>
#include <Poco/DOM/Document.h> #include <Poco/DOM/Document.h>
#include <gmock/gmock.h>
using namespace Mantid; using namespace Mantid;
using namespace Geometry; using namespace Geometry;
using Mantid::Kernel::V3D; using Mantid::Kernel::V3D;
using detail::ShapeInfo; using detail::ShapeInfo;
namespace {
// -----------------------------------------------------------------------------
// Mock Random Number Generator
// -----------------------------------------------------------------------------
class MockRNG final : public Mantid::Kernel::PseudoRandomNumberGenerator {
public:
GNU_DIAG_OFF_SUGGEST_OVERRIDE
MOCK_METHOD0(nextValue, double());
MOCK_METHOD2(nextValue, double(double, double));
MOCK_METHOD2(nextInt, int(int, int));
MOCK_METHOD0(restart, void());
MOCK_METHOD0(save, void());
MOCK_METHOD0(restore, void());
MOCK_METHOD1(setSeed, void(size_t));
MOCK_METHOD2(setRange, void(const double, const double));
MOCK_CONST_METHOD0(min, double());
MOCK_CONST_METHOD0(max, double());
GNU_DIAG_ON_SUGGEST_OVERRIDE
};
} // namespace
class CSGObjectTest : public CxxTest::TestSuite { class CSGObjectTest : public CxxTest::TestSuite {
public: public:
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#define MANTID_GEOMETRY_MESHOBJECT2DTEST_H_ #define MANTID_GEOMETRY_MESHOBJECT2DTEST_H_
#include <cxxtest/TestSuite.h> #include <cxxtest/TestSuite.h>
#include <gmock/gmock.h>
#include "MantidGeometry/Objects/BoundingBox.h" #include "MantidGeometry/Objects/BoundingBox.h"
#include "MantidGeometry/Objects/MeshObject2D.h" #include "MantidGeometry/Objects/MeshObject2D.h"
...@@ -16,9 +15,8 @@ ...@@ -16,9 +15,8 @@
#include "MantidGeometry/Rendering/GeometryHandler.h" #include "MantidGeometry/Rendering/GeometryHandler.h"
#include "MantidGeometry/Rendering/ShapeInfo.h" #include "MantidGeometry/Rendering/ShapeInfo.h"
#include "MantidKernel/Material.h" #include "MantidKernel/Material.h"
#include "MantidKernel/PseudoRandomNumberGenerator.h"
#include "MantidKernel/V3D.h"
#include "MantidKernel/WarningSuppressions.h" #include "MantidKernel/WarningSuppressions.h"
#include "MockRNG.h"
#include <cmath> #include <cmath>
using Mantid::Geometry::MeshObject2D; using Mantid::Geometry::MeshObject2D;
...@@ -42,24 +40,6 @@ MeshObject2D makeTrapezoidMesh(const V3D &a, const V3D &b, const V3D &c, ...@@ -42,24 +40,6 @@ MeshObject2D makeTrapezoidMesh(const V3D &a, const V3D &b, const V3D &c,
triangles.insert(triangles.end(), {2, 3, 0}); triangles.insert(triangles.end(), {2, 3, 0});
return MeshObject2D(triangles, vertices, Mantid::Kernel::Material()); return MeshObject2D(triangles, vertices, Mantid::Kernel::Material());
} }
// -----------------------------------------------------------------------------
// Mock Random Number Generator
// -----------------------------------------------------------------------------
class MockRNG : public Mantid::Kernel::PseudoRandomNumberGenerator {
public:
GNU_DIAG_OFF_SUGGEST_OVERRIDE
MOCK_METHOD0(nextValue, double());
MOCK_METHOD2(nextValue, double(double, double));
MOCK_METHOD2(nextInt, int(int, int));
MOCK_METHOD0(restart, void());
MOCK_METHOD0(save, void());
MOCK_METHOD0(restore, void());
MOCK_METHOD1(setSeed, void(size_t));
MOCK_METHOD2(setRange, void(const double, const double));
MOCK_CONST_METHOD0(min, double());
MOCK_CONST_METHOD0(max, double());
GNU_DIAG_ON_SUGGEST_OVERRIDE
};
} // namespace } // namespace
class MeshObject2DTest : public CxxTest::TestSuite { class MeshObject2DTest : public CxxTest::TestSuite {
......
...@@ -15,48 +15,19 @@ ...@@ -15,48 +15,19 @@
#include "MantidGeometry/Rendering/GeometryHandler.h" #include "MantidGeometry/Rendering/GeometryHandler.h"
#include "MantidKernel/Material.h" #include "MantidKernel/Material.h"
#include "MantidKernel/MersenneTwister.h" #include "MantidKernel/MersenneTwister.h"
#include "MantidKernel/WarningSuppressions.h"
#include "MantidKernel/make_unique.h"
#include "MantidTestHelpers/ComponentCreationHelper.h" #include "MantidTestHelpers/ComponentCreationHelper.h"
#include "MockRNG.h"
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cxxtest/TestSuite.h> #include <cxxtest/TestSuite.h>
#include <ostream>
#include <vector>
#include "boost/make_shared.hpp"
#include "boost/shared_ptr.hpp"
#include <Poco/DOM/AutoPtr.h> #include <Poco/DOM/AutoPtr.h>
#include <Poco/DOM/Document.h> #include <Poco/DOM/Document.h>
#include <gmock/gmock.h>
using namespace Mantid; using namespace Mantid;
using namespace Geometry; using namespace Geometry;
using Mantid::Kernel::V3D; using Mantid::Kernel::V3D;
namespace { namespace {
// -----------------------------------------------------------------------------
// Mock Random Number Generator
// -----------------------------------------------------------------------------
class MockRNG final : public Mantid::Kernel::PseudoRandomNumberGenerator {
public:
GNU_DIAG_OFF_SUGGEST_OVERRIDE
MOCK_METHOD0(nextValue, double());
MOCK_METHOD2(nextValue, double(double, double));
MOCK_METHOD2(nextInt, int(int, int));
MOCK_METHOD0(restart, void());
MOCK_METHOD0(save, void());
MOCK_METHOD0(restore, void());
MOCK_METHOD1(setSeed, void(size_t));
MOCK_METHOD2(setRange, void(const double, const double));
MOCK_CONST_METHOD0(min, double());
MOCK_CONST_METHOD0(max, double());
GNU_DIAG_ON_SUGGEST_OVERRIDE
};
std::unique_ptr<MeshObject> createCube(const double size, const V3D &centre) { std::unique_ptr<MeshObject> createCube(const double size, const V3D &centre) {
/** /**
* Create cube of side length size with specified centre, * Create cube of side length size with specified centre,
......
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright &copy; 2019 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTID_GEOMETRY_MOCKRNG_H_
#define MANTID_GEOMETRY_MOCKRNG_H_
#include "MantidKernel/PseudoRandomNumberGenerator.h"
#include "MantidKernel/WarningSuppressions.h"
#include <gmock/gmock.h>
// -----------------------------------------------------------------------------
// Mock Random Number Generator
// -----------------------------------------------------------------------------
class MockRNG : public Mantid::Kernel::PseudoRandomNumberGenerator {
public:
GNU_DIAG_OFF_SUGGEST_OVERRIDE
MOCK_METHOD0(nextValue, double());
MOCK_METHOD2(nextValue, double(double, double));
MOCK_METHOD2(nextInt, int(int, int));
MOCK_METHOD0(restart, void());
MOCK_METHOD0(save, void());
MOCK_METHOD0(restore, void());
MOCK_METHOD1(setSeed, void(size_t));
MOCK_METHOD2(setRange, void(const double, const double));
MOCK_CONST_METHOD0(min, double());
MOCK_CONST_METHOD0(max, double());
GNU_DIAG_ON_SUGGEST_OVERRIDE
};
#endif /* MANTID_GEOMETRY_MOCKRNG_H_ */
...@@ -14,34 +14,13 @@ ...@@ -14,34 +14,13 @@
#include "MantidKernel/V3D.h" #include "MantidKernel/V3D.h"
#include "MantidKernel/WarningSuppressions.h" #include "MantidKernel/WarningSuppressions.h"
#include "MantidTestHelpers/ComponentCreationHelper.h" #include "MantidTestHelpers/ComponentCreationHelper.h"
#include "MockRNG.h"
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <cxxtest/TestSuite.h> #include <cxxtest/TestSuite.h>
#include <gmock/gmock.h>
using Mantid::Geometry::SampleEnvironment; using Mantid::Geometry::SampleEnvironment;
namespace {
// -----------------------------------------------------------------------------
// Mock Random Number Generator
// -----------------------------------------------------------------------------
class MockRNG final : public Mantid::Kernel::PseudoRandomNumberGenerator {
public:
GNU_DIAG_OFF_SUGGEST_OVERRIDE
MOCK_METHOD0(nextValue, double());
MOCK_METHOD2(nextValue, double(double, double));
MOCK_METHOD2(nextInt, int(int, int));
MOCK_METHOD0(restart, void());
MOCK_METHOD0(save, void());
MOCK_METHOD0(restore, void());
MOCK_METHOD1(setSeed, void(size_t));
MOCK_METHOD2(setRange, void(const double, const double));
MOCK_CONST_METHOD0(min, double());
MOCK_CONST_METHOD0(max, double());
GNU_DIAG_ON_SUGGEST_OVERRIDE
};
} // namespace
class SampleEnvironmentTest : public CxxTest::TestSuite { class SampleEnvironmentTest : public CxxTest::TestSuite {
public: public:
// This pair of boilerplate methods prevent the suite being created statically // This pair of boilerplate methods prevent the suite being created statically
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment