test_utils.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #pragma once
  2. #include <iostream>
  3. #include <string>
  4. namespace qcloud_cos {
  5. class TestUtils {
  6. public:
  7. static void WriteStringtoFile(const std::string& file,
  8. const std::string& str);
  9. static void WriteRandomDatatoFile(const std::string& file, unsigned len);
  10. static void RemoveFile(const std::string& file);
  11. static std::string GetRandomString(unsigned size);
  12. static std::string CalcFileMd5(const std::string& file);
  13. static std::string CalcStreamMd5(std::istream& is);
  14. static std::string CalcStringMd5(const std::string& str);
  15. static std::string CalcStreamSHA1(std::istream& is);
  16. static std::string GetEnvVar(const std::string& env_var_name);
  17. #if defined(__linux__)
  18. static bool IsDirectoryExists(const std::string& path);
  19. static bool MakeDirectory(const std::string& path);
  20. static bool RemoveDirectory(const std::string& path);
  21. #endif
  22. };
  23. #define GetEnvVar TestUtils::GetEnvVar
  24. struct FileInfo {
  25. std::string m_object_name;
  26. std::string m_local_file;
  27. std::string m_local_file_download;
  28. uint64_t m_file_size;
  29. uint64_t m_file_crc64_origin;
  30. std::string m_file_md5_origin;
  31. int m_op_type;
  32. };
  33. } // namespace qcloud_cos