Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SuperElastix
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirrors
SuperElastix
Commits
99bda6d5
Commit
99bda6d5
authored
9 years ago
by
Floris Berendsen
Browse files
Options
Downloads
Patches
Plain Diff
ENH: integrate ComponentFactory in Unit testing
parent
42d2cb21
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Testing/Unit/CMakeLists.txt
+1
-0
1 addition, 0 deletions
Testing/Unit/CMakeLists.txt
Testing/Unit/elxComponentFactoryTest.cxx
+112
-0
112 additions, 0 deletions
Testing/Unit/elxComponentFactoryTest.cxx
with
113 additions
and
0 deletions
Testing/Unit/CMakeLists.txt
+
1
−
0
View file @
99bda6d5
...
...
@@ -6,6 +6,7 @@
set
(
ElastixUnitTestFilenames
elxExampleUnitTest.cxx
elxBlueprintTest.cxx
elxComponentFactoryTest.cxx
)
...
...
This diff is collapsed.
Click to expand it.
Testing/Unit/elxComponentFactoryTest.cxx
0 → 100644
+
112
−
0
View file @
99bda6d5
#include
"gtest/gtest.h"
#include
"itkTransformComponent1.h"
#include
"itkTransformComponent1Factory.h"
#include
"itkMetricComponent1.h"
#include
"itkMetricComponent1Factory.h"
namespace
{
class
ComponentFactoryTest
:
public
::
testing
::
Test
{
public:
typedef
std
::
list
<
itk
::
LightObject
::
Pointer
>
RegisteredObjectsContainerType
;
typedef
itk
::
ComponentBase
ComponentType
;
typedef
std
::
map
<
std
::
string
,
std
::
string
>
CriteriaType
;
typedef
std
::
pair
<
std
::
string
,
std
::
string
>
CriteriumType
;
typedef
itk
::
ComponentFactory
::
Pointer
NodePointer
;
virtual
void
SetUp
()
{
}
// each node can hold multiple components (or none). Its the overlord's task to make it one per node.
NodePointer
Node1
;
NodePointer
Node2
;
};
TEST_F
(
ComponentFactoryTest
,
EmptyObjectFactoryBase
)
{
// The Component factory is inspired on the ImageIO factory.
// In ITK Components (transformsIO and imageIO) can be preregistered: CMake\UseITK.cmake sets up the IOFactory_Register_Manager
// In Elastix (by Denis) GPU filters are preregistered using (simpleITK's) Typelists and Cmake
// In this test we manually register 2 dummy modules: itkTransformComponent1 and itkMetricComponent1.
RegisteredObjectsContainerType
registeredComponents
;
// "When CMake is not used to register the Component classes, there are"
EXPECT_NO_THROW
(
registeredComponents
=
itk
::
ObjectFactoryBase
::
CreateAllInstance
(
"itkComponentBase"
));
// " 0 Component objects available to the Overlord."
EXPECT_EQ
(
registeredComponents
.
size
(),
0
);
}
TEST_F
(
ComponentFactoryTest
,
FilledObjectFactoryBase
)
{
// In this test we manually register 2 dummy modules: itkTransformComponent1 and itkMetricComponent1.
RegisteredObjectsContainerType
registeredComponents
;
EXPECT_NO_THROW
(
itk
::
TransformComponent1Factory
::
RegisterOneFactory
());
EXPECT_NO_THROW
(
itk
::
MetricComponent1Factory
::
RegisterOneFactory
());
// After registering the TransformComponent1 and MetricComponent1object, there are
EXPECT_NO_THROW
(
registeredComponents
=
itk
::
ObjectFactoryBase
::
CreateAllInstance
(
"itkComponentBase"
));
// " 2 Component objects available to the Overlord."
EXPECT_EQ
(
registeredComponents
.
size
(),
2
);
}
TEST_F
(
ComponentFactoryTest
,
SetEmptyCriteria
)
{
CriteriaType
emptyCriteria
;
ASSERT_NO_THROW
(
Node1
=
itk
::
ComponentFactory
::
New
());
EXPECT_NO_THROW
(
Node1
->
SetCriteria
(
emptyCriteria
));
ComponentType
::
Pointer
Node1Component
;
EXPECT_NO_THROW
(
Node1Component
=
Node1
->
GetComponent
());
//Too few criteria means no Component could be selected."
EXPECT_TRUE
(
Node1Component
.
IsNull
());
}
TEST_F
(
ComponentFactoryTest
,
SetSufficientCriteria
)
{
CriteriaType
criteria2
;
criteria2
[
"ComponentInput"
]
=
"Transform"
;
//criteria1.insert(CriteriumType("ComponentInput", "Metric"));
ASSERT_NO_THROW
(
Node2
=
itk
::
ComponentFactory
::
New
());
Node2
->
SetCriteria
(
criteria2
);
ComponentType
::
Pointer
Node2Component
;
EXPECT_NO_THROW
(
Node2Component
=
Node2
->
GetComponent
());
//Sufficient criteria means one Component was selected."
EXPECT_FALSE
(
Node2Component
.
IsNull
());
//Based on the criteria MetricComponent1 should be selected
EXPECT_STREQ
(
Node2Component
->
GetNameOfClass
(),
"MetricComponent1"
);
}
TEST_F
(
ComponentFactoryTest
,
AddCriteria
)
{
CriteriaType
emptyCriteria
;
CriteriaType
criteria1
;
//criteria1.insert(CriteriumType("ComponentOutput","Metric"));
criteria1
[
"ComponentOutput"
]
=
"Transform"
;
//criteria1.insert(CriteriumType("ComponentInput", "Metric"));
Node1
=
itk
::
ComponentFactory
::
New
();
Node1
->
SetCriteria
(
emptyCriteria
);
EXPECT_NO_THROW
(
Node1
->
AddCriteria
(
criteria1
));
ComponentType
::
Pointer
Node1Component
;
EXPECT_NO_THROW
(
Node1Component
=
Node1
->
GetComponent
());
//Sufficient criteria means one Component was selected."
EXPECT_FALSE
(
Node1Component
.
IsNull
());
//Based on the criteria TransformComponent1 should be selected
EXPECT_STREQ
(
Node1Component
->
GetNameOfClass
(),
"TransformComponent1"
);
}
}
// namespace elx
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment