Unittest: Fix crash in Linux

Change-Id: I1e8dc10bd9f0f9d11b0f18716e284ffadef7c6c5
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Christian Stenger
2020-09-02 15:30:13 +02:00
parent a408bcfd3d
commit 5355aa7a37

View File

@@ -65,6 +65,12 @@ class StringCache : public testing::Test
protected: protected:
void SetUp() void SetUp()
{ {
mockStorageFetchDirectyId = [&](Utils::SmallStringView string) {
return mockStorage.fetchDirectoryId(string);
};
mockStorageFetchDirectyPath = [&](int id) {
return mockStorage.fetchDirectoryPath(id);
};
std::sort(filePaths.begin(), filePaths.end(), [](auto &f, auto &l) { std::sort(filePaths.begin(), filePaths.end(), [](auto &f, auto &l) {
return compare(f, l) < 0; return compare(f, l) < 0;
}); });
@@ -82,12 +88,8 @@ protected:
protected: protected:
NiceMock<MockSqliteDatabase> mockDatabase; NiceMock<MockSqliteDatabase> mockDatabase;
NiceMock<MockFilePathStorage> mockStorage{mockDatabase}; NiceMock<MockFilePathStorage> mockStorage{mockDatabase};
StorageIdFunction mockStorageFetchDirectyId = [&](Utils::SmallStringView string) { StorageIdFunction mockStorageFetchDirectyId;
return mockStorage.fetchDirectoryId(string); StorageStringFunction mockStorageFetchDirectyPath;
};
StorageStringFunction mockStorageFetchDirectyPath = [&](int id) {
return mockStorage.fetchDirectoryPath(id);
};
Cache cache; Cache cache;
typename Cache::MutexType &mockMutex = cache.mutex(); typename Cache::MutexType &mockMutex = cache.mutex();
Utils::PathString filePath1{"/file/pathOne"}; Utils::PathString filePath1{"/file/pathOne"};