From 1ab1f914c67e0cfc942f73a3921abafa63c58f8e Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Mon, 18 Feb 2019 22:24:13 +0100 Subject: [PATCH] Adding tests, moved deprecated tests --- include/CLI/App.hpp | 45 ++++-- tests/DeprecatedTest.cpp | 330 ++++++++++++++++++++++++++++++++++++++- tests/HelpTest.cpp | 12 +- tests/IniTest.cpp | 2 +- tests/SetTest.cpp | 46 +++--- 5 files changed, 384 insertions(+), 51 deletions(-) diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index 73e307a6a..6ab804e89 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -644,7 +644,7 @@ class App { } #endif - /// Add set of options (No default, temp reference, such as an inline set) + /// Add set of options (No default, temp reference, such as an inline set) DEPRECATED template Option *add_set(std::string option_name, T &member, ///< The selected member of the set @@ -656,7 +656,7 @@ class App { return opt; } - /// Add set of options (No default, set can be changed afterwords - do not destroy the set) + /// Add set of options (No default, set can be changed afterwords - do not destroy the set) DEPRECATED template Option *add_mutable_set(std::string option_name, T &member, ///< The selected member of the set @@ -668,7 +668,7 @@ class App { return opt; } - /// Add set of options (with default, static set, such as an inline set) + /// Add set of options (with default, static set, such as an inline set) DEPRECATED template Option *add_set(std::string option_name, T &member, ///< The selected member of the set @@ -681,7 +681,7 @@ class App { return opt; } - /// Add set of options (with default, set can be changed afterwards - do not destroy the set) + /// Add set of options (with default, set can be changed afterwards - do not destroy the set) DEPRECATED template Option *add_mutable_set(std::string option_name, T &member, ///< The selected member of the set @@ -694,7 +694,8 @@ class App { return opt; } - /// Add set of options, string only, ignore case (no default, static set) + /// Add set of options, string only, ignore case (no default, static set) DEPRECATED + CLI11_DEPRECATED("Use ->check(CLI::IsMember(..., CLI::ignore_case)) instead") Option *add_set_ignore_case(std::string option_name, std::string &member, ///< The selected member of the set std::set options, ///< The set of possibilities @@ -706,7 +707,8 @@ class App { } /// Add set of options, string only, ignore case (no default, set can be changed afterwards - do not destroy the - /// set) + /// set) DEPRECATED + CLI11_DEPRECATED("Use ->check(CLI::IsMember(..., CLI::ignore_case)) with a (shared) pointer instead") Option *add_mutable_set_ignore_case(std::string option_name, std::string &member, ///< The selected member of the set const std::set &options, ///< The set of possibilities @@ -717,7 +719,8 @@ class App { return opt; } - /// Add set of options, string only, ignore case (default, static set) + /// Add set of options, string only, ignore case (default, static set) DEPRECATED + CLI11_DEPRECATED("Use ->check(CLI::IsMember(..., CLI::ignore_case)) instead") Option *add_set_ignore_case(std::string option_name, std::string &member, ///< The selected member of the set std::set options, ///< The set of possibilities @@ -730,6 +733,8 @@ class App { } /// Add set of options, string only, ignore case (default, set can be changed afterwards - do not destroy the set) + /// DEPRECATED + CLI11_DEPRECATED("Use ->check(CLI::IsMember(...)) with a (shared) pointer instead") Option *add_mutable_set_ignore_case(std::string option_name, std::string &member, ///< The selected member of the set const std::set &options, ///< The set of possibilities @@ -741,7 +746,8 @@ class App { return opt; } - /// Add set of options, string only, ignore underscore (no default, static set) + /// Add set of options, string only, ignore underscore (no default, static set) DEPRECATED + CLI11_DEPRECATED("Use ->check(CLI::IsMember(..., CLI::ignore_underscore)) instead") Option *add_set_ignore_underscore(std::string option_name, std::string &member, ///< The selected member of the set std::set options, ///< The set of possibilities @@ -753,7 +759,8 @@ class App { } /// Add set of options, string only, ignore underscore (no default, set can be changed afterwards - do not destroy - /// the set) + /// the set) DEPRECATED + CLI11_DEPRECATED("Use ->check(CLI::IsMember(..., CLI::ignore_underscore)) with a (shared) pointer instead") Option *add_mutable_set_ignore_underscore(std::string option_name, std::string &member, ///< The selected member of the set const std::set &options, ///< The set of possibilities @@ -764,7 +771,8 @@ class App { return opt; } - /// Add set of options, string only, ignore underscore (default, static set) + /// Add set of options, string only, ignore underscore (default, static set) DEPRECATED + CLI11_DEPRECATED("Use ->check(CLI::IsMember(..., CLI::ignore_underscore)) instead") Option *add_set_ignore_underscore(std::string option_name, std::string &member, ///< The selected member of the set std::set options, ///< The set of possibilities @@ -777,7 +785,8 @@ class App { } /// Add set of options, string only, ignore underscore (default, set can be changed afterwards - do not destroy the - /// set) + /// set) DEPRECATED + CLI11_DEPRECATED("Use ->check(CLI::IsMember(..., CLI::ignore_underscore)) with a (shared) pointer instead") Option *add_mutable_set_ignore_underscore(std::string option_name, std::string &member, ///< The selected member of the set const std::set &options, ///< The set of possibilities @@ -789,7 +798,8 @@ class App { return opt; } - /// Add set of options, string only, ignore underscore and case (no default, static set) + /// Add set of options, string only, ignore underscore and case (no default, static set) DEPRECATED + CLI11_DEPRECATED("Use ->check(CLI::IsMember(..., CLI::ignore_case, CLI::ignore_underscore)) instead") Option *add_set_ignore_case_underscore(std::string option_name, std::string &member, ///< The selected member of the set std::set options, ///< The set of possibilities @@ -801,7 +811,9 @@ class App { } /// Add set of options, string only, ignore underscore and case (no default, set can be changed afterwards - do not - /// destroy the set) + /// destroy the set) DEPRECATED + CLI11_DEPRECATED( + "Use ->check(CLI::IsMember(..., CLI::ignore_case, CLI::ignore_underscore)) with a (shared) pointer instead") Option *add_mutable_set_ignore_case_underscore(std::string option_name, std::string &member, ///< The selected member of the set const std::set &options, ///< The set of possibilities @@ -812,7 +824,8 @@ class App { return opt; } - /// Add set of options, string only, ignore underscore and case (default, static set) + /// Add set of options, string only, ignore underscore and case (default, static set) DEPRECATED + CLI11_DEPRECATED("Use ->check(CLI::IsMember(..., CLI::ignore_case, CLI::ignore_underscore)) instead") Option *add_set_ignore_case_underscore(std::string option_name, std::string &member, ///< The selected member of the set std::set options, ///< The set of possibilities @@ -825,7 +838,9 @@ class App { } /// Add set of options, string only, ignore underscore and case (default, set can be changed afterwards - do not - /// destroy the set) + /// destroy the set) DEPRECATED + CLI11_DEPRECATED( + "Use ->check(CLI::IsMember(..., CLI::ignore_case, CLI::ignore_underscore)) with a (shared) pointer instead") Option *add_mutable_set_ignore_case_underscore(std::string option_name, std::string &member, ///< The selected member of the set const std::set &options, ///< The set of possibilities diff --git a/tests/DeprecatedTest.cpp b/tests/DeprecatedTest.cpp index 2e3463d48..c1981eaca 100644 --- a/tests/DeprecatedTest.cpp +++ b/tests/DeprecatedTest.cpp @@ -1,12 +1,328 @@ -#ifdef CLI11_SINGLE_FILE -#include "CLI11.hpp" -#else -#include "CLI/CLI.hpp" -#endif - -#include "gtest/gtest.h" +#include "app_helper.hpp" TEST(Deprecated, Emtpy) { // No deprecated features at this time. EXPECT_TRUE(true); } + +// Classic sets + +TEST_F(TApp, SetWithDefaults) { + int someint = 2; + app.add_set("-a", someint, {1, 2, 3, 4}, "", true); + + args = {"-a1", "-a2"}; + + EXPECT_THROW(run(), CLI::ArgumentMismatch); +} + +TEST_F(TApp, SetWithDefaultsConversion) { + int someint = 2; + app.add_set("-a", someint, {1, 2, 3, 4}, "", true); + + args = {"-a", "hi"}; + + EXPECT_THROW(run(), CLI::ValidationError); +} + +TEST_F(TApp, SetWithDefaultsIC) { + std::string someint = "ho"; + app.add_set_ignore_case("-a", someint, {"Hi", "Ho"}, "", true); + + args = {"-aHi", "-aHo"}; + + EXPECT_THROW(run(), CLI::ArgumentMismatch); +} + +TEST_F(TApp, InSet) { + + std::string choice; + app.add_set("-q,--quick", choice, {"one", "two", "three"}); + + args = {"--quick", "two"}; + + run(); + EXPECT_EQ("two", choice); + + args = {"--quick", "four"}; + EXPECT_THROW(run(), CLI::ValidationError); +} + +TEST_F(TApp, InSetWithDefault) { + + std::string choice = "one"; + app.add_set("-q,--quick", choice, {"one", "two", "three"}, "", true); + + run(); + EXPECT_EQ("one", choice); + + args = {"--quick", "two"}; + + run(); + EXPECT_EQ("two", choice); + + args = {"--quick", "four"}; + EXPECT_THROW(run(), CLI::ValidationError); +} + +TEST_F(TApp, InCaselessSetWithDefault) { + + std::string choice = "one"; + app.add_set_ignore_case("-q,--quick", choice, {"one", "two", "three"}, "", true); + + run(); + EXPECT_EQ("one", choice); + + args = {"--quick", "tWo"}; + + run(); + EXPECT_EQ("two", choice); + + args = {"--quick", "four"}; + EXPECT_THROW(run(), CLI::ValidationError); +} + +TEST_F(TApp, InIntSet) { + + int choice; + app.add_set("-q,--quick", choice, {1, 2, 3}); + + args = {"--quick", "2"}; + + run(); + EXPECT_EQ(2, choice); + + args = {"--quick", "4"}; + EXPECT_THROW(run(), CLI::ValidationError); +} + +TEST_F(TApp, InIntSetWindows) { + + int choice; + app.add_set("-q,--quick", choice, {1, 2, 3}); + app.allow_windows_style_options(); + args = {"/q", "2"}; + + run(); + EXPECT_EQ(2, choice); + + args = {"/q", "4"}; + EXPECT_THROW(run(), CLI::ValidationError); + + args = {"/q4"}; + EXPECT_THROW(run(), CLI::ExtrasError); +} + +TEST_F(TApp, FailSet) { + + int choice; + app.add_set("-q,--quick", choice, {1, 2, 3}); + + args = {"--quick", "3", "--quick=2"}; + EXPECT_THROW(run(), CLI::ArgumentMismatch); + + args = {"--quick=hello"}; + EXPECT_THROW(run(), CLI::ValidationError); +} + +TEST_F(TApp, FailMutableSet) { + + int choice; + std::set vals{1, 2, 3}; + app.add_mutable_set("-q,--quick", choice, vals); + app.add_mutable_set("-s,--slow", choice, vals, "", true); + + args = {"--quick=hello"}; + EXPECT_THROW(run(), CLI::ValidationError); + + args = {"--slow=hello"}; + EXPECT_THROW(run(), CLI::ValidationError); +} + +TEST_F(TApp, InSetIgnoreCase) { + + std::string choice; + app.add_set_ignore_case("-q,--quick", choice, {"one", "Two", "THREE"}); + + args = {"--quick", "One"}; + run(); + EXPECT_EQ("one", choice); + + args = {"--quick", "two"}; + run(); + EXPECT_EQ("Two", choice); // Keeps caps from set + + args = {"--quick", "ThrEE"}; + run(); + EXPECT_EQ("THREE", choice); // Keeps caps from set + + args = {"--quick", "four"}; + EXPECT_THROW(run(), CLI::ValidationError); + + args = {"--quick=one", "--quick=two"}; + EXPECT_THROW(run(), CLI::ArgumentMismatch); +} + +TEST_F(TApp, InSetIgnoreCaseMutableValue) { + + std::set options{"one", "Two", "THREE"}; + std::string choice; + app.add_mutable_set_ignore_case("-q,--quick", choice, options); + + args = {"--quick", "One"}; + run(); + EXPECT_EQ("one", choice); + + args = {"--quick", "two"}; + run(); + EXPECT_EQ("Two", choice); // Keeps caps from set + + args = {"--quick", "ThrEE"}; + run(); + EXPECT_EQ("THREE", choice); // Keeps caps from set + + options.clear(); + args = {"--quick", "ThrEE"}; + EXPECT_THROW(run(), CLI::ValidationError); +} + +TEST_F(TApp, InSetIgnoreCasePointer) { + + auto options = std::make_shared>(std::initializer_list{"one", "Two", "THREE"}); + std::string choice; + app.add_set_ignore_case("-q,--quick", choice, *options); + + args = {"--quick", "One"}; + run(); + EXPECT_EQ("one", choice); + + args = {"--quick", "two"}; + run(); + EXPECT_EQ("Two", choice); // Keeps caps from set + + args = {"--quick", "ThrEE"}; + run(); + EXPECT_EQ("THREE", choice); // Keeps caps from set + + options.reset(); + args = {"--quick", "ThrEE"}; + run(); + EXPECT_EQ("THREE", choice); // this does not throw a segfault + + args = {"--quick", "four"}; + EXPECT_THROW(run(), CLI::ValidationError); + + args = {"--quick=one", "--quick=two"}; + EXPECT_THROW(run(), CLI::ArgumentMismatch); +} + +TEST_F(TApp, InSetIgnoreUnderscore) { + + std::string choice; + app.add_set_ignore_underscore("-q,--quick", choice, {"option_one", "option_two", "optionthree"}); + + args = {"--quick", "option_one"}; + run(); + EXPECT_EQ("option_one", choice); + + args = {"--quick", "optiontwo"}; + run(); + EXPECT_EQ("option_two", choice); // Keeps underscore from set + + args = {"--quick", "_option_thr_ee"}; + run(); + EXPECT_EQ("optionthree", choice); // no underscore + + args = {"--quick", "Option4"}; + EXPECT_THROW(run(), CLI::ValidationError); + + args = {"--quick=option_one", "--quick=option_two"}; + EXPECT_THROW(run(), CLI::ArgumentMismatch); +} + +TEST_F(TApp, InSetIgnoreCaseUnderscore) { + + std::string choice; + app.add_set_ignore_case_underscore("-q,--quick", choice, {"Option_One", "option_two", "OptionThree"}); + + args = {"--quick", "option_one"}; + run(); + EXPECT_EQ("Option_One", choice); + + args = {"--quick", "OptionTwo"}; + run(); + EXPECT_EQ("option_two", choice); // Keeps underscore and case from set + + args = {"--quick", "_OPTION_thr_ee"}; + run(); + EXPECT_EQ("OptionThree", choice); // no underscore + + args = {"--quick", "Option4"}; + EXPECT_THROW(run(), CLI::ValidationError); + + args = {"--quick=option_one", "--quick=option_two"}; + EXPECT_THROW(run(), CLI::ArgumentMismatch); +} + +// #113 +TEST_F(TApp, AddRemoveSetItems) { + std::set items{"TYPE1", "TYPE2", "TYPE3", "TYPE4", "TYPE5"}; + + std::string type1, type2; + app.add_mutable_set("--type1", type1, items); + app.add_mutable_set("--type2", type2, items, "", true); + + args = {"--type1", "TYPE1", "--type2", "TYPE2"}; + + run(); + EXPECT_EQ(type1, "TYPE1"); + EXPECT_EQ(type2, "TYPE2"); + + items.insert("TYPE6"); + items.insert("TYPE7"); + + items.erase("TYPE1"); + items.erase("TYPE2"); + + args = {"--type1", "TYPE6", "--type2", "TYPE7"}; + run(); + EXPECT_EQ(type1, "TYPE6"); + EXPECT_EQ(type2, "TYPE7"); + + args = {"--type1", "TYPE1"}; + EXPECT_THROW(run(), CLI::ValidationError); + + args = {"--type2", "TYPE2"}; + EXPECT_THROW(run(), CLI::ValidationError); +} + +TEST_F(TApp, AddRemoveSetItemsNoCase) { + std::set items{"TYPE1", "TYPE2", "TYPE3", "TYPE4", "TYPE5"}; + + std::string type1, type2; + app.add_mutable_set_ignore_case("--type1", type1, items); + app.add_mutable_set_ignore_case("--type2", type2, items, "", true); + + args = {"--type1", "TYPe1", "--type2", "TyPE2"}; + + run(); + EXPECT_EQ(type1, "TYPE1"); + EXPECT_EQ(type2, "TYPE2"); + + items.insert("TYPE6"); + items.insert("TYPE7"); + + items.erase("TYPE1"); + items.erase("TYPE2"); + + args = {"--type1", "TyPE6", "--type2", "tYPE7"}; + run(); + EXPECT_EQ(type1, "TYPE6"); + EXPECT_EQ(type2, "TYPE7"); + + args = {"--type1", "TYPe1"}; + EXPECT_THROW(run(), CLI::ValidationError); + + args = {"--type2", "TYpE2"}; + EXPECT_THROW(run(), CLI::ValidationError); +} diff --git a/tests/HelpTest.cpp b/tests/HelpTest.cpp index b6c6865a9..1a48d73fe 100644 --- a/tests/HelpTest.cpp +++ b/tests/HelpTest.cpp @@ -280,7 +280,7 @@ TEST(THelp, IntDefaults) { int one{1}, two{2}; app.add_option("--one", one, "Help for one", true); - app.add_set("--set", two, {2, 3, 4}, "Help for set", true); + app.add_option("--set", two, "Help for set", true)->check(CLI::IsMember({2, 3, 4})); std::string help = app.help(); @@ -295,7 +295,7 @@ TEST(THelp, SetLower) { CLI::App app{"My prog"}; std::string def{"One"}; - app.add_set_ignore_case("--set", def, {"oNe", "twO", "THREE"}, "Help for set", true); + app.add_option("--set", def, "Help for set", true)->check(CLI::IsMember({"oNe", "twO", "THREE"})); std::string help = app.help(); @@ -795,7 +795,7 @@ TEST(THelp, ChangingSet) { std::set vals{1, 2, 3}; int val; - app.add_mutable_set("--val", val, vals); + app.add_option("--val", val)->check(CLI::IsMember(&vals)); std::string help = app.help(); @@ -816,7 +816,7 @@ TEST(THelp, ChangingSetDefaulted) { std::set vals{1, 2, 3}; int val = 2; - app.add_mutable_set("--val", val, vals, "", true); + app.add_option("--val", val, "", true)->check(CLI::IsMember(&vals)); std::string help = app.help(); @@ -836,7 +836,7 @@ TEST(THelp, ChangingCaselessSet) { std::set vals{"1", "2", "3"}; std::string val; - app.add_mutable_set_ignore_case("--val", val, vals); + app.add_option("--val", val)->check(CLI::IsMember(&vals, CLI::ignore_case)); std::string help = app.help(); @@ -857,7 +857,7 @@ TEST(THelp, ChangingCaselessSetDefaulted) { std::set vals{"1", "2", "3"}; std::string val = "2"; - app.add_mutable_set_ignore_case("--val", val, vals, "", true); + app.add_option("--val", val, "", true)->check(CLI::IsMember(&vals, CLI::ignore_case)); std::string help = app.help(); diff --git a/tests/IniTest.cpp b/tests/IniTest.cpp index bf3c0a92e..ea2c376c5 100644 --- a/tests/IniTest.cpp +++ b/tests/IniTest.cpp @@ -767,7 +767,7 @@ TEST_F(TApp, IniOutputFlag) { TEST_F(TApp, IniOutputSet) { int v; - app.add_set("--simple", v, {1, 2, 3}); + app.add_option("--simple", v)->check(CLI::IsMember({1, 2, 3})); args = {"--simple=2"}; diff --git a/tests/SetTest.cpp b/tests/SetTest.cpp index 1d3d2cc15..2db748ecb 100644 --- a/tests/SetTest.cpp +++ b/tests/SetTest.cpp @@ -126,11 +126,11 @@ TEST_F(TApp, NumericalSets) { EXPECT_EQ(value, 1); } -// Classic sets +// Converted original set tests TEST_F(TApp, SetWithDefaults) { int someint = 2; - app.add_set("-a", someint, {1, 2, 3, 4}, "", true); + app.add_option("-a", someint, "", true)->check(CLI::IsMember({1, 2, 3, 4})); args = {"-a1", "-a2"}; @@ -139,7 +139,7 @@ TEST_F(TApp, SetWithDefaults) { TEST_F(TApp, SetWithDefaultsConversion) { int someint = 2; - app.add_set("-a", someint, {1, 2, 3, 4}, "", true); + app.add_option("-a", someint, "", true)->check(CLI::IsMember({1, 2, 3, 4})); args = {"-a", "hi"}; @@ -148,7 +148,7 @@ TEST_F(TApp, SetWithDefaultsConversion) { TEST_F(TApp, SetWithDefaultsIC) { std::string someint = "ho"; - app.add_set_ignore_case("-a", someint, {"Hi", "Ho"}, "", true); + app.add_option("-a", someint, "", true)->check(CLI::IsMember({"Hi", "Ho"})); args = {"-aHi", "-aHo"}; @@ -158,7 +158,7 @@ TEST_F(TApp, SetWithDefaultsIC) { TEST_F(TApp, InSet) { std::string choice; - app.add_set("-q,--quick", choice, {"one", "two", "three"}); + app.add_option("-q,--quick", choice)->check(CLI::IsMember({"one", "two", "three"})); args = {"--quick", "two"}; @@ -172,7 +172,7 @@ TEST_F(TApp, InSet) { TEST_F(TApp, InSetWithDefault) { std::string choice = "one"; - app.add_set("-q,--quick", choice, {"one", "two", "three"}, "", true); + app.add_option("-q,--quick", choice, "", true)->check(CLI::IsMember({"one", "two", "three"})); run(); EXPECT_EQ("one", choice); @@ -189,7 +189,7 @@ TEST_F(TApp, InSetWithDefault) { TEST_F(TApp, InCaselessSetWithDefault) { std::string choice = "one"; - app.add_set_ignore_case("-q,--quick", choice, {"one", "two", "three"}, "", true); + app.add_option("-q,--quick", choice, "", true)->check(CLI::IsMember({"one", "two", "three"}, CLI::ignore_case)); run(); EXPECT_EQ("one", choice); @@ -206,7 +206,7 @@ TEST_F(TApp, InCaselessSetWithDefault) { TEST_F(TApp, InIntSet) { int choice; - app.add_set("-q,--quick", choice, {1, 2, 3}); + app.add_option("-q,--quick", choice)->check(CLI::IsMember({1, 2, 3})); args = {"--quick", "2"}; @@ -220,7 +220,7 @@ TEST_F(TApp, InIntSet) { TEST_F(TApp, InIntSetWindows) { int choice; - app.add_set("-q,--quick", choice, {1, 2, 3}); + app.add_option("-q,--quick", choice)->check(CLI::IsMember({1, 2, 3})); app.allow_windows_style_options(); args = {"/q", "2"}; @@ -237,7 +237,7 @@ TEST_F(TApp, InIntSetWindows) { TEST_F(TApp, FailSet) { int choice; - app.add_set("-q,--quick", choice, {1, 2, 3}); + app.add_option("-q,--quick", choice)->check(CLI::IsMember({1, 2, 3})); args = {"--quick", "3", "--quick=2"}; EXPECT_THROW(run(), CLI::ArgumentMismatch); @@ -249,9 +249,9 @@ TEST_F(TApp, FailSet) { TEST_F(TApp, FailMutableSet) { int choice; - std::set vals{1, 2, 3}; - app.add_mutable_set("-q,--quick", choice, vals); - app.add_mutable_set("-s,--slow", choice, vals, "", true); + auto vals = std::shared_ptr>(new std::set({1, 2, 3})); + app.add_option("-q,--quick", choice)->check(CLI::IsMember(vals)); + app.add_option("-s,--slow", choice, "", true)->check(CLI::IsMember(vals)); args = {"--quick=hello"}; EXPECT_THROW(run(), CLI::ValidationError); @@ -263,7 +263,7 @@ TEST_F(TApp, FailMutableSet) { TEST_F(TApp, InSetIgnoreCase) { std::string choice; - app.add_set_ignore_case("-q,--quick", choice, {"one", "Two", "THREE"}); + app.add_option("-q,--quick", choice)->check(CLI::IsMember({"one", "Two", "THREE"}, CLI::ignore_case)); args = {"--quick", "One"}; run(); @@ -288,7 +288,7 @@ TEST_F(TApp, InSetIgnoreCaseMutableValue) { std::set options{"one", "Two", "THREE"}; std::string choice; - app.add_mutable_set_ignore_case("-q,--quick", choice, options); + app.add_option("-q,--quick", choice)->check(CLI::IsMember(&options, CLI::ignore_case)); args = {"--quick", "One"}; run(); @@ -311,7 +311,7 @@ TEST_F(TApp, InSetIgnoreCasePointer) { std::set *options = new std::set{"one", "Two", "THREE"}; std::string choice; - app.add_set_ignore_case("-q,--quick", choice, *options); + app.add_option("-q,--quick", choice)->check(CLI::IsMember(*options, CLI::ignore_case)); args = {"--quick", "One"}; run(); @@ -340,7 +340,8 @@ TEST_F(TApp, InSetIgnoreCasePointer) { TEST_F(TApp, InSetIgnoreUnderscore) { std::string choice; - app.add_set_ignore_underscore("-q,--quick", choice, {"option_one", "option_two", "optionthree"}); + app.add_option("-q,--quick", choice) + ->check(CLI::IsMember({"option_one", "option_two", "optionthree"}, CLI::ignore_underscore)); args = {"--quick", "option_one"}; run(); @@ -364,7 +365,8 @@ TEST_F(TApp, InSetIgnoreUnderscore) { TEST_F(TApp, InSetIgnoreCaseUnderscore) { std::string choice; - app.add_set_ignore_case_underscore("-q,--quick", choice, {"Option_One", "option_two", "OptionThree"}); + app.add_option("-q,--quick", choice) + ->check(CLI::IsMember({"Option_One", "option_two", "OptionThree"}, CLI::ignore_case, CLI::ignore_underscore)); args = {"--quick", "option_one"}; run(); @@ -390,8 +392,8 @@ TEST_F(TApp, AddRemoveSetItems) { std::set items{"TYPE1", "TYPE2", "TYPE3", "TYPE4", "TYPE5"}; std::string type1, type2; - app.add_mutable_set("--type1", type1, items); - app.add_mutable_set("--type2", type2, items, "", true); + app.add_option("--type1", type1)->check(CLI::IsMember(&items)); + app.add_option("--type2", type2, "", true)->check(CLI::IsMember(&items)); args = {"--type1", "TYPE1", "--type2", "TYPE2"}; @@ -421,8 +423,8 @@ TEST_F(TApp, AddRemoveSetItemsNoCase) { std::set items{"TYPE1", "TYPE2", "TYPE3", "TYPE4", "TYPE5"}; std::string type1, type2; - app.add_mutable_set_ignore_case("--type1", type1, items); - app.add_mutable_set_ignore_case("--type2", type2, items, "", true); + app.add_option("--type1", type1)->check(CLI::IsMember(&items, CLI::ignore_case)); + app.add_option("--type2", type2, "", true)->check(CLI::IsMember(&items, CLI::ignore_case)); args = {"--type1", "TYPe1", "--type2", "TyPE2"};