Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guilhem Saurel
dynamic-graph
Commits
a955e307
Commit
a955e307
authored
Jan 15, 2020
by
Olivier Stasse
Committed by
olivier stasse
Jan 16, 2020
Browse files
[tests] Improve coverage of entity.
parent
ed29cdae
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/entity.cpp
View file @
a955e307
...
...
@@ -26,7 +26,7 @@ using boost::test_tools::output_test_stream;
namespace
dynamicgraph
{
class
CustomEntity
:
public
Entity
{
public:
dynamicgraph
::
SignalPtr
<
double
,
int
>
m_sigdSIN
;
dynamicgraph
::
SignalPtr
<
double
,
int
>
m_sigdSIN
,
m_sigdSIN2
;
dynamicgraph
::
SignalTimeDependent
<
double
,
int
>
m_sigdTimeDepSOUT
;
static
const
std
::
string
CLASS_NAME
;
...
...
@@ -34,13 +34,24 @@ public:
CustomEntity
(
const
std
::
string
n
)
:
Entity
(
n
),
m_sigdSIN
(
NULL
,
"CustomEntity("
+
name
+
")::input(double)::in_double"
),
m_sigdSIN2
(
NULL
,
"CustomEntity("
+
name
+
")::input(double)::in_double"
),
m_sigdTimeDepSOUT
(
boost
::
bind
(
&
CustomEntity
::
update
,
this
,
_1
,
_2
),
m_sigdSIN
,
"CustomEntity("
+
name
+
")::input(double)::out_double"
)
{}
void
addSignal
()
{
signalRegistration
(
m_sigdSIN
<<
m_sigdTimeDepSOUT
);
}
"CustomEntity("
+
name
+
")::input(double)::out_double"
)
{}
~
CustomEntity
()
{
entityDeregistration
();
}
void
addSignal
()
{
signalRegistration
(
m_sigdSIN
<<
m_sigdTimeDepSOUT
);
/// Try a second time to generate an exception
try
{
signalRegistration
(
m_sigdSIN2
<<
m_sigdTimeDepSOUT
);
}
catch
(
ExceptionFactory
&
aef
)
{
BOOST_CHECK_EQUAL
(
aef
.
getCode
(),
dynamicgraph
::
ExceptionFactory
::
SIGNAL_CONFLICT
);
}
}
void
rmValidSignal
()
{
signalDeregistration
(
"in_double"
);
...
...
@@ -90,6 +101,9 @@ BOOST_AUTO_TEST_CASE(constructor) {
output_test_stream
output
;
output
<<
entity2
.
m_value
;
output
<<
entity2
;
entity
.
getDocString
();
}
BOOST_AUTO_TEST_CASE
(
signal
)
{
...
...
@@ -119,6 +133,12 @@ BOOST_AUTO_TEST_CASE(signal) {
dynamicgraph
::
CustomEntity
*
customEntity
=
dynamic_cast
<
dynamicgraph
::
CustomEntity
*>
(
&
entity
);
customEntity
->
addSignal
();
std
::
string
signame
(
"CustomEntity(my-entity)::input(double)::in_double"
);
customEntity
->
Entity
::
hasSignal
(
signame
);
output_test_stream
output
;
customEntity
->
Entity
::
displaySignalList
(
output
);
dynamicgraph
::
Entity
::
SignalMap
asigmap
=
customEntity
->
getSignalMap
();
output
<<
customEntity
;
// Removing signals is working the first time
customEntity
->
rmValidSignal
();
// Removing signals generates an exception the second time.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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