#include "crow.h"

#include <iostream>
#include <sstream>
#include <vector>

#include "gtest/gtest.h"

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 (const runtime_error& e)
    {}

    int x = 0;

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

    r.validate();

    Response res;

    // executing handler
    ASSERT_EQUAL(0, x);
    boost::beast::http::request<boost::beast::http::string_body> req{};
    r.handle(Request(req), res, RoutingParams());
    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(req), res, RoutingParams());
    ASSERT_EQUAL(2, x);
}

TEST(Crow, ParameterTagging)
{
    static_assert(black_magic::isValid("<int><int><int>"), "valid url");
    static_assert(!black_magic::isValid("<int><int<<int>"), "invalid url");
    static_assert(!black_magic::isValid("nt>"), "invalid url");
    ASSERT_EQUAL(1, black_magic::getParameterTag("<int>"));
    ASSERT_EQUAL(2, black_magic::getParameterTag("<uint>"));
    ASSERT_EQUAL(3, black_magic::getParameterTag("<float>"));
    ASSERT_EQUAL(3, black_magic::getParameterTag("<double>"));
    ASSERT_EQUAL(4, black_magic::getParameterTag("<str>"));
    ASSERT_EQUAL(4, black_magic::getParameterTag("<string>"));
    ASSERT_EQUAL(5, black_magic::getParameterTag("<path>"));
    ASSERT_EQUAL(6 * 6 + 6 + 1,
                 black_magic::getParameterTag("<int><int><int>"));
    ASSERT_EQUAL(6 * 6 + 6 + 2,
                 black_magic::getParameterTag("<uint><int><int>"));
    ASSERT_EQUAL(6 * 6 + 6 * 3 + 2,
                 black_magic::getParameterTag("<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;

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

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

    {
        boost::beast::http::request<boost::beast::http::string_body> r{};
        Request req{r};
        Response res;

        req.url = "/file";

        app.handle(req, res);

        ASSERT_EQUAL(200, res.resultInt());
    }
    {
        boost::beast::http::request<boost::beast::http::string_body> r{};
        Request req{r};
        Response res;

        req.url = "/file/";

        app.handle(req, res);
        ASSERT_EQUAL(404, res.resultInt());
    }
    {
        boost::beast::http::request<boost::beast::http::string_body> r{};
        Request req{r};
        Response res;

        req.url = "/path";

        app.handle(req, res);
        ASSERT_NOTEQUAL(404, res.resultInt());
    }
    {
        boost::beast::http::request<boost::beast::http::string_body> r{};
        Request req{r};
        Response res;

        req.url = "/path/";

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

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

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

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

    BMCWEB_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";
    });

    BMCWEB_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.debugPrint();
    {
        boost::beast::http::request<boost::beast::http::string_body> r{};
        Request req{r};
        Response res;

        req.url = "/-1";

        app.handle(req, res);

        ASSERT_EQUAL(404, res.resultInt());
    }

    {
        boost::beast::http::request<boost::beast::http::string_body> r{};
        Request req{r};
        Response res;

        req.url = "/0/1001999";

        app.handle(req, res);

        ASSERT_EQUAL(200, res.resultInt());

        ASSERT_EQUAL(1001999, b);
    }

    {
        boost::beast::http::request<boost::beast::http::string_body> r{};
        Request req{r};
        Response res;

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

        app.handle(req, res);

        ASSERT_EQUAL(200, res.resultInt());

        ASSERT_EQUAL(-100, A);
        ASSERT_EQUAL(1999, b);
    }
    {
        boost::beast::http::request<boost::beast::http::string_body> r{};
        Request req{r};
        Response res;

        req.url = "/4/5000/3/-2.71828/hellhere";

        app.handle(req, res);

        ASSERT_EQUAL(200, res.resultInt());

        ASSERT_EQUAL(5000, A);
        ASSERT_EQUAL(3, b);
        ASSERT_EQUAL(-2.71828, C);
        ASSERT_EQUAL("hellhere", D);
    }
    {
        boost::beast::http::request<boost::beast::http::string_body> r{};
        Request req{r};
        Response res;

        req.url = "/5/-5/999/3.141592/hello_there/a/b/c/d";

        app.handle(req, res);

        ASSERT_EQUAL(200, res.resultInt());

        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_RoutingParams)
{
    ASSERT_EQUAL(100,
                 Response(boost::beast::http::status::continue_).resultInt());
    ASSERT_EQUAL(200, Response("Hello there").resultInt());
    ASSERT_EQUAL(500,
                 Response(boost::beast::http::status::internal_server_error,
                          "Internal Error?")
                     .resultInt());

    RoutingParams rp;
    rp.intParams.push_back(1);
    rp.intParams.push_back(5);
    rp.uintParams.push_back(2);
    rp.doubleParams.push_back(3);
    rp.stringParams.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;
    BMCWEB_ROUTE(app, "/")([](const crow::Request&, crow::Response&) {});
}

TEST(Crow, http_method)
{
    SimpleApp app;

    BMCWEB_ROUTE(app, "/").methods(boost::beast::http::verb::post,
                                   boost::beast::http::verb::get)(
        [](const Request& req) {
            if (req.method() == boost::beast::http::verb::get)
                return "2";
            else
                return "1";
        });

    BMCWEB_ROUTE(app, "/get_only")
        .methods(boost::beast::http::verb::get)(
            [](const Request& /*req*/) { return "get"; });
    BMCWEB_ROUTE(app, "/post_only")
        .methods(boost::beast::http::verb::post)(
            [](const Request& /*req*/) { return "post"; });

    // cannot have multiple handlers for the same url
    // BMCWEB_ROUTE(app, "/")
    //.methods(boost::beast::http::verb::get)
    //([]{ return "2"; });

    {
        boost::beast::http::request<boost::beast::http::string_body> r{};
        Request req{r};
        Response res;

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

        ASSERT_EQUAL("2", res.body());
    }
    {
        boost::beast::http::request<boost::beast::http::string_body> r{};
        Request req{r};
        Response res;

        req.url = "/";
        r.method(boost::beast::http::verb::post);
        app.handle(req, res);

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

    {
        boost::beast::http::request<boost::beast::http::string_body> r{};
        Request req{r};
        Response res;

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

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

    {
        boost::beast::http::request<boost::beast::http::string_body> r{};
        Request req{r};
        Response res;

        req.url = "/get_only";
        r.method(boost::beast::http::verb::post);
        app.handle(req, res);

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

TEST(Crow, server_handling_error_request)
{
    static char buf[2048];
    SimpleApp app;
    BMCWEB_ROUTE(app, "/")([] { return "A"; });
    Server<SimpleApp> server(&app, LOCALHOST_ADDRESS, 45451);
    auto _ = async(launch::async, [&] { server.run(); });
    std::string sendmsg = "POX";
    asio::io_context 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 (const std::exception& e)
        {
            // std::cerr << e.what() << std::endl;
        }
    }
    server.stop();
}

TEST(Crow, multi_server)
{
    static char buf[2048];
    SimpleApp app1, app2;
    BMCWEB_ROUTE(app1, "/").methods(boost::beast::http::verb::get,
                                    boost::beast::http::verb::post)(
        [] { return "A"; });
    BMCWEB_ROUTE(app2, "/").methods(boost::beast::http::verb::get,
                                    boost::beast::http::verb::post)(
        [] { 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_context 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, black_magic)
{
    using namespace black_magic;
    static_assert(
        std::is_same<void, LastElementType<int, char, void>::type>::value,
        "LastElementType");
    static_assert(
        std::is_same<char, PopBack<int, char,
                                   void>::rebind<LastElementType>::type>::value,
        "pop_back");
    static_assert(
        std::is_same<int, PopBack<int, char, void>::rebind<PopBack>::rebind<
                              LastElementType>::type>::value,
        "pop_back");
}

struct NullMiddleware
{
    struct Context
    {};

    template <typename AllContext>
    void beforeHandle(Request&, Response&, Context&, AllContext&)
    {}

    template <typename AllContext>
    void afterHandle(Request&, Response&, Context&, AllContext&)
    {}
};

struct NullSimpleMiddleware
{
    struct Context
    {};

    void beforeHandle(Request& /*req*/, Response& /*res*/, Context& /*ctx*/)
    {}

    void afterHandle(Request& /*req*/, Response& /*res*/, Context& /*ctx*/)
    {}
};

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

struct IntSettingMiddleware
{
    struct Context
    {
        int val;
    };

    template <typename AllContext>
    void beforeHandle(Request&, Response&, Context& ctx, AllContext&)
    {
        ctx.val = 1;
    }

    template <typename AllContext>
    void afterHandle(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 beforeHandle(Request& /*req*/, Response& /*res*/, Context& ctx)
    {
        ctx.v.push_back("1 before");
    }

    void afterHandle(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 beforeHandle(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 afterHandle(Request&, Response&, Context&, AllContext& all_ctx)
    {
        all_ctx.template get<FirstMW>().v.push_back("2 after");
    }
};

struct ThirdMW
{
    struct Context
    {};
    template <typename AllContext>
    void beforeHandle(Request&, Response&, Context&, AllContext& all_ctx)
    {
        all_ctx.template get<FirstMW>().v.push_back("3 before");
    }

    template <typename AllContext>
    void afterHandle(Request&, Response&, Context&, AllContext& all_ctx)
    {
        all_ctx.template get<FirstMW>().v.push_back("3 after");
    }
};

TEST(Crow, middlewareContext)
{
    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{};
    BMCWEB_ROUTE(app, "/")
    ([&](const Request& req) {
        {
            auto& ctx = app.getContext<IntSettingMiddleware>(req);
            x = ctx.val;
        }
        {
            auto& ctx = app.getContext<FirstMW>(req);
            ctx.v.push_back("handle");
        }

        return "";
    });
    BMCWEB_ROUTE(app, "/break")
    ([&](const Request& req) {
        {
            auto& ctx = app.getContext<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_context 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, bug_quick_repeated_request)
{
    static char buf[2048];

    SimpleApp app;

    BMCWEB_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_context 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;

    QueryString lastUrlParams;

    BMCWEB_ROUTE(app, "/params")
    ([&lastUrlParams](const crow::Request& req) {
        lastUrlParams = std::move(req.urlParams);
        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_context 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 << lastUrlParams;

        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(lastUrlParams.get("missing") == nullptr);
        ASSERT_TRUE(lastUrlParams.get("foobar") != nullptr);
        ASSERT_TRUE(lastUrlParams.getList("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(lastUrlParams.get("missing") == nullptr);
        ASSERT_TRUE(lastUrlParams.get("foo") != nullptr);
        ASSERT_TRUE(lastUrlParams.get("bar") != nullptr);
        ASSERT_TRUE(lastUrlParams.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(lastUrlParams.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(lastUrlParams.get("hello")), "world");
        ASSERT_EQUAL(string(lastUrlParams.get("left")), "right");
        ASSERT_EQUAL(string(lastUrlParams.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>(lastUrlParams.get("int")), 100);
        ASSERT_EQUAL(boost::lexical_cast<double>(lastUrlParams.get("double")),
                     123.45);
        ASSERT_EQUAL(boost::lexical_cast<bool>(lastUrlParams.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(lastUrlParams.get("tmnt") == nullptr);
        ASSERT_EQUAL(lastUrlParams.getList("tmnt").size(), 1);
        ASSERT_EQUAL(string(lastUrlParams.getList("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(lastUrlParams.getList("tmnt").size(), 3);
        ASSERT_EQUAL(string(lastUrlParams.getList("tmnt")[0]), "leonardo");
        ASSERT_EQUAL(string(lastUrlParams.getList("tmnt")[1]), "donatello");
        ASSERT_EQUAL(string(lastUrlParams.getList("tmnt")[2]), "raphael");
    }
    server.stop();
}

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

    app.routeDynamic("/set4")([&](const Request&) {
        x = 4;
        return "";
    });
    app.routeDynamic("/set5")([&](const Request&, Response& res) {
        x = 5;
        res.end();
    });

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

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

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

    {
        boost::beast::http::request<boost::beast::http::string_body> r{};
        Request req{r};
        Response res;
        req.url = "/";
        app.handle(req, res);
        ASSERT_EQUAL(x, 2);
    }
    {
        boost::beast::http::request<boost::beast::http::string_body> r{};
        Request req{r};
        Response res;
        req.url = "/set_int/42";
        app.handle(req, res);
        ASSERT_EQUAL(x, 42);
    }
    {
        boost::beast::http::request<boost::beast::http::string_body> r{};
        Request req{r};
        Response res;
        req.url = "/set5";
        app.handle(req, res);
        ASSERT_EQUAL(x, 5);
    }
    {
        boost::beast::http::request<boost::beast::http::string_body> r{};
        Request req{r};
        Response res;
        req.url = "/set4";
        app.handle(req, res);
        ASSERT_EQUAL(x, 4);
    }
}
