From e6f649cb2c07bf55d9214c2876619c56f1d6fe30 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 27 Jul 2019 20:27:08 +0300 Subject: test: Make tests arg type specific --- src/test/getarg_tests.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/test/getarg_tests.cpp') diff --git a/src/test/getarg_tests.cpp b/src/test/getarg_tests.cpp index e36ba4b3c1..77304fe918 100644 --- a/src/test/getarg_tests.cpp +++ b/src/test/getarg_tests.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -32,17 +33,18 @@ static void ResetArgs(const std::string& strArg) BOOST_CHECK(gArgs.ParseParameters(vecChar.size(), vecChar.data(), error)); } -static void SetupArgs(const std::vector& args) +static void SetupArgs(const std::vector>& args) { gArgs.ClearArgs(); - for (const std::string& arg : args) { - gArgs.AddArg(arg, "", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); + for (const auto& arg : args) { + gArgs.AddArg(arg.first, "", arg.second, OptionsCategory::OPTIONS); } } BOOST_AUTO_TEST_CASE(boolarg) { - SetupArgs({"-foo"}); + const auto foo = std::make_pair("-foo", ArgsManager::ALLOW_BOOL); + SetupArgs({foo}); ResetArgs("-foo"); BOOST_CHECK(gArgs.GetBoolArg("-foo", false)); BOOST_CHECK(gArgs.GetBoolArg("-foo", true)); @@ -95,7 +97,9 @@ BOOST_AUTO_TEST_CASE(boolarg) BOOST_AUTO_TEST_CASE(stringarg) { - SetupArgs({"-foo", "-bar"}); + const auto foo = std::make_pair("-foo", ArgsManager::ALLOW_STRING); + const auto bar = std::make_pair("-bar", ArgsManager::ALLOW_STRING); + SetupArgs({foo, bar}); ResetArgs(""); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", ""), ""); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", "eleven"), "eleven"); @@ -120,7 +124,9 @@ BOOST_AUTO_TEST_CASE(stringarg) BOOST_AUTO_TEST_CASE(intarg) { - SetupArgs({"-foo", "-bar"}); + const auto foo = std::make_pair("-foo", ArgsManager::ALLOW_INT); + const auto bar = std::make_pair("-bar", ArgsManager::ALLOW_INT); + SetupArgs({foo, bar}); ResetArgs(""); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", 11), 11); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", 0), 0); @@ -140,7 +146,9 @@ BOOST_AUTO_TEST_CASE(intarg) BOOST_AUTO_TEST_CASE(doubledash) { - SetupArgs({"-foo", "-bar"}); + const auto foo = std::make_pair("-foo", ArgsManager::ALLOW_ANY); + const auto bar = std::make_pair("-bar", ArgsManager::ALLOW_ANY); + SetupArgs({foo, bar}); ResetArgs("--foo"); BOOST_CHECK_EQUAL(gArgs.GetBoolArg("-foo", false), true); @@ -151,7 +159,9 @@ BOOST_AUTO_TEST_CASE(doubledash) BOOST_AUTO_TEST_CASE(boolargno) { - SetupArgs({"-foo", "-bar"}); + const auto foo = std::make_pair("-foo", ArgsManager::ALLOW_BOOL); + const auto bar = std::make_pair("-bar", ArgsManager::ALLOW_BOOL); + SetupArgs({foo, bar}); ResetArgs("-nofoo"); BOOST_CHECK(!gArgs.GetBoolArg("-foo", true)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", false)); -- cgit v1.2.3