lokinet/test/test_util.hpp

44 lines
596 B
C++
Raw Normal View History

2019-01-15 00:42:50 +00:00
#ifndef TEST_UTIL_HPP
#define TEST_UTIL_HPP
#include <util/fs.hpp>
2019-01-22 23:50:26 +00:00
#include <util/types.hpp>
2019-01-15 00:42:50 +00:00
namespace llarp
{
namespace test
{
std::string
randFilename();
2019-01-22 23:50:26 +00:00
template < typename Buf >
Buf
makeBuf(byte_t val)
{
Buf b;
b.Fill(val);
return b;
}
2019-01-15 00:42:50 +00:00
struct FileGuard
{
const fs::path &p;
explicit FileGuard(const fs::path &_p) : p(_p)
{
}
~FileGuard()
{
if(fs::exists(fs::status(p)))
{
fs::remove(p);
}
}
};
} // namespace test
} // namespace llarp
#endif