Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
dynamic-graph
Commits
3aa6df4d
Unverified
Commit
3aa6df4d
authored
Feb 05, 2020
by
Joseph Mirabel
Committed by
GitHub
Feb 05, 2020
Browse files
Merge pull request #60 from florent-lamiraux/signal-empty-string
Fix Signal<std::string>
parents
f0d43bc9
f0ddf275
Pipeline
#8501
passed with stage
in 4 minutes and 47 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/signal/signal-cast-helper.cpp
View file @
3aa6df4d
...
...
@@ -52,6 +52,15 @@ inline boost::any DefaultCastRegisterer<double>::cast(std::istringstream &iss) {
}
}
// for std::string, do not check failure. If input stream contains an
// empty string, iss.fail() returns true and an exception is thrown
template
<
>
inline
boost
::
any
DefaultCastRegisterer
<
std
::
string
>::
cast
(
std
::
istringstream
&
iss
)
{
std
::
string
inst
(
iss
.
str
());
return
inst
;
}
// for std::string, do not add std::endl at the end of the stream.
template
<
>
inline
void
DefaultCastRegisterer
<
std
::
string
>::
disp
(
const
boost
::
any
&
object
,
...
...
tests/signal-ptr.cpp
View file @
3aa6df4d
...
...
@@ -297,3 +297,19 @@ BOOST_AUTO_TEST_CASE(plug_signal_string) {
std
::
cout
<<
"res="
<<
res
<<
std
::
endl
;
BOOST_CHECK
(
res
==
str
);
}
BOOST_AUTO_TEST_CASE
(
set_signal_string
)
{
Signal
<
std
::
string
,
int
>
s
(
"signal"
);
std
::
string
str
(
""
);
std
::
ostringstream
os
;
os
<<
str
;
std
::
istringstream
value
(
os
.
str
());
try
{
s
.
set
(
value
);
}
catch
(
const
std
::
exception
&
exc
)
{
std
::
cout
<<
exc
.
what
()
<<
std
::
endl
;
BOOST_CHECK
(
!
"Tentative to set signal to empty string"
);
}
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment