X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FUtils%2FConsole%2FSTLSupport.test.cc;h=fa6466781874e4684c883d4b338fc081b7882e52;hb=0003d55730b447329342161d12cf2ed23b63459e;hp=ddc78dcf80c7871f3acf840fc36723789cad1295;hpb=1d058092bd771d52996416763b5d9cafadc2e087;p=senf.git diff --git a/senf/Utils/Console/STLSupport.test.cc b/senf/Utils/Console/STLSupport.test.cc index ddc78dc..fa64667 100644 --- a/senf/Utils/Console/STLSupport.test.cc +++ b/senf/Utils/Console/STLSupport.test.cc @@ -1,24 +1,29 @@ // $Id$ // -// Copyright (C) 2009 +// Copyright (C) 2009 // Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY -// Stefan Bund // -// 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 /** \file \brief STLSupport unit tests */ @@ -28,17 +33,13 @@ // Custom includes #include -#include "STLSupport.hh" -#include "ParsedCommand.hh" -#include "Executor.hh" -#include "Parse.hh" -#include "ScopedDirectory.hh" +#include "Console.hh" #include #include #define prefix_ -///////////////////////////////cc.p//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// namespace { @@ -66,19 +67,22 @@ namespace { } return std::make_pair(keys,sum); } - + } -BOOST_AUTO_UNIT_TEST(vectorSupport) +SENF_AUTO_UNIT_TEST(vectorSupport) { + namespace fty = senf::console::factory; + senf::console::Executor executor; senf::console::CommandParser parser; senf::console::ScopedDirectory<> dir; senf::console::root().add("test", dir); std::vector defv (boost::assign::list_of(7)(2).to_container(defv)); - dir.add("test", &Summer >::test) - .arg("data", "test data", senf::console::kw::default_value = defv); + dir.add("test", fty::Command(&Summer >::test) + .arg("data", "test data", senf::console::kw::default_value = defv) + ); std::stringstream ss; SENF_CHECK_NO_THROW( @@ -87,11 +91,11 @@ BOOST_AUTO_UNIT_TEST(vectorSupport) BOOST_CHECK_EQUAL( ss.str(), "9\n" "0\n" "5\n" "13\n" "17\n" ); ss.str(""); - SENF_CHECK_NO_THROW( + SENF_CHECK_NO_THROW( parser.parse("help test/test", boost::bind( boost::ref(executor), boost::ref(ss), _1 )) ); BOOST_CHECK_EQUAL( - ss.str(), + ss.str(), "Usage:\n" " test [data:vector]\n" "\n" @@ -100,16 +104,19 @@ BOOST_AUTO_UNIT_TEST(vectorSupport) " default: (7 2)\n" ); } -BOOST_AUTO_UNIT_TEST(listSupport) +SENF_AUTO_UNIT_TEST(listSupport) { + namespace fty = senf::console::factory; + senf::console::Executor executor; senf::console::CommandParser parser; senf::console::ScopedDirectory<> dir; senf::console::root().add("test", dir); std::list defv (boost::assign::list_of(7)(2).to_container(defv)); - dir.add("test", &Summer >::test) - .arg("data", "test data", senf::console::kw::default_value = defv); + dir.add("test", fty::Command(&Summer >::test) + .arg("data", "test data", senf::console::kw::default_value = defv) + ); std::stringstream ss; SENF_CHECK_NO_THROW( @@ -118,11 +125,11 @@ BOOST_AUTO_UNIT_TEST(listSupport) BOOST_CHECK_EQUAL( ss.str(), "9\n" "0\n" "5\n" "13\n" "17\n" ); ss.str(""); - SENF_CHECK_NO_THROW( + SENF_CHECK_NO_THROW( parser.parse("help test/test", boost::bind( boost::ref(executor), boost::ref(ss), _1 )) ); BOOST_CHECK_EQUAL( - ss.str(), + ss.str(), "Usage:\n" " test [data:list]\n" "\n" @@ -131,16 +138,19 @@ BOOST_AUTO_UNIT_TEST(listSupport) " default: (7 2)\n" ); } -BOOST_AUTO_UNIT_TEST(setSupport) +SENF_AUTO_UNIT_TEST(setSupport) { + namespace fty = senf::console::factory; + senf::console::Executor executor; senf::console::CommandParser parser; senf::console::ScopedDirectory<> dir; senf::console::root().add("test", dir); std::set defv (boost::assign::list_of(7)(2).to_container(defv)); - dir.add("test", &Summer >::test) - .arg("data", "test data", senf::console::kw::default_value = defv); + dir.add("test", fty::Command(&Summer >::test) + .arg("data", "test data", senf::console::kw::default_value = defv) + ); std::stringstream ss; SENF_CHECK_NO_THROW( @@ -149,11 +159,11 @@ BOOST_AUTO_UNIT_TEST(setSupport) BOOST_CHECK_EQUAL( ss.str(), "9\n" "0\n" "5\n" "13\n" "17\n" ); ss.str(""); - SENF_CHECK_NO_THROW( + SENF_CHECK_NO_THROW( parser.parse("help test/test", boost::bind( boost::ref(executor), boost::ref(ss), _1 )) ); BOOST_CHECK_EQUAL( - ss.str(), + ss.str(), "Usage:\n" " test [data:set]\n" "\n" @@ -162,8 +172,10 @@ BOOST_AUTO_UNIT_TEST(setSupport) " default: (2 7)\n" ); } -BOOST_AUTO_UNIT_TEST(mapSupport) +SENF_AUTO_UNIT_TEST(mapSupport) { + namespace fty = senf::console::factory; + senf::console::Executor executor; senf::console::CommandParser parser; senf::console::ScopedDirectory<> dir; @@ -171,22 +183,23 @@ BOOST_AUTO_UNIT_TEST(mapSupport) std::map defv ( boost::assign::map_list_of("foo bar",7)("bar",2).to_container(defv)); - dir.add("test", &mapTest) - .arg("data", "test data", senf::console::kw::default_value = defv); + dir.add("test", fty::Command(&mapTest) + .arg("data", "test data", senf::console::kw::default_value = defv) + ); std::stringstream ss; SENF_CHECK_NO_THROW( parser.parse("test/test; test/test (); " "test/test (vier=4 fuenf = 5 acht=8 )", boost::bind( boost::ref(executor), boost::ref(ss), _1 )) ); - BOOST_CHECK_EQUAL( ss.str(), "(\"barfoo bar\" 9)\n" "(\"\" 0)\n" "(achtfuenfvier 17)\n" ); // + BOOST_CHECK_EQUAL( ss.str(), "(\"barfoo bar\" 9)\n" "(\"\" 0)\n" "(achtfuenfvier 17)\n" ); // ss.str(""); - SENF_CHECK_NO_THROW( + SENF_CHECK_NO_THROW( parser.parse("help test/test", boost::bind( boost::ref(executor), boost::ref(ss), _1 )) ); BOOST_CHECK_EQUAL( - ss.str(), + ss.str(), "Usage:\n" " test [data:map]\n" "\n" @@ -195,7 +208,7 @@ BOOST_AUTO_UNIT_TEST(mapSupport) " default: (bar=2 \"foo bar\"=7)\n" ); } -///////////////////////////////cc.e//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// #undef prefix_