summaryrefslogtreecommitdiffhomepage
path: root/tests/test-connectionregistry.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2023-02-04 12:43:51 +0100
committerRoland Reichwein <mail@reichwein.it>2023-02-04 12:43:51 +0100
commitc4a1f194e79a7834a54fdbf63d73c33e434b4825 (patch)
tree51eae6c701f38e47790b7200b423de8c89b38465 /tests/test-connectionregistry.cpp
parent1771f788a5b9e844f0a5315faee104648e3b7d88 (diff)
Added stats.html
Diffstat (limited to 'tests/test-connectionregistry.cpp')
-rw-r--r--tests/test-connectionregistry.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test-connectionregistry.cpp b/tests/test-connectionregistry.cpp
index 1f68dd9..282f397 100644
--- a/tests/test-connectionregistry.cpp
+++ b/tests/test-connectionregistry.cpp
@@ -142,3 +142,26 @@ TEST_F(ConnectionRegistryTest, test_guard)
EXPECT_THROW(cr.delConnection(c), std::exception);
}
+TEST_F(ConnectionRegistryTest, number_of_connections)
+{
+ boost::asio::io_context ioc{1};
+
+ boost::asio::ip::tcp::socket ts0{ioc};
+ ConnectionRegistry::connection c0 {std::make_shared<ConnectionRegistry::connection::element_type>(std::move(ts0))};
+
+ boost::asio::ip::tcp::socket ts1{ioc};
+ ConnectionRegistry::connection c1 {std::make_shared<ConnectionRegistry::connection::element_type>(std::move(ts1))};
+
+ ConnectionRegistry cr{};
+
+ EXPECT_EQ(cr.number_of_connections(), 0);
+ cr.addConnection(c0);
+ EXPECT_EQ(cr.number_of_connections(), 1);
+ cr.addConnection(c1);
+ EXPECT_EQ(cr.number_of_connections(), 2);
+ cr.delConnection(c0);
+ EXPECT_EQ(cr.number_of_connections(), 1);
+ cr.delConnection(c1);
+ EXPECT_EQ(cr.number_of_connections(), 0);
+}
+