X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FConsole%2FParse.test.cc;h=bbc2c686afc6220335325f5b4d3691be96631f30;hb=bd9f9d3fd6fbcff0112a7bf48ab9284da9576b11;hp=7f85ac747295e8e70a22b429829816ec763f2a31;hpb=d001b1fe2a8fb121145d2a111d737219abae20d7;p=senf.git diff --git a/Utils/Console/Parse.test.cc b/Utils/Console/Parse.test.cc index 7f85ac7..bbc2c68 100644 --- a/Utils/Console/Parse.test.cc +++ b/Utils/Console/Parse.test.cc @@ -21,7 +21,7 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief Parse.test unit tests */ + \brief Parse unit tests */ //#include "Parse.test.hh" //#include "Parse.test.ih" @@ -66,6 +66,8 @@ namespace { os_ << "builtin_cd( " << senf::stringJoin(path, "/") << " )\n"; } void builtin_ls(std::vector const & path) { os_ << "builtin_ls( " << senf::stringJoin(path, "/") << " )\n"; } + void builtin_lr(std::vector const & path) + { os_ << "builtin_lr( " << senf::stringJoin(path, "/") << " )\n"; } void builtin_exit() { os_ << "builtin_exit()\n"; } void builtin_help(std::vector const & path) @@ -133,6 +135,15 @@ BOOST_AUTO_UNIT_TEST(commandGrammar) { ss.str(""); BOOST_CHECK( boost::spirit::parse( + "lr /foo/bar;", + grammar.use_parser(), + grammar.use_parser() ) . full ); + BOOST_CHECK_EQUAL( ss.str(), "builtin_lr( None('')/Word('foo')/Word('bar') )\n" ); + } + + { + ss.str(""); + BOOST_CHECK( boost::spirit::parse( "cd /foo/bar;", grammar.use_parser(), grammar.use_parser() ) . full ); @@ -214,6 +225,7 @@ BOOST_AUTO_UNIT_TEST(commandParser) BOOST_CHECK_EQUAL_COLLECTIONS( info.commandPath().begin(), info.commandPath().end(), path, path + sizeof(path)/sizeof(path[0]) ); + BOOST_CHECK_EQUAL( boost::next(info.commandPath().begin())->index(), 16u ); BOOST_CHECK_EQUAL( unsigned(info.tokens().size()), 15u ); char const * tokens[] = { "arg", @@ -243,11 +255,15 @@ BOOST_AUTO_UNIT_TEST(commandParser) BOOST_REQUIRE_EQUAL( args->size(), 8u ); for (unsigned i (0); i<8; ++i) BOOST_CHECK_EQUAL( args->begin()[i].value(), tokens[4+i] ); + BOOST_CHECK_EQUAL( info.tokens().begin()[3].index(), 96u ); + BOOST_CHECK_EQUAL( info.tokens().begin()[5].index(), 98u ); + BOOST_CHECK_EQUAL( info.tokens().begin()[12].index(), 109u ); ++ args; BOOST_REQUIRE( args != info.arguments().end() ); BOOST_REQUIRE_EQUAL( args->size(), 1u ); BOOST_CHECK_EQUAL( args->begin()->value(), tokens[13] ); + BOOST_CHECK_EQUAL( args->begin()->index(), 126u ); ++ args; BOOST_REQUIRE( args != info.arguments().end() );