From 004db5e7e4e9ab6ac5b4730873c6b8f58da92930 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 22 Jan 2023 12:02:16 +0100 Subject: Storage bugfix, whiteboard xml implementation --- tests/test-storage.cpp | 17 +++++++++++------ tests/test-whiteboard.cpp | 8 ++++++-- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/test-storage.cpp b/tests/test-storage.cpp index ce19c3e..d8259e1 100644 --- a/tests/test-storage.cpp +++ b/tests/test-storage.cpp @@ -210,15 +210,20 @@ TEST_F(StorageTest, revision_increment) TEST_F(StorageTest, generate_id) { Storage storage(*m_config); - std::string a{storage.generate_id()}; - std::string b{storage.generate_id()}; + for (int i = 0; i < 100; i++) { + std::string a{storage.generate_id()}; + std::string b{storage.generate_id()}; - EXPECT_NE(a, b); - EXPECT_NE(a, ""); - EXPECT_NE(b, ""); + EXPECT_NE(a, b); + EXPECT_NE(a, ""); + EXPECT_NE(b, ""); - EXPECT_GE(a.size(), 6); + EXPECT_GE(a.size(), 6); + for (char c: a + b) { + EXPECT_TRUE((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')); + } + } } TEST_F(StorageTest, checksum32) diff --git a/tests/test-whiteboard.cpp b/tests/test-whiteboard.cpp index 4ed10ae..a472d64 100644 --- a/tests/test-whiteboard.cpp +++ b/tests/test-whiteboard.cpp @@ -234,11 +234,15 @@ TEST_F(WhiteboardTest, generate_id) wc.write("newid"); std::string result0 {wc.read()}; - ASSERT_EQ(result0.size(), 6); + ASSERT_TRUE(boost::algorithm::starts_with(result0, "newid")); + ASSERT_TRUE(boost::algorithm::ends_with(result0, "")); + ASSERT_EQ(result0.size(), 58); wc.write("newid"); std::string result1 {wc.read()}; - ASSERT_EQ(result1.size(), 6); + ASSERT_TRUE(boost::algorithm::starts_with(result1, "newid")); + ASSERT_TRUE(boost::algorithm::ends_with(result1, "")); + ASSERT_EQ(result1.size(), 58); ASSERT_NE(result0, result1); } -- cgit v1.2.3