mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-04 01:32:31 +01:00
Unit tests for the GetArg() methods
This commit is contained in:
27
src/util.cpp
27
src/util.cpp
@@ -454,7 +454,7 @@ vector<unsigned char> ParseHex(const string& str)
|
||||
return ParseHex(str.c_str());
|
||||
}
|
||||
|
||||
void ParseParameters(int argc, char* argv[])
|
||||
void ParseParameters(int argc, const char*const argv[])
|
||||
{
|
||||
mapArgs.clear();
|
||||
mapMultiArgs.clear();
|
||||
@@ -480,6 +480,31 @@ void ParseParameters(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
std::string GetArg(const std::string& strArg, const std::string& strDefault)
|
||||
{
|
||||
if (mapArgs.count(strArg))
|
||||
return mapArgs[strArg];
|
||||
return strDefault;
|
||||
}
|
||||
|
||||
int64 GetArg(const std::string& strArg, int64 nDefault)
|
||||
{
|
||||
if (mapArgs.count(strArg))
|
||||
return atoi64(mapArgs[strArg]);
|
||||
return nDefault;
|
||||
}
|
||||
|
||||
bool GetBoolArg(const std::string& strArg, bool fDefault)
|
||||
{
|
||||
if (mapArgs.count(strArg))
|
||||
{
|
||||
if (mapArgs[strArg].empty())
|
||||
return true;
|
||||
return (atoi(mapArgs[strArg]) != 0);
|
||||
}
|
||||
return fDefault;
|
||||
}
|
||||
|
||||
bool SoftSetArg(const std::string& strArg, const std::string& strValue)
|
||||
{
|
||||
if (mapArgs.count(strArg))
|
||||
|
||||
Reference in New Issue
Block a user