aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Klitzke <[email protected]>2018-03-21 19:22:52 -0700
committerEvan Klitzke <[email protected]>2018-03-27 22:11:11 -0700
commit4f872b24501f40bd410227b5413bda2f2569af24 (patch)
tree188390ca279693c4c9bfb6050641e923cf73e5d1
parentMerge #12717: [REST] Handle UTXO retrieval when ignoring the mempool (diff)
downloaddiscoin-4f872b24501f40bd410227b5413bda2f2569af24.tar.xz
discoin-4f872b24501f40bd410227b5413bda2f2569af24.zip
Add additional tests for GetBoolArg()
This is meant to be an intermediate commit to prove that the next does not introduce any changes in the semantics of boolean option parsing.
-rw-r--r--src/test/util_tests.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
index b6f3cbe2b..094bc66ac 100644
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -223,6 +223,32 @@ BOOST_AUTO_TEST_CASE(util_ParseParameters)
BOOST_CHECK(testArgs.GetArgs("-ccc").size() == 2);
}
+BOOST_AUTO_TEST_CASE(util_GetBoolArg)
+{
+ TestArgsManager testArgs;
+ const char *argv_test[] = {
+ "ignored", "-a", "-nob", "-c=0", "-d=1", "-e=false", "-f=true"};
+ testArgs.ParseParameters(7, (char**)argv_test);
+
+ // Each letter should be set.
+ for (char opt : "abcdef")
+ BOOST_CHECK(testArgs.IsArgSet({'-', opt}) || !opt);
+
+ // Nothing else should be in the map
+ BOOST_CHECK(testArgs.GetMapArgs().size() == 6 &&
+ testArgs.GetMapMultiArgs().size() == 6);
+
+ // The -no prefix should get stripped on the way in.
+ BOOST_CHECK(!testArgs.IsArgSet("-nob"));
+
+ // Check expected values.
+ BOOST_CHECK(testArgs.GetBoolArg("-a", false) == true);
+ BOOST_CHECK(testArgs.GetBoolArg("-b", true) == false);
+ BOOST_CHECK(testArgs.GetBoolArg("-c", true) == false);
+ BOOST_CHECK(testArgs.GetBoolArg("-d", false) == true);
+ BOOST_CHECK(testArgs.GetBoolArg("-e", true) == false);
+ BOOST_CHECK(testArgs.GetBoolArg("-f", true) == false);
+}
BOOST_AUTO_TEST_CASE(util_GetArg)
{
TestArgsManager testArgs;