1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
/*
* SPDX-FileCopyrightText: 2021 bbarbisch
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <pistache/endpoint.h>
#include <pistache/router.h>
#include <gtest/gtest.h>
using namespace Pistache;
TEST(endpoint_initialization_test, initialize_options_before_handler)
{
Rest::Router router;
auto handler = router.handler();
Address addr(Ipv4::any(), Port(0));
Http::Endpoint endpoint(addr);
size_t maxReqSize = 123;
size_t maxRespSize = 456;
auto opts = Http::Endpoint::options();
opts.threads(2);
opts.maxRequestSize(maxReqSize);
opts.maxResponseSize(maxRespSize);
endpoint.init(opts);
endpoint.setHandler(handler);
ASSERT_EQ(handler->getMaxRequestSize(), maxReqSize);
ASSERT_EQ(handler->getMaxResponseSize(), maxRespSize);
}
TEST(endpoint_initialization_test, initialize_handler_before_options)
{
Rest::Router router;
auto handler = router.handler();
Address addr(Ipv4::any(), Port(0));
Http::Endpoint endpoint(addr);
size_t maxReqSize = 123;
size_t maxRespSize = 456;
auto opts = Http::Endpoint::options();
opts.threads(2);
opts.maxRequestSize(maxReqSize);
opts.maxResponseSize(maxRespSize);
endpoint.setHandler(handler);
endpoint.init(opts);
ASSERT_EQ(handler->getMaxRequestSize(), maxReqSize);
ASSERT_EQ(handler->getMaxResponseSize(), maxRespSize);
}
|