mu-command-parser: do not allow unknown parameters
We were simply ignoring unknown parameters; but it's better to raise an error, as it's likely unintented (typo or otherwise)
This commit is contained in:
@ -63,9 +63,11 @@ static void
|
||||
test_command()
|
||||
{
|
||||
using namespace Command;
|
||||
allow_warnings();
|
||||
|
||||
CommandMap cmap;
|
||||
|
||||
|
||||
cmap.emplace("my-command",
|
||||
CommandInfo{
|
||||
ArgMap{ {"param1", ArgInfo{Sexp::Type::String, true, "some string" }},
|
||||
@ -77,13 +79,15 @@ test_command()
|
||||
|
||||
g_assert_true(call(cmap, "(my-command :param1 \"hello\")"));
|
||||
g_assert_true(call(cmap, "(my-command :param1 \"hello\" :param2 123)"));
|
||||
g_assert_true(call(cmap, "(my-command :param1 \"hello\" :param2 123 :param3 xxx)"));
|
||||
|
||||
g_assert_false(call(cmap, "(my-command :param1 \"hello\" :param2 123 :param3 xxx)"));
|
||||
}
|
||||
|
||||
static void
|
||||
test_command2()
|
||||
{
|
||||
using namespace Command;
|
||||
allow_warnings();
|
||||
|
||||
CommandMap cmap;
|
||||
cmap.emplace("bla",
|
||||
@ -95,7 +99,8 @@ test_command2()
|
||||
[&](const auto& params){}});
|
||||
|
||||
|
||||
g_assert_true (call(cmap, "(bla :foo nil :bla nil)"));
|
||||
g_assert_true (call(cmap, "(bla :foo nil)"));
|
||||
g_assert_false (call(cmap, "(bla :foo nil :bla nil)"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user