11 namespace fs = std::filesystem;
16 const auto suffix = std::chrono::steady_clock::now().time_since_epoch().count();
17 path = fs::temp_directory_path() / (
"acmxvk-output-paths-" + std::to_string(suffix));
18 fs::create_directories(
path);
22 std::error_code error;
23 fs::remove_all(
path, error);
32 void expect(
bool condition,
const std::string &message) {
34 throw std::runtime_error(message);
38 void expect_suffix(
const fs::path &path, std::string_view suffix,
const std::string &message) {
expect(path.filename().string().ends_with(suffix), message); }
45 expect(
acmxvk::output_frame_directory((temporary.path /
"movie.mp4").string(),
"generate") == temporary.path /
"video_file-movie.mp4-generate",
"parent output directory was not retained");
47 const fs::path output_directory = temporary.path /
"nested/frames";
49 expect(fs::is_directory(output_directory),
"output directory was not created");
50 expect(
acmxvk::frame_path(output_directory, 42) == output_directory /
"frame-00000042.png",
"numbered PNG frame path is incorrect");
57 std::uint64_t counter = 7;
58 const auto timestamp = std::chrono::system_clock::from_time_t(0);
60 expect_suffix(first,
"-1920x1080-7.png",
"snapshot dimensions or counter are incorrect");
61 std::ofstream(first) <<
"collision";
63 expect(counter == 8,
"snapshot collision did not advance the counter");
64 expect_suffix(second,
"-1920x1080-8.png",
"collision-safe snapshot path is incorrect");
66 const fs::path regular_file = temporary.path /
"not-a-directory";
67 std::ofstream(regular_file) <<
"file";
68 bool rejected_file =
false;
71 }
catch (
const std::runtime_error &) {
74 expect(rejected_file,
"regular file was accepted as an output directory");
75 }
catch (
const std::exception &error) {
76 std::cerr <<
"output path test failed: " << error.what() <<
'\n';
int main(int argc, char **argv)
Application entry point.
TemporaryDirectory & operator=(const TemporaryDirectory &)=delete
TemporaryDirectory(const TemporaryDirectory &)=delete
fs::path snapshot_path(const fs::path &directory, std::uint32_t width, std::uint32_t height, std::uint64_t &counter, SnapshotFormat format, std::chrono::system_clock::time_point timestamp)
fs::path output_frame_directory(const std::string &filename, std::string_view suffix)
fs::path frame_path(const fs::path &directory, std::uint64_t index)
void create_output_directory(const fs::path &directory)
std::string_view snapshot_extension(SnapshotFormat format) noexcept
void expect(bool condition, const std::string &message)
void expect_suffix(const fs::path &path, std::string_view suffix, const std::string &message)