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
Stack Of Tasks
dynamic-graph
Commits
0b05a14e
Commit
0b05a14e
authored
13 years ago
by
Nicolas Mansard
Browse files
Options
Downloads
Patches
Plain Diff
Account for the Entity::getClassName becoming pure virtual.
parent
7a974b89
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/custom-entity.cpp
+1
-1
1 addition, 1 deletion
tests/custom-entity.cpp
tests/entity.cpp
+39
-19
39 additions, 19 deletions
tests/entity.cpp
tests/factory.cpp
+21
-1
21 additions, 1 deletion
tests/factory.cpp
with
61 additions
and
21 deletions
tests/custom-entity.cpp
+
1
−
1
View file @
0b05a14e
...
...
@@ -29,7 +29,7 @@ struct CustomEntity : public dynamicgraph::Entity
{
static
const
std
::
string
CLASS_NAME
;
virtual
const
std
::
string
&
getClassName
()
virtual
const
std
::
string
&
getClassName
()
const
{
return
CLASS_NAME
;
}
...
...
This diff is collapsed.
Click to expand it.
tests/entity.cpp
+
39
−
19
View file @
0b05a14e
...
...
@@ -16,6 +16,7 @@
#include
<sstream>
#include
<dynamic-graph/entity.h>
#include
<dynamic-graph/exception-factory.h>
#include
<dynamic-graph/factory.h>
#define BOOST_TEST_MODULE entity
...
...
@@ -24,20 +25,39 @@
using
boost
::
test_tools
::
output_test_stream
;
namespace
dynamicgraph
{
class
CustomEntity
:
public
Entity
{
public:
static
const
std
::
string
CLASS_NAME
;
virtual
const
std
::
string
&
getClassName
()
const
{
return
CLASS_NAME
;
}
CustomEntity
(
const
std
::
string
n
)
:
Entity
(
n
)
{
}
};
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
(
CustomEntity
,
"CustomEntity"
);
}
BOOST_AUTO_TEST_CASE
(
constructor
)
{
BOOST_CHECK_EQUAL
(
dynamicgraph
::
Entity
::
CLASS_NAME
,
"Entity"
);
BOOST_CHECK_EQUAL
(
dynamicgraph
::
Custom
Entity
::
CLASS_NAME
,
"
Custom
Entity"
);
dynamicgraph
::
Entity
entity
(
"my-entity"
);
BOOST_CHECK_EQUAL
(
entity
.
getName
(),
"my-entity"
);
BOOST_CHECK_EQUAL
(
entity
.
getClassName
(),
dynamicgraph
::
Entity
::
CLASS_NAME
);
dynamicgraph
::
Custom
Entity
entity
(
"my-entity"
);
BOOST_CHECK_EQUAL
(
entity
.
getName
(),
"my-entity"
);
BOOST_CHECK_EQUAL
(
entity
.
getClassName
(),
dynamicgraph
::
Entity
::
CLASS_NAME
);
dynamicgraph
::
Entity
entity2
(
""
);
dynamicgraph
::
Custom
Entity
entity2
(
""
);
}
BOOST_AUTO_TEST_CASE
(
signal
)
{
dynamicgraph
::
Entity
entity
(
""
);
dynamicgraph
::
Custom
Entity
entity
(
""
);
// Non const getter.
try
...
...
@@ -54,7 +74,7 @@ BOOST_AUTO_TEST_CASE (signal)
// Const getter.
try
{
const
dynamicgraph
::
Entity
&
entityConst
=
entity
;
const
dynamicgraph
::
Custom
Entity
&
entityConst
=
entity
;
entityConst
.
getSignal
(
"I do not exist"
);
BOOST_ERROR
(
"Should never happen."
);
}
...
...
@@ -67,7 +87,7 @@ BOOST_AUTO_TEST_CASE (signal)
BOOST_AUTO_TEST_CASE
(
displaySignalList
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
dynamicgraph
::
Custom
Entity
entity
(
"my-entity"
);
output_test_stream
output
;
...
...
@@ -77,7 +97,7 @@ BOOST_AUTO_TEST_CASE (displaySignalList)
BOOST_AUTO_TEST_CASE
(
display
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
dynamicgraph
::
Custom
Entity
entity
(
"my-entity"
);
output_test_stream
output
;
...
...
@@ -87,13 +107,13 @@ BOOST_AUTO_TEST_CASE (display)
BOOST_AUTO_TEST_CASE
(
getCommandList
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
dynamicgraph
::
Custom
Entity
entity
(
"my-entity"
);
BOOST_CHECK_EQUAL
(
entity
.
getCommandList
(),
"print
\n
signals
\n
signalDep"
);
}
BOOST_AUTO_TEST_CASE
(
commandLine_help
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
dynamicgraph
::
Custom
Entity
entity
(
"my-entity"
);
output_test_stream
output
;
...
...
@@ -112,19 +132,19 @@ BOOST_AUTO_TEST_CASE (commandLine_help)
BOOST_AUTO_TEST_CASE
(
commandLine_print
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
dynamicgraph
::
Custom
Entity
entity
(
"my-entity"
);
output_test_stream
output
;
std
::
istringstream
args
;
entity
.
commandLine
(
"print"
,
args
,
output
);
BOOST_CHECK
(
output
.
is_equal
(
"Entity: my-entity
\n
"
));
BOOST_CHECK
(
output
.
is_equal
(
"
Custom
Entity: my-entity
\n
"
));
}
BOOST_AUTO_TEST_CASE
(
commandLine_signals
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
dynamicgraph
::
Custom
Entity
entity
(
"my-entity"
);
output_test_stream
output
;
...
...
@@ -137,7 +157,7 @@ BOOST_AUTO_TEST_CASE (commandLine_signals)
// FIXME: is it what we should expect?
BOOST_AUTO_TEST_CASE
(
commandLine_signalDep
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
dynamicgraph
::
Custom
Entity
entity
(
"my-entity"
);
output_test_stream
output
;
...
...
@@ -159,7 +179,7 @@ BOOST_AUTO_TEST_CASE (commandLine_signalDep)
BOOST_AUTO_TEST_CASE
(
commandLine_unknown
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
dynamicgraph
::
Custom
Entity
entity
(
"my-entity"
);
output_test_stream
output
;
...
...
@@ -181,7 +201,7 @@ BOOST_AUTO_TEST_CASE (commandLine_unknown)
BOOST_AUTO_TEST_CASE
(
writeGraph
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
dynamicgraph
::
Custom
Entity
entity
(
"my-entity"
);
output_test_stream
output
;
entity
.
writeGraph
(
output
);
...
...
@@ -191,7 +211,7 @@ BOOST_AUTO_TEST_CASE (writeGraph)
BOOST_AUTO_TEST_CASE
(
writeCompletionList
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
dynamicgraph
::
Custom
Entity
entity
(
"my-entity"
);
output_test_stream
output
;
entity
.
writeGraph
(
output
);
...
...
@@ -202,7 +222,7 @@ BOOST_AUTO_TEST_CASE (writeCompletionList)
// WTF?
BOOST_AUTO_TEST_CASE
(
wtf
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
dynamicgraph
::
Custom
Entity
entity
(
"my-entity"
);
BOOST_CHECK_EQUAL
(
entity
.
test
(),
static_cast
<
dynamicgraph
::
SignalBase
<
int
>*>
(
0
));
...
...
This diff is collapsed.
Click to expand it.
tests/factory.cpp
+
21
−
1
View file @
0b05a14e
...
...
@@ -26,9 +26,29 @@
using
boost
::
test_tools
::
output_test_stream
;
namespace
dynamicgraph
{
class
CustomEntity
:
public
Entity
{
public:
static
const
std
::
string
CLASS_NAME
;
virtual
const
std
::
string
&
getClassName
()
const
{
return
CLASS_NAME
;
}
CustomEntity
(
const
std
::
string
n
)
:
Entity
(
n
)
{
}
};
const
std
::
string
CustomEntity
::
CLASS_NAME
=
"CustomEntity"
;
}
dynamicgraph
::
Entity
*
makeEntity
(
const
std
::
string
&
objectName
)
{
return
new
dynamicgraph
::
Entity
(
objectName
);
return
new
dynamicgraph
::
Custom
Entity
(
objectName
);
}
...
...
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