#include #include #include #include #include #include Void::Testing::Test temp_file_creates_under_temp_and_removes() { std::filesystem::path captured; { Void::FileSystem::TempFile tmp; captured = tmp.path(); Void::Testing::expect(std::filesystem::is_regular_file(captured)); Void::Testing::expect(captured.parent_path() == std::filesystem::temp_directory_path()); } Void::Testing::expect(!std::filesystem::exists(captured)); } Void::Testing::Test temp_file_honors_extension() { Void::FileSystem::TempFile tmp{"void_", ".so"}; Void::Testing::expect_eq(tmp.path().extension().string(), std::string{".so"}); } Void::Testing::Test temp_file_keep_persists() { std::filesystem::path captured; { Void::FileSystem::TempFile tmp; captured = tmp.keep(); } Void::Testing::expect(std::filesystem::exists(captured)); std::error_code ec; std::filesystem::remove(captured, ec); // manual cleanup } Void::Testing::Test temp_file_move_transfers_ownership() { std::filesystem::path captured; { Void::FileSystem::TempFile a; captured = a.path(); Void::FileSystem::TempFile b = std::move(a); Void::Testing::expect_eq(b.path(), captured); Void::Testing::expect(a.path().empty()); } // Removed once (by b); no double-remove crash. Void::Testing::expect(!std::filesystem::exists(captured)); } Void::Testing::Test temp_files_are_unique() { Void::FileSystem::TempFile a; Void::FileSystem::TempFile b; Void::Testing::expect(a.path() != b.path()); }