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
23f858ac
Commit
23f858ac
authored
5 years ago
by
Olivier Stasse
Browse files
Options
Downloads
Patches
Plain Diff
[tests] Add cmake tests.
parent
6cd1a4ce
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
+1
-0
1 addition, 0 deletions
tests/CMakeLists.txt
tests/command-test.cpp
+166
-0
166 additions, 0 deletions
tests/command-test.cpp
with
167 additions
and
0 deletions
tests/CMakeLists.txt
+
1
−
0
View file @
23f858ac
...
@@ -61,3 +61,4 @@ DYNAMIC_GRAPH_TEST(debug-tracer)
...
@@ -61,3 +61,4 @@ DYNAMIC_GRAPH_TEST(debug-tracer)
TARGET_LINK_LIBRARIES
(
debug-tracer tracer
)
TARGET_LINK_LIBRARIES
(
debug-tracer tracer
)
DYNAMIC_GRAPH_TEST
(
debug-logger
)
DYNAMIC_GRAPH_TEST
(
debug-logger
)
DYNAMIC_GRAPH_TEST
(
debug-logger-winit
)
DYNAMIC_GRAPH_TEST
(
debug-logger-winit
)
DYNAMIC_GRAPH_TEST
(
command-test
)
This diff is collapsed.
Click to expand it.
tests/command-test.cpp
0 → 100644
+
166
−
0
View file @
23f858ac
/* Copyright 2019, LAAS-CNRS
*
* Olivier Stasse
*
* See LICENSE file
*
*/
#include
<sstream>
#include
<iostream>
#include
<dynamic-graph/entity.h>
#include
<dynamic-graph/exception-factory.h>
#include
"dynamic-graph/factory.h"
#include
"dynamic-graph/pool.h"
#include
"dynamic-graph/command-bind.h"
#define ENABLE_RT_LOG
#include
<dynamic-graph/real-time-logger.h>
#include
<dynamic-graph/logger.h>
#define BOOST_TEST_MODULE debug-logger
#include
<boost/test/unit_test.hpp>
#include
<boost/test/output_test_stream.hpp>
using
boost
::
test_tools
::
output_test_stream
;
using
namespace
dynamicgraph
::
command
;
namespace
dynamicgraph
{
class
CustomEntity
:
public
Entity
{
public:
static
const
std
::
string
CLASS_NAME
;
bool
test_zero_arg_
;
bool
test_one_arg_
;
bool
test_two_args_
;
bool
test_three_args_
;
bool
test_four_args_
;
virtual
const
std
::
string
&
getClassName
()
const
{
return
CLASS_NAME
;
}
CustomEntity
(
const
std
::
string
n
)
:
Entity
(
n
)
{
test_zero_arg_
=
false
;
test_one_arg_
=
false
;
test_two_args_
=
false
;
test_three_args_
=
false
;
test_four_args_
=
false
;
addCommand
(
"0_arg"
,
makeCommandVoid0
(
*
this
,
&
CustomEntity
::
zero_arg
,
docCommandVoid0
(
"zero arg"
)));
addCommand
(
"1_arg"
,
makeCommandVoid1
(
*
this
,
&
CustomEntity
::
one_arg
,
docCommandVoid1
(
"one arg"
,
"int"
)));
addCommand
(
"2_args"
,
makeCommandVoid2
(
*
this
,
&
CustomEntity
::
two_args
,
docCommandVoid2
(
"two args"
,
"int"
,
"int"
)));
addCommand
(
"3_args"
,
makeCommandVoid3
(
*
this
,
&
CustomEntity
::
three_args
,
docCommandVoid3
(
"three args"
,
"int"
,
"int"
,
"int"
)));
addCommand
(
"4_args"
,
makeCommandVoid4
(
*
this
,
&
CustomEntity
::
four_args
,
docCommandVoid4
(
"four args"
,
"int"
,
"int"
,
"int"
,
"int"
)));
}
~
CustomEntity
()
{
}
void
zero_arg
()
{
test_zero_arg_
=
true
;
}
void
one_arg
(
const
int
&
)
{
test_one_arg_
=
true
;
}
void
two_args
(
const
int
&
,
const
int
&
)
{
test_two_args_
=
true
;
}
void
three_args
(
const
int
&
,
const
int
&
,
const
int
&
)
{
test_three_args_
=
true
;
}
void
four_args
(
const
int
&
,
const
int
&
,
const
int
&
,
const
int
&
)
{
test_four_args_
=
true
;
}
};
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
(
CustomEntity
,
"CustomEntity"
);
}
BOOST_AUTO_TEST_CASE
(
command_test
)
{
dynamicgraph
::
CustomEntity
&
entity
=
*
(
dynamic_cast
<
dynamicgraph
::
CustomEntity
*>
(
dynamicgraph
::
FactoryStorage
::
getInstance
()
->
newEntity
(
"CustomEntity"
,
"my-entity"
)));
std
::
map
<
const
std
::
string
,
Command
*>
aCommandMap
=
entity
.
getNewStyleCommandMap
();
std
::
map
<
const
std
::
string
,
Command
*>::
iterator
it_map
;
it_map
=
aCommandMap
.
find
(
"0_arg"
);
if
(
it_map
==
aCommandMap
.
end
())
BOOST_CHECK
(
false
);
it_map
->
second
->
execute
();
BOOST_CHECK
(
entity
.
test_zero_arg_
);
int
first_arg
=
1
;
Value
aValue
(
first_arg
);
std
::
vector
<
std
::
string
>
vec_fname
(
4
);
vec_fname
[
0
]
=
"1_arg"
;
vec_fname
[
1
]
=
"2_args"
;
vec_fname
[
2
]
=
"3_args"
;
vec_fname
[
3
]
=
"4_args"
;
std
::
vector
<
Value
>
values
;
for
(
unsigned
int
i
=
0
;
i
<
4
;
i
++
)
{
it_map
=
aCommandMap
.
find
(
vec_fname
[
i
]);
if
(
it_map
==
aCommandMap
.
end
())
BOOST_CHECK
(
false
);
values
.
push_back
(
aValue
);
it_map
->
second
->
setParameterValues
(
values
);
it_map
->
second
->
execute
();
}
BOOST_CHECK
(
entity
.
test_one_arg_
);
BOOST_CHECK
(
entity
.
test_two_args_
);
BOOST_CHECK
(
entity
.
test_three_args_
);
BOOST_CHECK
(
entity
.
test_four_args_
);
}
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