summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test-connectionregistry.cpp23
-rw-r--r--tests/test-storage.cpp28
2 files changed, 44 insertions, 7 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);
+}
+
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
@@ -228,13 +228,27 @@ 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());
}