summaryrefslogtreecommitdiffhomepage
path: root/tests
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
parent0851f92abcb1e9d84c2748607ff8d548b582540c (diff)
Separated out libreichwein (file.cpp)
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile5
-rw-r--r--tests/test-config.cpp3
-rw-r--r--tests/test-storage.cpp38
3 files changed, 23 insertions, 23 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 4ade005..057eae9 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -11,7 +11,7 @@ CXXFLAGS+=--coverage
LDFLAGS+=--coverage
endif
-UNITS=storage.cpp config.cpp file.cpp compiledsql.cpp qrcode.cpp whiteboard.cpp
+UNITS=storage.cpp config.cpp compiledsql.cpp qrcode.cpp whiteboard.cpp
UNITTESTS=test-config.cpp \
test-storage.cpp
@@ -47,9 +47,6 @@ unittests: libgmock.a $(UNITTESTS:.cpp=.o) $(UNITS:.cpp=.o)
config.o: ../config.cpp
$(CXX) $(CXXFLAGS) -o $@ -c $<
-file.o: ../file.cpp
- $(CXX) $(CXXFLAGS) -o $@ -c $<
-
storage.o: ../storage.cpp
$(CXX) $(CXXFLAGS) -o $@ -c $<
diff --git a/tests/test-config.cpp b/tests/test-config.cpp
index cd358a6..1aafcf9 100644
--- a/tests/test-config.cpp
+++ b/tests/test-config.cpp
@@ -4,8 +4,9 @@
#include <string>
#include <system_error>
+#include "libreichwein/file.h"
+
#include "config.h"
-#include "file.h"
namespace fs = std::filesystem;
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");