From a72cd70af957a06ae870d93314b4ed0f3625f6ee Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 1 Jan 2023 21:16:19 +0100 Subject: Adjust to Debian 11 build --- tests/Makefile | 10 +++++----- tests/test-storage.cpp | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 94789f9..4ade005 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -2,7 +2,7 @@ CXXFLAGS=-g -O0 include ../common.mk -ifeq ($(CXX),clang++-14) +ifeq ($(CXXTYPE),clang++) CXXFLAGS+=-fprofile-instr-generate -fcoverage-mapping LDFLAGS+=-fprofile-instr-generate -fcoverage-mapping else @@ -25,10 +25,10 @@ CXXFLAGS+=\ test: unittests # https://clang.llvm.org/docs/SourceBasedCodeCoverage.html -ifeq ($(CXX),clang++-14) +ifeq ($(CXXTYPE),clang++) 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 + $(LLVMPROFDATA) merge -sparse unittests.profraw -o unittests.profdata + $(LLVMCOV) report --ignore-filename-regex='google' --ignore-filename-regex='test-' --show-region-summary=0 -instr-profile unittests.profdata unittests else ./unittests #gcov-12 storage.o @@ -36,7 +36,7 @@ else endif coverage: - llvm-cov-14 show -instr-profile unittests.profdata $(UNITS:.cpp=.o) + $(LLVMCOV) show -instr-profile unittests.profdata $(UNITS:.cpp=.o) unittests: libgmock.a $(UNITTESTS:.cpp=.o) $(UNITS:.cpp=.o) $(CXX) $(LDFLAGS) $^ $(LDLIBS) $(LIBS) -o $@ diff --git a/tests/test-storage.cpp b/tests/test-storage.cpp index 87168fc..158a9bd 100644 --- a/tests/test-storage.cpp +++ b/tests/test-storage.cpp @@ -184,3 +184,23 @@ TEST_F(StorageTest, getRow) EXPECT_EQ(std::get<2>(row), 456); } +TEST_F(StorageTest, revision_increment) +{ + Storage storage(m_config); + storage.setDocument("0", "xyz"); + storage.setDocument("0bc", "xyz2"); + storage.setDocument("iabc", "xyz3"); + + EXPECT_EQ(storage.getRevision("0"), 0); + EXPECT_EQ(storage.getRevision("0bc"), 0); + EXPECT_EQ(storage.getRevision("iabc"), 0); + + storage.setDocument("0bc", "xyz234"); + EXPECT_EQ(storage.getRevision("0bc"), 1); + + storage.setDocument("0bc", "xyz2345"); + EXPECT_EQ(storage.getRevision("0"), 0); + EXPECT_EQ(storage.getRevision("0bc"), 2); + EXPECT_EQ(storage.getRevision("iabc"), 0); +} + -- cgit v1.2.3