Unverified Commit 3aa6df4d authored by Joseph Mirabel's avatar Joseph Mirabel Committed by GitHub

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
......@@ -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,
......
......@@ -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");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment