20#ifndef TEST_UNIT_TEST_DIRGUARD_H
21#define TEST_UNIT_TEST_DIRGUARD_H
23#include <test/jtx/TestSuite.h>
25#include <xrpl/basics/contract.h>
27#include <boost/filesystem.hpp>
39 using path = boost::filesystem::path;
51 if (is_directory(toRm) && is_empty(toRm))
54 test_.
log <<
"Expected " << toRm.string()
55 <<
" to be an empty existing directory." <<
std::endl;
62 using namespace boost::filesystem;
64 static auto subDirCounter = 0;
78 Throw<std::runtime_error>(
79 "Cannot create directory: " +
subDir_.string());
87 using namespace boost::filesystem;
121 bool useCounter =
true,
123 :
DirGuard(test, subDir, useCounter)
137 Throw<std::runtime_error>(
138 "Refusing to overwrite existing file: " +
file_.string());
146 using namespace boost::filesystem;
155 <<
" to be an existing file." <<
std::endl;
174 return boost::filesystem::exists(
file_);
log_os< char > log
Logging output stream.
Create a directory and remove it when it's done.
path const & subdir() const
DirGuard(beast::unit_test::suite &test, path subDir, bool useCounter=true)
auto rmDir(path const &toRm)
beast::unit_test::suite & test_
boost::filesystem::path path
Write a file in a directory and remove when done.
path const & file() const
FileDirGuard(beast::unit_test::suite &test, path subDir, path file, std::string const &contents, bool useCounter=true, bool create=true)
Json::Value create(AccountID const &account, AccountID const &to, STAmount const &amount, NetClock::duration const &settleDelay, PublicKey const &pk, std::optional< NetClock::time_point > const &cancelAfter, std::optional< std::uint32_t > const &dstTag)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.