From e7c6d3c6d189f0eecd696cb15951c0852b5d8496 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 4 Mar 2021 17:19:56 -0500 Subject: [PATCH 1/2] refactor!: drop sets --- include/CLI/App.hpp | 50 -------------- tests/DeprecatedTest.cpp | 138 --------------------------------------- 2 files changed, 188 deletions(-) diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index d3c513bd0..4c46409c5 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -897,56 +897,6 @@ class App { } #endif - /// 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 - std::set 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 - Option *add_mutable_set(std::string option_name, - T &member, ///< The selected member of the set - const std::set &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 - Option *add_set(std::string option_name, - T &member, ///< The selected member of the set - std::set 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 - Option *add_mutable_set(std::string option_name, - T &member, ///< The selected member of the set - const std::set &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 Option *add_complex(std::string option_name, diff --git a/tests/DeprecatedTest.cpp b/tests/DeprecatedTest.cpp index 62d3619dd..cf9987c6d 100644 --- a/tests/DeprecatedTest.cpp +++ b/tests/DeprecatedTest.cpp @@ -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 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 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"}; From 1bc539abdfe4e31c9878ca3705cdefdf036bd152 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 4 Mar 2021 17:22:25 -0500 Subject: [PATCH 2/2] ci: fix clang 10 build --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 90017c62f..c72c748e6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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'] ]