File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,15 @@ inline boost::any DefaultCastRegisterer<double>::cast(std::istringstream &iss) {
5252 }
5353}
5454
55+ // for std::string, do not check failure. If input stream contains an
56+ // empty string, iss.fail() returns true and an exception is thrown
57+ template <>
58+ inline boost::any
59+ DefaultCastRegisterer<std::string>::cast(std::istringstream &iss) {
60+ std::string inst (iss.str ());
61+ return inst;
62+ }
63+
5564// for std::string, do not add std::endl at the end of the stream.
5665template <>
5766inline void DefaultCastRegisterer<std::string>::disp(const boost::any &object,
Original file line number Diff line number Diff line change @@ -297,3 +297,19 @@ BOOST_AUTO_TEST_CASE(plug_signal_string) {
297297 std::cout << " res=" << res << std::endl;
298298 BOOST_CHECK (res == str);
299299}
300+
301+ BOOST_AUTO_TEST_CASE (set_signal_string) {
302+ Signal<std::string, int > s (" signal" );
303+ std::string str (" " );
304+ std::ostringstream os;
305+ os << str;
306+ std::istringstream value (os.str ());
307+ try {
308+ s.set (value);
309+ }
310+ catch (const std::exception& exc)
311+ {
312+ std::cout << exc.what () << std::endl;
313+ BOOST_CHECK (!" Tentative to set signal to empty string" );
314+ }
315+ }
You can’t perform that action at this time.
0 commit comments