Skip to content

Commit

Permalink
fix coverage and cpplint
Browse files Browse the repository at this point in the history
  • Loading branch information
phlptp committed Oct 20, 2024
1 parent 9c704bb commit f380df4
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 38 deletions.
3 changes: 0 additions & 3 deletions include/CLI/impl/App_inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,6 @@ CLI11_INLINE Option *App::add_option(std::string option_name,
}
}
for(auto &opt : options_) {
if(opt->snames_.empty()) {
continue;
}
for(const auto &osn : opt->snames_) {
if(osn.size() > 1) {
std::string test_name;
Expand Down
10 changes: 10 additions & 0 deletions tests/AppTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,18 @@ TEST_CASE_METHOD(TApp, "singledash", "[app]") {
} catch(...) {
CHECK(false);
}
app.allow_non_standard_option_names();
try {
app.add_option("-!I{am}bad");
} catch(const CLI::BadNameString &e) {
std::string str = e.what();
CHECK_THAT(str, Contains("!I{am}bad"));
} catch(...) {
CHECK(false);
}
}


TEST_CASE_METHOD(TApp, "FlagLikeOption", "[app]") {
bool val{false};
auto *opt = app.add_option("--flag", val)->type_size(0)->default_str("true");
Expand Down
63 changes: 28 additions & 35 deletions tests/BoostOptionTypeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,14 @@
#include <utility>
#include <vector>

using small_vector = boost::container::small_vector;
using flat_set = boost::container::flat_set;
using flat_map = boost::container::flat_map;
using slist = boost::container::slist;
using stable_vector = boost::container::stable_vector;
using static_vector = boost::container::static_vector;
using vector = boost::container::vector;

TEMPLATE_TEST_CASE("Boost container single",
"[boost][optional]",
(small_vector<int, 2>),
(small_vector<int, 3>),
flat_set<int>,
stable_vector<int>,
slist<int>) {
(boost::container::small_vector<int, 2>),
(boost::container::small_vector<int, 3>),
boost::container::flat_set<int>,
boost::container::stable_vector<int>,
boost::container::slist<int>) {
TApp tapp;
TestType cv;
CLI::Option *opt = tapp.app.add_option("-v", cv);
Expand All @@ -53,12 +46,12 @@ using isp = std::pair<int, std::string>;

TEMPLATE_TEST_CASE("Boost container pair",
"[boost][optional]",
stable_vector<isp>,
(small_vector<isp, 2>),
flat_set<isp>,
slist<isp>,
vector<isp>,
(flat_map<int, std::string>)) {
boost::container::stable_vector<isp>,
(boost::container::small_vector<isp, 2>),
boost::container::flat_set<isp>,
boost::container::slist<isp>,
boost::container::vector<isp>,
(boost::container::flat_map<int, std::string>)) {

TApp tapp;
TestType cv;
Expand All @@ -79,10 +72,10 @@ using tup_obj = std::tuple<int, std::string, double>;

TEMPLATE_TEST_CASE("Boost container tuple",
"[boost][optional]",
(small_vector<tup_obj, 3>),
stable_vector<tup_obj>,
flat_set<tup_obj>,
slist<tup_obj>) {
(boost::container::small_vector<tup_obj, 3>),
boost::container::stable_vector<tup_obj>,
boost::container::flat_set<tup_obj>,
boost::container::slist<tup_obj>) {
TApp tapp;
TestType cv;

Expand All @@ -98,24 +91,24 @@ TEMPLATE_TEST_CASE("Boost container tuple",
CHECK(3u == cv.size());
}

using icontainer1 = vector<int>;
using icontainer2 = flat_set<int>;
using icontainer3 = slist<int>;
using icontainer1 = boost::container::vector<int>;
using icontainer2 = boost::container::flat_set<int>;
using icontainer3 = boost::container::slist<int>;

TEMPLATE_TEST_CASE("Boost container container",
"[boost][optional]",
std::vector<icontainer1>,
slist<icontainer1>,
flat_set<icontainer1>,
(small_vector<icontainer1, 2>),
boost::container::slist<icontainer1>,
boost::container::flat_set<icontainer1>,
(boost::container::small_vector<icontainer1, 2>),
std::vector<icontainer2>,
slist<icontainer2>,
flat_set<icontainer2>,
stable_vector<icontainer2>,
(static_vector<icontainer2, 10>),
slist<icontainer3>,
flat_set<icontainer3>,
(static_vector<icontainer3, 10>)) {
boost::container::slist<icontainer2>,
boost::container::flat_set<icontainer2>,
boost::container::stable_vector<icontainer2>,
(boost::container::static_vector<icontainer2, 10>),
boost::container::slist<icontainer3>,
boost::container::flat_set<icontainer3>,
(boost::container::static_vector<icontainer3, 10>)) {

TApp tapp;
TestType cv;
Expand Down
1 change: 1 addition & 0 deletions tests/ConfigFileTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <string>
#include <tuple>
#include <vector>
#include <set>

TEST_CASE("StringBased: convert_arg_for_ini", "[config]") {

Expand Down
1 change: 1 addition & 0 deletions tests/HelpTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <set>
#include <string>
#include <vector>
#include <utility>

TEST_CASE("THelp: Basic", "[help]") {
CLI::App app{"My prog"};
Expand Down

0 comments on commit f380df4

Please sign in to comment.