4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief Utility.test unit tests */
26 //#include "Utility.test.hh"
27 //#include "Utility.test.ih"
32 #include <senf/Utils/auto_unit_test.hh>
33 #include <boost/test/test_tools.hpp>
36 ///////////////////////////////cc.p////////////////////////////////////////
40 char charTest(char value) { return value; }
42 enum TestEnum { Foo=1, Bar=2, FooBar=4 };
43 SENF_CONSOLE_REGISTER_ENUM( TestEnum, (Foo)(Bar)(FooBar) );
45 senf::console::FlagCollection<TestEnum> collectionTest(
46 senf::console::FlagCollection<TestEnum> flags) { return flags; }
50 SENF_AUTO_UNIT_TEST(charAsString)
52 namespace fty = senf::console::factory;
54 senf::console::Executor executor;
55 senf::console::CommandParser parser;
56 senf::console::ScopedDirectory<> dir;
57 senf::console::root().add("test", dir);
61 fty::Command<senf::console::CharAsString<char> (senf::console::CharAsString<char>)>(
66 parser.parse("test/test \"\\x01\"",
67 boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
68 BOOST_CHECK_EQUAL( ss.str(), "\x01\n" );
71 SENF_AUTO_UNIT_TEST(flagCollection)
73 namespace fty = senf::console::factory;
75 senf::console::Executor executor;
76 senf::console::CommandParser parser;
77 senf::console::ScopedDirectory<> dir;
78 senf::console::root().add("test", dir);
81 dir.add("test",fty::Command(&collectionTest));
85 parser.parse("test/test foo",
86 boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
87 BOOST_CHECK_EQUAL( ss.str(), "Foo\n" );
91 parser.parse("test/test (foo bar)",
92 boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
93 BOOST_CHECK_EQUAL( ss.str(), "(Foo Bar)\n" );
97 parser.parse("test/test ()",
98 boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
99 BOOST_CHECK_EQUAL( ss.str(), "()\n" );
102 ///////////////////////////////cc.e////////////////////////////////////////
109 // comment-column: 40
110 // c-file-style: "senf"
111 // indent-tabs-mode: nil
112 // ispell-local-dictionary: "american"
113 // compile-command: "scons -u test"