Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynamic-graph
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
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
Olivier Stasse
dynamic-graph
Commits
e7614beb
Commit
e7614beb
authored
6 years ago
by
Olivier Stasse
Browse files
Options
Downloads
Patches
Plain Diff
[tests] Improve test on pool
Testing and checking output of writeGraph.
parent
00b2d6ce
No related branches found
No related tags found
No related merge requests found
Pipeline
#3111
failed
6 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/pool.cpp
+55
-2
55 additions, 2 deletions
tests/pool.cpp
with
55 additions
and
2 deletions
tests/pool.cpp
+
55
−
2
View file @
e7614beb
...
...
@@ -19,6 +19,8 @@
#include
<dynamic-graph/factory.h>
#include
<dynamic-graph/exception-factory.h>
#include
<dynamic-graph/pool.h>
#include
<dynamic-graph/signal-ptr.h>
#include
<dynamic-graph/signal-time-dependent.h>
#define BOOST_TEST_MODULE pool
...
...
@@ -31,9 +33,18 @@ struct MyEntity : public dynamicgraph::Entity
{
static
const
std
::
string
CLASS_NAME
;
dynamicgraph
::
SignalPtr
<
double
,
int
>
m_sigdSIN
;
dynamicgraph
::
SignalTimeDependent
<
double
,
int
>
m_sigdTimeDepSOUT
;
MyEntity
(
const
std
::
string
&
name
)
:
Entity
(
name
)
{}
,
m_sigdSIN
(
NULL
,
"MyEntity("
+
name
+
")::input(double)::in_double"
)
,
m_sigdTimeDepSOUT
(
boost
::
bind
(
&
MyEntity
::
update
,
this
,
_1
,
_2
),
m_sigdSIN
,
"MyEntity("
+
name
+
")::input(double)::out_double"
)
{
signalRegistration
(
m_sigdSIN
<<
m_sigdTimeDepSOUT
);
}
virtual
void
display
(
std
::
ostream
&
os
)
const
{
...
...
@@ -44,6 +55,14 @@ struct MyEntity : public dynamicgraph::Entity
{
return
CLASS_NAME
;
}
double
&
update
(
double
&
res
,
const
int
&
inTime
)
{
const
double
&
aDouble
=
m_sigdSIN
(
inTime
);
res
=
aDouble
;
return
res
;
}
};
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
(
MyEntity
,
"MyEntity"
);
...
...
@@ -80,7 +99,41 @@ BOOST_AUTO_TEST_CASE (pool_display)
// Testing the completion list of pool storage
dg
::
PoolStorage
::
getInstance
()
->
writeCompletionList
(
output
);
BOOST_CHECK
(
output
.
is_equal
(
"print
\n
signals
\n
signalDep
\n
"
));
BOOST_CHECK
(
output
.
is_equal
(
"MyEntityInst.in_double
\n
MyEntityInst.out_double
\n
print
\n
signals
\n
signalDep
\n
"
));
// Checking the graph generated by the pool
dg
::
PoolStorage
::
getInstance
()
->
writeGraph
(
"output.dot"
);
std
::
fstream
the_debug_file
;
the_debug_file
.
open
(
"output.dot"
);
std
::
ostringstream
oss_output_wgph
;
oss_output_wgph
<<
the_debug_file
.
rdbuf
();
the_debug_file
.
close
();
/* Use a predefined output */
std
::
string
str_to_test
=
"/* This graph has been automatically generated.
\n
"
" 2019 Month: 2 Day: 28 Time: 11:28 */
\n
"
"digraph
\"
output
\"
{ graph [ label=
\"
output
\"
bgcolor = white rankdir=LR ]
\n
"
"
\t
node [ fontcolor = black, color = black, fillcolor = gold1, style=filled, shape=box ] ;
\n
"
"
\t
subgraph cluster_Entities {
\n
"
"
\t
}
\n
"
"
\"
MyEntityInst
\"
[ label =
\"
MyEntityInst
\"
,
\n
"
" fontcolor = black, color = black, fillcolor=cyan, style=filled, shape=box ]
\n
"
"}
\n
"
;
/* Check the two substring (remove the date) */
std
::
string
s_output_wgph
=
oss_output_wgph
.
str
();
std
::
string
s_crmk
=
"*/"
;
std
::
size_t
find_s_output_wgph
=
s_output_wgph
.
find
(
s_crmk
);
std
::
string
sub_s_output_wgph
=
s_output_wgph
.
substr
(
find_s_output_wgph
,
s_output_wgph
.
length
());
std
::
size_t
find_str_to_test
=
str_to_test
.
find
(
s_crmk
);
std
::
string
sub_str_to_test
=
str_to_test
.
substr
(
find_str_to_test
,
str_to_test
.
length
());
bool
two_sub_string_identical
;
two_sub_string_identical
=
sub_str_to_test
==
sub_s_output_wgph
;
BOOST_CHECK
(
two_sub_string_identical
);
// Deregister the entity.
dg
::
PoolStorage
::
getInstance
()
->
deregisterEntity
...
...
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