Skip to content

Commit

Permalink
drop: set (#565)
Browse files Browse the repository at this point in the history
* refactor!: drop sets

* ci: fix clang 10 build
  • Loading branch information
henryiii authored Apr 4, 2021
1 parent 3eb5e1e commit 51ea7eb
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 189 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
cli11.std: 17
cli11.options: -DCLI11_FORCE_LIBCXX=ON
clang10_20:
containerImage: helics/buildenv:clang10-builder
containerImage: silkeh/clang:10
cli11.std: 20
cli11.options: -DCLI11_FORCE_LIBCXX=ON -DCMAKE_CXX_FLAGS=-std=c++20
container: $[ variables['containerImage'] ]
Expand Down
50 changes: 0 additions & 50 deletions include/CLI/App.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -897,56 +897,6 @@ class App {
}
#endif

/// Add set of options (No default, temp reference, such as an inline set) DEPRECATED
template <typename T>
Option *add_set(std::string option_name,
T &member, ///< The selected member of the set
std::set<T> options, ///< The set of possibilities
std::string option_description = "") {

Option *opt = add_option(option_name, member, std::move(option_description));
opt->check(IsMember{options});
return opt;
}

/// Add set of options (No default, set can be changed afterwards - do not destroy the set) DEPRECATED
template <typename T>
Option *add_mutable_set(std::string option_name,
T &member, ///< The selected member of the set
const std::set<T> &options, ///< The set of possibilities
std::string option_description = "") {

Option *opt = add_option(option_name, member, std::move(option_description));
opt->check(IsMember{&options});
return opt;
}

/// Add set of options (with default, static set, such as an inline set) DEPRECATED
template <typename T>
Option *add_set(std::string option_name,
T &member, ///< The selected member of the set
std::set<T> options, ///< The set of possibilities
std::string option_description,
bool defaulted) {

Option *opt = add_option(option_name, member, std::move(option_description), defaulted);
opt->check(IsMember{options});
return opt;
}

/// Add set of options (with default, set can be changed afterwards - do not destroy the set) DEPRECATED
template <typename T>
Option *add_mutable_set(std::string option_name,
T &member, ///< The selected member of the set
const std::set<T> &options, ///< The set of possibilities
std::string option_description,
bool defaulted) {

Option *opt = add_option(option_name, member, std::move(option_description), defaulted);
opt->check(IsMember{&options});
return opt;
}

/// Add a complex number DEPRECATED --use add_option instead
template <typename T, typename XC = double>
Option *add_complex(std::string option_name,
Expand Down
138 changes: 0 additions & 138 deletions tests/DeprecatedTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,144 +15,6 @@ TEST_CASE("Deprecated: Empty", "[deprecated]") {

// Classic sets

TEST_CASE_METHOD(TApp, "SetWithDefaults", "[deprecated]") {
int someint = 2;
app.add_set("-a", someint, {1, 2, 3, 4}, "", true);

args = {"-a1", "-a2"};

CHECK_THROWS_AS(run(), CLI::ArgumentMismatch);
}

TEST_CASE_METHOD(TApp, "SetWithDefaultsConversion", "[deprecated]") {
int someint = 2;
app.add_set("-a", someint, {1, 2, 3, 4}, "", true);

args = {"-a", "hi"};

CHECK_THROWS_AS(run(), CLI::ValidationError);
}

TEST_CASE_METHOD(TApp, "InSet", "[deprecated]") {

std::string choice;
app.add_set("-q,--quick", choice, {"one", "two", "three"});

args = {"--quick", "two"};

run();
CHECK(choice == "two");

args = {"--quick", "four"};
CHECK_THROWS_AS(run(), CLI::ValidationError);
}

TEST_CASE_METHOD(TApp, "InSetWithDefault", "[deprecated]") {

std::string choice = "one";
app.add_set("-q,--quick", choice, {"one", "two", "three"}, "", true);

run();
CHECK(choice == "one");

args = {"--quick", "two"};

run();
CHECK(choice == "two");

args = {"--quick", "four"};
CHECK_THROWS_AS(run(), CLI::ValidationError);
}

TEST_CASE_METHOD(TApp, "InIntSet", "[deprecated]") {

int choice;
app.add_set("-q,--quick", choice, {1, 2, 3});

args = {"--quick", "2"};

run();
CHECK(choice == 2);

args = {"--quick", "4"};
CHECK_THROWS_AS(run(), CLI::ValidationError);
}

TEST_CASE_METHOD(TApp, "InIntSetWindows", "[deprecated]") {

int choice;
app.add_set("-q,--quick", choice, {1, 2, 3});
app.allow_windows_style_options();
args = {"/q", "2"};

run();
CHECK(choice == 2);

args = {"/q", "4"};
CHECK_THROWS_AS(run(), CLI::ValidationError);

args = {"/q4"};
CHECK_THROWS_AS(run(), CLI::ExtrasError);
}

TEST_CASE_METHOD(TApp, "FailSet", "[deprecated]") {

int choice;
app.add_set("-q,--quick", choice, {1, 2, 3});

args = {"--quick", "3", "--quick=2"};
CHECK_THROWS_AS(run(), CLI::ArgumentMismatch);

args = {"--quick=hello"};
CHECK_THROWS_AS(run(), CLI::ValidationError);
}

TEST_CASE_METHOD(TApp, "FailMutableSet", "[deprecated]") {

int choice;
std::set<int> vals{1, 2, 3};
app.add_mutable_set("-q,--quick", choice, vals);
app.add_mutable_set("-s,--slow", choice, vals, "", true);

args = {"--quick=hello"};
CHECK_THROWS_AS(run(), CLI::ValidationError);

args = {"--slow=hello"};
CHECK_THROWS_AS(run(), CLI::ValidationError);
}

// #113
TEST_CASE_METHOD(TApp, "AddRemoveSetItems", "[deprecated]") {
std::set<std::string> 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();
CHECK("TYPE1" == type1);
CHECK("TYPE2" == type2);

items.insert("TYPE6");
items.insert("TYPE7");

items.erase("TYPE1");
items.erase("TYPE2");

args = {"--type1", "TYPE6", "--type2", "TYPE7"};
run();
CHECK("TYPE6" == type1);
CHECK("TYPE7" == type2);

args = {"--type1", "TYPE1"};
CHECK_THROWS_AS(run(), CLI::ValidationError);

args = {"--type2", "TYPE2"};
CHECK_THROWS_AS(run(), CLI::ValidationError);
}

TEST_CASE("THelp: Defaults", "[deprecated]") {
CLI::App app{"My prog"};

Expand Down

0 comments on commit 51ea7eb

Please sign in to comment.