1
0

hurl_test.cpp 635 B

1234567891011121314151617181920212223
  1. #include <assert.h>
  2. #include "hurl.h"
  3. int main(int argc, char** argv) {
  4. std::string strURL = "http://www.example.com/path?query#fragment";
  5. HUrl url;
  6. if (!url.parse(strURL)) {
  7. printf("parse url %s error!\n", strURL.c_str());
  8. return -1;
  9. }
  10. std::string dumpURL = url.dump();
  11. printf("%s =>\n%s\n", strURL.c_str(), dumpURL.c_str());
  12. assert(strURL == dumpURL);
  13. const char* str = "中 文";
  14. std::string escaped = HUrl::escape(str);
  15. std::string unescaped = HUrl::unescape(escaped.c_str());
  16. printf("%s => %s\n", str, escaped.c_str());
  17. assert(str == unescaped);
  18. return 0;
  19. }