Skip to content
Snippets Groups Projects
Unverified Commit 3aa6df4d authored by Joseph Mirabel's avatar Joseph Mirabel Committed by GitHub
Browse files

Merge pull request #60 from florent-lamiraux/signal-empty-string

Fix Signal<std::string>
parents f0d43bc9 f0ddf275
No related branches found
No related tags found
No related merge requests found
......@@ -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");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment