File: test-http-url_decode.cpp

package info (click to toggle)
i2pd 2.58.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,612 kB
  • sloc: cpp: 59,663; makefile: 224; sh: 138
file content (19 lines) | stat: -rw-r--r-- 425 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <cassert>
#include "HTTP.h"

using namespace i2p::http;

int main() {
  std::string in("/%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0/");
  std::string out = UrlDecode(in);

  assert(strcmp(out.c_str(), "/страница/") == 0);

  in = "/%00/";
  out = UrlDecode(in, false);
  assert(strcmp(out.c_str(), "/%00/") == 0);
  out = UrlDecode(in, true);
  assert(strcmp(out.c_str(), "/\0/") == 0);

  return 0;
}