17#include <boost/test/unit_test.hpp>
25 std::vector<std::string> vecArg;
31 vecArg.insert(vecArg.begin(),
"testbitcoin");
34 std::vector<const char*> vecChar;
35 vecChar.reserve(vecArg.size());
36 for (
const std::string&
s : vecArg)
37 vecChar.push_back(
s.c_str());
40 BOOST_CHECK(local_args.ParseParameters(vecChar.size(), vecChar.data(), error));
45 for (
const auto& arg :
args) {
197 ResetArgs(local_args,
"-foo=1 -nofoo=1");
201 ResetArgs(local_args,
"-foo=0 -nofoo=0");
259 ResetArgs(local_args,
"-foo=-9223372036854775809 -bar=9223372036854775808");
263 ResetArgs(local_args,
"-foo=11 -bar=12");
267 ResetArgs(local_args,
"-foo=NaN -bar=NotANumber");
295 const fs::path win_root_path{
"C:\\"};
315 const fs::path absolute_path{
"/home/user/.bitcoin"};
316 ResetArgs(local_args,
"-dir=/home/user/.bitcoin");
319 ResetArgs(local_args,
"-dir=/root/../home/user/.bitcoin");
322 ResetArgs(local_args,
"-dir=/home/./user/.bitcoin");
325 ResetArgs(local_args,
"-dir=/home/user/.bitcoin/");
328 ResetArgs(local_args,
"-dir=/home/user/.bitcoin//");
331 ResetArgs(local_args,
"-dir=/home/user/.bitcoin/.");
334 ResetArgs(local_args,
"-dir=/home/user/.bitcoin/./");
337 ResetArgs(local_args,
"-dir=/home/user/.bitcoin/.//");
340 const fs::path relative_path{
"user/.bitcoin"};
341 ResetArgs(local_args,
"-dir=user/.bitcoin");
344 ResetArgs(local_args,
"-dir=somewhere/../user/.bitcoin");
347 ResetArgs(local_args,
"-dir=user/./.bitcoin");
350 ResetArgs(local_args,
"-dir=user/.bitcoin/");
353 ResetArgs(local_args,
"-dir=user/.bitcoin//");
356 ResetArgs(local_args,
"-dir=user/.bitcoin/.");
359 ResetArgs(local_args,
"-dir=user/.bitcoin/./");
362 ResetArgs(local_args,
"-dir=user/.bitcoin/.//");
394 ResetArgs(local_args,
"--foo=verbose --bar=1");
435 SetupArgs(local_args, {okaylog_bool, okaylog_negbool, okaylog, dontlog});
436 ResetArgs(local_args,
"-okaylog-bool -nookaylog-negbool -okaylog=public -dontlog=private42");
441 [&str](
const std::string&
s) {
450 BOOST_CHECK(str.find(
"Command-line arg: okaylog-bool=\"\"") != std::string::npos);
451 BOOST_CHECK(str.find(
"Command-line arg: okaylog-negbool=false") != std::string::npos);
452 BOOST_CHECK(str.find(
"Command-line arg: okaylog=\"public\"") != std::string::npos);
453 BOOST_CHECK(str.find(
"dontlog=****") != std::string::npos);
454 BOOST_CHECK(str.find(
"private42") == std::string::npos);
@ ALLOW_ANY
disable validation
common::SettingsValue GetSetting(const std::string &arg) const
Get setting value.
void LockSettings(Fn &&fn)
Access settings with lock held.
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
void LogArgs() const
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
Return string argument or default value.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
fs::path GetPathArg(std::string arg, const fs::path &default_value={}) const
Return path 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
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
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.