Changeset View
Changeset View
Standalone View
Standalone View
src/test/util_tests.cpp
Show First 20 Lines • Show All 229 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(util_GetBoolArg) { | ||||
const char *avail_args[] = {"-a", "-b", "-c", "-d", "-e", "-f"}; | const char *avail_args[] = {"-a", "-b", "-c", "-d", "-e", "-f"}; | ||||
const char *argv_test[] = {"ignored", "-a", "-nob", "-c=0", | const char *argv_test[] = {"ignored", "-a", "-nob", "-c=0", | ||||
"-d=1", "-e=false", "-f=true"}; | "-d=1", "-e=false", "-f=true"}; | ||||
std::string error; | std::string error; | ||||
testArgs.SetupArgs(6, avail_args); | testArgs.SetupArgs(6, avail_args); | ||||
testArgs.ParseParameters(7, (char **)argv_test, error); | testArgs.ParseParameters(7, (char **)argv_test, error); | ||||
// Each letter should be set. | // Each letter should be set. | ||||
for (char opt : "abcdef") { | for (const char opt : "abcdef") { | ||||
BOOST_CHECK(testArgs.IsArgSet({'-', opt}) || !opt); | BOOST_CHECK(testArgs.IsArgSet({'-', opt}) || !opt); | ||||
} | } | ||||
// Nothing else should be in the map | // Nothing else should be in the map | ||||
BOOST_CHECK(testArgs.GetOverrideArgs().size() == 6 && | BOOST_CHECK(testArgs.GetOverrideArgs().size() == 6 && | ||||
testArgs.GetConfigArgs().empty()); | testArgs.GetConfigArgs().empty()); | ||||
// The -no prefix should get stripped on the way in. | // The -no prefix should get stripped on the way in. | ||||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | BOOST_CHECK(test_args.GetArg("-a", "xxx") == "" && | ||||
test_args.GetArg("-d", "xxx") == "e" && | test_args.GetArg("-d", "xxx") == "e" && | ||||
test_args.GetArg("-fff", "xxx") == "0" && | test_args.GetArg("-fff", "xxx") == "0" && | ||||
test_args.GetArg("-ggg", "xxx") == "1" && | test_args.GetArg("-ggg", "xxx") == "1" && | ||||
test_args.GetArg("-h", "xxx") == "0" && | test_args.GetArg("-h", "xxx") == "0" && | ||||
test_args.GetArg("-i", "xxx") == "1" && | test_args.GetArg("-i", "xxx") == "1" && | ||||
test_args.GetArg("-zzz", "xxx") == "xxx" && | test_args.GetArg("-zzz", "xxx") == "xxx" && | ||||
test_args.GetArg("-iii", "xxx") == "xxx"); | test_args.GetArg("-iii", "xxx") == "xxx"); | ||||
for (bool def : {false, true}) { | for (const bool def : {false, true}) { | ||||
BOOST_CHECK(test_args.GetBoolArg("-a", def) && | BOOST_CHECK(test_args.GetBoolArg("-a", def) && | ||||
test_args.GetBoolArg("-b", def) && | test_args.GetBoolArg("-b", def) && | ||||
!test_args.GetBoolArg("-ccc", def) && | !test_args.GetBoolArg("-ccc", def) && | ||||
!test_args.GetBoolArg("-d", def) && | !test_args.GetBoolArg("-d", def) && | ||||
!test_args.GetBoolArg("-fff", def) && | !test_args.GetBoolArg("-fff", def) && | ||||
test_args.GetBoolArg("-ggg", def) && | test_args.GetBoolArg("-ggg", def) && | ||||
!test_args.GetBoolArg("-h", def) && | !test_args.GetBoolArg("-h", def) && | ||||
test_args.GetBoolArg("-i", def) && | test_args.GetBoolArg("-i", def) && | ||||
▲ Show 20 Lines • Show All 1,048 Lines • Show Last 20 Lines |