From 676e924f7c5bd780250a80187bfcb74550348af7 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Mon, 2 Jan 2023 21:00:10 +0100 Subject: Added tests --- tests/test-storage.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') diff --git a/tests/test-storage.cpp b/tests/test-storage.cpp index b9994fb..1f3eda4 100644 --- a/tests/test-storage.cpp +++ b/tests/test-storage.cpp @@ -206,3 +206,29 @@ TEST_F(StorageTest, revision_increment) EXPECT_EQ(storage.getRevision("iabc"), 0); } +TEST_F(StorageTest, generate_id) +{ + Storage storage(*m_config); + std::string a{storage.generate_id()}; + std::string b{storage.generate_id()}; + + EXPECT_NE(a, b); + EXPECT_NE(a, ""); + EXPECT_NE(b, ""); + + EXPECT_GE(a.size(), 6); + +} + +TEST_F(StorageTest, checksum32) +{ + 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); +} + -- cgit v1.2.3