18#include <boost/test/unit_test.hpp>
26 std::vector<std::string> vecArg;
32 vecArg.insert(vecArg.begin(),
"testbitcoin");
35 std::vector<const char*> vecChar;
36 vecChar.reserve(vecArg.size());
37 for (
const std::string&
s : vecArg)
38 vecChar.push_back(
s.c_str());
41 BOOST_CHECK(local_args.ParseParameters(vecChar.size(), vecChar.data(), error));
46 for (
const auto& arg :
args) {
198 ResetArgs(local_args,
"-foo=1 -nofoo=1");
202 ResetArgs(local_args,
"-foo=0 -nofoo=0");
267 ResetArgs(local_args,
"-foo=-9223372036854775809 -bar=9223372036854775808");
275 ResetArgs(local_args,
"-foo=11 -bar=12");
281 ResetArgs(local_args,
"-foo=NaN -bar=NotANumber");
297 const fs::path root_path{
"/"};
311 const fs::path win_root_path{
"C:\\"};
331 const fs::path absolute_path{
"/home/user/.bitcoin"};
332 ResetArgs(local_args,
"-dir=/home/user/.bitcoin");
335 ResetArgs(local_args,
"-dir=/root/../home/user/.bitcoin");
338 ResetArgs(local_args,
"-dir=/home/./user/.bitcoin");
341 ResetArgs(local_args,
"-dir=/home/user/.bitcoin/");
344 ResetArgs(local_args,
"-dir=/home/user/.bitcoin//");
347 ResetArgs(local_args,
"-dir=/home/user/.bitcoin/.");
350 ResetArgs(local_args,
"-dir=/home/user/.bitcoin/./");
353 ResetArgs(local_args,
"-dir=/home/user/.bitcoin/.//");
356 const fs::path relative_path{
"user/.bitcoin"};
357 ResetArgs(local_args,
"-dir=user/.bitcoin");
360 ResetArgs(local_args,
"-dir=somewhere/../user/.bitcoin");
363 ResetArgs(local_args,
"-dir=user/./.bitcoin");
366 ResetArgs(local_args,
"-dir=user/.bitcoin/");
369 ResetArgs(local_args,
"-dir=user/.bitcoin//");
372 ResetArgs(local_args,
"-dir=user/.bitcoin/.");
375 ResetArgs(local_args,
"-dir=user/.bitcoin/./");
378 ResetArgs(local_args,
"-dir=user/.bitcoin/.//");
410 ResetArgs(local_args,
"--foo=verbose --bar=1");
451 SetupArgs(local_args, {okaylog_bool, okaylog_negbool, okaylog, dontlog});
452 ResetArgs(local_args,
"-okaylog-bool -nookaylog-negbool -okaylog=public -dontlog=private42");
457 [&str](
const std::string&
s) {
466 BOOST_CHECK(str.find(
"Command-line arg: okaylog-bool=\"\"") != std::string::npos);
467 BOOST_CHECK(str.find(
"Command-line arg: okaylog-negbool=false") != std::string::npos);
468 BOOST_CHECK(str.find(
"Command-line arg: okaylog=\"public\"") != std::string::npos);
469 BOOST_CHECK(str.find(
"dontlog=****") != std::string::npos);
470 BOOST_CHECK(str.find(
"private42") == std::string::npos);
@ ALLOW_ANY
disable validation
common::SettingsValue GetSetting(const std::string &arg) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Get setting value.
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Add argument.
void LockSettings(Fn &&fn) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Access settings with lock held.
fs::path GetPathArg(std::string arg, const fs::path &default_value={}) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Return path argument or default value.
void LogArgs() const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Log the config file options and the command line arguments, useful for troubleshooting.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Return string argument or default value.
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
bool GetBoolArg(const std::string &strArg, bool fDefault) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Return boolean argument or default value.
std::list< std::function< void(conststd::string &)> >::iterator PushBackCallback(std::function< void(const std::string &)> fun) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Connect a slot to the print signal and return the connection.
void DeleteCallback(std::list< std::function< void(const std::string &)> >::iterator it) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Delete a connection.
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
void ResetArgs(ArgsManager &local_args, const std::string &strArg)
void SetupArgs(ArgsManager &local_args, const std::vector< std::pair< std::string, unsigned int > > &args)
BOOST_AUTO_TEST_CASE(setting_args)
BCLog::Logger & LogInstance()
std::vector< std::string > SplitString(std::string_view str, char sep)
#define BOOST_CHECK_THROW(stmt, excMatch)
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
std::map< std::string, SettingsValue > rw_settings
Map of setting name to read-write file setting value.