From 5355aa7a3706790079f4681dd0f34bc77802f3b6 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 2 Sep 2020 15:30:13 +0200 Subject: [PATCH] Unittest: Fix crash in Linux Change-Id: I1e8dc10bd9f0f9d11b0f18716e284ffadef7c6c5 Reviewed-by: Christian Kandeler --- tests/unit/unittest/stringcache-test.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/unit/unittest/stringcache-test.cpp b/tests/unit/unittest/stringcache-test.cpp index 8eecd92c449..5a2b1d404dc 100644 --- a/tests/unit/unittest/stringcache-test.cpp +++ b/tests/unit/unittest/stringcache-test.cpp @@ -65,6 +65,12 @@ class StringCache : public testing::Test protected: 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) { return compare(f, l) < 0; }); @@ -82,12 +88,8 @@ protected: protected: NiceMock mockDatabase; NiceMock mockStorage{mockDatabase}; - StorageIdFunction mockStorageFetchDirectyId = [&](Utils::SmallStringView string) { - return mockStorage.fetchDirectoryId(string); - }; - StorageStringFunction mockStorageFetchDirectyPath = [&](int id) { - return mockStorage.fetchDirectoryPath(id); - }; + StorageIdFunction mockStorageFetchDirectyId; + StorageStringFunction mockStorageFetchDirectyPath; Cache cache; typename Cache::MutexType &mockMutex = cache.mutex(); Utils::PathString filePath1{"/file/pathOne"};