remove GetBoolArg() fDefault parameter defaulting to false
- explicitly set the default of all GetBoolArg() calls - rework getarg_test.cpp and util_tests.cpp to cover this change - some indentation fixes - move macdockiconhandler.h include in bitcoin.cpp to the "our headers" section
This commit is contained in:
parent
3d661110da
commit
3260b4c090
10 changed files with 61 additions and 76 deletions
|
@ -757,7 +757,7 @@ void StartRPCThreads()
|
||||||
rpc_io_service = new asio::io_service();
|
rpc_io_service = new asio::io_service();
|
||||||
rpc_ssl_context = new ssl::context(*rpc_io_service, ssl::context::sslv23);
|
rpc_ssl_context = new ssl::context(*rpc_io_service, ssl::context::sslv23);
|
||||||
|
|
||||||
const bool fUseSSL = GetBoolArg("-rpcssl");
|
const bool fUseSSL = GetBoolArg("-rpcssl", false);
|
||||||
|
|
||||||
if (fUseSSL)
|
if (fUseSSL)
|
||||||
{
|
{
|
||||||
|
@ -1037,7 +1037,7 @@ json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_s
|
||||||
|
|
||||||
// Observe safe mode
|
// Observe safe mode
|
||||||
string strWarning = GetWarnings("rpc");
|
string strWarning = GetWarnings("rpc");
|
||||||
if (strWarning != "" && !GetBoolArg("-disablesafemode") &&
|
if (strWarning != "" && !GetBoolArg("-disablesafemode", false) &&
|
||||||
!pcmd->okSafeMode)
|
!pcmd->okSafeMode)
|
||||||
throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, string("Safe mode: ") + strWarning);
|
throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, string("Safe mode: ") + strWarning);
|
||||||
|
|
||||||
|
@ -1071,7 +1071,7 @@ Object CallRPC(const string& strMethod, const Array& params)
|
||||||
GetConfigFile().string().c_str()));
|
GetConfigFile().string().c_str()));
|
||||||
|
|
||||||
// Connect to localhost
|
// Connect to localhost
|
||||||
bool fUseSSL = GetBoolArg("-rpcssl");
|
bool fUseSSL = GetBoolArg("-rpcssl", false);
|
||||||
asio::io_service io_service;
|
asio::io_service io_service;
|
||||||
ssl::context context(io_service, ssl::context::sslv23);
|
ssl::context context(io_service, ssl::context::sslv23);
|
||||||
context.set_options(ssl::context::no_sslv2);
|
context.set_options(ssl::context::no_sslv2);
|
||||||
|
|
28
src/init.cpp
28
src/init.cpp
|
@ -198,7 +198,7 @@ bool AppInit(int argc, char* argv[])
|
||||||
exit(ret);
|
exit(ret);
|
||||||
}
|
}
|
||||||
#if !defined(WIN32)
|
#if !defined(WIN32)
|
||||||
fDaemon = GetBoolArg("-daemon");
|
fDaemon = GetBoolArg("-daemon", false);
|
||||||
if (fDaemon)
|
if (fDaemon)
|
||||||
{
|
{
|
||||||
// Daemonize
|
// Daemonize
|
||||||
|
@ -495,7 +495,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||||
|
|
||||||
// ********************************************************* Step 2: parameter interactions
|
// ********************************************************* Step 2: parameter interactions
|
||||||
|
|
||||||
fTestNet = GetBoolArg("-testnet");
|
fTestNet = GetBoolArg("-testnet", false);
|
||||||
Checkpoints::fEnabled = GetBoolArg("-checkpoints", true);
|
Checkpoints::fEnabled = GetBoolArg("-checkpoints", true);
|
||||||
|
|
||||||
if (mapArgs.count("-bind")) {
|
if (mapArgs.count("-bind")) {
|
||||||
|
@ -526,7 +526,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||||
SoftSetBoolArg("-discover", false);
|
SoftSetBoolArg("-discover", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetBoolArg("-salvagewallet")) {
|
if (GetBoolArg("-salvagewallet", false)) {
|
||||||
// Rewrite just private keys: rescan to find transactions
|
// Rewrite just private keys: rescan to find transactions
|
||||||
SoftSetBoolArg("-rescan", true);
|
SoftSetBoolArg("-rescan", true);
|
||||||
}
|
}
|
||||||
|
@ -543,8 +543,8 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||||
|
|
||||||
// ********************************************************* Step 3: parameter-to-internal-flags
|
// ********************************************************* Step 3: parameter-to-internal-flags
|
||||||
|
|
||||||
fDebug = GetBoolArg("-debug");
|
fDebug = GetBoolArg("-debug", false);
|
||||||
fBenchmark = GetBoolArg("-benchmark");
|
fBenchmark = GetBoolArg("-benchmark", false);
|
||||||
|
|
||||||
// -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency
|
// -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency
|
||||||
nScriptCheckThreads = GetArg("-par", 0);
|
nScriptCheckThreads = GetArg("-par", 0);
|
||||||
|
@ -559,20 +559,20 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||||
if (fDebug)
|
if (fDebug)
|
||||||
fDebugNet = true;
|
fDebugNet = true;
|
||||||
else
|
else
|
||||||
fDebugNet = GetBoolArg("-debugnet");
|
fDebugNet = GetBoolArg("-debugnet", false);
|
||||||
|
|
||||||
if (fDaemon)
|
if (fDaemon)
|
||||||
fServer = true;
|
fServer = true;
|
||||||
else
|
else
|
||||||
fServer = GetBoolArg("-server");
|
fServer = GetBoolArg("-server", false);
|
||||||
|
|
||||||
/* force fServer when running without GUI */
|
/* force fServer when running without GUI */
|
||||||
#if !defined(QT_GUI)
|
#if !defined(QT_GUI)
|
||||||
fServer = true;
|
fServer = true;
|
||||||
#endif
|
#endif
|
||||||
fPrintToConsole = GetBoolArg("-printtoconsole");
|
fPrintToConsole = GetBoolArg("-printtoconsole", false);
|
||||||
fPrintToDebugger = GetBoolArg("-printtodebugger");
|
fPrintToDebugger = GetBoolArg("-printtodebugger", false);
|
||||||
fLogTimestamps = GetBoolArg("-logtimestamps");
|
fLogTimestamps = GetBoolArg("-logtimestamps", false);
|
||||||
|
|
||||||
if (mapArgs.count("-timeout"))
|
if (mapArgs.count("-timeout"))
|
||||||
{
|
{
|
||||||
|
@ -677,7 +677,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetBoolArg("-salvagewallet"))
|
if (GetBoolArg("-salvagewallet", false))
|
||||||
{
|
{
|
||||||
// Recover readable keypairs:
|
// Recover readable keypairs:
|
||||||
if (!CWalletDB::Recover(bitdb, "wallet.dat", true))
|
if (!CWalletDB::Recover(bitdb, "wallet.dat", true))
|
||||||
|
@ -799,7 +799,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||||
|
|
||||||
// ********************************************************* Step 7: load block chain
|
// ********************************************************* Step 7: load block chain
|
||||||
|
|
||||||
fReindex = GetBoolArg("-reindex");
|
fReindex = GetBoolArg("-reindex", false);
|
||||||
|
|
||||||
// Upgrading to 0.8; hard-link the old blknnnn.dat files into /blocks/
|
// Upgrading to 0.8; hard-link the old blknnnn.dat files into /blocks/
|
||||||
filesystem::path blocksDir = GetDataDir() / "blocks";
|
filesystem::path blocksDir = GetDataDir() / "blocks";
|
||||||
|
@ -922,7 +922,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||||
}
|
}
|
||||||
printf(" block index %15"PRI64d"ms\n", GetTimeMillis() - nStart);
|
printf(" block index %15"PRI64d"ms\n", GetTimeMillis() - nStart);
|
||||||
|
|
||||||
if (GetBoolArg("-printblockindex") || GetBoolArg("-printblocktree"))
|
if (GetBoolArg("-printblockindex", false) || GetBoolArg("-printblocktree", false))
|
||||||
{
|
{
|
||||||
PrintBlockTree();
|
PrintBlockTree();
|
||||||
return false;
|
return false;
|
||||||
|
@ -1018,7 +1018,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||||
RegisterWallet(pwalletMain);
|
RegisterWallet(pwalletMain);
|
||||||
|
|
||||||
CBlockIndex *pindexRescan = pindexBest;
|
CBlockIndex *pindexRescan = pindexBest;
|
||||||
if (GetBoolArg("-rescan"))
|
if (GetBoolArg("-rescan", false))
|
||||||
pindexRescan = pindexGenesisBlock;
|
pindexRescan = pindexGenesisBlock;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -2931,7 +2931,7 @@ string GetWarnings(string strFor)
|
||||||
string strStatusBar;
|
string strStatusBar;
|
||||||
string strRPC;
|
string strRPC;
|
||||||
|
|
||||||
if (GetBoolArg("-testsafemode"))
|
if (GetBoolArg("-testsafemode", false))
|
||||||
strRPC = "test";
|
strRPC = "test";
|
||||||
|
|
||||||
if (!CLIENT_VERSION_IS_RELEASE)
|
if (!CLIENT_VERSION_IS_RELEASE)
|
||||||
|
@ -4175,7 +4175,7 @@ CBlockTemplate* CreateNewBlock(CReserveKey& reservekey)
|
||||||
// Priority order to process transactions
|
// Priority order to process transactions
|
||||||
list<COrphan> vOrphan; // list memory doesn't move
|
list<COrphan> vOrphan; // list memory doesn't move
|
||||||
map<uint256, vector<COrphan*> > mapDependers;
|
map<uint256, vector<COrphan*> > mapDependers;
|
||||||
bool fPrintPriority = GetBoolArg("-printpriority");
|
bool fPrintPriority = GetBoolArg("-printpriority", false);
|
||||||
|
|
||||||
// This vector will be sorted into a priority queue:
|
// This vector will be sorted into a priority queue:
|
||||||
vector<TxPriority> vecPriority;
|
vector<TxPriority> vecPriority;
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
#include "ui_interface.h"
|
#include "ui_interface.h"
|
||||||
#include "paymentserver.h"
|
#include "paymentserver.h"
|
||||||
#include "splashscreen.h"
|
#include "splashscreen.h"
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
#include "macdockiconhandler.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
@ -23,10 +26,6 @@
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
#include "macdockiconhandler.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(BITCOIN_NEED_QT_PLUGINS) && !defined(_BITCOIN_QT_PLUGINS_INCLUDED)
|
#if defined(BITCOIN_NEED_QT_PLUGINS) && !defined(_BITCOIN_QT_PLUGINS_INCLUDED)
|
||||||
#define _BITCOIN_QT_PLUGINS_INCLUDED
|
#define _BITCOIN_QT_PLUGINS_INCLUDED
|
||||||
#define __INSURE__
|
#define __INSURE__
|
||||||
|
@ -152,7 +151,7 @@ int main(int argc, char *argv[])
|
||||||
// as it is used to locate QSettings)
|
// as it is used to locate QSettings)
|
||||||
QApplication::setOrganizationName("Bitcoin");
|
QApplication::setOrganizationName("Bitcoin");
|
||||||
QApplication::setOrganizationDomain("bitcoin.org");
|
QApplication::setOrganizationDomain("bitcoin.org");
|
||||||
if(GetBoolArg("-testnet")) // Separate UI settings for testnet
|
if (GetBoolArg("-testnet", false)) // Separate UI settings for testnet
|
||||||
QApplication::setApplicationName("Bitcoin-Qt-testnet");
|
QApplication::setApplicationName("Bitcoin-Qt-testnet");
|
||||||
else
|
else
|
||||||
QApplication::setApplicationName("Bitcoin-Qt");
|
QApplication::setApplicationName("Bitcoin-Qt");
|
||||||
|
@ -204,13 +203,14 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
// on mac, also change the icon now because it would look strange to have a testnet splash (green) and a std app icon (orange)
|
// on mac, also change the icon now because it would look strange to have a testnet splash (green) and a std app icon (orange)
|
||||||
if(GetBoolArg("-testnet")) {
|
if(GetBoolArg("-testnet", false))
|
||||||
|
{
|
||||||
MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin_testnet"));
|
MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin_testnet"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SplashScreen splash(QPixmap(), 0);
|
SplashScreen splash(QPixmap(), 0);
|
||||||
if (GetBoolArg("-splash", true) && !GetBoolArg("-min"))
|
if (GetBoolArg("-splash", true) && !GetBoolArg("-min", false))
|
||||||
{
|
{
|
||||||
splash.show();
|
splash.show();
|
||||||
splash.setAutoFillBackground(true);
|
splash.setAutoFillBackground(true);
|
||||||
|
@ -254,7 +254,7 @@ int main(int argc, char *argv[])
|
||||||
window.setCurrentWallet("~Default");
|
window.setCurrentWallet("~Default");
|
||||||
|
|
||||||
// If -min option passed, start window minimized.
|
// If -min option passed, start window minimized.
|
||||||
if(GetBoolArg("-min"))
|
if(GetBoolArg("-min", false))
|
||||||
{
|
{
|
||||||
window.showMinimized();
|
window.showMinimized();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f) :
|
||||||
|
|
||||||
// load the bitmap for writing some text over it
|
// load the bitmap for writing some text over it
|
||||||
QPixmap newPixmap;
|
QPixmap newPixmap;
|
||||||
if(GetBoolArg("-testnet")) {
|
if(GetBoolArg("-testnet", false)) {
|
||||||
newPixmap = QPixmap(":/images/splash_testnet");
|
newPixmap = QPixmap(":/images/splash_testnet");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -33,7 +33,7 @@ Value getgenerate(const Array& params, bool fHelp)
|
||||||
"getgenerate\n"
|
"getgenerate\n"
|
||||||
"Returns true or false.");
|
"Returns true or false.");
|
||||||
|
|
||||||
return GetBoolArg("-gen");
|
return GetBoolArg("-gen", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ Value getmininginfo(const Array& params, bool fHelp)
|
||||||
obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx));
|
obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx));
|
||||||
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
|
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
|
||||||
obj.push_back(Pair("errors", GetWarnings("statusbar")));
|
obj.push_back(Pair("errors", GetWarnings("statusbar")));
|
||||||
obj.push_back(Pair("generate", GetBoolArg("-gen")));
|
obj.push_back(Pair("generate", GetBoolArg("-gen", false)));
|
||||||
obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1)));
|
obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1)));
|
||||||
obj.push_back(Pair("hashespersec", gethashespersec(params, false)));
|
obj.push_back(Pair("hashespersec", gethashespersec(params, false)));
|
||||||
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
|
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
|
||||||
|
|
|
@ -6,8 +6,7 @@
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(getarg_tests)
|
BOOST_AUTO_TEST_SUITE(getarg_tests)
|
||||||
|
|
||||||
static void
|
static void ResetArgs(const std::string& strArg)
|
||||||
ResetArgs(const std::string& strArg)
|
|
||||||
{
|
{
|
||||||
std::vector<std::string> vecArg;
|
std::vector<std::string> vecArg;
|
||||||
boost::split(vecArg, strArg, boost::is_space(), boost::token_compress_on);
|
boost::split(vecArg, strArg, boost::is_space(), boost::token_compress_on);
|
||||||
|
@ -26,62 +25,50 @@ ResetArgs(const std::string& strArg)
|
||||||
BOOST_AUTO_TEST_CASE(boolarg)
|
BOOST_AUTO_TEST_CASE(boolarg)
|
||||||
{
|
{
|
||||||
ResetArgs("-foo");
|
ResetArgs("-foo");
|
||||||
BOOST_CHECK(GetBoolArg("-foo"));
|
|
||||||
BOOST_CHECK(GetBoolArg("-foo", false));
|
BOOST_CHECK(GetBoolArg("-foo", false));
|
||||||
BOOST_CHECK(GetBoolArg("-foo", true));
|
BOOST_CHECK(GetBoolArg("-foo", true));
|
||||||
|
|
||||||
BOOST_CHECK(!GetBoolArg("-fo"));
|
|
||||||
BOOST_CHECK(!GetBoolArg("-fo", false));
|
BOOST_CHECK(!GetBoolArg("-fo", false));
|
||||||
BOOST_CHECK(GetBoolArg("-fo", true));
|
BOOST_CHECK(GetBoolArg("-fo", true));
|
||||||
|
|
||||||
BOOST_CHECK(!GetBoolArg("-fooo"));
|
|
||||||
BOOST_CHECK(!GetBoolArg("-fooo", false));
|
BOOST_CHECK(!GetBoolArg("-fooo", false));
|
||||||
BOOST_CHECK(GetBoolArg("-fooo", true));
|
BOOST_CHECK(GetBoolArg("-fooo", true));
|
||||||
|
|
||||||
ResetArgs("-foo=0");
|
ResetArgs("-foo=0");
|
||||||
BOOST_CHECK(!GetBoolArg("-foo"));
|
|
||||||
BOOST_CHECK(!GetBoolArg("-foo", false));
|
BOOST_CHECK(!GetBoolArg("-foo", false));
|
||||||
BOOST_CHECK(!GetBoolArg("-foo", true));
|
BOOST_CHECK(!GetBoolArg("-foo", true));
|
||||||
|
|
||||||
ResetArgs("-foo=1");
|
ResetArgs("-foo=1");
|
||||||
BOOST_CHECK(GetBoolArg("-foo"));
|
|
||||||
BOOST_CHECK(GetBoolArg("-foo", false));
|
BOOST_CHECK(GetBoolArg("-foo", false));
|
||||||
BOOST_CHECK(GetBoolArg("-foo", true));
|
BOOST_CHECK(GetBoolArg("-foo", true));
|
||||||
|
|
||||||
// New 0.6 feature: auto-map -nosomething to !-something:
|
// New 0.6 feature: auto-map -nosomething to !-something:
|
||||||
ResetArgs("-nofoo");
|
ResetArgs("-nofoo");
|
||||||
BOOST_CHECK(!GetBoolArg("-foo"));
|
|
||||||
BOOST_CHECK(!GetBoolArg("-foo", false));
|
BOOST_CHECK(!GetBoolArg("-foo", false));
|
||||||
BOOST_CHECK(!GetBoolArg("-foo", true));
|
BOOST_CHECK(!GetBoolArg("-foo", true));
|
||||||
|
|
||||||
ResetArgs("-nofoo=1");
|
ResetArgs("-nofoo=1");
|
||||||
BOOST_CHECK(!GetBoolArg("-foo"));
|
|
||||||
BOOST_CHECK(!GetBoolArg("-foo", false));
|
BOOST_CHECK(!GetBoolArg("-foo", false));
|
||||||
BOOST_CHECK(!GetBoolArg("-foo", true));
|
BOOST_CHECK(!GetBoolArg("-foo", true));
|
||||||
|
|
||||||
ResetArgs("-foo -nofoo"); // -foo should win
|
ResetArgs("-foo -nofoo"); // -foo should win
|
||||||
BOOST_CHECK(GetBoolArg("-foo"));
|
|
||||||
BOOST_CHECK(GetBoolArg("-foo", false));
|
BOOST_CHECK(GetBoolArg("-foo", false));
|
||||||
BOOST_CHECK(GetBoolArg("-foo", true));
|
BOOST_CHECK(GetBoolArg("-foo", true));
|
||||||
|
|
||||||
ResetArgs("-foo=1 -nofoo=1"); // -foo should win
|
ResetArgs("-foo=1 -nofoo=1"); // -foo should win
|
||||||
BOOST_CHECK(GetBoolArg("-foo"));
|
|
||||||
BOOST_CHECK(GetBoolArg("-foo", false));
|
BOOST_CHECK(GetBoolArg("-foo", false));
|
||||||
BOOST_CHECK(GetBoolArg("-foo", true));
|
BOOST_CHECK(GetBoolArg("-foo", true));
|
||||||
|
|
||||||
ResetArgs("-foo=0 -nofoo=0"); // -foo should win
|
ResetArgs("-foo=0 -nofoo=0"); // -foo should win
|
||||||
BOOST_CHECK(!GetBoolArg("-foo"));
|
|
||||||
BOOST_CHECK(!GetBoolArg("-foo", false));
|
BOOST_CHECK(!GetBoolArg("-foo", false));
|
||||||
BOOST_CHECK(!GetBoolArg("-foo", true));
|
BOOST_CHECK(!GetBoolArg("-foo", true));
|
||||||
|
|
||||||
// New 0.6 feature: treat -- same as -:
|
// New 0.6 feature: treat -- same as -:
|
||||||
ResetArgs("--foo=1");
|
ResetArgs("--foo=1");
|
||||||
BOOST_CHECK(GetBoolArg("-foo"));
|
|
||||||
BOOST_CHECK(GetBoolArg("-foo", false));
|
BOOST_CHECK(GetBoolArg("-foo", false));
|
||||||
BOOST_CHECK(GetBoolArg("-foo", true));
|
BOOST_CHECK(GetBoolArg("-foo", true));
|
||||||
|
|
||||||
ResetArgs("--nofoo=1");
|
ResetArgs("--nofoo=1");
|
||||||
BOOST_CHECK(!GetBoolArg("-foo"));
|
|
||||||
BOOST_CHECK(!GetBoolArg("-foo", false));
|
BOOST_CHECK(!GetBoolArg("-foo", false));
|
||||||
BOOST_CHECK(!GetBoolArg("-foo", true));
|
BOOST_CHECK(!GetBoolArg("-foo", true));
|
||||||
|
|
||||||
|
@ -133,7 +120,7 @@ BOOST_AUTO_TEST_CASE(intarg)
|
||||||
BOOST_AUTO_TEST_CASE(doubledash)
|
BOOST_AUTO_TEST_CASE(doubledash)
|
||||||
{
|
{
|
||||||
ResetArgs("--foo");
|
ResetArgs("--foo");
|
||||||
BOOST_CHECK_EQUAL(GetBoolArg("-foo"), true);
|
BOOST_CHECK_EQUAL(GetBoolArg("-foo", false), true);
|
||||||
|
|
||||||
ResetArgs("--foo=verbose --bar=1");
|
ResetArgs("--foo=verbose --bar=1");
|
||||||
BOOST_CHECK_EQUAL(GetArg("-foo", ""), "verbose");
|
BOOST_CHECK_EQUAL(GetArg("-foo", ""), "verbose");
|
||||||
|
@ -143,25 +130,24 @@ BOOST_AUTO_TEST_CASE(doubledash)
|
||||||
BOOST_AUTO_TEST_CASE(boolargno)
|
BOOST_AUTO_TEST_CASE(boolargno)
|
||||||
{
|
{
|
||||||
ResetArgs("-nofoo");
|
ResetArgs("-nofoo");
|
||||||
BOOST_CHECK(!GetBoolArg("-foo"));
|
|
||||||
BOOST_CHECK(!GetBoolArg("-foo", true));
|
BOOST_CHECK(!GetBoolArg("-foo", true));
|
||||||
BOOST_CHECK(!GetBoolArg("-foo", false));
|
BOOST_CHECK(!GetBoolArg("-foo", false));
|
||||||
|
|
||||||
ResetArgs("-nofoo=1");
|
ResetArgs("-nofoo=1");
|
||||||
BOOST_CHECK(!GetBoolArg("-foo"));
|
|
||||||
BOOST_CHECK(!GetBoolArg("-foo", true));
|
BOOST_CHECK(!GetBoolArg("-foo", true));
|
||||||
BOOST_CHECK(!GetBoolArg("-foo", false));
|
BOOST_CHECK(!GetBoolArg("-foo", false));
|
||||||
|
|
||||||
ResetArgs("-nofoo=0");
|
ResetArgs("-nofoo=0");
|
||||||
BOOST_CHECK(GetBoolArg("-foo"));
|
|
||||||
BOOST_CHECK(GetBoolArg("-foo", true));
|
BOOST_CHECK(GetBoolArg("-foo", true));
|
||||||
BOOST_CHECK(GetBoolArg("-foo", false));
|
BOOST_CHECK(GetBoolArg("-foo", false));
|
||||||
|
|
||||||
ResetArgs("-foo --nofoo");
|
ResetArgs("-foo --nofoo");
|
||||||
BOOST_CHECK(GetBoolArg("-foo"));
|
BOOST_CHECK(GetBoolArg("-foo", true));
|
||||||
|
BOOST_CHECK(GetBoolArg("-foo", false));
|
||||||
|
|
||||||
ResetArgs("-nofoo -foo"); // foo always wins:
|
ResetArgs("-nofoo -foo"); // foo always wins:
|
||||||
BOOST_CHECK(GetBoolArg("-foo"));
|
BOOST_CHECK(GetBoolArg("-foo", true));
|
||||||
|
BOOST_CHECK(GetBoolArg("-foo", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
|
@ -154,10 +154,10 @@ BOOST_AUTO_TEST_CASE(util_GetArg)
|
||||||
BOOST_CHECK_EQUAL(GetArg("inttest1", -1), 12345);
|
BOOST_CHECK_EQUAL(GetArg("inttest1", -1), 12345);
|
||||||
BOOST_CHECK_EQUAL(GetArg("inttest2", -1), 81985529216486895LL);
|
BOOST_CHECK_EQUAL(GetArg("inttest2", -1), 81985529216486895LL);
|
||||||
BOOST_CHECK_EQUAL(GetArg("inttest3", -1), -1);
|
BOOST_CHECK_EQUAL(GetArg("inttest3", -1), -1);
|
||||||
BOOST_CHECK_EQUAL(GetBoolArg("booltest1"), true);
|
BOOST_CHECK_EQUAL(GetBoolArg("booltest1", false), true);
|
||||||
BOOST_CHECK_EQUAL(GetBoolArg("booltest2"), false);
|
BOOST_CHECK_EQUAL(GetBoolArg("booltest2", false), false);
|
||||||
BOOST_CHECK_EQUAL(GetBoolArg("booltest3"), false);
|
BOOST_CHECK_EQUAL(GetBoolArg("booltest3", false), false);
|
||||||
BOOST_CHECK_EQUAL(GetBoolArg("booltest4"), true);
|
BOOST_CHECK_EQUAL(GetBoolArg("booltest4", false), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(util_WildcardMatch)
|
BOOST_AUTO_TEST_CASE(util_WildcardMatch)
|
||||||
|
|
|
@ -518,7 +518,7 @@ static void InterpretNegativeSetting(string name, map<string, string>& mapSettin
|
||||||
positive.append(name.begin()+3, name.end());
|
positive.append(name.begin()+3, name.end());
|
||||||
if (mapSettingsRet.count(positive) == 0)
|
if (mapSettingsRet.count(positive) == 0)
|
||||||
{
|
{
|
||||||
bool value = !GetBoolArg(name);
|
bool value = !GetBoolArg(name, false);
|
||||||
mapSettingsRet[positive] = (value ? "1" : "0");
|
mapSettingsRet[positive] = (value ? "1" : "0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1171,7 +1171,6 @@ bool TruncateFile(FILE *file, unsigned int length) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// this function tries to raise the file descriptor limit to the requested number.
|
// this function tries to raise the file descriptor limit to the requested number.
|
||||||
// It returns the actual file descriptor limit (which may be more or less than nMinFD)
|
// It returns the actual file descriptor limit (which may be more or less than nMinFD)
|
||||||
int RaiseFileDescriptorLimit(int nMinFD) {
|
int RaiseFileDescriptorLimit(int nMinFD) {
|
||||||
|
|
|
@ -390,7 +390,7 @@ int64 GetArg(const std::string& strArg, int64 nDefault);
|
||||||
* @param default (true or false)
|
* @param default (true or false)
|
||||||
* @return command-line argument or default value
|
* @return command-line argument or default value
|
||||||
*/
|
*/
|
||||||
bool GetBoolArg(const std::string& strArg, bool fDefault=false);
|
bool GetBoolArg(const std::string& strArg, bool fDefault);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set an argument if it doesn't already have a value
|
* Set an argument if it doesn't already have a value
|
||||||
|
|
Loading…
Reference in a new issue