From c4a1f194e79a7834a54fdbf63d73c33e434b4825 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 4 Feb 2023 12:43:51 +0100 Subject: Added stats.html --- tests/test-connectionregistry.cpp | 23 +++++++++++++++++++++++ tests/test-storage.cpp | 28 +++++++++++++++++++++------- 2 files changed, 44 insertions(+), 7 deletions(-) (limited to 'tests') 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(std::move(ts0))}; + + boost::asio::ip::tcp::socket ts1{ioc}; + ConnectionRegistry::connection c1 {std::make_shared(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); +} + diff --git a/tests/test-storage.cpp b/tests/test-storage.cpp index d8259e1..51a6058 100644 --- a/tests/test-storage.cpp +++ b/tests/test-storage.cpp @@ -227,14 +227,28 @@ TEST_F(StorageTest, generate_id) } TEST_F(StorageTest, checksum32) +{ + EXPECT_EQ(checksum32(""), 0); + EXPECT_EQ(checksum32("0"), 48); + EXPECT_EQ(checksum32("\x00"), 0); + EXPECT_EQ(checksum32("123"), 1073741862); + EXPECT_EQ(checksum32("a"), 97); + EXPECT_EQ(checksum32("ab"), 82); + EXPECT_EQ(checksum32("abc"), 1073741898); +} + +TEST_F(StorageTest, db_size) { Storage storage(*m_config); - EXPECT_EQ(storage.checksum32(""), 0); - EXPECT_EQ(storage.checksum32("0"), 48); - EXPECT_EQ(storage.checksum32("\x00"), 0); - EXPECT_EQ(storage.checksum32("123"), 1073741862); - EXPECT_EQ(storage.checksum32("a"), 97); - EXPECT_EQ(storage.checksum32("ab"), 82); - EXPECT_EQ(storage.checksum32("abc"), 1073741898); + auto dbsize_gross{storage.dbsize_gross()}; + auto dbsize_net{storage.dbsize_net()}; + + EXPECT_LE(0, storage.dbsize_net()); + EXPECT_LE(storage.dbsize_net(), storage.dbsize_gross()); + + storage.setDocument("0", "xyz"); + + EXPECT_LE(dbsize_net, storage.dbsize_net()); + EXPECT_LE(dbsize_gross, storage.dbsize_gross()); } -- cgit v1.2.3