diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2021-11-17 22:34:57 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2021-11-17 22:34:57 +0100 |
| commit | 6232d13f5321b87ddf12a1aa36b4545da45f173d (patch) | |
| tree | 23f3316470a14136debd9d02f9e920ca2b06f4cc /test/file_test.hh | |
Travel3: Simple image and video display site
Reads the images and videos from filesystem and builds a site in
memroy.
Diffstat (limited to 'test/file_test.hh')
| -rw-r--r-- | test/file_test.hh | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/file_test.hh b/test/file_test.hh new file mode 100644 index 0000000..af66dfc --- /dev/null +++ b/test/file_test.hh @@ -0,0 +1,45 @@ +#ifndef FILE_TEST_HH +#define FILE_TEST_HH + +#include "unique_fd.hh" + +#include <filesystem> +#include <gtest/gtest.h> +#include <utility> + +class FileTest : public testing::Test { +public: + static unique_fd create_temp_file(std::string const& extension, + std::filesystem::path* path); + +protected: + FileTest(); + ~FileTest() override; + + void SetUp() override; + + std::filesystem::path const& path() const { + return path_; + } + + void write(std::string_view content); + + int fd() const { + return fd_.get(); + } + + unique_fd release() { + return std::move(fd_); + } + + void close(); + +protected: + virtual std::string const& extension(); + +private: + std::filesystem::path path_; + unique_fd fd_; +}; + +#endif // FILE_TEST_HH |
