1#ifndef TEST_UNIT_TEST_DIRGUARD_H
2#define TEST_UNIT_TEST_DIRGUARD_H
4#include <test/jtx/TestSuite.h>
6#include <xrpl/basics/contract.h>
8#include <boost/filesystem.hpp>
21 using path = boost::filesystem::path;
33 if (is_directory(toRm) && is_empty(toRm))
36 test_.
log <<
"Expected " << toRm.string()
37 <<
" to be an empty existing directory." <<
std::endl;
44 using namespace boost::filesystem;
46 static auto subDirCounter = 0;
60 Throw<std::runtime_error>(
61 "Cannot create directory: " +
subDir_.string());
69 using namespace boost::filesystem;
103 bool useCounter =
true,
105 :
DirGuard(test, subDir, useCounter)
119 Throw<std::runtime_error>(
120 "Refusing to overwrite existing file: " +
file_.string());
128 using namespace boost::filesystem;
137 <<
" to be an existing file." <<
std::endl;
156 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.