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
86cfe22b
Commit
86cfe22b
authored
14 years ago
by
Thomas Moulard
Browse files
Options
Downloads
Patches
Plain Diff
Add unit test for Entity class.
parent
38c251ae
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
tests/CMakeLists.txt
+3
-0
3 additions, 0 deletions
tests/CMakeLists.txt
tests/entity.cpp
+190
-0
190 additions, 0 deletions
tests/entity.cpp
with
193 additions
and
0 deletions
tests/CMakeLists.txt
+
3
−
0
View file @
86cfe22b
...
...
@@ -55,3 +55,6 @@ FOREACH(lib ${signalcast_libs})
ENDFOREACH
()
DYNAMIC_GRAPH_TEST
(
test_signalcast
)
TARGET_LINK_LIBRARIES
(
${
EXECUTABLE_NAME
}
${
signalcast_libs
}
)
# Unit testing.
DYNAMIC_GRAPH_TEST
(
entity
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/entity.cpp
0 → 100644
+
190
−
0
View file @
86cfe22b
// Copyright 2010 Thomas Moulard.
//
// This file is part of dynamic-graph.
// dynamic-graph is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// dynamic-graph is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public License
// along with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
#include
<sstream>
#include
<dynamic-graph/entity.h>
#include
<dynamic-graph/exception-factory.h>
#define BOOST_TEST_MODULE entity
#include
<boost/test/unit_test.hpp>
#include
<boost/test/output_test_stream.hpp>
using
boost
::
test_tools
::
output_test_stream
;
BOOST_AUTO_TEST_CASE
(
constructor
)
{
BOOST_CHECK_EQUAL
(
dynamicgraph
::
Entity
::
CLASS_NAME
,
"Entity"
);
dynamicgraph
::
Entity
entity
(
"my-entity"
);
BOOST_CHECK_EQUAL
(
entity
.
getName
(),
"my-entity"
);
BOOST_CHECK_EQUAL
(
entity
.
getClassName
(),
dynamicgraph
::
Entity
::
CLASS_NAME
);
dynamicgraph
::
Entity
entity2
(
""
);
}
BOOST_AUTO_TEST_CASE
(
signal
)
{
dynamicgraph
::
Entity
entity
(
""
);
// Non const getter.
try
{
entity
.
getSignal
(
"I do not exist"
);
}
catch
(
dynamicgraph
::
ExceptionFactory
&
exception
)
{
//FIXME: getCode should be const.
BOOST_CHECK_EQUAL
(
exception
.
getCode
(),
dynamicgraph
::
ExceptionFactory
::
UNREFERED_SIGNAL
);
}
// Const getter.
try
{
const
dynamicgraph
::
Entity
&
entityConst
=
entity
;
entityConst
.
getSignal
(
"I do not exist"
);
}
catch
(
dynamicgraph
::
ExceptionFactory
&
exception
)
{
//FIXME: getCode should be const.
BOOST_CHECK_EQUAL
(
exception
.
getCode
(),
dynamicgraph
::
ExceptionFactory
::
UNREFERED_SIGNAL
);
}
}
BOOST_AUTO_TEST_CASE
(
displaySignalList
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
output_test_stream
output
;
entity
.
displaySignalList
(
output
);
BOOST_CHECK
(
output
.
is_equal
(
"--- <my-entity> signal list:
\n
"
));
}
BOOST_AUTO_TEST_CASE
(
display
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
output_test_stream
output
;
entity
.
display
(
output
);
BOOST_CHECK
(
output
.
is_equal
(
"Entity: my-entity"
));
}
BOOST_AUTO_TEST_CASE
(
getCommandList
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
//FIXME: this is wrong, another available command is help.
BOOST_CHECK_EQUAL
(
entity
.
getCommandList
(),
"print
\n
signals
\n
signalDep"
);
}
BOOST_AUTO_TEST_CASE
(
commandLine_help
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
output_test_stream
output
;
std
::
istringstream
args
;
entity
.
commandLine
(
"help"
,
args
,
output
);
BOOST_CHECK
(
output
.
is_equal
(
"Entity :
\n
"
" - print
\t\t\t
What d'you think?
\n
"
" - signals
\t\t\t
Display the signals list.
\n
"
" - signalDep <signame>
\t
Display the dependency graph for signal signame.
\n
"
));
}
BOOST_AUTO_TEST_CASE
(
commandLine_print
)
{
dynamicgraph
::
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_AUTO_TEST_CASE
(
commandLine_signals
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
output_test_stream
output
;
std
::
istringstream
args
;
entity
.
commandLine
(
"signals"
,
args
,
output
);
BOOST_CHECK
(
output
.
is_equal
(
"--- <my-entity> signal list:
\n
"
));
}
// FIXME: is it what we should expect?
BOOST_AUTO_TEST_CASE
(
commandLine_signalDep
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
output_test_stream
output
;
std
::
istringstream
args
;
try
{
entity
.
commandLine
(
"signalDep"
,
args
,
output
);
}
catch
(
dynamicgraph
::
ExceptionFactory
&
exception
)
{
//FIXME: getCode should be const.
BOOST_CHECK_EQUAL
(
exception
.
getCode
(),
dynamicgraph
::
ExceptionFactory
::
UNREFERED_SIGNAL
);
}
BOOST_CHECK
(
output
.
is_empty
());
}
BOOST_AUTO_TEST_CASE
(
writeGraph
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
output_test_stream
output
;
entity
.
writeGraph
(
output
);
BOOST_CHECK
(
output
.
is_equal
(
""
));
}
BOOST_AUTO_TEST_CASE
(
writeCompletionList
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
output_test_stream
output
;
entity
.
writeGraph
(
output
);
BOOST_CHECK
(
output
.
is_equal
(
""
));
}
// WTF?
BOOST_AUTO_TEST_CASE
(
wtf
)
{
dynamicgraph
::
Entity
entity
(
"my-entity"
);
BOOST_CHECK_EQUAL
(
entity
.
test
(),
static_cast
<
dynamicgraph
::
SignalBase
<
int
>*>
(
0
));
entity
.
test2
(
static_cast
<
dynamicgraph
::
SignalBase
<
int
>*>
(
0
));
}
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