Console: Add console logging documentation
[senf.git] / Console / ParsedCommand.test.cc
index 39f028d..223a3e3 100644 (file)
@@ -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<void>( 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<float()>(&cb2))
+            .formatter( &testFormatter );
+        BOOST_CHECK_NO_THROW(
+            parser.parse("test/cb7",
+                         boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
+        BOOST_CHECK_EQUAL( ss.str(), "formatter\n" );
     }
 
     {