//#define CROW_ENABLE_LOGGING
#define CROW_ENABLE_DEBUG
#include <iostream>
#include <sstream>
#include <vector>
#include "crow.h"
#include "gtest/gtest.h"
#undef CROW_LOG_LEVEL
#define CROW_LOG_LEVEL 0

using namespace std;
using namespace crow;

bool failed__ = false;
void error_print() { cerr << endl; }

template <typename A, typename... Args>
void error_print(const A& a, Args... args) {
  cerr << a;
  error_print(args...);
}

template <typename... Args>
void fail(Args... args) {
  error_print(args...);
  failed__ = true;
}

#define ASSERT_EQUAL(a, b)                                                  \
  if ((a) != (b))                                                           \
  fail(__FILE__ ":", __LINE__, ": Assert fail: expected ", (a), " actual ", \
       (b), ", " #a " == " #b ", at " __FILE__ ":", __LINE__)
#define ASSERT_NOTEQUAL(a, b)                                       \
  if ((a) == (b))                                                   \
  fail(__FILE__ ":", __LINE__, ": Assert fail: not expected ", (a), \
       ", " #a " != " #b ", at " __FILE__ ":", __LINE__)

#define DISABLE_TEST(x) \
  struct test##x {      \
    void test();        \
  } x##_;               \
  void test##x::test()

#define LOCALHOST_ADDRESS "127.0.0.1"

TEST(Crow, Rule) {
  TaggedRule<> r("/http/");
  r.name("abc");

  // empty handler - fail to validate
  try {
    r.validate();
    fail("empty handler should fail to validate");
  } catch (runtime_error& e) {
  }

  int x = 0;

  // registering handler
  r([&x] {
    x = 1;
    return "";
  });

  r.validate();

  response res;

  // executing handler
  ASSERT_EQUAL(0, x);
  r.handle(request(), res, routing_params());
  ASSERT_EQUAL(1, x);

  // registering handler with request argument
  r([&x](const crow::request&) {
    x = 2;
    return "";
  });

  r.validate();

  // executing handler
  ASSERT_EQUAL(1, x);
  r.handle(request(), res, routing_params());
  ASSERT_EQUAL(2, x);
}

TEST(Crow, ParameterTagging) {
  static_assert(black_magic::is_valid("<int><int><int>"), "valid url");
  static_assert(!black_magic::is_valid("<int><int<<int>"), "invalid url");
  static_assert(!black_magic::is_valid("nt>"), "invalid url");
  ASSERT_EQUAL(1, black_magic::get_parameter_tag("<int>"));
  ASSERT_EQUAL(2, black_magic::get_parameter_tag("<uint>"));
  ASSERT_EQUAL(3, black_magic::get_parameter_tag("<float>"));
  ASSERT_EQUAL(3, black_magic::get_parameter_tag("<double>"));
  ASSERT_EQUAL(4, black_magic::get_parameter_tag("<str>"));
  ASSERT_EQUAL(4, black_magic::get_parameter_tag("<string>"));
  ASSERT_EQUAL(5, black_magic::get_parameter_tag("<path>"));
  ASSERT_EQUAL(6 * 6 + 6 + 1,
               black_magic::get_parameter_tag("<int><int><int>"));
  ASSERT_EQUAL(6 * 6 + 6 + 2,
               black_magic::get_parameter_tag("<uint><int><int>"));
  ASSERT_EQUAL(6 * 6 + 6 * 3 + 2,
               black_magic::get_parameter_tag("<uint><double><int>"));

  // url definition parsed in compile time, build into *one number*, and given
  // to template argument
  static_assert(
      std::is_same<black_magic::S<uint64_t, double, int64_t>,
                   black_magic::arguments<6 * 6 + 6 * 3 + 2>::type>::value,
      "tag to type container");
}

TEST(Crow, PathRouting) {
  SimpleApp app;

  CROW_ROUTE(app, "/file")
  ([] { return "file"; });

  CROW_ROUTE(app, "/path/")
  ([] { return "path"; });

  {
    request req;
    response res;

    req.url = "/file";

    app.handle(req, res);

    ASSERT_EQUAL(200, res.code);
  }
  {
    request req;
    response res;

    req.url = "/file/";

    app.handle(req, res);
    ASSERT_EQUAL(404, res.code);
  }
  {
    request req;
    response res;

    req.url = "/path";

    app.handle(req, res);
    ASSERT_NOTEQUAL(404, res.code);
  }
  {
    request req;
    response res;

    req.url = "/path/";

    app.handle(req, res);
    ASSERT_EQUAL(200, res.code);
  }
}

TEST(Crow, RoutingTest) {
  SimpleApp app;
  int A{};
  uint32_t B{};
  double C{};
  string D{};
  string E{};

  CROW_ROUTE(app, "/0/<uint>")
  ([&](uint32_t b) {
    B = b;
    return "OK";
  });

  CROW_ROUTE(app, "/1/<int>/<uint>")
  ([&](int a, uint32_t b) {
    A = a;
    B = b;
    return "OK";
  });

  CROW_ROUTE(app, "/4/<int>/<uint>/<double>/<string>")
  ([&](int a, uint32_t b, double c, string d) {
    A = a;
    B = b;
    C = c;
    D = d;
    return "OK";
  });

  CROW_ROUTE(app, "/5/<int>/<uint>/<double>/<string>/<path>")
  ([&](int a, uint32_t b, double c, string d, string e) {
    A = a;
    B = b;
    C = c;
    D = d;
    E = e;
    return "OK";
  });

  app.validate();
  // app.debug_print();
  {
    request req;
    response res;

    req.url = "/-1";

    app.handle(req, res);

    ASSERT_EQUAL(404, res.code);
  }

  {
    request req;
    response res;

    req.url = "/0/1001999";

    app.handle(req, res);

    ASSERT_EQUAL(200, res.code);

    ASSERT_EQUAL(1001999, B);
  }

  {
    request req;
    response res;

    req.url = "/1/-100/1999";

    app.handle(req, res);

    ASSERT_EQUAL(200, res.code);

    ASSERT_EQUAL(-100, A);
    ASSERT_EQUAL(1999, B);
  }
  {
    request req;
    response res;

    req.url = "/4/5000/3/-2.71828/hellhere";
    req.add_header("TestHeader", "Value");

    app.handle(req, res);

    ASSERT_EQUAL(200, res.code);

    ASSERT_EQUAL(5000, A);
    ASSERT_EQUAL(3, B);
    ASSERT_EQUAL(-2.71828, C);
    ASSERT_EQUAL("hellhere", D);
  }
  {
    request req;
    response res;

    req.url = "/5/-5/999/3.141592/hello_there/a/b/c/d";
    req.add_header("TestHeader", "Value");

    app.handle(req, res);

    ASSERT_EQUAL(200, res.code);

    ASSERT_EQUAL(-5, A);
    ASSERT_EQUAL(999, B);
    ASSERT_EQUAL(3.141592, C);
    ASSERT_EQUAL("hello_there", D);
    ASSERT_EQUAL("a/b/c/d", E);
  }
}

TEST(Crow, simple_response_routing_params) {
  ASSERT_EQUAL(100, response(100).code);
  ASSERT_EQUAL(200, response("Hello there").code);
  ASSERT_EQUAL(500, response(500, "Internal Error?").code);

  routing_params rp;
  rp.int_params.push_back(1);
  rp.int_params.push_back(5);
  rp.uint_params.push_back(2);
  rp.double_params.push_back(3);
  rp.string_params.push_back("hello");
  ASSERT_EQUAL(1, rp.get<int64_t>(0));
  ASSERT_EQUAL(5, rp.get<int64_t>(1));
  ASSERT_EQUAL(2, rp.get<uint64_t>(0));
  ASSERT_EQUAL(3, rp.get<double>(0));
  ASSERT_EQUAL("hello", rp.get<string>(0));
}

TEST(Crow, handler_with_response) {
  SimpleApp app;
  CROW_ROUTE(app, "/")([](const crow::request&, crow::response&) {});
}

TEST(Crow, http_method) {
  SimpleApp app;

  CROW_ROUTE(app, "/").methods("POST"_method,
                               "GET"_method)([](const request& req) {
    if (req.method == "GET"_method)
      return "2";
    else
      return "1";
  });

  CROW_ROUTE(app, "/get_only")
      .methods("GET"_method)([](const request& /*req*/) { return "get"; });
  CROW_ROUTE(app, "/post_only")
      .methods("POST"_method)([](const request& /*req*/) { return "post"; });

  // cannot have multiple handlers for the same url
  // CROW_ROUTE(app, "/")
  //.methods("GET"_method)
  //([]{ return "2"; });

  {
    request req;
    response res;

    req.url = "/";
    app.handle(req, res);

    ASSERT_EQUAL("2", res.body);
  }
  {
    request req;
    response res;

    req.url = "/";
    req.method = "POST"_method;
    app.handle(req, res);

    ASSERT_EQUAL("1", res.body);
  }

  {
    request req;
    response res;

    req.url = "/get_only";
    app.handle(req, res);

    ASSERT_EQUAL("get", res.body);
  }

  {
    request req;
    response res;

    req.url = "/get_only";
    req.method = "POST"_method;
    app.handle(req, res);

    ASSERT_NOTEQUAL("get", res.body);
  }
}

TEST(Crow, server_handling_error_request) {
  static char buf[2048];
  SimpleApp app;
  CROW_ROUTE(app, "/")([] { return "A"; });
  Server<SimpleApp> server(&app, LOCALHOST_ADDRESS, 45451);
  auto _ = async(launch::async, [&] { server.run(); });
  std::string sendmsg = "POX";
  asio::io_service is;
  {
    asio::ip::tcp::socket c(is);
    c.connect(asio::ip::tcp::endpoint(
        asio::ip::address::from_string(LOCALHOST_ADDRESS), 45451));

    c.send(asio::buffer(sendmsg));

    try {
      c.receive(asio::buffer(buf, 2048));
      fail();
    } catch (std::exception& e) {
      // std::cerr << e.what() << std::endl;
    }
  }
  server.stop();
}

TEST(Crow, multi_server) {
  static char buf[2048];
  SimpleApp app1, app2;
  CROW_ROUTE(app1, "/").methods("GET"_method,
                                "POST"_method)([] { return "A"; });
  CROW_ROUTE(app2, "/").methods("GET"_method,
                                "POST"_method)([] { return "B"; });

  Server<SimpleApp> server1(&app1, LOCALHOST_ADDRESS, 45451);
  Server<SimpleApp> server2(&app2, LOCALHOST_ADDRESS, 45452);

  auto _ = async(launch::async, [&] { server1.run(); });
  auto _2 = async(launch::async, [&] { server2.run(); });

  std::string sendmsg =
      "POST /\r\nContent-Length:3\r\nX-HeaderTest: 123\r\n\r\nA=B\r\n";
  asio::io_service is;
  {
    asio::ip::tcp::socket c(is);
    c.connect(asio::ip::tcp::endpoint(
        asio::ip::address::from_string(LOCALHOST_ADDRESS), 45451));

    c.send(asio::buffer(sendmsg));

    size_t recved = c.receive(asio::buffer(buf, 2048));
    ASSERT_EQUAL('A', buf[recved - 1]);
  }

  {
    asio::ip::tcp::socket c(is);
    c.connect(asio::ip::tcp::endpoint(
        asio::ip::address::from_string(LOCALHOST_ADDRESS), 45452));

    for (auto ch : sendmsg) {
      char buf[1] = {ch};
      c.send(asio::buffer(buf));
    }

    size_t recved = c.receive(asio::buffer(buf, 2048));
    ASSERT_EQUAL('B', buf[recved - 1]);
  }

  server1.stop();
  server2.stop();
}

TEST(Crow, json_read) {
  {
    const char* json_error_tests[] = {
        "{} 3",
        "{{}",
        "{3}",
        "3.4.5",
        "+3",
        "3-2",
        "00",
        "03",
        "1e3e3",
        "1e+.3",
        "nll",
        "f",
        "t",
        "{\"x\":3,}",
        "{\"x\"}",
        "{\"x\":3   q}",
        "{\"x\":[3 4]}",
        "{\"x\":[\"",
        "{\"x\":[[], 4],\"y\",}",
        "{\"x\":[3",
        "{\"x\":[ null, false, true}",
    };
    for (auto s : json_error_tests) {
      auto x = json::load(s);
      if (x) {
        fail("should fail to parse ", s);
        return;
      }
    }
  }

  auto x = json::load(R"({"message":"hello, world"})");
  if (!x) fail("fail to parse");
  ASSERT_EQUAL("hello, world", x["message"]);
  ASSERT_EQUAL(1, x.size());
  ASSERT_EQUAL(false, x.has("mess"));
  ASSERT_THROW(x["mess"], std::exception);
  // TODO returning false is better than exception
  // ASSERT_THROW(3 == x["message"], std::exception);
  ASSERT_EQUAL(12, x["message"].size());

  std::string s = R"({"int":3,     "ints"  :[1,2,3,4,5]		})";
  auto y = json::load(s);
  ASSERT_EQUAL(3, y["int"]);
  ASSERT_EQUAL(3.0, y["int"]);
  ASSERT_NOTEQUAL(3.01, y["int"]);
  ASSERT_EQUAL(5, y["ints"].size());
  ASSERT_EQUAL(1, y["ints"][0]);
  ASSERT_EQUAL(2, y["ints"][1]);
  ASSERT_EQUAL(3, y["ints"][2]);
  ASSERT_EQUAL(4, y["ints"][3]);
  ASSERT_EQUAL(5, y["ints"][4]);
  ASSERT_EQUAL(1u, y["ints"][0]);
  ASSERT_EQUAL(1.f, y["ints"][0]);

  int q = (int)y["ints"][1];
  ASSERT_EQUAL(2, q);
  q = y["ints"][2].i();
  ASSERT_EQUAL(3, q);

  std::string s2 = R"({"bools":[true, false], "doubles":[1.2, -3.4]})";
  auto z = json::load(s2);
  ASSERT_EQUAL(2, z["bools"].size());
  ASSERT_EQUAL(2, z["doubles"].size());
  ASSERT_EQUAL(true, z["bools"][0].b());
  ASSERT_EQUAL(false, z["bools"][1].b());
  ASSERT_EQUAL(1.2, z["doubles"][0].d());
  ASSERT_EQUAL(-3.4, z["doubles"][1].d());

  std::string s3 = R"({"uint64": 18446744073709551615})";
  auto z1 = json::load(s3);
  ASSERT_EQUAL(18446744073709551615ull, z1["uint64"].u());
}

TEST(Crow, json_read_real) {
  vector<std::string> v{"0.036303908355795146",
                        "0.18320417789757412",
                        "0.05319940476190476",
                        "0.15224702380952382",
                        "0",
                        "0.3296201145552561",
                        "0.47921580188679247",
                        "0.05873511904761905",
                        "0.1577827380952381",
                        "0.4996841307277628",
                        "0.6425412735849056",
                        "0.052113095238095236",
                        "0.12830357142857143",
                        "0.7871041105121294",
                        "0.954220013477089",
                        "0.05869047619047619",
                        "0.1625",
                        "0.8144794474393531",
                        "0.9721613881401617",
                        "0.1399404761904762",
                        "0.24470238095238095",
                        "0.04527459568733154",
                        "0.2096950808625337",
                        "0.35267857142857145",
                        "0.42791666666666667",
                        "0.855731974393531",
                        "0.9352467991913747",
                        "0.3816220238095238",
                        "0.4282886904761905",
                        "0.39414167789757415",
                        "0.5316079851752021",
                        "0.3809375",
                        "0.4571279761904762",
                        "0.03522995283018868",
                        "0.1915641846361186",
                        "0.6164136904761904",
                        "0.7192708333333333",
                        "0.05675117924528302",
                        "0.21308541105121293",
                        "0.7045386904761904",
                        "0.8016815476190476"};
  for (auto x : v) {
    CROW_LOG_DEBUG << x;
    ASSERT_EQUAL(json::load(x).d(), boost::lexical_cast<double>(x));
  }

  auto ret = json::load(
      R"---({"balloons":[{"mode":"ellipse","left":0.036303908355795146,"right":0.18320417789757412,"top":0.05319940476190476,"bottom":0.15224702380952382,"index":"0"},{"mode":"ellipse","left":0.3296201145552561,"right":0.47921580188679247,"top":0.05873511904761905,"bottom":0.1577827380952381,"index":"1"},{"mode":"ellipse","left":0.4996841307277628,"right":0.6425412735849056,"top":0.052113095238095236,"bottom":0.12830357142857143,"index":"2"},{"mode":"ellipse","left":0.7871041105121294,"right":0.954220013477089,"top":0.05869047619047619,"bottom":0.1625,"index":"3"},{"mode":"ellipse","left":0.8144794474393531,"right":0.9721613881401617,"top":0.1399404761904762,"bottom":0.24470238095238095,"index":"4"},{"mode":"ellipse","left":0.04527459568733154,"right":0.2096950808625337,"top":0.35267857142857145,"bottom":0.42791666666666667,"index":"5"},{"mode":"ellipse","left":0.855731974393531,"right":0.9352467991913747,"top":0.3816220238095238,"bottom":0.4282886904761905,"index":"6"},{"mode":"ellipse","left":0.39414167789757415,"right":0.5316079851752021,"top":0.3809375,"bottom":0.4571279761904762,"index":"7"},{"mode":"ellipse","left":0.03522995283018868,"right":0.1915641846361186,"top":0.6164136904761904,"bottom":0.7192708333333333,"index":"8"},{"mode":"ellipse","left":0.05675117924528302,"right":0.21308541105121293,"top":0.7045386904761904,"bottom":0.8016815476190476,"index":"9"}]})---");
  ASSERT_TRUE(static_cast<bool>(ret));
}

TEST(Crow, json_read_unescaping) {
  {
    auto x = json::load(R"({"data":"\ud55c\n\t\r"})");
    if (!x) {
      fail("fail to parse");
      return;
    }
    ASSERT_EQUAL(6, x["data"].size());
    ASSERT_EQUAL("한\n\t\r", x["data"]);
  }
  {
    // multiple r_string instance
    auto x = json::load(R"({"data":"\ud55c\n\t\r"})");
    auto a = x["data"].s();
    auto b = x["data"].s();
    ASSERT_EQUAL(6, a.size());
    ASSERT_EQUAL(6, b.size());
    ASSERT_EQUAL(6, x["data"].size());
  }
}

TEST(Crow, json_write) {
  json::wvalue x;
  x["message"] = "hello world";
  ASSERT_EQUAL(R"({"message":"hello world"})", json::dump(x));
  x["message"] = std::string("string value");
  ASSERT_EQUAL(R"({"message":"string value"})", json::dump(x));
  x["message"]["x"] = 3;
  ASSERT_EQUAL(R"({"message":{"x":3}})", json::dump(x));
  x["message"]["y"] = 5;
  ASSERT_TRUE(R"({"message":{"x":3,"y":5}})" == json::dump(x) ||
              R"({"message":{"y":5,"x":3}})" == json::dump(x));
  x["message"] = 5.5;
  ASSERT_EQUAL(R"({"message":5.5})", json::dump(x));

  json::wvalue y;
  y["scores"][0] = 1;
  y["scores"][1] = "king";
  y["scores"][2] = 3.5;
  ASSERT_EQUAL(R"({"scores":[1,"king",3.5]})", json::dump(y));

  y["scores"][2][0] = "real";
  y["scores"][2][1] = false;
  y["scores"][2][2] = true;
  ASSERT_EQUAL(R"({"scores":[1,"king",["real",false,true]]})", json::dump(y));

  y["scores"]["a"]["b"]["c"] = nullptr;
  ASSERT_EQUAL(R"({"scores":{"a":{"b":{"c":null}}}})", json::dump(y));

  y["scores"] = std::vector<int>{1, 2, 3};
  ASSERT_EQUAL(R"({"scores":[1,2,3]})", json::dump(y));
}

TEST(Crow, template_basic) {
  auto t = crow::mustache::compile(R"---(attack of {{name}})---");
  crow::mustache::context ctx;
  ctx["name"] = "killer tomatoes";
  auto result = t.render(ctx);
  ASSERT_EQUAL("attack of killer tomatoes", result);
  // crow::mustache::load("basic.mustache");
}

TEST(Crow, template_load) {
  crow::mustache::set_base(".");
  ofstream("test.mustache") << R"---(attack of {{name}})---";
  auto t = crow::mustache::load("test.mustache");
  crow::mustache::context ctx;
  ctx["name"] = "killer tomatoes";
  auto result = t.render(ctx);
  ASSERT_EQUAL("attack of killer tomatoes", result);
  unlink("test.mustache");
}

TEST(Crow, black_magic) {
  using namespace black_magic;
  static_assert(
      std::is_same<void, last_element_type<int, char, void>::type>::value,
      "last_element_type");
  static_assert(std::is_same<char, pop_back<int, char, void>::rebind<
                                       last_element_type>::type>::value,
                "pop_back");
  static_assert(
      std::is_same<int, pop_back<int, char, void>::rebind<pop_back>::rebind<
                            last_element_type>::type>::value,
      "pop_back");
}

struct NullMiddleware {
  struct context {};

  template <typename AllContext>
  void before_handle(request&, response&, context&, AllContext&) {}

  template <typename AllContext>
  void after_handle(request&, response&, context&, AllContext&) {}
};

struct NullSimpleMiddleware {
  struct context {};

  void before_handle(request& /*req*/, response& /*res*/, context& /*ctx*/) {}

  void after_handle(request& /*req*/, response& /*res*/, context& /*ctx*/) {}
};

TEST(Crow, middleware_simple) {
  App<NullMiddleware, NullSimpleMiddleware> app;
  decltype(app)::server_t server(&app, LOCALHOST_ADDRESS, 45451);
  CROW_ROUTE(app, "/")
  ([&](const crow::request& req) {
    app.get_context<NullMiddleware>(req);
    app.get_context<NullSimpleMiddleware>(req);
    return "";
  });
}

struct IntSettingMiddleware {
  struct context {
    int val;
  };

  template <typename AllContext>
  void before_handle(request&, response&, context& ctx, AllContext&) {
    ctx.val = 1;
  }

  template <typename AllContext>
  void after_handle(request&, response&, context& ctx, AllContext&) {
    ctx.val = 2;
  }
};

std::vector<std::string> test_middleware_context_vector;

struct FirstMW {
  struct context {
    std::vector<string> v;
  };

  void before_handle(request& /*req*/, response& /*res*/, context& ctx) {
    ctx.v.push_back("1 before");
  }

  void after_handle(request& /*req*/, response& /*res*/, context& ctx) {
    ctx.v.push_back("1 after");
    test_middleware_context_vector = ctx.v;
  }
};

struct SecondMW {
  struct context {};
  template <typename AllContext>
  void before_handle(request& req, response& res, context&,
                     AllContext& all_ctx) {
    all_ctx.template get<FirstMW>().v.push_back("2 before");
    if (req.url == "/break") res.end();
  }

  template <typename AllContext>
  void after_handle(request&, response&, context&, AllContext& all_ctx) {
    all_ctx.template get<FirstMW>().v.push_back("2 after");
  }
};

struct ThirdMW {
  struct context {};
  template <typename AllContext>
  void before_handle(request&, response&, context&, AllContext& all_ctx) {
    all_ctx.template get<FirstMW>().v.push_back("3 before");
  }

  template <typename AllContext>
  void after_handle(request&, response&, context&, AllContext& all_ctx) {
    all_ctx.template get<FirstMW>().v.push_back("3 after");
  }
};

TEST(Crow, middleware_context) {
  static char buf[2048];
  // SecondMW depends on FirstMW (it uses all_ctx.get<FirstMW>)
  // so it leads to compile error if we remove FirstMW from definition
  // App<IntSettingMiddleware, SecondMW> app;
  // or change the order of FirstMW and SecondMW
  // App<IntSettingMiddleware, SecondMW, FirstMW> app;

  App<IntSettingMiddleware, FirstMW, SecondMW, ThirdMW> app;

  int x{};
  CROW_ROUTE(app, "/")
  ([&](const request& req) {
    {
      auto& ctx = app.get_context<IntSettingMiddleware>(req);
      x = ctx.val;
    }
    {
      auto& ctx = app.get_context<FirstMW>(req);
      ctx.v.push_back("handle");
    }

    return "";
  });
  CROW_ROUTE(app, "/break")
  ([&](const request& req) {
    {
      auto& ctx = app.get_context<FirstMW>(req);
      ctx.v.push_back("handle");
    }

    return "";
  });

  decltype(app)::server_t server(&app, LOCALHOST_ADDRESS, 45451);
  auto _ = async(launch::async, [&] { server.run(); });
  std::string sendmsg = "GET /\r\n\r\n";
  asio::io_service is;
  {
    asio::ip::tcp::socket c(is);
    c.connect(asio::ip::tcp::endpoint(
        asio::ip::address::from_string(LOCALHOST_ADDRESS), 45451));

    c.send(asio::buffer(sendmsg));

    c.receive(asio::buffer(buf, 2048));
    c.close();
  }
  {
    auto& out = test_middleware_context_vector;
    ASSERT_EQUAL(1, x);
    ASSERT_EQUAL(7, out.size());
    ASSERT_EQUAL("1 before", out[0]);
    ASSERT_EQUAL("2 before", out[1]);
    ASSERT_EQUAL("3 before", out[2]);
    ASSERT_EQUAL("handle", out[3]);
    ASSERT_EQUAL("3 after", out[4]);
    ASSERT_EQUAL("2 after", out[5]);
    ASSERT_EQUAL("1 after", out[6]);
  }
  std::string sendmsg2 = "GET /break\r\n\r\n";
  {
    asio::ip::tcp::socket c(is);
    c.connect(asio::ip::tcp::endpoint(
        asio::ip::address::from_string(LOCALHOST_ADDRESS), 45451));

    c.send(asio::buffer(sendmsg2));

    c.receive(asio::buffer(buf, 2048));
    c.close();
  }
  {
    auto& out = test_middleware_context_vector;
    ASSERT_EQUAL(4, out.size());
    ASSERT_EQUAL("1 before", out[0]);
    ASSERT_EQUAL("2 before", out[1]);
    ASSERT_EQUAL("2 after", out[2]);
    ASSERT_EQUAL("1 after", out[3]);
  }
  server.stop();
}

TEST(Crow, middleware_cookieparser) {
  static char buf[2048];

  App<CookieParser> app;

  std::string value1;
  std::string value2;

  CROW_ROUTE(app, "/")
  ([&](const request& req) {
    {
      auto& ctx = app.get_context<CookieParser>(req);
      value1 = ctx.get_cookie("key1");
      value2 = ctx.get_cookie("key2");
    }

    return "";
  });

  decltype(app)::server_t server(&app, LOCALHOST_ADDRESS, 45451);
  auto _ = async(launch::async, [&] { server.run(); });
  std::string sendmsg =
      "GET /\r\nCookie: key1=value1; key2=\"val\\\"ue2\"\r\n\r\n";
  asio::io_service is;
  {
    asio::ip::tcp::socket c(is);
    c.connect(asio::ip::tcp::endpoint(
        asio::ip::address::from_string(LOCALHOST_ADDRESS), 45451));

    c.send(asio::buffer(sendmsg));

    c.receive(asio::buffer(buf, 2048));
    c.close();
  }
  {
    ASSERT_EQUAL("value1", value1);
    ASSERT_EQUAL("val\"ue2", value2);
  }
  server.stop();
}

TEST(Crow, bug_quick_repeated_request) {
  static char buf[2048];

  SimpleApp app;

  CROW_ROUTE(app, "/")([&] { return "hello"; });

  decltype(app)::server_t server(&app, LOCALHOST_ADDRESS, 45451);
  auto _ = async(launch::async, [&] { server.run(); });
  std::string sendmsg = "GET / HTTP/1.1\r\nHost: localhost\r\n\r\n";
  asio::io_service is;
  {
    std::vector<std::future<void>> v;
    for (int i = 0; i < 5; i++) {
      v.push_back(async(launch::async, [&] {
        asio::ip::tcp::socket c(is);
        c.connect(asio::ip::tcp::endpoint(
            asio::ip::address::from_string(LOCALHOST_ADDRESS), 45451));

        for (int j = 0; j < 5; j++) {
          c.send(asio::buffer(sendmsg));

          size_t received = c.receive(asio::buffer(buf, 2048));
          ASSERT_EQUAL("hello",
                       std::string(buf + received - 5, buf + received));
        }
        c.close();
      }));
    }
  }
  server.stop();
}

TEST(Crow, simple_url_params) {
  static char buf[2048];

  SimpleApp app;

  query_string last_url_params;

  CROW_ROUTE(app, "/params")
  ([&last_url_params](const crow::request& req) {
    last_url_params = std::move(req.url_params);
    return "OK";
  });

  /// params?h=1&foo=bar&lol&count[]=1&count[]=4&pew=5.2

  decltype(app)::server_t server(&app, LOCALHOST_ADDRESS, 45451);
  auto _ = async(launch::async, [&] { server.run(); });
  asio::io_service is;
  std::string sendmsg;

  // check empty params
  sendmsg = "GET /params\r\n\r\n";
  {
    asio::ip::tcp::socket c(is);
    c.connect(asio::ip::tcp::endpoint(
        asio::ip::address::from_string(LOCALHOST_ADDRESS), 45451));
    c.send(asio::buffer(sendmsg));
    c.receive(asio::buffer(buf, 2048));
    c.close();

    stringstream ss;
    ss << last_url_params;

    ASSERT_EQUAL("[  ]", ss.str());
  }
  // check single presence
  sendmsg = "GET /params?foobar\r\n\r\n";
  {
    asio::ip::tcp::socket c(is);
    c.connect(asio::ip::tcp::endpoint(
        asio::ip::address::from_string(LOCALHOST_ADDRESS), 45451));
    c.send(asio::buffer(sendmsg));
    c.receive(asio::buffer(buf, 2048));
    c.close();

    ASSERT_TRUE(last_url_params.get("missing") == nullptr);
    ASSERT_TRUE(last_url_params.get("foobar") != nullptr);
    ASSERT_TRUE(last_url_params.get_list("missing").empty());
  }
  // check multiple presence
  sendmsg = "GET /params?foo&bar&baz\r\n\r\n";
  {
    asio::ip::tcp::socket c(is);
    c.connect(asio::ip::tcp::endpoint(
        asio::ip::address::from_string(LOCALHOST_ADDRESS), 45451));
    c.send(asio::buffer(sendmsg));
    c.receive(asio::buffer(buf, 2048));
    c.close();

    ASSERT_TRUE(last_url_params.get("missing") == nullptr);
    ASSERT_TRUE(last_url_params.get("foo") != nullptr);
    ASSERT_TRUE(last_url_params.get("bar") != nullptr);
    ASSERT_TRUE(last_url_params.get("baz") != nullptr);
  }
  // check single value
  sendmsg = "GET /params?hello=world\r\n\r\n";
  {
    asio::ip::tcp::socket c(is);
    c.connect(asio::ip::tcp::endpoint(
        asio::ip::address::from_string(LOCALHOST_ADDRESS), 45451));
    c.send(asio::buffer(sendmsg));
    c.receive(asio::buffer(buf, 2048));
    c.close();

    ASSERT_EQUAL(string(last_url_params.get("hello")), "world");
  }
  // check multiple value
  sendmsg = "GET /params?hello=world&left=right&up=down\r\n\r\n";
  {
    asio::ip::tcp::socket c(is);
    c.connect(asio::ip::tcp::endpoint(
        asio::ip::address::from_string(LOCALHOST_ADDRESS), 45451));
    c.send(asio::buffer(sendmsg));
    c.receive(asio::buffer(buf, 2048));
    c.close();

    ASSERT_EQUAL(string(last_url_params.get("hello")), "world");
    ASSERT_EQUAL(string(last_url_params.get("left")), "right");
    ASSERT_EQUAL(string(last_url_params.get("up")), "down");
  }
  // check multiple value, multiple types
  sendmsg = "GET /params?int=100&double=123.45&boolean=1\r\n\r\n";
  {
    asio::ip::tcp::socket c(is);
    c.connect(asio::ip::tcp::endpoint(
        asio::ip::address::from_string(LOCALHOST_ADDRESS), 45451));
    c.send(asio::buffer(sendmsg));
    c.receive(asio::buffer(buf, 2048));
    c.close();

    ASSERT_EQUAL(boost::lexical_cast<int>(last_url_params.get("int")), 100);
    ASSERT_EQUAL(boost::lexical_cast<double>(last_url_params.get("double")),
                 123.45);
    ASSERT_EQUAL(boost::lexical_cast<bool>(last_url_params.get("boolean")),
                 true);
  }
  // check single array value
  sendmsg = "GET /params?tmnt[]=leonardo\r\n\r\n";
  {
    asio::ip::tcp::socket c(is);

    c.connect(asio::ip::tcp::endpoint(
        asio::ip::address::from_string(LOCALHOST_ADDRESS), 45451));
    c.send(asio::buffer(sendmsg));
    c.receive(asio::buffer(buf, 2048));
    c.close();

    ASSERT_TRUE(last_url_params.get("tmnt") == nullptr);
    ASSERT_EQUAL(last_url_params.get_list("tmnt").size(), 1);
    ASSERT_EQUAL(string(last_url_params.get_list("tmnt")[0]), "leonardo");
  }
  // check multiple array value
  sendmsg =
      "GET /params?tmnt[]=leonardo&tmnt[]=donatello&tmnt[]=raphael\r\n\r\n";
  {
    asio::ip::tcp::socket c(is);

    c.connect(asio::ip::tcp::endpoint(
        asio::ip::address::from_string(LOCALHOST_ADDRESS), 45451));
    c.send(asio::buffer(sendmsg));
    c.receive(asio::buffer(buf, 2048));
    c.close();

    ASSERT_EQUAL(last_url_params.get_list("tmnt").size(), 3);
    ASSERT_EQUAL(string(last_url_params.get_list("tmnt")[0]), "leonardo");
    ASSERT_EQUAL(string(last_url_params.get_list("tmnt")[1]), "donatello");
    ASSERT_EQUAL(string(last_url_params.get_list("tmnt")[2]), "raphael");
  }
  server.stop();
}

TEST(Crow, route_dynamic) {
  SimpleApp app;
  int x = 1;
  app.route_dynamic("/")([&] {
    x = 2;
    return "";
  });

  app.route_dynamic("/set4")([&](const request&) {
    x = 4;
    return "";
  });
  app.route_dynamic("/set5")([&](const request&, response& res) {
    x = 5;
    res.end();
  });

  app.route_dynamic("/set_int/<int>")([&](int y) {
    x = y;
    return "";
  });

  try {
    app.route_dynamic("/invalid_test/<double>/<path>")([]() { return ""; });
    fail();
  } catch (std::exception&) {
  }

  // app is in an invalid state when route_dynamic throws an exception.
  try {
    app.validate();
    fail();
  } catch (std::exception&) {
  }

  {
    request req;
    response res;
    req.url = "/";
    app.handle(req, res);
    ASSERT_EQUAL(x, 2);
  }
  {
    request req;
    response res;
    req.url = "/set_int/42";
    app.handle(req, res);
    ASSERT_EQUAL(x, 42);
  }
  {
    request req;
    response res;
    req.url = "/set5";
    app.handle(req, res);
    ASSERT_EQUAL(x, 5);
  }
  {
    request req;
    response res;
    req.url = "/set4";
    app.handle(req, res);
    ASSERT_EQUAL(x, 4);
  }
}
