diff --git a/tests/unit/unittest/unittest.pro b/tests/unit/unittest/unittest.pro index da56757a141..f541665978c 100644 --- a/tests/unit/unittest/unittest.pro +++ b/tests/unit/unittest/unittest.pro @@ -102,7 +102,8 @@ SOURCES += \ projectpartqueue-test.cpp \ processormanager-test.cpp \ taskscheduler-test.cpp \ - compileroptionsbuilder-test.cpp + compileroptionsbuilder-test.cpp \ + usedmacroandsourcestorage-test.cpp !isEmpty(LIBCLANG_LIBS) { SOURCES += \ @@ -246,7 +247,6 @@ HEADERS += \ mockprocessor.h \ mockprocessormanager.h \ mocktaskscheduler.h \ - usedmacroandsourcestorage-test.h \ mockusedmacroandsourcestorage.h !isEmpty(LIBCLANG_LIBS) { diff --git a/tests/unit/unittest/usedmacroandsourcestorage-test.h b/tests/unit/unittest/usedmacroandsourcestorage-test.cpp similarity index 89% rename from tests/unit/unittest/usedmacroandsourcestorage-test.h rename to tests/unit/unittest/usedmacroandsourcestorage-test.cpp index 76d56b232e5..d9acc7f123c 100644 --- a/tests/unit/unittest/usedmacroandsourcestorage-test.h +++ b/tests/unit/unittest/usedmacroandsourcestorage-test.cpp @@ -31,8 +31,6 @@ #include #include -#include - #include namespace { @@ -45,7 +43,7 @@ using Sqlite::Table; using Storage = ClangBackEnd::UsedMacroAndSourceStorage; -class SymbolStorage : public testing::Test +class UsedMacroAndSourceStorage : public testing::Test { protected: NiceMock mockDatabase; @@ -62,7 +60,7 @@ protected: MockSqliteReadStatement &getLowestLastModifiedTimeOfDependencies = storage.m_getLowestLastModifiedTimeOfDependencies; }; -TEST_F(SymbolStorage, ConvertStringsToJson) +TEST_F(UsedMacroAndSourceStorage, ConvertStringsToJson) { Utils::SmallStringVector strings{"foo", "bar", "foo"}; @@ -71,7 +69,7 @@ TEST_F(SymbolStorage, ConvertStringsToJson) ASSERT_THAT(jsonText, Eq("[\"foo\",\"bar\",\"foo\"]")); } -TEST_F(SymbolStorage, InsertOrUpdateUsedMacros) +TEST_F(UsedMacroAndSourceStorage, InsertOrUpdateUsedMacros) { InSequence sequence; @@ -84,7 +82,7 @@ TEST_F(SymbolStorage, InsertOrUpdateUsedMacros) storage.insertOrUpdateUsedMacros({{"FOO", {1, 42}}, {"BAR", {1, 43}}}); } -TEST_F(SymbolStorage, InsertFileStatuses) +TEST_F(UsedMacroAndSourceStorage, InsertFileStatuses) { EXPECT_CALL(insertFileStatuses, write(TypedEq(42), TypedEq(1), TypedEq(2), TypedEq(false))); EXPECT_CALL(insertFileStatuses, write(TypedEq(43), TypedEq(4), TypedEq(5), TypedEq(true))); @@ -92,7 +90,7 @@ TEST_F(SymbolStorage, InsertFileStatuses) storage.insertFileStatuses({{{1, 42}, 1, 2, false}, {{1, 43}, 4, 5, true}}); } -TEST_F(SymbolStorage, InsertOrUpdateSourceDependencies) +TEST_F(UsedMacroAndSourceStorage, InsertOrUpdateSourceDependencies) { InSequence sequence; @@ -105,7 +103,7 @@ TEST_F(SymbolStorage, InsertOrUpdateSourceDependencies) storage.insertOrUpdateSourceDependencies({{{1, 42}, {1, 1}}, {{1, 42}, {1, 2}}}); } -TEST_F(SymbolStorage, AddTablesInConstructor) +TEST_F(UsedMacroAndSourceStorage, AddTablesInConstructor) { InSequence s; @@ -120,7 +118,7 @@ TEST_F(SymbolStorage, AddTablesInConstructor) } -TEST_F(SymbolStorage, FetchLowestLastModifiedTimeIfNoModificationTimeExists) +TEST_F(UsedMacroAndSourceStorage, FetchLowestLastModifiedTimeIfNoModificationTimeExists) { EXPECT_CALL(getLowestLastModifiedTimeOfDependencies, valueReturnInt64(Eq(1))); @@ -129,7 +127,7 @@ TEST_F(SymbolStorage, FetchLowestLastModifiedTimeIfNoModificationTimeExists) ASSERT_THAT(lowestLastModified, Eq(0)); } -TEST_F(SymbolStorage, FetchLowestLastModifiedTime) +TEST_F(UsedMacroAndSourceStorage, FetchLowestLastModifiedTime) { EXPECT_CALL(getLowestLastModifiedTimeOfDependencies, valueReturnInt64(Eq(21))) .WillRepeatedly(Return(12)); @@ -139,24 +137,24 @@ TEST_F(SymbolStorage, FetchLowestLastModifiedTime) ASSERT_THAT(lowestLastModified, Eq(12)); } -TEST_F(SymbolStorage, AddNewUsedMacroTable) +TEST_F(UsedMacroAndSourceStorage, AddNewUsedMacroTable) { InSequence s; EXPECT_CALL(mockDatabase, execute(Eq("CREATE TEMPORARY TABLE newUsedMacros(sourceId INTEGER, macroName TEXT)"))); EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_newUsedMacros_sourceId_macroName ON newUsedMacros(sourceId, macroName)"))); - factory.createNewUsedMacrosTable(); + storage.createNewUsedMacrosTable(); } -TEST_F(SymbolStorage, AddNewSourceDependenciesTable) +TEST_F(UsedMacroAndSourceStorage, AddNewSourceDependenciesTable) { InSequence s; EXPECT_CALL(mockDatabase, execute(Eq("CREATE TEMPORARY TABLE newSourceDependencies(sourceId INTEGER, dependencySourceId TEXT)"))); EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_newSourceDependencies_sourceId_dependencySourceId ON newSourceDependencies(sourceId, dependencySourceId)"))); - factory.createNewSourceDependenciesTable(); + storage.createNewSourceDependenciesTable(); } }