From 93d0b5a1d34b6dd8ff58e68c2e2daaa59a05dbb5 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Tue, 19 Jul 2022 14:33:00 +0200 Subject: [PATCH] Sqlite: Make the statement conversion operator id aware Before you had to use an constructor which is has an integer as parameter. Like struct Foo { Foo{long long id} : id{id} {} Foo{TypeId id} : id{id} {} TypeId id; } Now you can write: struct Foo { TypeId id; } With C++ 20 we can even remove more contructors. Change-Id: I374505a037a71339b672f5f3a57b06dcf443b4bf Reviewed-by: Tim Jenssen Reviewed-by: Qt CI Bot --- src/libs/sqlite/sqlitebasestatement.h | 26 +++-- src/libs/sqlite/sqliteids.h | 13 ++- .../designercore/projectstorage/filestatus.h | 6 - .../projectstorage/projectstorage.h | 75 ++++++------ .../projectstorage/projectstoragetypes.h | 55 ++++----- .../projectstorage/sourcepathcachetypes.h | 14 +-- .../projectstorage/storagecache.h | 2 +- .../projectstorage/storagecacheentry.h | 5 - .../unittest/directorypathcompressor-test.cpp | 4 +- tests/unit/unittest/filestatuscache-test.cpp | 8 +- tests/unit/unittest/projectstorage-test.cpp | 15 +-- .../projectstoragepathwatcher-test.cpp | 24 ++-- tests/unit/unittest/sourcepathcache-test.cpp | 107 +++++++++--------- tests/unit/unittest/sqlitestatement-test.cpp | 10 ++ tests/unit/unittest/storagecache-test.cpp | 28 ++--- 15 files changed, 194 insertions(+), 198 deletions(-) diff --git a/src/libs/sqlite/sqlitebasestatement.h b/src/libs/sqlite/sqlitebasestatement.h index d4a98d8c24c..7b40f99193e 100644 --- a/src/libs/sqlite/sqlitebasestatement.h +++ b/src/libs/sqlite/sqlitebasestatement.h @@ -96,10 +96,10 @@ public: void bind(int index, ValueView value); void bind(int index, BlobView blobView); - template - void bind(int index, BasicId id) + template> + void bind(int index, Type id) { - bind(index, id.id); + bind(index, &id); } void bind(int index, uint value) { bind(index, static_cast(value)); } @@ -452,14 +452,24 @@ private: , column(column) {} - operator int() { return statement.fetchIntValue(column); } - operator long() { return statement.fetchLongValue(column); } - operator long long() { return statement.fetchLongLongValue(column); } - operator double() { return statement.fetchDoubleValue(column); } + operator int() const { return statement.fetchIntValue(column); } + operator long() const { return statement.fetchLongValue(column); } + operator long long() const { return statement.fetchLongLongValue(column); } + operator double() const { return statement.fetchDoubleValue(column); } operator Utils::SmallStringView() { return statement.fetchSmallStringViewValue(column); } operator BlobView() { return statement.fetchBlobValue(column); } operator ValueView() { return statement.fetchValueView(column); } + template> + constexpr operator ConversionType() + { + if constexpr (std::is_same_v) + return ConversionType::create(statement.fetchIntValue(column)); + else + return ConversionType::create(statement.fetchLongLongValue(column)); + } + StatementImplementation &statement; int column; }; @@ -491,7 +501,7 @@ private: template ResultType createValue(std::integer_sequence) { - return ResultType{ValueGetter(*this, ColumnIndices)...}; + return ResultType(ValueGetter(*this, ColumnIndices)...); } template diff --git a/src/libs/sqlite/sqliteids.h b/src/libs/sqlite/sqliteids.h index cb1b237f4a5..3bb7378bf88 100644 --- a/src/libs/sqlite/sqliteids.h +++ b/src/libs/sqlite/sqliteids.h @@ -27,6 +27,7 @@ #include +#include #include namespace Sqlite { @@ -35,15 +36,19 @@ template class BasicId { public: + using IsBasicId = std::true_type; using DatabaseType = InternalIntegerType; constexpr explicit BasicId() = default; constexpr BasicId(const char *) = delete; - constexpr explicit BasicId(InternalIntegerType id) - : id{id} - {} + static constexpr BasicId create(InternalIntegerType idNumber) + { + BasicId id; + id.id = idNumber; + return id; + } constexpr friend bool operator==(BasicId first, BasicId second) { @@ -71,7 +76,7 @@ public: InternalIntegerType operator&() const { return id; } -public: +private: InternalIntegerType id = -1; }; diff --git a/src/plugins/qmldesigner/designercore/projectstorage/filestatus.h b/src/plugins/qmldesigner/designercore/projectstorage/filestatus.h index 9a2b4036ef5..94cf0c4bb16 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/filestatus.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/filestatus.h @@ -41,12 +41,6 @@ public: , lastModified{lastModified} {} - explicit FileStatus(int sourceId, long long size, long long lastModified) - : sourceId{sourceId} - , size{size} - , lastModified{lastModified} - {} - friend bool operator==(const FileStatus &first, const FileStatus &second) { return first.sourceId == second.sourceId && first.size == second.size diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h index e24db05a9e9..d3490d7f15d 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h @@ -519,14 +519,6 @@ private: , importedTypeNameId{std::move(importedTypeNameId)} {} - explicit PropertyDeclaration(long long typeId, - long long propertyDeclarationId, - long long importedTypeNameId) - : typeId{typeId} - , propertyDeclarationId{propertyDeclarationId} - , importedTypeNameId{importedTypeNameId} - {} - friend bool operator<(const PropertyDeclaration &first, const PropertyDeclaration &second) { return std::tie(first.typeId, first.propertyDeclarationId) @@ -876,15 +868,15 @@ private: void handleAliasPropertyDeclarationsWithPropertyType( TypeId typeId, AliasPropertyDeclarations &relinkableAliasPropertyDeclarations) { - auto callback = [&](long long typeId, - long long propertyDeclarationId, - long long propertyImportedTypeNameId, - long long aliasPropertyDeclarationId, - long long aliasPropertyDeclarationTailId) { + auto callback = [&](TypeId typeId, + PropertyDeclarationId propertyDeclarationId, + ImportedTypeNameId propertyImportedTypeNameId, + PropertyDeclarationId aliasPropertyDeclarationId, + PropertyDeclarationId aliasPropertyDeclarationTailId) { auto aliasPropertyName = selectPropertyNameStatement.template value( aliasPropertyDeclarationId); Utils::SmallString aliasPropertyNameTail; - if (aliasPropertyDeclarationTailId != -1) + if (aliasPropertyDeclarationTailId) aliasPropertyNameTail = selectPropertyNameStatement.template value( aliasPropertyDeclarationTailId); @@ -901,7 +893,7 @@ private: }; selectAliasPropertiesDeclarationForPropertiesWithTypeIdStatement.readCallback(callback, - &typeId); + typeId); } void handlePropertyDeclarationWithPropertyType(TypeId typeId, @@ -913,8 +905,8 @@ private: void handlePrototypes(TypeId prototypeId, Prototypes &relinkablePrototypes) { - auto callback = [&](long long typeId, long long prototypeNameId) { - relinkablePrototypes.emplace_back(TypeId{typeId}, ImportedTypeNameId{prototypeNameId}); + auto callback = [&](TypeId typeId, ImportedTypeNameId prototypeNameId) { + relinkablePrototypes.emplace_back(typeId, prototypeNameId); return Sqlite::CallbackControl::Continue; }; @@ -1017,9 +1009,9 @@ private: Prototypes &relinkablePrototypes, TypeIds &deletedTypeIds) { - auto callback = [&](long long typeId) { - deletedTypeIds.push_back(TypeId{typeId}); - deleteType(TypeId{typeId}, + auto callback = [&](TypeId typeId) { + deletedTypeIds.push_back(typeId); + deleteType(typeId, relinkableAliasPropertyDeclarations, relinkablePropertyDeclarations, relinkablePrototypes); @@ -1030,7 +1022,7 @@ private: toIntegers(updatedSourceIds), toIntegers(updatedTypeIds)); for (TypeId typeIdToBeDeleted : typeIdsToBeDeleted) - callback(&typeIdToBeDeleted); + callback(typeIdToBeDeleted); } void relink(AliasPropertyDeclarations &relinkableAliasPropertyDeclarations, @@ -1207,9 +1199,9 @@ private: SourceId sourceId, TypeId typeId) { - auto callback = [&](long long propertyDeclarationId) { + auto callback = [&](PropertyDeclarationId propertyDeclarationId) { insertedAliasPropertyDeclarations.emplace_back(typeId, - PropertyDeclarationId{propertyDeclarationId}, + propertyDeclarationId, fetchImportedTypeNameId(value.typeName, sourceId), value.aliasPropertyName, @@ -1365,8 +1357,8 @@ private: { public: explicit AliasPropertyDeclarationView(Utils::SmallStringView name, - long long id, - long long aliasId) + PropertyDeclarationId id, + PropertyDeclarationId aliasId) : name{name} , id{id} , aliasId{aliasId} @@ -1481,12 +1473,12 @@ private: auto insert = [&](const Storage::Synchronization::Import &import) { insertDocumentImport(import, importKind, import.moduleId, ModuleExportedImportId{}); - auto callback = [&](int exportedModuleId, + auto callback = [&](ModuleId exportedModuleId, int majorVersion, int minorVersion, - long long moduleExportedImportId) { + ModuleExportedImportId moduleExportedImportId) { Storage::Synchronization::Import additionImport{ - ModuleId{exportedModuleId}, + exportedModuleId, Storage::Synchronization::Version{majorVersion, minorVersion}, import.sourceId}; @@ -1497,7 +1489,7 @@ private: insertDocumentImport(additionImport, exportedImportKind, import.moduleId, - ModuleExportedImportId{moduleExportedImportId}); + moduleExportedImportId); return Sqlite::CallbackControl::Continue; }; @@ -1812,7 +1804,7 @@ private: class TypeWithDefaultPropertyView { public: - TypeWithDefaultPropertyView(long long typeId, long long defaultPropertyId) + TypeWithDefaultPropertyView(TypeId typeId, PropertyDeclarationId defaultPropertyId) : typeId{typeId} , defaultPropertyId{defaultPropertyId} {} @@ -1893,8 +1885,8 @@ private: void checkForPrototypeChainCycle(TypeId typeId) const { - auto callback = [=](long long currentTypeId) { - if (typeId == TypeId{currentTypeId}) + auto callback = [=](TypeId currentTypeId) { + if (typeId == currentTypeId) throw PrototypeChainCycle{}; return Sqlite::CallbackControl::Continue; @@ -1905,8 +1897,8 @@ private: void checkForAliasChainCycle(PropertyDeclarationId propertyDeclarationId) const { - auto callback = [=](long long currentPropertyDeclarationId) { - if (propertyDeclarationId == PropertyDeclarationId{currentPropertyDeclarationId}) + auto callback = [=](PropertyDeclarationId currentPropertyDeclarationId) { + if (propertyDeclarationId == currentPropertyDeclarationId) throw AliasChainCycle{}; return Sqlite::CallbackControl::Continue; @@ -2032,8 +2024,8 @@ private: class FetchPropertyDeclarationResult { public: - FetchPropertyDeclarationResult(long long propertyTypeId, - long long propertyDeclarationId, + FetchPropertyDeclarationResult(TypeId propertyTypeId, + PropertyDeclarationId propertyDeclarationId, long long propertyTraits) : propertyTypeId{propertyTypeId} , propertyDeclarationId{propertyDeclarationId} @@ -2087,14 +2079,14 @@ private: { insertIntoSourceContextsStatement.write(sourceContextPath); - return SourceContextId(database.lastInsertedRowId()); + return SourceContextId::create(database.lastInsertedRowId()); } SourceId writeSourceId(SourceContextId sourceContextId, Utils::SmallStringView sourceName) { insertIntoSourcesStatement.write(sourceContextId, sourceName); - return SourceId(database.lastInsertedRowId()); + return SourceId::create(database.lastInsertedRowId()); } SourceId readSourceId(SourceContextId sourceContextId, Utils::SmallStringView sourceName) @@ -2121,7 +2113,7 @@ private: auto callback = [&](Utils::SmallStringView name, Utils::SmallStringView returnType, - long long functionDeclarationId) { + FunctionDeclarationId functionDeclarationId) { auto &functionDeclaration = functionDeclarations.emplace_back(name, returnType); functionDeclaration.parameters = selectFunctionParameterDeclarationsStatement.template values< Storage::Synchronization::ParameterDeclaration>(8, functionDeclarationId); @@ -2138,7 +2130,7 @@ private: { Storage::Synchronization::SignalDeclarations signalDeclarations; - auto callback = [&](Utils::SmallStringView name, long long signalDeclarationId) { + auto callback = [&](Utils::SmallStringView name, SignalDeclarationId signalDeclarationId) { auto &signalDeclaration = signalDeclarations.emplace_back(name); signalDeclaration.parameters = selectSignalParameterDeclarationsStatement.template values< Storage::Synchronization::ParameterDeclaration>(8, signalDeclarationId); @@ -2155,7 +2147,8 @@ private: { Storage::Synchronization::EnumerationDeclarations enumerationDeclarations; - auto callback = [&](Utils::SmallStringView name, long long enumerationDeclarationId) { + auto callback = [&](Utils::SmallStringView name, + EnumerationDeclarationId enumerationDeclarationId) { enumerationDeclarations.emplace_back( name, selectEnumeratorDeclarationStatement.template values< diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstoragetypes.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstoragetypes.h index 2786d3ac415..25933a039f6 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/projectstoragetypes.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstoragetypes.h @@ -174,7 +174,7 @@ public: , sourceId{sourceId} {} - explicit Import(int moduleId, int majorVersion, int minorVersion, int sourceId) + explicit Import(ModuleId moduleId, int majorVersion, int minorVersion, SourceId sourceId) : version{majorVersion, minorVersion} , moduleId{moduleId} , sourceId{sourceId} @@ -205,7 +205,8 @@ class ImportView public: explicit ImportView() = default; - explicit ImportView(long long importId, int sourceId, int moduleId, int majorVersion, int minorVersion) + explicit ImportView( + ImportId importId, SourceId sourceId, ModuleId moduleId, int majorVersion, int minorVersion) : importId{importId} , sourceId{sourceId} , moduleId{moduleId} @@ -272,9 +273,9 @@ class ModuleExportedImportView public: explicit ModuleExportedImportView() = default; - explicit ModuleExportedImportView(long long moduleExportedImportId, - int moduleId, - int exportedModuleId, + explicit ModuleExportedImportView(ModuleExportedImportId moduleExportedImportId, + ModuleId moduleId, + ModuleId exportedModuleId, int majorVersion, int minorVersion, int isAutoVersion) @@ -360,7 +361,7 @@ public: , moduleId{moduleId} {} - explicit ExportedType(int moduleId, Utils::SmallStringView name, int majorVersion, int minorVersion) + explicit ExportedType(ModuleId moduleId, Utils::SmallStringView name, int majorVersion, int minorVersion) : name{name} , version{majorVersion, minorVersion} , moduleId{moduleId} @@ -395,12 +396,12 @@ public: , version{version} , moduleId{moduleId} {} - explicit ExportedTypeView(int moduleId, + explicit ExportedTypeView(ModuleId moduleId, Utils::SmallStringView name, int majorVersion, int minorVersion, - int typeId, - long long exportedTypeNameId) + TypeId typeId, + ExportedTypeNameId exportedTypeNameId) : name{name} , version{majorVersion, minorVersion} , typeId{typeId} @@ -475,7 +476,7 @@ public: explicit EnumerationDeclarationView() = default; explicit EnumerationDeclarationView(Utils::SmallStringView name, Utils::SmallStringView enumeratorDeclarations, - long long id) + EnumerationDeclarationId id) : name{name} , enumeratorDeclarations{std::move(enumeratorDeclarations)} , id{id} @@ -550,7 +551,7 @@ public: explicit SignalDeclarationView() = default; explicit SignalDeclarationView(Utils::SmallStringView name, Utils::SmallStringView signature, - long long id) + SignalDeclarationId id) : name{name} , signature{signature} , id{id} @@ -601,7 +602,7 @@ public: explicit FunctionDeclarationView(Utils::SmallStringView name, Utils::SmallStringView returnTypeName, Utils::SmallStringView signature, - long long id) + FunctionDeclarationId id) : name{name} , returnTypeName{returnTypeName} , signature{signature} @@ -667,7 +668,7 @@ public: {} explicit PropertyDeclaration(Utils::SmallStringView name, - long long propertyTypeId, + TypeId propertyTypeId, int traits, Utils::SmallStringView aliasPropertyName, Utils::SmallStringView aliasPropertyNameTail = {}) @@ -718,10 +719,10 @@ class PropertyDeclarationView public: explicit PropertyDeclarationView(Utils::SmallStringView name, int traits, - long long typeId, - long long typeNameId, - long long id, - long long aliasId) + TypeId typeId, + ImportedTypeNameId typeNameId, + PropertyDeclarationId id, + PropertyDeclarationId aliasId) : name{name} , traits{static_cast(traits)} , typeId{typeId} @@ -794,7 +795,7 @@ public: explicit Type(Utils::SmallStringView typeName, Utils::SmallStringView prototype, int accessSemantics, - int sourceId) + SourceId sourceId) : typeName{typeName} , prototype{ImportedType{prototype}} , accessSemantics{static_cast(accessSemantics)} @@ -802,10 +803,10 @@ public: {} - explicit Type(int sourceId, + explicit Type(SourceId sourceId, Utils::SmallStringView typeName, - long long typeId, - long long prototypeId, + TypeId typeId, + TypeId prototypeId, int accessSemantics, Utils::SmallStringView defaultPropertyName) : typeName{typeName} @@ -855,7 +856,7 @@ public: , fileType{fileType} {} - ProjectData(int projectSourceId, int sourceId, int moduleId, int fileType) + ProjectData(SourceId projectSourceId, SourceId sourceId, ModuleId moduleId, int fileType) : projectSourceId{projectSourceId} , sourceId{sourceId} , moduleId{moduleId} @@ -938,10 +939,7 @@ namespace QmlDesigner::Storage::Info { class PropertyDeclaration { public: - PropertyDeclaration(long long typeId, - Utils::SmallStringView name, - long long traits, - long long propertyTypeId) + PropertyDeclaration(TypeId typeId, Utils::SmallStringView name, long long traits, TypeId propertyTypeId) : typeId{typeId} , name{name} , traits{static_cast(traits)} @@ -967,11 +965,6 @@ public: class Type { public: - Type(long long defaultPropertyId) - : defaultPropertyId{defaultPropertyId} - - {} - Type(PropertyDeclarationId defaultPropertyId) : defaultPropertyId{defaultPropertyId} {} diff --git a/src/plugins/qmldesigner/designercore/projectstorage/sourcepathcachetypes.h b/src/plugins/qmldesigner/designercore/projectstorage/sourcepathcachetypes.h index b0c5491036e..0cf02108ef3 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/sourcepathcachetypes.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/sourcepathcachetypes.h @@ -57,11 +57,6 @@ public: class SourceNameEntry { public: - SourceNameEntry(Utils::SmallStringView sourceName, int sourceContextId) - : sourceName(sourceName) - , sourceContextId(sourceContextId) - {} - SourceNameEntry(Utils::SmallStringView sourceName, SourceContextId sourceContextId) : sourceName(sourceName) , sourceContextId(sourceContextId) @@ -129,10 +124,6 @@ public: : Base{{sourceName, sourceContextId}, sourceId} {} - Source(Utils::SmallStringView sourceName, int sourceContextId, int sourceId) - : Base{{sourceName, SourceContextId{sourceContextId}}, SourceId{sourceId}} - {} - friend bool operator==(const Source &first, const Source &second) { return first.id == second.id && first.value == second.value; @@ -145,10 +136,7 @@ class SourceNameAndSourceContextId { public: constexpr SourceNameAndSourceContextId() = default; - SourceNameAndSourceContextId(Utils::SmallStringView sourceName, int sourceContextId) - : sourceName(sourceName) - , sourceContextId(sourceContextId) - {} + SourceNameAndSourceContextId(Utils::SmallStringView sourceName, SourceContextId sourceContextId) : sourceName{sourceName} , sourceContextId{sourceContextId} diff --git a/src/plugins/qmldesigner/designercore/projectstorage/storagecache.h b/src/plugins/qmldesigner/designercore/projectstorage/storagecache.h index 27d2905e8e4..81c5c15f068 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/storagecache.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/storagecache.h @@ -269,7 +269,7 @@ public: { std::shared_lock sharedLock(m_mutex); - if (IndexType{static_cast(m_indices.size())} > id) { + if (IndexType::create(static_cast(m_indices.size())) > id) { if (auto indirectionIndex = m_indices.at(static_cast(id)); indirectionIndex.isValid()) return m_entries.at(static_cast(indirectionIndex)).value; diff --git a/src/plugins/qmldesigner/designercore/projectstorage/storagecacheentry.h b/src/plugins/qmldesigner/designercore/projectstorage/storagecacheentry.h index 9d246af2faf..128bec99632 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/storagecacheentry.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/storagecacheentry.h @@ -36,11 +36,6 @@ public: , id(id) {} - StorageCacheEntry(ViewType value, typename IndexType::DatabaseType id) - : value(value) - , id{id} - {} - operator ViewType() const noexcept { return value; } friend bool operator==(const StorageCacheEntry &first, const StorageCacheEntry &second) { diff --git a/tests/unit/unittest/directorypathcompressor-test.cpp b/tests/unit/unittest/directorypathcompressor-test.cpp index 99d52fab3ab..21a04638ee5 100644 --- a/tests/unit/unittest/directorypathcompressor-test.cpp +++ b/tests/unit/unittest/directorypathcompressor-test.cpp @@ -47,8 +47,8 @@ protected: NiceMock> mockCompressorCallback; QmlDesigner::DirectoryPathCompressor> compressor; NiceMock &mockTimer = compressor.timer(); - SourceContextId sourceContextId1{1}; - SourceContextId sourceContextId2{2}; + SourceContextId sourceContextId1{SourceContextId::create(1)}; + SourceContextId sourceContextId2{SourceContextId::create(2)}; }; TEST_F(DirectoryPathCompressor, AddFilePath) diff --git a/tests/unit/unittest/filestatuscache-test.cpp b/tests/unit/unittest/filestatuscache-test.cpp index 243bc80e143..3b43e234ab7 100644 --- a/tests/unit/unittest/filestatuscache-test.cpp +++ b/tests/unit/unittest/filestatuscache-test.cpp @@ -57,10 +57,10 @@ protected: protected: NiceMock fileSystem; QmlDesigner::FileStatusCache cache{fileSystem}; - SourceId header{1}; - SourceId source{2}; - SourceId header2{3}; - SourceId source2{4}; + SourceId header{SourceId::create(1)}; + SourceId source{SourceId::create(2)}; + SourceId header2{SourceId::create(3)}; + SourceId source2{SourceId::create(4)}; SourceIds entries{header, source, header2, source2}; long long headerLastModifiedTime = 100; long long headerLastModifiedTime2 = 110; diff --git a/tests/unit/unittest/projectstorage-test.cpp b/tests/unit/unittest/projectstorage-test.cpp index e98d024154b..394edd947ee 100644 --- a/tests/unit/unittest/projectstorage-test.cpp +++ b/tests/unit/unittest/projectstorage-test.cpp @@ -1024,7 +1024,7 @@ TEST_F(ProjectStorage, FetchSourceContextPath) TEST_F(ProjectStorage, FetchUnknownSourceContextPathThrows) { - ASSERT_THROW(storage.fetchSourceContextPath(SourceContextId{323}), + ASSERT_THROW(storage.fetchSourceContextPath(SourceContextId::create(323)), QmlDesigner::SourceContextIdDoesNotExists); } @@ -1096,13 +1096,13 @@ TEST_F(ProjectStorage, FetchSourceIdWithDifferentNameAreNotEqual) TEST_F(ProjectStorage, FetchSourceIdWithNonExistingSourceContextIdThrows) { - ASSERT_THROW(storage.fetchSourceId(SourceContextId{42}, "foo"), + ASSERT_THROW(storage.fetchSourceId(SourceContextId::create(42), "foo"), Sqlite::ConstraintPreventsModification); } TEST_F(ProjectStorage, FetchSourceNameAndSourceContextIdForNonExistingSourceId) { - ASSERT_THROW(storage.fetchSourceNameAndSourceContextId(SourceId{212}), + ASSERT_THROW(storage.fetchSourceNameAndSourceContextId(SourceId::create(212)), QmlDesigner::SourceIdDoesNotExists); } @@ -1119,7 +1119,8 @@ TEST_F(ProjectStorage, FetchSourceNameAndSourceContextIdForNonExistingEntry) TEST_F(ProjectStorage, FetchSourceContextIdForNonExistingSourceId) { - ASSERT_THROW(storage.fetchSourceContextId(SourceId{212}), QmlDesigner::SourceIdDoesNotExists); + ASSERT_THROW(storage.fetchSourceContextId(SourceId::create(212)), + QmlDesigner::SourceIdDoesNotExists); } TEST_F(ProjectStorage, FetchSourceContextIdForExistingSourceId) @@ -1194,7 +1195,7 @@ TEST_F(ProjectStorage, FetchSourceIdUnguardedWithNonExistingSourceContextIdThrow { std::lock_guard lock{database}; - ASSERT_THROW(storage.fetchSourceIdUnguarded(SourceContextId{42}, "foo"), + ASSERT_THROW(storage.fetchSourceIdUnguarded(SourceContextId::create(42), "foo"), Sqlite::ConstraintPreventsModification); } @@ -1261,7 +1262,7 @@ TEST_F(ProjectStorage, SynchronizeTypesAddsNewTypesWithMissingModule) Storage::Synchronization::ImportedType{}, TypeAccessSemantics::Reference, sourceId3, - {Storage::Synchronization::ExportedType{ModuleId{22}, "Object2"}, + {Storage::Synchronization::ExportedType{ModuleId::create(22), "Object2"}, Storage::Synchronization::ExportedType{pathToModuleId, "Obj2"}}}); ASSERT_THROW(storage.synchronize(std::move(package)), QmlDesigner::ExportedTypeCannotBeInserted); @@ -4475,7 +4476,7 @@ TEST_F(ProjectStorage, ModuleNameThrowsIfIdIsInvalid) TEST_F(ProjectStorage, ModuleNameThrowsIfIdDoesNotExists) { - ASSERT_THROW(storage.moduleName(ModuleId{222}), QmlDesigner::ModuleDoesNotExists); + ASSERT_THROW(storage.moduleName(ModuleId::create(222)), QmlDesigner::ModuleDoesNotExists); } TEST_F(ProjectStorage, GetModuleName) diff --git a/tests/unit/unittest/projectstoragepathwatcher-test.cpp b/tests/unit/unittest/projectstoragepathwatcher-test.cpp index f4843017b78..093c2f3eaeb 100644 --- a/tests/unit/unittest/projectstoragepathwatcher-test.cpp +++ b/tests/unit/unittest/projectstoragepathwatcher-test.cpp @@ -117,9 +117,9 @@ protected: NiceMock mockFileSystem; Watcher watcher{sourcePathCacheMock, mockFileSystem, ¬ifier}; NiceMock &mockQFileSytemWatcher = watcher.fileSystemWatcher(); - ProjectChunkId id1{ProjectPartId{2}, SourceType::Qml}; - ProjectChunkId id2{ProjectPartId{2}, SourceType::QmlUi}; - ProjectChunkId id3{ProjectPartId{4}, SourceType::QmlTypes}; + ProjectChunkId id1{ProjectPartId::create(2), SourceType::Qml}; + ProjectChunkId id2{ProjectPartId::create(2), SourceType::QmlUi}; + ProjectChunkId id3{ProjectPartId::create(4), SourceType::QmlTypes}; SourcePathView path1{"/path/path1"}; SourcePathView path2{"/path/path2"}; SourcePathView path3{"/path2/path1"}; @@ -132,8 +132,14 @@ protected: QString sourceContextPath3 = "/path3"; Utils::PathString sourceContextPathString = sourceContextPath; Utils::PathString sourceContextPathString2 = sourceContextPath2; - SourceIds pathIds = {SourceId{1}, SourceId{2}, SourceId{3}, SourceId{4}, SourceId{5}}; - SourceContextIds sourceContextIds = {SourceContextId{1}, SourceContextId{2}, SourceContextId{3}}; + SourceIds pathIds = {SourceId::create(1), + SourceId::create(2), + SourceId::create(3), + SourceId::create(4), + SourceId::create(5)}; + SourceContextIds sourceContextIds = {SourceContextId::create(1), + SourceContextId::create(2), + SourceContextId::create(3)}; ProjectChunkIds ids{id1, id2, id3}; WatcherEntry watcherEntry1{id1, sourceContextIds[0], pathIds[0]}; WatcherEntry watcherEntry2{id2, sourceContextIds[0], pathIds[0]}; @@ -273,7 +279,7 @@ TEST_F(ProjectStoragePathWatcher, RemoveEntriesWithId) {id2, {pathIds[0], pathIds[1]}}, {id3, {pathIds[1], pathIds[3]}}}); - watcher.removeIds({ProjectPartId{2}}); + watcher.removeIds({ProjectPartId::create(2)}); ASSERT_THAT(watcher.watchedEntries(), ElementsAre(watcherEntry5, watcherEntry8)); } @@ -370,9 +376,9 @@ TEST_F(ProjectStoragePathWatcher, TwoNotifyFileChanges) .WillByDefault(Return(FileStatus{pathIds[3], 1, 2})); EXPECT_CALL(notifier, - pathsWithIdsChanged( - ElementsAre(IdPaths{id1, {SourceId{1}, SourceId{2}}}, - IdPaths{id2, {SourceId{1}, SourceId{2}, SourceId{4}}}))); + pathsWithIdsChanged(ElementsAre( + IdPaths{id1, {SourceId::create(1), SourceId::create(2)}}, + IdPaths{id2, {SourceId::create(1), SourceId::create(2), SourceId::create(4)}}))); mockQFileSytemWatcher.directoryChanged(sourceContextPath); mockQFileSytemWatcher.directoryChanged(sourceContextPath2); diff --git a/tests/unit/unittest/sourcepathcache-test.cpp b/tests/unit/unittest/sourcepathcache-test.cpp index abb3bf29d1c..972ded50df0 100644 --- a/tests/unit/unittest/sourcepathcache-test.cpp +++ b/tests/unit/unittest/sourcepathcache-test.cpp @@ -47,32 +47,33 @@ protected: SourcePathCache() { ON_CALL(storageMock, fetchSourceContextId(Eq("/path/to"))) - .WillByDefault(Return(SourceContextId{5})); + .WillByDefault(Return(SourceContextId::create(5))); ON_CALL(storageMock, fetchSourceContextId(Eq("/path2/to"))) - .WillByDefault(Return(SourceContextId{6})); - ON_CALL(storageMock, fetchSourceId(SourceContextId{5}, Eq("file.cpp"))) - .WillByDefault(Return(SourceId{42})); - ON_CALL(storageMock, fetchSourceId(SourceContextId{5}, Eq("file2.cpp"))) - .WillByDefault(Return(SourceId{63})); - ON_CALL(storageMock, fetchSourceId(SourceContextId{6}, Eq("file.cpp"))) - .WillByDefault(Return(SourceId{72})); - ON_CALL(storageMock, fetchSourceContextPath(SourceContextId{5})) + .WillByDefault(Return(SourceContextId::create(6))); + ON_CALL(storageMock, fetchSourceId(SourceContextId::create(5), Eq("file.cpp"))) + .WillByDefault(Return(SourceId::create(42))); + ON_CALL(storageMock, fetchSourceId(SourceContextId::create(5), Eq("file2.cpp"))) + .WillByDefault(Return(SourceId::create(63))); + ON_CALL(storageMock, fetchSourceId(SourceContextId::create(6), Eq("file.cpp"))) + .WillByDefault(Return(SourceId::create(72))); + ON_CALL(storageMock, fetchSourceContextPath(SourceContextId::create(5))) .WillByDefault(Return(Utils::PathString("/path/to"))); - ON_CALL(storageMock, fetchSourceNameAndSourceContextId(SourceId{42})) - .WillByDefault(Return(SourceNameAndSourceContextId("file.cpp", SourceContextId{5}))); + ON_CALL(storageMock, fetchSourceNameAndSourceContextId(SourceId::create(42))) + .WillByDefault( + Return(SourceNameAndSourceContextId("file.cpp", SourceContextId::create(5)))); ON_CALL(storageMockFilled, fetchAllSources()) .WillByDefault(Return(std::vector({ - {"file.cpp", SourceContextId{6}, SourceId{72}}, - {"file2.cpp", SourceContextId{5}, SourceId{63}}, - {"file.cpp", SourceContextId{5}, SourceId{42}}, + {"file.cpp", SourceContextId::create(6), SourceId::create(72)}, + {"file2.cpp", SourceContextId::create(5), SourceId::create(63)}, + {"file.cpp", SourceContextId::create(5), SourceId::create(42)}, }))); ON_CALL(storageMockFilled, fetchAllSourceContexts()) .WillByDefault(Return(std::vector( - {{"/path2/to", SourceContextId{6}}, {"/path/to", SourceContextId{5}}}))); + {{"/path2/to", SourceContextId::create(6)}, {"/path/to", SourceContextId::create(5)}}))); ON_CALL(storageMockFilled, fetchSourceContextId(Eq("/path/to"))) - .WillByDefault(Return(SourceContextId{5})); - ON_CALL(storageMockFilled, fetchSourceId(SourceContextId{5}, Eq("file.cpp"))) - .WillByDefault(Return(SourceId{42})); + .WillByDefault(Return(SourceContextId::create(5))); + ON_CALL(storageMockFilled, fetchSourceId(SourceContextId::create(5), Eq("file.cpp"))) + .WillByDefault(Return(SourceId::create(42))); } protected: @@ -91,7 +92,7 @@ TEST_F(SourcePathCache, SourceIdWithOutAnyEntryCallSourceContextId) TEST_F(SourcePathCache, SourceIdWithOutAnyEntryCalls) { - EXPECT_CALL(storageMock, fetchSourceId(SourceContextId{5}, Eq("file.cpp"))); + EXPECT_CALL(storageMock, fetchSourceId(SourceContextId::create(5), Eq("file.cpp"))); cache.sourceId(SourcePathView("/path/to/file.cpp")); } @@ -100,7 +101,7 @@ TEST_F(SourcePathCache, SourceIdOfSourceIdWithOutAnyEntry) { auto sourceId = cache.sourceId(SourcePathView("/path/to/file.cpp")); - ASSERT_THAT(sourceId, SourceId{42}); + ASSERT_THAT(sourceId, SourceId::create(42)); } TEST_F(SourcePathCache, SourceIdWithSourceContextIdAndSourceName) @@ -109,7 +110,7 @@ TEST_F(SourcePathCache, SourceIdWithSourceContextIdAndSourceName) auto sourceId = cache.sourceId(sourceContextId, "file.cpp"_sv); - ASSERT_THAT(sourceId, SourceId{42}); + ASSERT_THAT(sourceId, SourceId::create(42)); } TEST_F(SourcePathCache, IfEntryExistsDontCallInStrorage) @@ -117,7 +118,7 @@ TEST_F(SourcePathCache, IfEntryExistsDontCallInStrorage) cache.sourceId(SourcePathView("/path/to/file.cpp")); EXPECT_CALL(storageMock, fetchSourceContextId(Eq("/path/to"))).Times(0); - EXPECT_CALL(storageMock, fetchSourceId(SourceContextId{5}, Eq("file.cpp"))).Times(0); + EXPECT_CALL(storageMock, fetchSourceId(SourceContextId::create(5), Eq("file.cpp"))).Times(0); cache.sourceId(SourcePathView("/path/to/file.cpp")); } @@ -127,7 +128,7 @@ TEST_F(SourcePathCache, IfDirectoryEntryExistsDontCallFetchSourceContextIdButSti cache.sourceId(SourcePathView("/path/to/file2.cpp")); EXPECT_CALL(storageMock, fetchSourceContextId(Eq("/path/to"))).Times(0); - EXPECT_CALL(storageMock, fetchSourceId(SourceContextId{5}, Eq("file.cpp"))); + EXPECT_CALL(storageMock, fetchSourceId(SourceContextId::create(5), Eq("file.cpp"))); cache.sourceId(SourcePathView("/path/to/file.cpp")); } @@ -138,7 +139,7 @@ TEST_F(SourcePathCache, GetSourceIdWithCachedValue) auto sourceId = cache.sourceId(SourcePathView("/path/to/file.cpp")); - ASSERT_THAT(sourceId, SourceId{42}); + ASSERT_THAT(sourceId, SourceId::create(42)); } TEST_F(SourcePathCache, GetSourceIdWithSourceContextIdCached) @@ -147,7 +148,7 @@ TEST_F(SourcePathCache, GetSourceIdWithSourceContextIdCached) auto sourceId = cache.sourceId(SourcePathView("/path/to/file2.cpp")); - ASSERT_THAT(sourceId, SourceId{63}); + ASSERT_THAT(sourceId, SourceId::create(63)); } TEST_F(SourcePathCache, ThrowForGettingAFilePathWithAnInvalidId) @@ -168,7 +169,7 @@ TEST_F(SourcePathCache, GetAFilePath) TEST_F(SourcePathCache, GetAFilePathWithCachedSourceId) { - SourceId sourceId{42}; + SourceId sourceId{SourceId::create(42)}; auto sourcePath = cache.sourcePath(sourceId); @@ -220,7 +221,7 @@ TEST_F(SourcePathCache, SourceContextId) { auto id = cache.sourceContextId(Utils::SmallString("/path/to")); - ASSERT_THAT(id, Eq(SourceContextId{5})); + ASSERT_THAT(id, Eq(SourceContextId::create(5))); } TEST_F(SourcePathCache, SourceContextIdIsAlreadyInCache) @@ -269,7 +270,7 @@ TEST_F(SourcePathCache, ThrowForGettingADirectoryPathWithAnInvalidId) TEST_F(SourcePathCache, GetADirectoryPath) { - SourceContextId sourceContextId{5}; + SourceContextId sourceContextId{SourceContextId::create(5)}; auto sourceContextPath = cache.sourceContextPath(sourceContextId); @@ -278,7 +279,7 @@ TEST_F(SourcePathCache, GetADirectoryPath) TEST_F(SourcePathCache, GetADirectoryPathWithCachedSourceContextId) { - SourceContextId sourceContextId{5}; + SourceContextId sourceContextId{SourceContextId::create(5)}; cache.sourceContextPath(sourceContextId); auto sourceContextPath = cache.sourceContextPath(sourceContextId); @@ -288,18 +289,18 @@ TEST_F(SourcePathCache, GetADirectoryPathWithCachedSourceContextId) TEST_F(SourcePathCache, DirectoryPathCallsFetchDirectoryPath) { - EXPECT_CALL(storageMock, fetchSourceContextPath(Eq(SourceContextId{5}))); + EXPECT_CALL(storageMock, fetchSourceContextPath(Eq(SourceContextId::create(5)))); - cache.sourceContextPath(SourceContextId{5}); + cache.sourceContextPath(SourceContextId::create(5)); } TEST_F(SourcePathCache, SecondDirectoryPathCallsNotFetchDirectoryPath) { - cache.sourceContextPath(SourceContextId{5}); + cache.sourceContextPath(SourceContextId::create(5)); EXPECT_CALL(storageMock, fetchSourceContextPath(_)).Times(0); - cache.sourceContextPath(SourceContextId{5}); + cache.sourceContextPath(SourceContextId::create(5)); } TEST_F(SourcePathCache, ThrowForGettingASourceContextIdWithAnInvalidSourceId) @@ -311,36 +312,36 @@ TEST_F(SourcePathCache, ThrowForGettingASourceContextIdWithAnInvalidSourceId) TEST_F(SourcePathCache, FetchSourceContextIdBySourceId) { - auto sourceContextId = cache.sourceContextId(SourceId{42}); + auto sourceContextId = cache.sourceContextId(SourceId::create(42)); - ASSERT_THAT(sourceContextId, Eq(SourceContextId{5})); + ASSERT_THAT(sourceContextId, Eq(SourceContextId::create(5))); } TEST_F(SourcePathCache, FetchSourceContextIdBySourceIdCached) { - cache.sourceContextId(SourceId{42}); + cache.sourceContextId(SourceId::create(42)); - auto sourceContextId = cache.sourceContextId(SourceId{42}); + auto sourceContextId = cache.sourceContextId(SourceId::create(42)); - ASSERT_THAT(sourceContextId, Eq(SourceContextId{5})); + ASSERT_THAT(sourceContextId, Eq(SourceContextId::create(5))); } TEST_F(SourcePathCache, FetchFilePathAfterFetchingSourceContextIdBySourceId) { - cache.sourceContextId(SourceId{42}); + cache.sourceContextId(SourceId::create(42)); - auto sourcePath = cache.sourcePath(SourceId{42}); + auto sourcePath = cache.sourcePath(SourceId::create(42)); ASSERT_THAT(sourcePath, Eq("/path/to/file.cpp")); } TEST_F(SourcePathCache, FetchSourceContextIdAfterFetchingFilePathBySourceId) { - cache.sourcePath(SourceId{42}); + cache.sourcePath(SourceId::create(42)); - auto sourceContextId = cache.sourceContextId(SourceId{42}); + auto sourceContextId = cache.sourceContextId(SourceId::create(42)); - ASSERT_THAT(sourceContextId, Eq(SourceContextId{5})); + ASSERT_THAT(sourceContextId, Eq(SourceContextId::create(5))); } TEST_F(SourcePathCache, FetchAllSourceContextsAndSourcesAtCreation) @@ -357,23 +358,23 @@ TEST_F(SourcePathCache, GetFileIdInFilledCache) auto id = cacheFilled.sourceId("/path2/to/file.cpp"); - ASSERT_THAT(id, Eq(SourceId{72})); + ASSERT_THAT(id, Eq(SourceId::create(72))); } TEST_F(SourcePathCache, GetSourceContextIdInFilledCache) { Cache cacheFilled{storageMockFilled}; - auto id = cacheFilled.sourceContextId(SourceId{42}); + auto id = cacheFilled.sourceContextId(SourceId::create(42)); - ASSERT_THAT(id, Eq(SourceContextId{5})); + ASSERT_THAT(id, Eq(SourceContextId::create(5))); } TEST_F(SourcePathCache, GetDirectoryPathInFilledCache) { Cache cacheFilled{storageMockFilled}; - auto path = cacheFilled.sourceContextPath(SourceContextId{5}); + auto path = cacheFilled.sourceContextPath(SourceContextId::create(5)); ASSERT_THAT(path, Eq("/path/to")); } @@ -382,7 +383,7 @@ TEST_F(SourcePathCache, GetFilePathInFilledCache) { Cache cacheFilled{storageMockFilled}; - auto path = cacheFilled.sourcePath(SourceId{42}); + auto path = cacheFilled.sourcePath(SourceId::create(42)); ASSERT_THAT(path, Eq("/path/to/file.cpp")); } @@ -393,7 +394,7 @@ TEST_F(SourcePathCache, GetFileIdInAfterPopulateIfEmpty) auto id = cacheNotFilled.sourceId("/path2/to/file.cpp"); - ASSERT_THAT(id, Eq(SourceId{72})); + ASSERT_THAT(id, Eq(SourceId::create(72))); } TEST_F(SourcePathCache, DontPopulateIfNotEmpty) @@ -410,16 +411,16 @@ TEST_F(SourcePathCache, GetSourceContextIdAfterPopulateIfEmpty) { cacheNotFilled.populateIfEmpty(); - auto id = cacheNotFilled.sourceContextId(SourceId{42}); + auto id = cacheNotFilled.sourceContextId(SourceId::create(42)); - ASSERT_THAT(id, Eq(SourceContextId{5})); + ASSERT_THAT(id, Eq(SourceContextId::create(5))); } TEST_F(SourcePathCache, GetDirectoryPathAfterPopulateIfEmpty) { cacheNotFilled.populateIfEmpty(); - auto path = cacheNotFilled.sourceContextPath(SourceContextId{5}); + auto path = cacheNotFilled.sourceContextPath(SourceContextId::create(5)); ASSERT_THAT(path, Eq("/path/to")); } @@ -428,7 +429,7 @@ TEST_F(SourcePathCache, GetFilePathAfterPopulateIfEmptye) { cacheNotFilled.populateIfEmpty(); - auto path = cacheNotFilled.sourcePath(SourceId{42}); + auto path = cacheNotFilled.sourcePath(SourceId::create(42)); ASSERT_THAT(path, Eq("/path/to/file.cpp")); } diff --git a/tests/unit/unittest/sqlitestatement-test.cpp b/tests/unit/unittest/sqlitestatement-test.cpp index ff5348585a4..83b6921522b 100644 --- a/tests/unit/unittest/sqlitestatement-test.cpp +++ b/tests/unit/unittest/sqlitestatement-test.cpp @@ -1162,6 +1162,11 @@ TEST_F(SqliteStatement, GetValueCallsReset) { struct Value { + Value() = default; + Value(int x) + : x(x) + {} + int x = 0; }; MockSqliteStatement<1, 1> mockStatement{databaseMock}; @@ -1175,6 +1180,11 @@ TEST_F(SqliteStatement, GetValueCallsResetIfExceptionIsThrown) { struct Value { + Value() = default; + Value(int x) + : x(x) + {} + int x = 0; }; MockSqliteStatement<1, 1> mockStatement{databaseMock}; diff --git a/tests/unit/unittest/storagecache-test.cpp b/tests/unit/unittest/storagecache-test.cpp index 6fca4afb14e..712f907ba3d 100644 --- a/tests/unit/unittest/storagecache-test.cpp +++ b/tests/unit/unittest/storagecache-test.cpp @@ -112,16 +112,16 @@ protected: Utils::PathString filePath5{"/file/pathFife"}; Utils::PathStringVector filePaths{filePath1, filePath2, filePath3, filePath4, filePath5}; Utils::PathStringVector reverseFilePaths{filePath1, filePath2, filePath3, filePath4, filePath5}; - SourceContextId id1{0}; - SourceContextId id2{1}; - SourceContextId id3{2}; - SourceContextId id4{3}; - SourceContextId id5{4}; - SourceContextId id41{41}; - SourceContextId id42{42}; - SourceContextId id43{43}; - SourceContextId id44{44}; - SourceContextId id45{45}; + SourceContextId id1{SourceContextId::create(0)}; + SourceContextId id2{SourceContextId::create(1)}; + SourceContextId id3{SourceContextId::create(2)}; + SourceContextId id4{SourceContextId::create(3)}; + SourceContextId id5{SourceContextId::create(4)}; + SourceContextId id41{SourceContextId::create(41)}; + SourceContextId id42{SourceContextId::create(42)}; + SourceContextId id43{SourceContextId::create(43)}; + SourceContextId id44{SourceContextId::create(44)}; + SourceContextId id45{SourceContextId::create(45)}; }; using CacheTypes = ::testing::Types; @@ -240,7 +240,7 @@ TYPED_TEST(StorageCache, IsNotEmptyAfterPopulateWithSomeEntries) typename TypeParam::CacheEntries entries{{this->filePath1.clone(), this->id1}, {this->filePath2.clone(), this->id4}, {this->filePath3.clone(), this->id3}, - {this->filePath4.clone(), SourceContextId{5}}}; + {this->filePath4.clone(), SourceContextId::create(5)}}; ON_CALL(this->mockStorage, fetchAllSourceContexts()).WillByDefault(Return(entries)); this->cache.uncheckedPopulate(); @@ -252,12 +252,12 @@ TYPED_TEST(StorageCache, GetEntryAfterPopulateWithSomeEntries) { typename TypeParam::CacheEntries entries{{this->filePath1.clone(), this->id1}, {this->filePath2.clone(), this->id2}, - {this->filePath3.clone(), SourceContextId{7}}, + {this->filePath3.clone(), SourceContextId::create(7)}, {this->filePath4.clone(), this->id4}}; ON_CALL(this->mockStorage, fetchAllSourceContexts()).WillByDefault(Return(entries)); this->cache.uncheckedPopulate(); - auto value = this->cache.value(SourceContextId{7}); + auto value = this->cache.value(SourceContextId::create(7)); ASSERT_THAT(value, this->filePath3); } @@ -442,7 +442,7 @@ TYPED_TEST(StorageCache, GetEntryByIndexAfterInsertingByCustomIndex) TYPED_TEST(StorageCache, CallFetchSourceContextPathForLowerIndex) { auto index = this->cache.id("foo"); - SourceContextId lowerIndex{&index - 1}; + SourceContextId lowerIndex{SourceContextId::create(&index - 1)}; EXPECT_CALL(this->mockStorage, fetchSourceContextPath(Eq(lowerIndex)));