Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
bfc04495
Commit
bfc04495
authored
Aug 27, 2014
by
Gigg, Martyn Anthony
Browse files
Implement unit tests for Object copy and assignment.
Refs #10178
parent
d1085a4b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Code/Mantid/Framework/Geometry/test/ObjectTest.h
View file @
bfc04495
...
...
@@ -21,6 +21,9 @@
#include
"MantidGeometry/Objects/Track.h"
#include
"MantidGeometry/Rendering/GluGeometryHandler.h"
#include
"MantidGeometry/Objects/BoundingBox.h"
#include
"MantidGeometry/Objects/ShapeFactory.h"
#include
"MantidTestHelpers/ComponentCreationHelper.h"
using
namespace
Mantid
;
using
namespace
Geometry
;
...
...
@@ -31,6 +34,48 @@ class ObjectTest: public CxxTest::TestSuite
public:
void
testCopyConstructorGivesObjectWithSameAttributes
()
{
Object_sptr
original
=
ComponentCreationHelper
::
createSphere
(
1.0
,
V3D
(),
"sphere"
);
int
objType
(
-
1
);
double
radius
(
-
1.0
),
height
(
-
1.0
);
std
::
vector
<
V3D
>
pts
;
original
->
GetObjectGeom
(
objType
,
pts
,
radius
,
height
);
TS_ASSERT_EQUALS
(
2
,
objType
);
TS_ASSERT
(
boost
::
dynamic_pointer_cast
<
GluGeometryHandler
>
(
original
->
getGeometryHandler
()));
Object
copy
(
*
original
);
// The copy should be a primitive object with a GluGeometryHandler
objType
=
-
1
;
copy
.
GetObjectGeom
(
objType
,
pts
,
radius
,
height
);
TS_ASSERT_EQUALS
(
2
,
objType
);
TS_ASSERT
(
boost
::
dynamic_pointer_cast
<
GluGeometryHandler
>
(
copy
.
getGeometryHandler
()));
TS_ASSERT_EQUALS
(
copy
.
getName
(),
original
->
getName
());
// Check the string representation is the same
TS_ASSERT_EQUALS
(
copy
.
str
(),
original
->
str
());
TS_ASSERT_EQUALS
(
copy
.
getSurfaceIndex
(),
original
->
getSurfaceIndex
());
}
void
testAssignmentOperatorGivesObjectWithSameAttributes
()
{
Object_sptr
original
=
ComponentCreationHelper
::
createSphere
(
1.0
,
V3D
(),
"sphere"
);
int
objType
(
-
1
);
double
radius
(
-
1.0
),
height
(
-
1.0
);
std
::
vector
<
V3D
>
pts
;
original
->
GetObjectGeom
(
objType
,
pts
,
radius
,
height
);
TS_ASSERT_EQUALS
(
2
,
objType
);
TS_ASSERT
(
boost
::
dynamic_pointer_cast
<
GluGeometryHandler
>
(
original
->
getGeometryHandler
()));
Object
lhs
;
// initialize
lhs
=
*
original
;
// assign
// The copy should be a primitive object with a GluGeometryHandler
objType
=
-
1
;
lhs
.
GetObjectGeom
(
objType
,
pts
,
radius
,
height
);
TS_ASSERT_EQUALS
(
2
,
objType
);
TS_ASSERT
(
boost
::
dynamic_pointer_cast
<
GluGeometryHandler
>
(
lhs
.
getGeometryHandler
()));
}
void
testCreateUnitCube
()
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment