summaryrefslogtreecommitdiffhomepage
path: root/tests/test-storage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-storage.cpp')
-rw-r--r--tests/test-storage.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test-storage.cpp b/tests/test-storage.cpp
index 51a6058..6239f8f 100644
--- a/tests/test-storage.cpp
+++ b/tests/test-storage.cpp
@@ -12,6 +12,7 @@
namespace fs = std::filesystem;
using namespace Reichwein;
+using namespace std::string_literals;
namespace {
const std::string testConfigFilename{"./test.conf"};
@@ -118,6 +119,16 @@ TEST_F(StorageTest, setDocument)
EXPECT_EQ(storage.getDocument("0"), "abc");
}
+TEST_F(StorageTest, touchDocument)
+{
+ Storage storage(*m_config);
+ EXPECT_THROW(storage.touchDocument("0"), std::exception);
+ storage.setDocument("0", "abc");
+ storage.touchDocument("0");
+ EXPECT_EQ(storage.getNumberOfDocuments(), 1UL);
+ EXPECT_EQ(storage.getDocument("0"), "abc");
+}
+
TEST_F(StorageTest, setRevision)
{
Storage storage(*m_config);
@@ -126,6 +137,15 @@ TEST_F(StorageTest, setRevision)
EXPECT_EQ(storage.getNumberOfDocuments(), 1UL);
EXPECT_EQ(storage.getRevision("0"), 123);
+
+ try {
+ storage.setRevision("1", 123);
+ FAIL();
+ } catch(const std::exception& ex) {
+ EXPECT_EQ("Unable to set revision for id 1"s, ex.what());
+ } catch(...) {
+ FAIL();
+ }
}
TEST_F(StorageTest, setCursorPos)
@@ -136,6 +156,15 @@ TEST_F(StorageTest, setCursorPos)
EXPECT_EQ(storage.getNumberOfDocuments(), 1UL);
EXPECT_EQ(storage.getCursorPos("0"), 1234);
+
+ try {
+ storage.setCursorPos("1", 12345);
+ FAIL();
+ } catch(const std::exception& ex) {
+ EXPECT_EQ("Unable to set cursor position for id 1"s, ex.what());
+ } catch(...) {
+ FAIL();
+ }
}
TEST_F(StorageTest, setRow)