Fix issue with printing longHelp
Corrected a bug where the parser misinterpreted `help cd` as an invalid
command, expecting `helpcd`. This problem was caused by an issue within
the help grammar rules.
Issue: https://tree.taiga.io/project/jktjkt-netconf-cli/issue/234
Change-Id: I3494f99013d1b119ce255ab68faf448b4bc25b1f
diff --git a/tests/misc_commands.cpp b/tests/misc_commands.cpp
index 868189d..ae36808 100644
--- a/tests/misc_commands.cpp
+++ b/tests/misc_commands.cpp
@@ -38,4 +38,31 @@
}
REQUIRE(boost::get<switch_>(parser.parseCommand(input, errorStream)) == expected);
}
+
+ SECTION("help")
+ {
+ std::string input;
+ bool expectedCommand = false;
+ SECTION("Short help")
+ {
+ input = "help";
+ }
+ SECTION("Short help with trailing whitespace")
+ {
+ input = "help ";
+ }
+ SECTION("Long help")
+ {
+ input = "help cd";
+ expectedCommand = true;
+ }
+ SECTION("Long help with trailing whitespace")
+ {
+ input = "help cd ";
+ expectedCommand = true;
+ }
+
+ auto result = boost::get<help_>(parser.parseCommand(input, errorStream));
+ REQUIRE(!!result.m_cmd == expectedCommand);
+ }
}