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
Guilhem Saurel
dynamic-graph
Commits
933ea05c
Commit
933ea05c
authored
5 years ago
by
Olivier Stasse
Committed by
olivier stasse
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[tests] Improve tests on value.cpp
parent
6441dda2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/value.cpp
+128
-14
128 additions, 14 deletions
tests/value.cpp
with
128 additions
and
14 deletions
tests/value.cpp
+
128
−
14
View file @
933ea05c
// Copyright 2011 Florent Lamiraux, Thomas Moulard.
// Copyright 2011 Florent Lamiraux, Thomas Moulard.
//
//
#include
<dynamic-graph/exception-factory.h>
#include
"dynamic-graph/value.h"
#include
"dynamic-graph/value.h"
#include
<iostream>
#include
<iostream>
...
@@ -11,21 +12,24 @@
...
@@ -11,21 +12,24 @@
using
boost
::
test_tools
::
output_test_stream
;
using
boost
::
test_tools
::
output_test_stream
;
BOOST_AUTO_TEST_CASE
(
value_none
)
{
namespace
dg
=
dynamicgraph
;
using
dynamicgraph
::
command
::
Value
;
Value
value1
();
BOOST_AUTO_TEST_CASE
(
value_none
)
{
using
dg
::
command
::
Value
;
Value
value1
;
Value
value
(
value1
);
{
{
output_test_stream
output
;
output_test_stream
output
;
output
<<
value1
;
output
<<
value1
;
BOOST_CHECK
(
output
.
is_equal
(
"
1
"
));
BOOST_CHECK
(
output
.
is_equal
(
"
Type=unknown, value=
"
));
}
}
}
}
BOOST_AUTO_TEST_CASE
(
value_bool
)
{
BOOST_AUTO_TEST_CASE
(
value_bool
)
{
using
d
ynamicgraph
::
command
::
Value
;
using
d
g
::
command
::
Value
;
bool
abool1
(
false
);
bool
abool1
(
false
);
Value
value1
(
abool1
);
Value
value1
(
abool1
);
...
@@ -44,8 +48,118 @@ BOOST_AUTO_TEST_CASE(value_bool) {
...
@@ -44,8 +48,118 @@ BOOST_AUTO_TEST_CASE(value_bool) {
}
}
}
}
BOOST_AUTO_TEST_CASE
(
value_exceptions
)
{
using
dg
::
command
::
Value
;
Value
value1
;
dg
::
command
::
EitherType
anet
(
value1
);
output_test_stream
output
;
// Check if the exception is working when calling intValue
// while we are having a none.
bool
res
=
false
;
try
{
int
aInt
(
anet
);
output
<<
aInt
;
}
catch
(
const
dg
::
ExceptionAbstract
&
aea
)
{
res
=
(
aea
.
getCode
()
==
dg
::
ExceptionAbstract
::
TOOLS
);
}
BOOST_CHECK
(
res
);
// Check if the exception is working when calling boolValue
// while we are having a none.
res
=
false
;
try
{
bool
abool
(
anet
);
output
<<
abool
;
}
catch
(
const
dg
::
ExceptionAbstract
&
aea
)
{
res
=
(
aea
.
getCode
()
==
dg
::
ExceptionAbstract
::
TOOLS
);
}
BOOST_CHECK
(
res
);
// Check if the exception is working when calling unsignedintValue
// while we are having a none.
res
=
false
;
try
{
unsigned
int
aint
(
anet
);
output
<<
aint
;
}
catch
(
const
dg
::
ExceptionAbstract
&
aea
)
{
res
=
(
aea
.
getCode
()
==
dg
::
ExceptionAbstract
::
TOOLS
);
}
BOOST_CHECK
(
res
);
// Check if the exception is working when calling doubleValue
// while we are having a none.
res
=
false
;
try
{
double
adouble
(
anet
);
output
<<
adouble
;
}
catch
(
const
dg
::
ExceptionAbstract
&
aea
)
{
res
=
(
aea
.
getCode
()
==
dg
::
ExceptionAbstract
::
TOOLS
);
}
BOOST_CHECK
(
res
);
// Check if the exception is working when calling floatValue
// while we are having a none.
res
=
false
;
try
{
float
afloat
(
anet
);
output
<<
afloat
;
}
catch
(
const
dg
::
ExceptionAbstract
&
aea
)
{
res
=
(
aea
.
getCode
()
==
dg
::
ExceptionAbstract
::
TOOLS
);
}
BOOST_CHECK
(
res
);
// Check if the exception is working when calling stringValue
// while we are having a none.
res
=
false
;
try
{
std
::
string
astring
(
anet
);
output
<<
astring
;
}
catch
(
const
dg
::
ExceptionAbstract
&
aea
)
{
res
=
(
aea
.
getCode
()
==
dg
::
ExceptionAbstract
::
TOOLS
);
}
BOOST_CHECK
(
res
);
// Check if the exception is working when calling vectorValue
// while we are having a none.
res
=
false
;
try
{
dg
::
Vector
avector
;
avector
=
anet
;
output
<<
avector
;
}
catch
(
const
dg
::
ExceptionAbstract
&
aea
)
{
res
=
(
aea
.
getCode
()
==
dg
::
ExceptionAbstract
::
TOOLS
);
}
BOOST_CHECK
(
res
);
// Check if the exception is working when calling matrixXdValue
// while we are having a none.
res
=
false
;
try
{
Eigen
::
MatrixXd
amatrixXd
;
amatrixXd
=
anet
;
output
<<
amatrixXd
;
}
catch
(
const
dg
::
ExceptionAbstract
&
aea
)
{
res
=
(
aea
.
getCode
()
==
dg
::
ExceptionAbstract
::
TOOLS
);
}
BOOST_CHECK
(
res
);
// Check if the exception is working when calling matrix4dValue
// while we are having a none.
res
=
false
;
try
{
Eigen
::
Matrix4d
amatrix4d
;
amatrix4d
=
anet
;
}
catch
(
const
dg
::
ExceptionAbstract
&
aea
)
{
res
=
(
aea
.
getCode
()
==
dg
::
ExceptionAbstract
::
TOOLS
);
}
BOOST_CHECK
(
res
);
}
BOOST_AUTO_TEST_CASE
(
value_unsigned_int
)
{
BOOST_AUTO_TEST_CASE
(
value_unsigned_int
)
{
using
d
ynamicgraph
::
command
::
Value
;
using
d
g
::
command
::
Value
;
unsigned
int
aint1
(
5
);
unsigned
int
aint1
(
5
);
Value
value1
(
aint1
);
Value
value1
(
aint1
);
...
@@ -65,7 +179,7 @@ BOOST_AUTO_TEST_CASE(value_unsigned_int) {
...
@@ -65,7 +179,7 @@ BOOST_AUTO_TEST_CASE(value_unsigned_int) {
}
}
BOOST_AUTO_TEST_CASE
(
value_int
)
{
BOOST_AUTO_TEST_CASE
(
value_int
)
{
using
d
ynamicgraph
::
command
::
Value
;
using
d
g
::
command
::
Value
;
int
aint1
(
5
);
int
aint1
(
5
);
Value
value1
(
aint1
);
Value
value1
(
aint1
);
...
@@ -85,7 +199,7 @@ BOOST_AUTO_TEST_CASE(value_int) {
...
@@ -85,7 +199,7 @@ BOOST_AUTO_TEST_CASE(value_int) {
}
}
BOOST_AUTO_TEST_CASE
(
value_float
)
{
BOOST_AUTO_TEST_CASE
(
value_float
)
{
using
d
ynamicgraph
::
command
::
Value
;
using
d
g
::
command
::
Value
;
float
afloat1
(
0.5
);
float
afloat1
(
0.5
);
Value
value1
(
afloat1
);
Value
value1
(
afloat1
);
...
@@ -105,7 +219,7 @@ BOOST_AUTO_TEST_CASE(value_float) {
...
@@ -105,7 +219,7 @@ BOOST_AUTO_TEST_CASE(value_float) {
}
}
BOOST_AUTO_TEST_CASE
(
value_double
)
{
BOOST_AUTO_TEST_CASE
(
value_double
)
{
using
d
ynamicgraph
::
command
::
Value
;
using
d
g
::
command
::
Value
;
double
adouble1
(
0.5
);
double
adouble1
(
0.5
);
Value
value1
(
adouble1
);
Value
value1
(
adouble1
);
...
@@ -125,9 +239,9 @@ BOOST_AUTO_TEST_CASE(value_double) {
...
@@ -125,9 +239,9 @@ BOOST_AUTO_TEST_CASE(value_double) {
}
}
BOOST_AUTO_TEST_CASE
(
value_vector
)
{
BOOST_AUTO_TEST_CASE
(
value_vector
)
{
using
d
ynamicgraph
::
command
::
Value
;
using
d
g
::
command
::
Value
;
d
ynamicgraph
::
Vector
avector1
;
d
g
::
Vector
avector1
;
avector1
.
resize
(
2
);
avector1
.
resize
(
2
);
avector1
[
0
]
=
0.5
;
avector1
[
1
]
=
1.5
;
avector1
[
0
]
=
0.5
;
avector1
[
1
]
=
1.5
;
Value
value1
(
avector1
);
Value
value1
(
avector1
);
...
@@ -147,7 +261,7 @@ BOOST_AUTO_TEST_CASE(value_vector) {
...
@@ -147,7 +261,7 @@ BOOST_AUTO_TEST_CASE(value_vector) {
}
}
BOOST_AUTO_TEST_CASE
(
value_string
)
{
BOOST_AUTO_TEST_CASE
(
value_string
)
{
using
d
ynamicgraph
::
command
::
Value
;
using
d
g
::
command
::
Value
;
std
::
string
str1
(
"value #1"
);
std
::
string
str1
(
"value #1"
);
Value
value1
(
str1
);
Value
value1
(
str1
);
...
@@ -183,7 +297,7 @@ BOOST_AUTO_TEST_CASE(value_string) {
...
@@ -183,7 +297,7 @@ BOOST_AUTO_TEST_CASE(value_string) {
}
}
BOOST_AUTO_TEST_CASE
(
value_matrixXd
)
{
BOOST_AUTO_TEST_CASE
(
value_matrixXd
)
{
using
d
ynamicgraph
::
command
::
Value
;
using
d
g
::
command
::
Value
;
Eigen
::
MatrixXd
avector1
;
Eigen
::
MatrixXd
avector1
;
avector1
.
resize
(
2
,
2
);
avector1
.
resize
(
2
,
2
);
...
@@ -206,7 +320,7 @@ BOOST_AUTO_TEST_CASE(value_matrixXd) {
...
@@ -206,7 +320,7 @@ BOOST_AUTO_TEST_CASE(value_matrixXd) {
}
}
BOOST_AUTO_TEST_CASE
(
value_matrix4d
)
{
BOOST_AUTO_TEST_CASE
(
value_matrix4d
)
{
using
d
ynamicgraph
::
command
::
Value
;
using
d
g
::
command
::
Value
;
Eigen
::
Matrix4d
avector1
;
Eigen
::
Matrix4d
avector1
;
avector1
.
setZero
();
avector1
.
setZero
();
...
...
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