TestUtil.h 1.6 KB

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