X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Console%2FParse.test.cc;h=3f83d57265064480e2825ce5b9f85846af3168f5;hb=16d94efc2159cba35fc44e5b26747ae0a2ab237b;hp=11d8a383b4845115f1167b88d962a81f2f89f403;hpb=412cf8e222086fb5d89b15cb11556799e131f390;p=senf.git diff --git a/Console/Parse.test.cc b/Console/Parse.test.cc index 11d8a38..3f83d57 100644 --- a/Console/Parse.test.cc +++ b/Console/Parse.test.cc @@ -35,7 +35,7 @@ #include "Parse.ih" #include "../Utils/String.hh" -#include +#include "../Utils/auto_unit_test.hh" #include #define prefix_ @@ -51,6 +51,11 @@ namespace std::ostream & os_; + void pushDirectory(std::vector const & path) + { os_ << "pushDirectory( " << senf::stringJoin(path,"/") << " )\n"; } + void popDirectory() + { os_ << "popDirectory()\n"; } + void beginCommand(std::vector const & command) { os_ << "beginCommand( " << senf::stringJoin(command, "/") << " )\n"; } void endCommand() @@ -71,10 +76,12 @@ namespace { os_ << "builtin_cd( " << senf::stringJoin(path, "/") << " )\n"; } void builtin_ls(std::vector const & path) { os_ << "builtin_cd( " << senf::stringJoin(path, "/") << " )\n"; } + void builtin_exit() + { os_ << "builtin_exit()\n"; } }; } -BOOST_AUTO_UNIT_TEST(commandParser) +BOOST_AUTO_UNIT_TEST(commandGrammar) { senf::console::detail::CommandGrammar::Context context; std::stringstream ss; @@ -117,9 +124,15 @@ BOOST_AUTO_UNIT_TEST(commandParser) "endCommand()\n" ); } -BOOST_AUTO_UNIT_TEST(singleCommandParser) +namespace { + senf::console::ParseCommandInfo info; + void setInfo(senf::console::ParseCommandInfo const & i) + { info = i; } +} + +BOOST_AUTO_UNIT_TEST(commandParser) { - senf::console::SingleCommandParser parser; + senf::console::CommandParser parser; char const text[] = "# Comment\n" @@ -131,8 +144,7 @@ BOOST_AUTO_UNIT_TEST(singleCommandParser) " x\"01 02 # Inner comment\n" " 0304\""; - senf::console::ParseCommandInfo info; - BOOST_CHECK( parser.parseCommand(text, info) ); + BOOST_CHECK( parser.parse(text, &setInfo) ); char const * path[] = { "doo", "bii", "doo" };