switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Utils / Console / ParsedCommand.test.cc
index 197b0ab..c8808f8 100644 (file)
@@ -1,24 +1,29 @@
 // $Id$
 //
-// Copyright (C) 2008 
+// Copyright (C) 2008
 // Fraunhofer Institute for Open Communication Systems (FOKUS)
-// Competence Center NETwork research (NET), St. Augustin, GERMANY
-//     Stefan Bund <g0dil@berlios.de>
 //
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
+// The contents of this file are subject to the Fraunhofer FOKUS Public License
+// Version 1.0 (the "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at 
+// http://senf.berlios.de/license.html
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// The Fraunhofer FOKUS Public License Version 1.0 is based on, 
+// but modifies the Mozilla Public License Version 1.1.
+// See the full license text for the amendments.
 //
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the
-// Free Software Foundation, Inc.,
-// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+// Software distributed under the License is distributed on an "AS IS" basis, 
+// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
+// for the specific language governing rights and limitations under the License.
+//
+// The Original Code is Fraunhofer FOKUS code.
+//
+// The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
+// (registered association), Hansastraße 27 c, 80686 Munich, Germany.
+// All Rights Reserved.
+//
+// Contributor(s):
+//   Stefan Bund <g0dil@berlios.de>
 
 /** \file
     \brief ParsedCommand unit tests */
@@ -35,7 +40,7 @@
 #include <boost/test/test_tools.hpp>
 
 #define prefix_
-///////////////////////////////cc.p////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 
 namespace {
 
@@ -45,7 +50,7 @@ namespace {
     std::string cb4(std::ostream & os) { os << "text\n"; return "value"; }
     void cb5(std::ostream & os, std::string const & v) { os << "Value: " << v << "\n"; }
 
-    struct TestParser 
+    struct TestParser
     {
         void operator()(senf::console::ParseCommandInfo::TokensRange const &,
                         std::string & out) const
@@ -68,7 +73,7 @@ SENF_AUTO_UNIT_TEST(parsedCommand)
     {
         std::stringstream ss;
         dir.add("cb1", fty::Command(&cb1));
-        parser.parse("test/cb1 2 3.2", 
+        parser.parse("test/cb1 2 3.2",
                      boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 ));
         BOOST_CHECK_EQUAL( ss.str(), "5\n" );
     }
@@ -108,18 +113,18 @@ SENF_AUTO_UNIT_TEST(parsedCommand)
     {
         std::stringstream ss;
 
-        BOOST_CHECK_THROW( 
-            parser.parse("test/cb1 2 3.2 foo", 
+        BOOST_CHECK_THROW(
+            parser.parse("test/cb1 2 3.2 foo",
                          boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )),
             senf::console::SyntaxErrorException );
 
         BOOST_CHECK_THROW(
-            parser.parse("test/cb1 2", 
+            parser.parse("test/cb1 2",
                          boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )),
             senf::console::SyntaxErrorException );
 
         BOOST_CHECK_THROW(
-            parser.parse("test/cb1 2 foo", 
+            parser.parse("test/cb1 2 foo",
                          boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )),
             senf::console::SyntaxErrorException );
     }
@@ -129,7 +134,7 @@ SENF_AUTO_UNIT_TEST(parsedCommand)
         std::stringstream ss;
 
         // Just for the fun of it, use a functor and not a function pointer as parser ...
-        dir.add("cb6", 
+        dir.add("cb6",
                 fty::Command(&cb5)
                     .arg( kw::parser = TestParser() )
             );
@@ -142,9 +147,9 @@ SENF_AUTO_UNIT_TEST(parsedCommand)
     {
         std::stringstream ss;
 
-        // This tests adding boost::function objects and at the same time validates, that 
+        // This tests adding boost::function objects and at the same time validates, that
         // compatible types also work
-        dir.add("cb7", 
+        dir.add("cb7",
                 fty::Command(boost::function<float()>(&cb2))
                     .formatter( &testFormatter )
             );
@@ -177,7 +182,7 @@ SENF_AUTO_UNIT_TEST(parsedCommand)
 
             .arg( description   = "Bar didelfrump di desgorb. Nu widsoflar brimeldrgf." )
 
-            .arg( name          = "checkup", 
+            .arg( name          = "checkup",
                   type_name     = "number",
                   description   = "Florgel, dargel and durgel",
                   default_value = 2.1,
@@ -189,11 +194,11 @@ SENF_AUTO_UNIT_TEST(parsedCommand)
                 .overloadDoc(
                     "Uus Primordia fundo falsidicus corium, diurnitas humo pro leto. Sui Ueraciter\n"
                     "hio eruca lenis qua Agalmate ut fors penitentia. Iugum obdormio anxio nuncupo\n"
-                    "iam, in vos nam Custodi." ) 
+                    "iam, in vos nam Custodi." )
                 .arg( "text", default_value = "" ) )
             );
 
-        (void) cbNode;
+        senf::IGNORE( cbNode );
 
         SENF_CHECK_NO_THROW(
             parser.parse("test/cb 111 222.4",
@@ -216,8 +221,8 @@ SENF_AUTO_UNIT_TEST(parsedCommand)
     {
         std::stringstream ss;
         senf::console::root()["test"]("cb").help(ss);
-        BOOST_CHECK_EQUAL( 
-            ss.str(), 
+        BOOST_CHECK_EQUAL(
+            ss.str(),
             "Usage:\n"
             "    1- cb arg11:int [checkup:number]\n"
             "    2- cb [text:string]\n"
@@ -248,7 +253,7 @@ SENF_AUTO_UNIT_TEST(parsedCommand)
 }
 
 namespace {
-    struct Test 
+    struct Test
     {
         senf::console::ScopedDirectory<Test> dir;
         std::string name_;
@@ -271,11 +276,11 @@ SENF_AUTO_UNIT_TEST(memberParsedCommand)
     senf::console::CommandParser parser;
     senf::console::ScopedDirectory<> dir;
     senf::console::root().add("test", dir);
-    
+
     {
         Test obj ("bar");
         dir.add("obj", obj.dir);
-        
+
         std::stringstream ss;
         parser.parse("test/obj/name \": foo\"",
                      boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 ));
@@ -285,7 +290,7 @@ SENF_AUTO_UNIT_TEST(memberParsedCommand)
 
 namespace {
 
-    senf::console::DirectoryNode::ptr dircb() 
+    senf::console::DirectoryNode::ptr dircb()
     {
         namespace fty = senf::console::factory;
 
@@ -312,11 +317,11 @@ SENF_AUTO_UNIT_TEST(directoryReturn)
         SENF_CHECK_NO_THROW(
             parser.parse("test/test { ll; }",
                          boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
-        BOOST_CHECK_EQUAL( ss.str(), 
+        BOOST_CHECK_EQUAL( ss.str(),
                            "<Directory at '/test/dircb'>\n"
                            "cb1                         \n" );
     }
-    
+
 }
 
 #ifdef COMPILE_CHECK
@@ -343,8 +348,8 @@ COMPILE_FAIL(defaultDoc)
 }
 
 #endif
-    
-///////////////////////////////cc.e////////////////////////////////////////
+
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 #undef prefix_
 
 \f