X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Console%2FParsedCommand.test.cc;h=223a3e3808a09637c279f6a26db03e83c370c049;hb=1b1d76302a5d61e918ef71f1c8e11f80ac1262e2;hp=39f028d6318e5e41deb10df2e00f750e1fe5a40b;hpb=8e708e9784c76461252c3bdf646d291c593a49be;p=senf.git diff --git a/Console/ParsedCommand.test.cc b/Console/ParsedCommand.test.cc index 39f028d..223a3e3 100644 --- a/Console/ParsedCommand.test.cc +++ b/Console/ParsedCommand.test.cc @@ -50,14 +50,13 @@ namespace { struct TestParser { - typedef senf::console::ParseCommandInfo::TokensRange const & first_argument_type; - typedef std::string & second_argument_type; - typedef void result_type; - - result_type operator()(first_argument_type, second_argument_type out) const + void operator()(senf::console::ParseCommandInfo::TokensRange const &, + std::string & out) const { out = "true"; } }; + void testFormatter(double, std::ostream & os) + { os << "formatter"; } } BOOST_AUTO_UNIT_TEST(parsedCommand) @@ -137,7 +136,19 @@ BOOST_AUTO_UNIT_TEST(parsedCommand) parser.parse("test/cb6 false", boost::bind( boost::ref(executor), boost::ref(ss), _1 )) ); BOOST_CHECK_EQUAL( ss.str(), "Value: true\n" ); - + } + + { + std::stringstream ss; + + // This tests adding boost::function objects and at the same time validates, that + // compatible types also work + dir.add("cb7", boost::function(&cb2)) + .formatter( &testFormatter ); + BOOST_CHECK_NO_THROW( + parser.parse("test/cb7", + boost::bind( boost::ref(executor), boost::ref(ss), _1 )) ); + BOOST_CHECK_EQUAL( ss.str(), "formatter\n" ); } {