diff options
Diffstat (limited to 'tests/test-connectionregistry.cpp')
-rw-r--r-- | tests/test-connectionregistry.cpp | 23 |
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); +} + |