Commit 5ed664d7 authored by Karl Palmen's avatar Karl Palmen
Browse files

Begin Unit Test re #12827



Signed-off-by: default avatarKarl Palmen <karl.palmen@stfc.ac.uk>
parent ffe125b4
......@@ -362,6 +362,7 @@ set ( TEST_FILES
MathSupportTest.h
MatrixVectorPairParserTest.h
MatrixVectorPairTest.h
MeshObjectTest.h
NiggliCellTest.h
NullImplicitFunctionTest.h
ObjCompAssemblyTest.h
......
#ifndef MANTID_TESTOBJECT__
#define MANTID_TESTOBJECT__
#ifndef MANTID_TESTCSGOBJECT__
#define MANTID_TESTCSGOBJECT__
#include "MantidGeometry/Objects/CSGObject.h"
......@@ -1552,4 +1552,4 @@ private:
IObject_sptr shell;
};
#endif // MANTID_TESTOBJECT__
#endif // MANTID_TESTCSGOBJECT__
#ifndef MANTID_TESTMESHOBJECT__
#define MANTID_TESTMESHOBJECT__
#include "MantidGeometry/Objects/MeshObject.h"
#include "MantidGeometry/Math/Algebra.h"
#include "MantidGeometry/Objects/Track.h"
#include "MantidGeometry/Rendering/GluGeometryHandler.h"
#include "MantidGeometry/Objects/ShapeFactory.h"
#include "MantidKernel/make_unique.h"
#include "MantidKernel/Material.h"
#include "MantidKernel/MersenneTwister.h"
#include "MantidKernel/WarningSuppressions.h"
#include "MantidTestHelpers/ComponentCreationHelper.h"
#include <cxxtest/TestSuite.h>
#include <cmath>
#include <ostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include "boost/shared_ptr.hpp"
#include "boost/make_shared.hpp"
#include <gmock/gmock.h>
#include <Poco/DOM/AutoPtr.h>
#include <Poco/DOM/Document.h>
using namespace Mantid;
using namespace Geometry;
using Mantid::Kernel::V3D;
namespace {
// -----------------------------------------------------------------------------
// Mock Random Number Generator
// -----------------------------------------------------------------------------
class MockRNG final : public Mantid::Kernel::PseudoRandomNumberGenerator {
public:
GCC_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());
GCC_DIAG_ON_SUGGEST_OVERRIDE
};
}
class MeshObjectTest : public CxxTest::TestSuite {
public:
void testDefaultObjectHasEmptyMaterial() {
CSGObject obj;
TSM_ASSERT_DELTA("Expected a zero number density", 0.0,
obj.material().numberDensity(), 1e-12);
}
void testObjectSetMaterialReplacesExisting() {
using Mantid::Kernel::Material;
CSGObject obj;
TSM_ASSERT_DELTA("Expected a zero number density", 0.0,
obj.material().numberDensity(), 1e-12);
obj.setMaterial(
Material("arm", PhysicalConstants::getNeutronAtom(13), 45.0));
TSM_ASSERT_DELTA("Expected a number density of 45", 45.0,
obj.material().numberDensity(), 1e-12);
}
private:
boost::shared_ptr<MeshObject> createCube(double size) {
boost::shared_ptr<MeshObject> retVal =
boost::shared_ptr<MeshObject>(new MeshObject);
return retVal;
}
};
// -----------------------------------------------------------------------------
// Performance tests
// -----------------------------------------------------------------------------
#endif // MANTID_TESTMESHOBJECT__
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