forked from qt-creator/qt-creator
Clang: Honor directories for the file name
The file name id must be unique for very entry, so the directory id must be incorporated too. Now there is always one unique integer id for every file path. The directory id is there to access and compare the directory much faster but not provide any data to the uniqueness of the id. Change-Id: I0f9a2ca70bc9dda0ce32ebc45eb7b082821eb909 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -156,14 +156,36 @@ TEST_F(FilePathCache, GetAFilePathWithCachedFilePathId)
|
||||
ASSERT_THAT(filePath, Eq(FilePathView{"/path/to/file.cpp"}));
|
||||
}
|
||||
|
||||
TEST_F(FilePathCache, FileNamesAreUniqueForEveryDirectory)
|
||||
{
|
||||
FilePathId filePathId = cache.filePathId(FilePathView("/path/to/file.cpp"));
|
||||
|
||||
FilePathId filePath2Id = cache.filePathId(FilePathView("/path2/to/file.cpp"));
|
||||
|
||||
ASSERT_THAT(filePath2Id.filePathId, Ne(filePathId.filePathId));
|
||||
}
|
||||
|
||||
TEST_F(FilePathCache, DuplicateFilePathsAreEqual)
|
||||
{
|
||||
FilePathId filePath1Id = cache.filePathId(FilePathView("/path/to/file.cpp"));
|
||||
|
||||
FilePathId filePath2Id = cache.filePathId(FilePathView("/path/to/file.cpp"));
|
||||
|
||||
ASSERT_THAT(filePath2Id, Eq(filePath1Id));
|
||||
}
|
||||
|
||||
void FilePathCache::SetUp()
|
||||
{
|
||||
ON_CALL(mockStorage, fetchDirectoryId(Eq("/path/to")))
|
||||
.WillByDefault(Return(5));
|
||||
ON_CALL(mockStorage, fetchDirectoryId(Eq("/path2/to")))
|
||||
.WillByDefault(Return(6));
|
||||
ON_CALL(mockStorage, fetchSourceId(5, Eq("file.cpp")))
|
||||
.WillByDefault(Return(42));
|
||||
ON_CALL(mockStorage, fetchSourceId(5, Eq("file2.cpp")))
|
||||
.WillByDefault(Return(63));
|
||||
ON_CALL(mockStorage, fetchSourceId(6, Eq("file.cpp")))
|
||||
.WillByDefault(Return(72));
|
||||
ON_CALL(mockStorage, fetchDirectoryPath(5))
|
||||
.WillByDefault(Return(Utils::PathString("/path/to")));
|
||||
ON_CALL(mockStorage, fetchSourceName(42))
|
||||
|
||||
Reference in New Issue
Block a user