libcruft-util/test/fs/scoped.cpp

40 lines
858 B
C++

#include <cruft/util/tap.hpp>
#include <cruft/util/fs/scoped.hpp>
#include <cruft/util/fs/tmp.hpp>
int
main (int, char**)
{
cruft::TAP::logger tap;
{
bool success = true;
auto const path = cruft::fs::mktmpdir ();
{
cruft::fs::scoped_dir dir (path);
success = success && std::filesystem::is_directory (path);
}
success = success && !exists(path);
tap.expect (success, "scoped_dir removes directory after scope");
}
{
bool success = true;
auto const path = cruft::fs::mktmpdir ();
cruft::fs::scoped_path dir (path);
success = success && std::filesystem::exists (path);
dir.reset ();
success = success && !std::filesystem::exists (path);
tap.expect (true, "scoped_path");
}
return tap.status ();
}