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
fea230b1
Commit
fea230b1
authored
5 years ago
by
Olivier Stasse
Committed by
olivier stasse
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[tests] Improve coverage of signal-ptr.
parent
a955e307
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/signal-ptr.cpp
+64
-33
64 additions, 33 deletions
tests/signal-ptr.cpp
with
64 additions
and
33 deletions
tests/signal-ptr.cpp
+
64
−
33
View file @
fea230b1
...
...
@@ -88,20 +88,16 @@ BOOST_AUTO_TEST_CASE(normal_cst_test) {
try
{
// Signal<double, int> * r =
sigNotPlug
.
getPtr
();
}
catch
(
const
ExceptionSignal
&
aea
)
{
res
=
(
aea
.
getCode
()
==
ExceptionSignal
::
NOT_INITIALIZED
);
}
catch
(
const
ExceptionSignal
&
aea
)
{
res
=
(
aea
.
getCode
()
==
ExceptionSignal
::
NOT_INITIALIZED
);
}
BOOST_CHECK
(
res
);
/// Testing const getPtr() interface: no plug case
try
{
cstSigNotPlug
.
getPtr
();
}
catch
(
const
ExceptionSignal
&
aea
)
{
res
=
(
aea
.
getCode
()
==
ExceptionSignal
::
NOT_INITIALIZED
);
}
catch
(
const
ExceptionSignal
&
aea
)
{
res
=
(
aea
.
getCode
()
==
ExceptionSignal
::
NOT_INITIALIZED
);
}
BOOST_CHECK
(
res
);
...
...
@@ -112,35 +108,34 @@ BOOST_AUTO_TEST_CASE(normal_cst_test) {
sigNotPlug
.
display
(
output
);
cstSigNotPlug
.
display
(
output
);
/// Testing getAbsatractPtr() interface: no plug
res
=
false
;
/// Testing getAbsatractPtr() interface: no plug
res
=
false
;
try
{
sigNotPlug
.
getAbstractPtr
();
}
catch
(
const
ExceptionSignal
&
aea
)
{
res
=
(
aea
.
getCode
()
==
ExceptionSignal
::
NOT_INITIALIZED
);
}
catch
(
const
ExceptionSignal
&
aea
)
{
res
=
(
aea
.
getCode
()
==
ExceptionSignal
::
NOT_INITIALIZED
);
}
BOOST_CHECK
(
res
);
/// Testing const getAbstractPtr() interface: no plug case
try
{
cstSigNotPlug
.
getAbstractPtr
();
}
catch
(
const
ExceptionSignal
&
aea
)
{
res
=
(
aea
.
getCode
()
==
ExceptionSignal
::
NOT_INITIALIZED
);
}
catch
(
const
ExceptionSignal
&
aea
)
{
res
=
(
aea
.
getCode
()
==
ExceptionSignal
::
NOT_INITIALIZED
);
}
BOOST_CHECK
(
res
);
try
{
sigNotPlug
.
checkCompatibility
();
}
catch
(...)
{
}
try
{
sigNotPlug
.
checkCompatibility
();
}
catch
(...)
{
}
BOOST_CHECK
(
res
);
}
BOOST_AUTO_TEST_CASE
(
normal_test
)
{
Signal
<
double
,
int
>
sig
(
"sig"
);
Signal
<
int
,
int
>
sigint
(
"sig"
);
Signal
<
std
::
string
,
int
>
sigstr
(
"sig_str"
);
SignalPtr
<
double
,
int
>
sigPtrA
(
NULL
,
"sigPtrA"
),
sigPtrB
(
NULL
,
"sigPtrB"
);
SignalPtr
<
double
,
int
>
sigPtrAbstract
(
NULL
,
"sigPtrAbstract"
);
DummyClass
<
double
>
pro3
(
"pro3"
);
...
...
@@ -156,32 +151,68 @@ BOOST_AUTO_TEST_CASE(normal_test) {
e
.
getExceptionName
();
}
BOOST_CHECK
(
true
);
sigPtrA
.
setFunction
(
boost
::
bind
(
&
DummyClass
<
double
>::
fun
,
&
pro3
,
_1
,
_2
));
sigPtrA
.
setFunction
(
boost
::
bind
(
&
DummyClass
<
double
>::
fun
,
&
pro3
,
_1
,
_2
));
/// Plugging signal.
SignalBase
<
int
>
&
sigRef
=
sig
;
SignalBase
<
int
>
&
sigRef
=
sig
,
sigBase
(
"sigBase"
)
;
SignalBase
<
int
>
&
sigPtrARef
=
sigPtrA
,
&
sigPtrBRef
=
sigPtrB
,
&
sigPtrAbstractRef
=
sigPtrAbstract
;
sigPtrARef
.
plug
(
0
);
sigPtrARef
.
plug
(
0
);
sigPtrARef
.
plug
(
&
sigRef
);
sigPtrBRef
.
plug
(
&
sigPtrARef
);
/// Try to plug an incompatible signal.
/// leave
bool
res
=
false
;
try
{
sigPtrARef
.
plug
(
&
sigstr
);
}
catch
(
const
ExceptionSignal
&
aes
)
{
res
=
(
aes
.
getCode
()
==
ExceptionSignal
::
PLUG_IMPOSSIBLE
);
}
BOOST_CHECK
(
res
);
/// Plug the signal.
sigPtrAbstractRef
.
plug
(
&
sigRef
);
sigPtrA
.
getPtr
();
BOOST_CHECK
(
true
);
try
{
sigPtrARef
.
checkCompatibility
();
}
catch
(...)
{
}
try
{
sigPtrARef
.
checkCompatibility
();
}
catch
(
const
ExceptionSignal
&
aes
)
{
/// Should be NOT_INITIALIZED becase the last plug
/// on sigstr failed.
res
=
(
aes
.
getCode
()
==
ExceptionSignal
::
NOT_INITIALIZED
);
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cout
<<
"Standard Exception:"
<<
e
.
what
()
<<
std
::
endl
;
}
catch
(...)
{
std
::
cout
<<
"Anything else: "
<<
std
::
endl
;
}
sigPtrA
.
needUpdate
(
5
);
//
BOOST_CHECK(
res
);
BOOST_CHECK
(
true
);
int
ltime
=
sigPtrA
.
getTime
();
sigPtrA
.
getPluged
();
sigPtrA
(
ltime
);
BOOST_CHECK
(
true
);
sigPtrB
.
getPtr
();
sigPtrAbstract
.
getAbstractPtr
();
/// Test sigPtrAbstract with a normal plug.
res
=
false
;
try
{
sigPtrAbstract
.
getAbstractPtr
();
}
catch
(
ExceptionSignal
&
aes
)
{
/// Should be NOT_INITIALIZED becase the last plug
/// on sigstr failed.
std
::
cout
<<
"Code: "
<<
aes
.
getCode
()
<<
std
::
endl
;
res
=
(
aes
.
getCode
()
==
ExceptionSignal
::
NOT_INITIALIZED
);
}
catch
(...)
{
std
::
cout
<<
"Anything else with sigPtrAbstract.getAbstractPtr()"
<<
std
::
endl
;
}
BOOST_CHECK
(
true
);
/// Test the case where the plug ref is zero.
sigPtrAbstractRef
.
plug
(
0
);
BOOST_CHECK
(
true
);
assert
(
sigRef
.
isPlugged
()
!=
true
);
SignalBase
<
int
>
*
t
=
sigRef
.
getPluged
();
...
...
@@ -204,12 +235,12 @@ BOOST_AUTO_TEST_CASE(normal_test) {
sigPtrA
.
setReferenceNonConstant
(
tab_D
,
NULL
);
sigPtrA
.
access
(
5
);
sigPtrA
.
display
(
output
);
// getreference
sigPtrA
.
operator
=
(
1.2
);
// getconstant
sigPtrA
.
displayDependencies
(
output
);
cout
<<
t
<<
std
::
endl
;
cout
<<
"Sig = "
;
sigRef
.
get
(
cout
);
...
...
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