Esempio n. 1
0
bool TestExtUrl::test_http_build_query() {
  {
    Array data = CREATE_MAP4("foo", "bar", "baz", "boom", "cow", "milk",
                             "php", "hypertext processor");
    VS(f_http_build_query(data),
       "foo=bar&baz=boom&cow=milk&php=hypertext+processor");
    VS(f_http_build_query(data, "", "&"),
       "foo=bar&baz=boom&cow=milk&php=hypertext+processor");
  }
  {
    Array data = Array(NEW(ArrayElement)("foo"),
                       NEW(ArrayElement)("bar"),
                       NEW(ArrayElement)("baz"),
                       NEW(ArrayElement)("boom"),
                       NEW(ArrayElement)("cow", "milk"),
                       NEW(ArrayElement)("php", "hypertext processor"),
                       NULL);
    VS(f_http_build_query(data),
       "0=foo&1=bar&2=baz&3=boom&cow=milk&php=hypertext+processor");
    VS(f_http_build_query(data, "myvar_"),
       "myvar_0=foo&myvar_1=bar&myvar_2=baz&myvar_3=boom&cow=milk&"
       "php=hypertext+processor");
  }
  {
    Array data = Array
      (NEW(ArrayElement)("user",
                         CREATE_MAP4("name", "Bob Smith",
                                     "age", 47,
                                     "sex", "M",
                                     "dob", "5/12/1956")),
       NEW(ArrayElement)("pastimes",
                         CREATE_VECTOR4("golf", "opera", "poker", "rap")),
       NEW(ArrayElement)("children",
                         CREATE_MAP2("bobby", CREATE_MAP2("age",12,"sex","M"),
                                     "sally", CREATE_MAP2("age", 8,"sex","F"))
                         ),
       NEW(ArrayElement)("CEO"),
       NULL);

    VS(f_http_build_query(data, "flags_"),
       "user%5Bname%5D=Bob+Smith&user%5Bage%5D=47&user%5Bsex%5D=M&"
       "user%5Bdob%5D=5%2F12%2F1956&pastimes%5B0%5D=golf&"
       "pastimes%5B1%5D=opera&pastimes%5B2%5D=poker&"
       "pastimes%5B3%5D=rap&children%5Bbobby%5D%5Bage%5D=12&"
       "children%5Bbobby%5D%5Bsex%5D=M&children%5Bsally%5D%5Bage%5D=8&"
       "children%5Bsally%5D%5Bsex%5D=F&flags_0=CEO");
  }
  {
    Object obj(NEW(c_stdclass)());
    obj->o_set("foo", -1, "bar");
    obj->o_set("baz", -1, "boom");
    VS(f_http_build_query(obj), "foo=bar&baz=boom");
  }
  return Count(true);
}
bool TestExtFile::test_parse_ini_string() {
  String ini
    (";;; Created on Tuesday, October 27, 2009 at 12:01 PM GMT\n"
     "[GJK_Browscap_Version]\n"
     "Version=4520\n"
     "Released=Tue, 27 Oct 2009 12:01:07 -0000\n"
     "\n"
     "\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DefaultProperties\n"
     "\n"
     "[DefaultProperties]\n"
     "Browser=\"DefaultProperties\"\n"
     "Version=0\n"
     "Platform=unknown\n"
     "Beta=false\n");
  VS(f_parse_ini_string(ini),
     CREATE_MAP5("Version", "0",
                 "Released", "Tue, 27 Oct 2009 12:01:07 -0000",
                 "Browser", "DefaultProperties",
                 "Platform", "unknown",
                 "Beta", ""));
  VS(f_parse_ini_string(ini, true),
     CREATE_MAP2("GJK_Browscap_Version",
                 CREATE_MAP2("Version", "4520",
                             "Released", "Tue, 27 Oct 2009 12:01:07 -0000"),
                 "DefaultProperties",
                 CREATE_MAP4("Browser", "DefaultProperties",
                             "Version", "0",
                             "Platform", "unknown",
                             "Beta", "")));
  return Count(true);
}
Esempio n. 3
0
void CmdMachine::UpdateIntercept(DebuggerClient *client,
                                 const std::string &host, int port) {
  CmdMachine cmd;
  cmd.m_body = "rpc";
  cmd.m_rpcConfig = CREATE_MAP4
    ("host", String(host),
     "port", port ? port : RuntimeOption::DebuggerDefaultRpcPort,
     "auth", String(RuntimeOption::DebuggerDefaultRpcAuth),
     "timeout", RuntimeOption::DebuggerDefaultRpcTimeout);
  client->send(&cmd);
}
Esempio n. 4
0
void CmdMachine::UpdateIntercept(DebuggerClient &client,
                                 const std::string &host, int port) {
  CmdMachine cmd;
  cmd.m_body = "rpc";
  cmd.m_rpcConfig = CREATE_MAP4
    (s_host, String(host),
     s_port, port ? port : RuntimeOption::DebuggerDefaultRpcPort,
     s_auth, String(RuntimeOption::DebuggerDefaultRpcAuth),
     s_timeout, RuntimeOption::DebuggerDefaultRpcTimeout);
  client.xend<CmdMachine>(&cmd);
}
Esempio n. 5
0
bool TestExtIconv::test_iconv_mime_encode() {
  Array preferences = CREATE_MAP4("input-charset", "ISO-8859-1",
                                  "output-charset", "UTF-8",
                                  "line-length", 76,
                                  "line-break-chars", "\n");
  preferences.set("scheme", "Q");
  VS(f_iconv_mime_encode("Subject", "Pr\xDC""fung Pr\xDC""fung", preferences),
     "Subject: =?UTF-8?Q?Pr=C3=9Cfung=20Pr=C3=9Cfung?=");

  preferences.set("scheme", "B");
  VS(f_iconv_mime_encode("Subject", "Pr\xDC""fung Pr\xDC""fung", preferences),
     "Subject: =?UTF-8?B?UHLDnGZ1bmcgUHLDnGZ1bmc=?=");

  return Count(true);
}