#include "test.h" #include "gtest/gtest.h" /* Utility functions */ std::vector generic_read_file(const std::string& filename) { auto ifstream = std::ifstream{filename, std::ios::binary}; auto path = std::filesystem::path{filename}; auto size = std::filesystem::file_size(path); std::vector buf(size); ifstream.read(reinterpret_cast(buf.data()), size); return buf; } std::vector get_created_filenames( const horcrux::FsCryptoOutput& out) { std::vector result(out.created_files.size()); transform(out.created_files.begin(), out.created_files.end(), result.begin(), [](auto path) { return path.string(); } ); return result; } void delete_created_files(const horcrux::FsCryptoOutput& out) { std::for_each(out.created_files.begin(), out.created_files.end(), [](auto f) { std::filesystem::remove(f); } ); } std::vector get_encrypted_files(const std::string& folder, const std::string& basename) { std::vector result; for (auto& p: std::filesystem::directory_iterator(folder)) { if (p.path().string().starts_with(basename) && p.path().string().ends_with(".enc")) { result.push_back(p.path().string()); } } std::sort(result.begin(), result.end()); return result; } int main(int argc, char *argv[]) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }