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>
40 using path = boost::filesystem::path;
52 if (is_directory(toRm) && is_empty(toRm))
55 test_.
log <<
"Expected " << toRm.string()
56 <<
" to be an empty existing directory." <<
std::endl;
63 using namespace boost::filesystem;
65 static auto subDirCounter = 0;
79 Throw<std::runtime_error>(
80 "Cannot create directory: " +
subDir_.string());
88 using namespace boost::filesystem;
122 bool useCounter =
true,
124 :
DirGuard(test, subDir, useCounter)
138 Throw<std::runtime_error>(
139 "Refusing to overwrite existing file: " +
file_.string());
147 using namespace boost::filesystem;
156 <<
" to be an existing file." <<
std::endl;
175 return boost::filesystem::exists(
file_);
log_os< char > log
Logging output stream.
Create a directory and remove it when it's done.
auto rmDir(path const &toRm)
DirGuard(beast::unit_test::suite &test, path subDir, bool useCounter=true)
boost::filesystem::path path
path const & subdir() const
beast::unit_test::suite & test_
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)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.