Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jarro2783/cxxopts.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSourabh Mehta <73165318+soumeh01@users.noreply.github.com>2022-11-09 23:24:19 +0300
committerGitHub <noreply@github.com>2022-11-09 23:24:19 +0300
commit1dcb44e79a17e703e024594487b3a442d87e4741 (patch)
treeffa4b19b809687aa581ac7ecd4b2ccfd39be2b1e /test
parentf087dc8fcdcd6aabba68e671ae17ff3e975134f4 (diff)
Fix an additional space in help generated (#377)HEADmaster
Diffstat (limited to 'test')
-rw-r--r--test/options.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/options.cpp b/test/options.cpp
index 288810d..4fed683 100644
--- a/test/options.cpp
+++ b/test/options.cpp
@@ -918,3 +918,27 @@ TEST_CASE("Iterator", "[iterator]") {
REQUIRE(++iter == result.end());
}
+
+TEST_CASE("No Options help", "[options]")
+{
+ std::vector<std::string> positional;
+
+ cxxopts::Options options("test", "test no options help");
+
+ // explicitly setting custom help empty to overwrite
+ // default "[OPTION...]" when there are no options
+ options.positional_help("<posArg1>...<posArgN>")
+ .custom_help("")
+ .add_options()
+ ("positional", "", cxxopts::value<std::vector<std::string>>(positional));
+
+ Argv av({"test", "posArg1", "posArg2", "posArg3"});
+
+ auto argc = av.argc();
+ auto** argv = av.argv();
+
+ options.parse_positional({"positional"});
+
+ CHECK_NOTHROW(options.parse(argc, argv));
+ CHECK(options.help().find("test <posArg1>...<posArgN>") != std::string::npos);
+}