summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile14
-rw-r--r--tests/test-config.cpp4
-rw-r--r--tests/test-storage.cpp24
3 files changed, 23 insertions, 19 deletions
diff --git a/tests/Makefile b/tests/Makefile
index e36198b..94789f9 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,16 +1,16 @@
CXXFLAGS=-g -O0
+include ../common.mk
+
ifeq ($(CXX),clang++-14)
CXXFLAGS+=-fprofile-instr-generate -fcoverage-mapping
+LDFLAGS+=-fprofile-instr-generate -fcoverage-mapping
else
# GCC
CXXFLAGS+=--coverage
+LDFLAGS+=--coverage
endif
-include ../common.mk
-
-LDFLAGS+=-fprofile-instr-generate -fcoverage-mapping
-
UNITS=storage.cpp config.cpp file.cpp compiledsql.cpp qrcode.cpp whiteboard.cpp
UNITTESTS=test-config.cpp \
@@ -29,6 +29,10 @@ ifeq ($(CXX),clang++-14)
LLVM_PROFILE_FILE="unittests.profraw" ./unittests
llvm-profdata-14 merge -sparse unittests.profraw -o unittests.profdata
llvm-cov-14 report --ignore-filename-regex='google' --ignore-filename-regex='test-' --show-region-summary=0 -instr-profile unittests.profdata unittests
+else
+ ./unittests
+ #gcov-12 storage.o
+ gcovr -r ..
endif
coverage:
@@ -65,4 +69,4 @@ libgmock.a:
ar -rv libgmock.a gmock-all.o gtest-all.o gmock_main.o
clean:
- -rm -f *.o *.a unittests *.gcno *.profraw *.profdata
+ -rm -f *.o *.a unittests *.gcda *.gcno *.profraw *.profdata *.gcov
diff --git a/tests/test-config.cpp b/tests/test-config.cpp
index 065dedf..cd358a6 100644
--- a/tests/test-config.cpp
+++ b/tests/test-config.cpp
@@ -33,7 +33,7 @@ TEST_F(ConfigTest, defaultData)
{
Config config{filename};
EXPECT_EQ(config.getDataPath(), "/var/lib/whiteboard");
- EXPECT_EQ(config.getMaxage(), 0);
+ EXPECT_EQ(config.getMaxage(), 0UL);
ASSERT_TRUE(!fs::exists(filename));
}
@@ -52,7 +52,7 @@ TEST_F(ConfigTest, testData)
{
Config config{testConfigFilename};
EXPECT_EQ(config.getDataPath(), "/some/other/location");
- EXPECT_EQ(config.getMaxage(), 2592000);
+ EXPECT_EQ(config.getMaxage(), 2592000UL);
}
std::error_code ec;
diff --git a/tests/test-storage.cpp b/tests/test-storage.cpp
index 11d8a20..87168fc 100644
--- a/tests/test-storage.cpp
+++ b/tests/test-storage.cpp
@@ -64,29 +64,29 @@ TEST_F(StorageTest, create)
TEST_F(StorageTest, getNumberOfDocuments)
{
Storage storage(m_config);
- EXPECT_EQ(storage.getNumberOfDocuments(), 0);
+ EXPECT_EQ(storage.getNumberOfDocuments(), 0UL);
storage.setDocument("123", "abc");
- EXPECT_EQ(storage.getNumberOfDocuments(), 1);
+ EXPECT_EQ(storage.getNumberOfDocuments(), 1UL);
storage.setDocument("def", "xyz");
- EXPECT_EQ(storage.getNumberOfDocuments(), 2);
+ EXPECT_EQ(storage.getNumberOfDocuments(), 2UL);
}
TEST_F(StorageTest, cleanup_empty)
{
Storage storage(m_config);
- EXPECT_EQ(storage.getNumberOfDocuments(), 0);
+ EXPECT_EQ(storage.getNumberOfDocuments(), 0UL);
storage.cleanup();
- EXPECT_EQ(storage.getNumberOfDocuments(), 0);
+ EXPECT_EQ(storage.getNumberOfDocuments(), 0UL);
}
TEST_F(StorageTest, cleanup)
{
Storage storage(m_config);
- EXPECT_EQ(storage.getNumberOfDocuments(), 0);
+ EXPECT_EQ(storage.getNumberOfDocuments(), 0UL);
storage.setDocument("123", "abc");
- EXPECT_EQ(storage.getNumberOfDocuments(), 1);
+ EXPECT_EQ(storage.getNumberOfDocuments(), 1UL);
storage.cleanup();
- EXPECT_EQ(storage.getNumberOfDocuments(), 1);
+ EXPECT_EQ(storage.getNumberOfDocuments(), 1UL);
}
TEST_F(StorageTest, exists)
@@ -111,7 +111,7 @@ TEST_F(StorageTest, setDocument)
{
Storage storage(m_config);
storage.setDocument("0", "abc");
- EXPECT_EQ(storage.getNumberOfDocuments(), 1);
+ EXPECT_EQ(storage.getNumberOfDocuments(), 1UL);
EXPECT_EQ(storage.getDocument("0"), "abc");
}
@@ -121,7 +121,7 @@ TEST_F(StorageTest, setRevision)
storage.setDocument("0", "abc");
storage.setRevision("0", 123);
- EXPECT_EQ(storage.getNumberOfDocuments(), 1);
+ EXPECT_EQ(storage.getNumberOfDocuments(), 1UL);
EXPECT_EQ(storage.getRevision("0"), 123);
}
@@ -131,7 +131,7 @@ TEST_F(StorageTest, setCursorPos)
storage.setDocument("0", "abc");
storage.setCursorPos("0", 1234);
- EXPECT_EQ(storage.getNumberOfDocuments(), 1);
+ EXPECT_EQ(storage.getNumberOfDocuments(), 1UL);
EXPECT_EQ(storage.getCursorPos("0"), 1234);
}
@@ -140,7 +140,7 @@ TEST_F(StorageTest, setRow)
Storage storage(m_config);
storage.setRow("0", "abc", 56, 67);
- EXPECT_EQ(storage.getNumberOfDocuments(), 1);
+ EXPECT_EQ(storage.getNumberOfDocuments(), 1UL);
EXPECT_EQ(storage.getDocument("0"), "abc");
EXPECT_EQ(storage.getRevision("0"), 56);
EXPECT_EQ(storage.getCursorPos("0"), 67);