Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
dynamic-graph
Commits
00b2d6ce
Commit
00b2d6ce
authored
Feb 28, 2019
by
Olivier Stasse
Browse files
[tests] Increase the coverage of unit tests for pool object.
parent
4f18015a
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/pool.cpp
View file @
00b2d6ce
...
...
@@ -14,6 +14,7 @@
// along with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
#include
<sstream>
#include
<iostream>
#include
<dynamic-graph/entity.h>
#include
<dynamic-graph/factory.h>
#include
<dynamic-graph/exception-factory.h>
...
...
@@ -47,18 +48,48 @@ struct MyEntity : public dynamicgraph::Entity
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
(
MyEntity
,
"MyEntity"
);
namespace
dg
=
dynamicgraph
;
BOOST_AUTO_TEST_CASE
(
pool_display
)
{
dynamicgraph
::
Entity
*
entity
=
dynamicgraph
::
FactoryStorage
::
getInstance
()
->
// Create Entity
dg
::
Entity
*
entity
=
dg
::
FactoryStorage
::
getInstance
()
->
newEntity
(
"MyEntity"
,
"MyEntityInst"
);
// Search for an entity inside the map
output_test_stream
output
;
d
ynamicgraph
::
Entity
&
e
=
d
ynamicgraph
::
PoolStorage
::
getInstance
()
->
getEntity
d
g
::
Entity
&
e
=
d
g
::
PoolStorage
::
getInstance
()
->
getEntity
(
"MyEntityInst"
);
e
.
display
(
output
);
BOOST_CHECK
(
output
.
is_equal
(
"Hello! My name is MyEntityInst !
\n
"
));
dynamicgraph
::
PoolStorage
::
getInstance
()
->
deregisterEntity
// Testing entityMap
const
dg
::
PoolStorage
::
Entities
&
anEntityMap
=
dg
::
PoolStorage
::
getInstance
()
->
getEntityMap
();
bool
testExistence
=
anEntityMap
.
find
(
"MyEntityInst"
)
==
anEntityMap
.
end
();
BOOST_CHECK
(
!
testExistence
);
// Testing the existence of an entity
testExistence
=
dg
::
PoolStorage
::
getInstance
()
->
existEntity
(
"MyEntityInst"
,
entity
);
BOOST_CHECK
(
testExistence
);
// Testing the completion list of pool storage
dg
::
PoolStorage
::
getInstance
()
->
writeCompletionList
(
output
);
BOOST_CHECK
(
output
.
is_equal
(
"print
\n
signals
\n
signalDep
\n
"
));
// Deregister the entity.
dg
::
PoolStorage
::
getInstance
()
->
deregisterEntity
(
entity
->
getName
());
dynamicgraph
::
PoolStorage
::
destroy
();
// Testing the existance of an entity
testExistence
=
dg
::
PoolStorage
::
getInstance
()
->
existEntity
(
"MyEntityInst"
,
entity
);
BOOST_CHECK
(
!
testExistence
);
dg
::
PoolStorage
::
destroy
();
}
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