From 52702a0438e3ba4044cebf14c2d9413a01f967b7 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 11 Feb 2023 11:00:54 +0100 Subject: Test maxconnections --- tests/test-whiteboard.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/test-whiteboard.cpp b/tests/test-whiteboard.cpp index e1df17a..b6fe9c5 100644 --- a/tests/test-whiteboard.cpp +++ b/tests/test-whiteboard.cpp @@ -57,6 +57,7 @@ protected: . 2592000 4 + 3 )CONFIG"); std::error_code ec; @@ -159,6 +160,11 @@ public: { } + bool is_open() + { + return ws_->is_open(); + } + private: boost::asio::io_context ioc_; boost::asio::ip::tcp::resolver::results_type resolver_results_; @@ -200,3 +206,19 @@ TEST_F(WhiteboardTest, threads) ASSERT_GE(Process::number_of_threads(m_pid), 4); } +TEST_F(WhiteboardTest, max_connections) +{ + WebsocketClient wc1; + std::this_thread::sleep_for(std::chrono::milliseconds(20)); + ASSERT_TRUE(wc1.is_open()); + + WebsocketClient wc2; + std::this_thread::sleep_for(std::chrono::milliseconds(20)); + ASSERT_TRUE(wc2.is_open()); + + WebsocketClient wc3; + std::this_thread::sleep_for(std::chrono::milliseconds(20)); + ASSERT_TRUE(wc3.is_open()); + + ASSERT_THROW(WebsocketClient wc4, std::exception); +} -- cgit v1.2.3