summaryrefslogtreecommitdiffhomepage
path: root/tests/test-storage.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2023-01-02 17:38:35 +0100
committerRoland Reichwein <mail@reichwein.it>2023-01-02 17:38:35 +0100
commit20ceb53ec1c1bc18face8e831292dfe81fed3817 (patch)
treea1107d98cf8699b28ef6034c09567f39c68b160b /tests/test-storage.cpp
parent0851f92abcb1e9d84c2748607ff8d548b582540c (diff)
Separated out libreichwein (file.cpp)
Diffstat (limited to 'tests/test-storage.cpp')
-rw-r--r--tests/test-storage.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/tests/test-storage.cpp b/tests/test-storage.cpp
index 158a9bd..b9994fb 100644
--- a/tests/test-storage.cpp
+++ b/tests/test-storage.cpp
@@ -1,11 +1,13 @@
#include <gtest/gtest.h>
#include <filesystem>
+#include <memory>
#include <string>
#include <system_error>
+#include "libreichwein/file.h"
+
#include "config.h"
-#include "file.h"
#include "storage.h"
namespace fs = std::filesystem;
@@ -35,7 +37,7 @@ protected:
std::error_code ec;
fs::remove(testDbFilename, ec);
- m_config = Config{testConfigFilename};
+ m_config = std::make_shared<Config>(testConfigFilename);
}
void TearDown() override
@@ -45,7 +47,7 @@ protected:
fs::remove(testConfigFilename, ec);
}
- Config m_config;
+ std::shared_ptr<Config> m_config;
};
TEST_F(StorageTest, create)
@@ -53,9 +55,9 @@ TEST_F(StorageTest, create)
ASSERT_TRUE(!fs::exists(testDbFilename));
{
- ASSERT_EQ(m_config.getDataPath(), ".");
+ ASSERT_EQ(m_config->getDataPath(), ".");
ASSERT_TRUE(!fs::exists(testDbFilename));
- Storage storage(m_config);
+ Storage storage(*m_config);
}
ASSERT_TRUE(fs::exists(testDbFilename));
@@ -63,7 +65,7 @@ TEST_F(StorageTest, create)
TEST_F(StorageTest, getNumberOfDocuments)
{
- Storage storage(m_config);
+ Storage storage(*m_config);
EXPECT_EQ(storage.getNumberOfDocuments(), 0UL);
storage.setDocument("123", "abc");
EXPECT_EQ(storage.getNumberOfDocuments(), 1UL);
@@ -73,7 +75,7 @@ TEST_F(StorageTest, getNumberOfDocuments)
TEST_F(StorageTest, cleanup_empty)
{
- Storage storage(m_config);
+ Storage storage(*m_config);
EXPECT_EQ(storage.getNumberOfDocuments(), 0UL);
storage.cleanup();
EXPECT_EQ(storage.getNumberOfDocuments(), 0UL);
@@ -81,7 +83,7 @@ TEST_F(StorageTest, cleanup_empty)
TEST_F(StorageTest, cleanup)
{
- Storage storage(m_config);
+ Storage storage(*m_config);
EXPECT_EQ(storage.getNumberOfDocuments(), 0UL);
storage.setDocument("123", "abc");
EXPECT_EQ(storage.getNumberOfDocuments(), 1UL);
@@ -91,7 +93,7 @@ TEST_F(StorageTest, cleanup)
TEST_F(StorageTest, exists)
{
- Storage storage(m_config);
+ Storage storage(*m_config);
EXPECT_EQ(storage.exists(""), false);
EXPECT_EQ(storage.exists("0"), false);
EXPECT_EQ(storage.exists("123"), false);
@@ -109,7 +111,7 @@ TEST_F(StorageTest, exists)
TEST_F(StorageTest, setDocument)
{
- Storage storage(m_config);
+ Storage storage(*m_config);
storage.setDocument("0", "abc");
EXPECT_EQ(storage.getNumberOfDocuments(), 1UL);
EXPECT_EQ(storage.getDocument("0"), "abc");
@@ -117,7 +119,7 @@ TEST_F(StorageTest, setDocument)
TEST_F(StorageTest, setRevision)
{
- Storage storage(m_config);
+ Storage storage(*m_config);
storage.setDocument("0", "abc");
storage.setRevision("0", 123);
@@ -127,7 +129,7 @@ TEST_F(StorageTest, setRevision)
TEST_F(StorageTest, setCursorPos)
{
- Storage storage(m_config);
+ Storage storage(*m_config);
storage.setDocument("0", "abc");
storage.setCursorPos("0", 1234);
@@ -137,7 +139,7 @@ TEST_F(StorageTest, setCursorPos)
TEST_F(StorageTest, setRow)
{
- Storage storage(m_config);
+ Storage storage(*m_config);
storage.setRow("0", "abc", 56, 67);
EXPECT_EQ(storage.getNumberOfDocuments(), 1UL);
@@ -148,7 +150,7 @@ TEST_F(StorageTest, setRow)
TEST_F(StorageTest, getDocument)
{
- Storage storage(m_config);
+ Storage storage(*m_config);
storage.setDocument("0", "xyz");
storage.setDocument("0bc", "xyz2");
storage.setDocument("iabc", "xyz3");
@@ -159,7 +161,7 @@ TEST_F(StorageTest, getDocument)
TEST_F(StorageTest, getRevision)
{
- Storage storage(m_config);
+ Storage storage(*m_config);
storage.setRow("0", "abc", 123, 456);
EXPECT_EQ(storage.getRevision("0"), 123);
@@ -167,7 +169,7 @@ TEST_F(StorageTest, getRevision)
TEST_F(StorageTest, getCursorPos)
{
- Storage storage(m_config);
+ Storage storage(*m_config);
storage.setRow("0", "abc", 123, 456);
EXPECT_EQ(storage.getCursorPos("0"), 456);
@@ -175,7 +177,7 @@ TEST_F(StorageTest, getCursorPos)
TEST_F(StorageTest, getRow)
{
- Storage storage(m_config);
+ Storage storage(*m_config);
storage.setRow("0", "abc", 123, 456);
auto row{storage.getRow("0")};
@@ -186,7 +188,7 @@ TEST_F(StorageTest, getRow)
TEST_F(StorageTest, revision_increment)
{
- Storage storage(m_config);
+ Storage storage(*m_config);
storage.setDocument("0", "xyz");
storage.setDocument("0bc", "xyz2");
storage.setDocument("iabc", "xyz3");