TestUtil.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "common.h"
  2. #include <string>
  3. #include "SharedHandle.h"
  4. #include "Cookie.h"
  5. #include "WrDiskCacheEntry.h"
  6. namespace aria2 {
  7. class MessageDigest;
  8. void createFile(const std::string& filename, size_t length);
  9. std::string readFile(const std::string& path);
  10. class CookieSorter {
  11. public:
  12. bool operator()(const Cookie& lhs, const Cookie& rhs) const
  13. {
  14. if(lhs.getDomain() == rhs.getDomain()) {
  15. return lhs.getName() < rhs.getName();
  16. } else {
  17. return lhs.getDomain() < rhs.getDomain();
  18. }
  19. }
  20. };
  21. Cookie createCookie
  22. (const std::string& name,
  23. const std::string& value,
  24. const std::string& domain,
  25. bool hostOnly,
  26. const std::string& path,
  27. bool secure);
  28. Cookie createCookie
  29. (const std::string& name,
  30. const std::string& value,
  31. time_t expiryTime,
  32. const std::string& domain,
  33. bool hostOnly,
  34. const std::string& path,
  35. bool secure);
  36. std::string fromHex(const std::string& s);
  37. #ifdef ENABLE_MESSAGE_DIGEST
  38. // Returns hex digest of contents of file denoted by filename.
  39. std::string fileHexDigest
  40. (const SharedHandle<MessageDigest>& ctx, const std::string& filename);
  41. #endif // ENABLE_MESSAGE_DIGEST
  42. WrDiskCacheEntry::DataCell* createDataCell(int64_t goff,
  43. const char* data,
  44. size_t offset = 0);
  45. } // namespace aria2