mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
Unit tests for the GetArg() methods
This commit is contained in:
parent
0b452dff5e
commit
3ae0735553
3 changed files with 146 additions and 24 deletions
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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue