summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2018-11-06 19:02:00 +0100
committerMarco Bubke <marco.bubke@qt.io>2018-11-08 12:51:15 +0000
commit6eb620238b31af81bb097260afb53bcac1054221 (patch)
tree7c4842e2e8a3d0630a72da993d45344f677b1288
parentd37ec2c1e511df19f48b4a621270df3e7135a731 (diff)
downloadqt-creator-6eb620238b31af81bb097260afb53bcac1054221.tar.gz
Clang: Refactor FilePathId
We don't need the directory id any more. It's not used widely any way. Task-number: QTCREATORBUG-21443 Change-Id: Ia95ea4c72fe9530ac56262f61f17faca04d313ba Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
-rw-r--r--src/libs/clangsupport/filepathcache.h22
-rw-r--r--src/libs/clangsupport/filepathid.cpp2
-rw-r--r--src/libs/clangsupport/filepathid.h17
-rw-r--r--src/libs/clangsupport/filepathstorage.h8
-rw-r--r--src/libs/clangsupport/filepathstoragesources.h11
-rw-r--r--src/libs/clangsupport/filepathstoragesqlitestatementfactory.h4
-rw-r--r--src/plugins/clangrefactoring/querysqlitestatementfactory.h4
-rw-r--r--src/plugins/clangrefactoring/sourcelocations.h4
-rw-r--r--src/plugins/clangrefactoring/symbolquery.h4
-rw-r--r--src/tools/clangpchmanagerbackend/source/sourceentry.h22
-rw-r--r--src/tools/clangrefactoringbackend/source/clangquery.cpp2
-rw-r--r--tests/unit/unittest/builddependenciesprovider-test.cpp50
-rw-r--r--tests/unit/unittest/clangpathwatcher-test.cpp2
-rw-r--r--tests/unit/unittest/clangqueryexamplehighlightmarker-test.cpp34
-rw-r--r--tests/unit/unittest/clangqueryhighlightmarker-test.cpp58
-rw-r--r--tests/unit/unittest/filepathcache-test.cpp64
-rw-r--r--tests/unit/unittest/filepathstorage-test.cpp122
-rw-r--r--tests/unit/unittest/filepathstoragesqlitestatementfactory-test.cpp4
-rw-r--r--tests/unit/unittest/gtest-creator-printing.cpp6
-rw-r--r--tests/unit/unittest/locatorfilter-test.cpp2
-rw-r--r--tests/unit/unittest/mockfilepathstorage.h6
-rw-r--r--tests/unit/unittest/mocksqlitereadstatement.cpp18
-rw-r--r--tests/unit/unittest/mocksqlitereadstatement.h21
-rw-r--r--tests/unit/unittest/mocksqlitewritestatement.h6
-rw-r--r--tests/unit/unittest/pchmanagerserver-test.cpp2
-rw-r--r--tests/unit/unittest/pchtaskgenerator-test.cpp2
-rw-r--r--tests/unit/unittest/projectpartqueue-test.cpp16
-rw-r--r--tests/unit/unittest/projectparts-test.cpp10
-rw-r--r--tests/unit/unittest/refactoringclient-test.cpp12
-rw-r--r--tests/unit/unittest/sourcerangeextractor-test.cpp2
-rw-r--r--tests/unit/unittest/sourcerangefilter-test.cpp26
-rw-r--r--tests/unit/unittest/sourcesmanager-test.cpp116
-rw-r--r--tests/unit/unittest/symbolindexer-test.cpp20
-rw-r--r--tests/unit/unittest/symbolindexertaskqueue-test.cpp104
-rw-r--r--tests/unit/unittest/symbolquery-test.cpp26
-rw-r--r--tests/unit/unittest/symbolstorage-test.cpp14
-rw-r--r--tests/unit/unittest/usedmacroandsourcestorage-test.cpp10
37 files changed, 443 insertions, 410 deletions
diff --git a/src/libs/clangsupport/filepathcache.h b/src/libs/clangsupport/filepathcache.h
index d0c8a529df..bdd925a79c 100644
--- a/src/libs/clangsupport/filepathcache.h
+++ b/src/libs/clangsupport/filepathcache.h
@@ -133,7 +133,7 @@ public:
return m_filePathStorage.fetchSourceId(directoryId, fileName);
});
- return {directoryId, fileNameId};
+ return fileNameId;
}
FilePath filePath(FilePathId filePathId) const
@@ -141,20 +141,20 @@ public:
if (Q_UNLIKELY(!filePathId.isValid()))
throw NoFilePathForInvalidFilePathId();
- auto fetchFilePath = [&] (int id) { return m_filePathStorage.fetchDirectoryPath(id); };
-
- Utils::PathString directoryPath = m_directoryPathCache.string(filePathId.directoryId,
- fetchFilePath);
+ auto fetchSoureNameAndDirectoryId = [&] (int id) {
+ auto entry = m_filePathStorage.fetchSourceNameAndDirectoryId(id);
+ return FileNameEntry{entry.sourceName, entry.directoryId};
+ };
+ FileNameEntry entry = m_fileNameCache.string(filePathId.filePathId,
+ fetchSoureNameAndDirectoryId);
- auto fetchSoureName = [&] (int id) {
- return FileNameEntry{m_filePathStorage.fetchSourceName(id), filePathId.directoryId};
- };
+ auto fetchDirectoryPath = [&] (int id) { return m_filePathStorage.fetchDirectoryPath(id); };
- Utils::SmallString fileName = m_fileNameCache.string(filePathId.filePathId,
- fetchSoureName);
+ Utils::PathString directoryPath = m_directoryPathCache.string(entry.directoryId,
+ fetchDirectoryPath);
- return FilePath{directoryPath, fileName};
+ return FilePath{directoryPath, entry.fileName};
}
private:
diff --git a/src/libs/clangsupport/filepathid.cpp b/src/libs/clangsupport/filepathid.cpp
index 7d059e0ea2..2491bc02d0 100644
--- a/src/libs/clangsupport/filepathid.cpp
+++ b/src/libs/clangsupport/filepathid.cpp
@@ -31,7 +31,7 @@ namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const FilePathId &filePathId)
{
- debug.nospace() << "(" << filePathId.directoryId << ", " << filePathId.filePathId << ")";
+ debug.nospace() << "(" << filePathId.filePathId << ")";
return debug;
}
diff --git a/src/libs/clangsupport/filepathid.h b/src/libs/clangsupport/filepathid.h
index 38762bd44b..88426d93fc 100644
--- a/src/libs/clangsupport/filepathid.h
+++ b/src/libs/clangsupport/filepathid.h
@@ -39,14 +39,14 @@ class FilePathId
{
public:
constexpr FilePathId() = default;
- FilePathId(int directoryId, int filePathId)
- : directoryId(directoryId),
- filePathId(filePathId)
+
+ FilePathId(int filePathId)
+ : filePathId(filePathId)
{}
bool isValid() const
{
- return directoryId >= 0 && filePathId >= 0;
+ return filePathId >= 0;
}
friend bool operator==(FilePathId first, FilePathId second)
@@ -66,7 +66,6 @@ public:
friend QDataStream &operator<<(QDataStream &out, const FilePathId &filePathId)
{
- out << filePathId.directoryId;
out << filePathId.filePathId;
return out;
@@ -74,14 +73,12 @@ public:
friend QDataStream &operator>>(QDataStream &in, FilePathId &filePathId)
{
- in >> filePathId.directoryId;
in >> filePathId.filePathId;
return in;
}
public:
- int directoryId = -1;
int filePathId = -1;
};
@@ -97,11 +94,7 @@ template<> struct hash<ClangBackEnd::FilePathId>
using result_type = std::size_t;
result_type operator()(const argument_type& filePathId) const
{
- long long hash = filePathId.directoryId;
- hash = hash << 32;
- hash += filePathId.filePathId;
-
- return std::hash<long long>{}(hash);
+ return std::hash<int>{}(filePathId.filePathId);
}
};
diff --git a/src/libs/clangsupport/filepathstorage.h b/src/libs/clangsupport/filepathstorage.h
index 69388a45d2..5917504dbf 100644
--- a/src/libs/clangsupport/filepathstorage.h
+++ b/src/libs/clangsupport/filepathstorage.h
@@ -165,14 +165,14 @@ public:
return statement.template value<int>(directoryId, sourceName);
}
- Utils::SmallString fetchSourceName(int sourceId)
+ Sources::SourceNameAndDirectoryId fetchSourceNameAndDirectoryId(int sourceId)
{
try {
Sqlite::DeferredTransaction transaction{m_statementFactory.database};
- ReadStatement &statement = m_statementFactory.selectSourceNameFromSourcesBySourceId;
+ ReadStatement &statement = m_statementFactory.selectSourceNameAndDirectoryIdFromSourcesBySourceId;
- auto optionalSourceName = statement.template value<Utils::SmallString>(sourceId);
+ auto optionalSourceName = statement.template value<Sources::SourceNameAndDirectoryId, 2>(sourceId);
if (!optionalSourceName)
throw SourceNameIdDoesNotExists();
@@ -181,7 +181,7 @@ public:
return optionalSourceName.value();
} catch (const Sqlite::StatementIsBusy &) {
- return fetchSourceName(sourceId);
+ return fetchSourceNameAndDirectoryId(sourceId);
}
}
diff --git a/src/libs/clangsupport/filepathstoragesources.h b/src/libs/clangsupport/filepathstoragesources.h
index 7561aca908..e76cb3b2cf 100644
--- a/src/libs/clangsupport/filepathstoragesources.h
+++ b/src/libs/clangsupport/filepathstoragesources.h
@@ -69,6 +69,17 @@ public:
int sourceId;
Utils::PathString sourceName;
};
+
+class SourceNameAndDirectoryId
+{
+public:
+ SourceNameAndDirectoryId(Utils::SmallStringView sourceName, int directoryId)
+ : sourceName(sourceName), directoryId(directoryId)
+ {}
+
+ Utils::SmallString sourceName;
+ int directoryId = -1;
+};
} // namespace ClangBackEnd
} // namespace ClangBackEnd
diff --git a/src/libs/clangsupport/filepathstoragesqlitestatementfactory.h b/src/libs/clangsupport/filepathstoragesqlitestatementfactory.h
index 71e2c3e773..dbf8071775 100644
--- a/src/libs/clangsupport/filepathstoragesqlitestatementfactory.h
+++ b/src/libs/clangsupport/filepathstoragesqlitestatementfactory.h
@@ -65,8 +65,8 @@ public:
"SELECT sourceId FROM sources WHERE directoryId = ? AND sourceName = ?",
database
};
- ReadStatement selectSourceNameFromSourcesBySourceId{
- "SELECT sourceName FROM sources WHERE sourceId = ?",
+ ReadStatement selectSourceNameAndDirectoryIdFromSourcesBySourceId{
+ "SELECT sourceName, directoryId FROM sources WHERE sourceId = ?",
database
};
WriteStatement insertIntoSources{
diff --git a/src/plugins/clangrefactoring/querysqlitestatementfactory.h b/src/plugins/clangrefactoring/querysqlitestatementfactory.h
index 21a1f022ec..14fc27149d 100644
--- a/src/plugins/clangrefactoring/querysqlitestatementfactory.h
+++ b/src/plugins/clangrefactoring/querysqlitestatementfactory.h
@@ -40,7 +40,7 @@ public:
{}
Database &database;
ReadStatement selectLocationsForSymbolLocation{
- "SELECT directoryId, sourceId, line, column FROM locations JOIN sources USING(sourceId) WHERE symbolId = "
+ "SELECT sourceId, line, column FROM locations WHERE symbolId = "
" (SELECT symbolId FROM locations WHERE sourceId=? AND line=? AND column=?) "
"ORDER BY sourceId, line, column",
database};
@@ -59,7 +59,7 @@ public:
"SELECT symbolId, symbolName, signature FROM symbols WHERE symbolKind IN (?,?,?) AND symbolName LIKE ?",
database};
ReadStatement selectLocationOfSymbol{
- "SELECT (SELECT directoryId FROM sources WHERE sourceId = l.sourceId), sourceId, line, column FROM locations AS l WHERE symbolId = ? AND locationKind = ?",
+ "SELECT sourceId, line, column FROM locations AS l WHERE symbolId = ? AND locationKind = ?",
database};
};
diff --git a/src/plugins/clangrefactoring/sourcelocations.h b/src/plugins/clangrefactoring/sourcelocations.h
index 9766a779b5..80fc0d89c0 100644
--- a/src/plugins/clangrefactoring/sourcelocations.h
+++ b/src/plugins/clangrefactoring/sourcelocations.h
@@ -45,8 +45,8 @@ public:
SourceLocation(ClangBackEnd::FilePathId filePathId, int line, int column)
: filePathId{filePathId}, lineColumn{line, column}
{}
- SourceLocation(int directoryId, int sourceId, int line, int column)
- : filePathId{directoryId, sourceId}, lineColumn{line, column}
+ SourceLocation(int sourceId, int line, int column)
+ : filePathId{sourceId}, lineColumn{line, column}
{}
friend bool operator==(SourceLocation first, SourceLocation second)
diff --git a/src/plugins/clangrefactoring/symbolquery.h b/src/plugins/clangrefactoring/symbolquery.h
index 507d032f06..b5a46ab7e6 100644
--- a/src/plugins/clangrefactoring/symbolquery.h
+++ b/src/plugins/clangrefactoring/symbolquery.h
@@ -55,7 +55,7 @@ public:
const std::size_t reserveSize = 128;
- return locationsStatement.template values<SourceLocation, 4>(reserveSize,
+ return locationsStatement.template values<SourceLocation, 3>(reserveSize,
filePathId.filePathId,
line,
utf8Column);
@@ -120,7 +120,7 @@ public:
{
ReadStatement &statement = m_statementFactory.selectLocationOfSymbol;
- return statement.template value<SourceLocation, 4>(symbolId, int(kind));
+ return statement.template value<SourceLocation, 3>(symbolId, int(kind));
}
private:
StatementFactory &m_statementFactory;
diff --git a/src/tools/clangpchmanagerbackend/source/sourceentry.h b/src/tools/clangpchmanagerbackend/source/sourceentry.h
index 2e0646b987..2a5e4ba06f 100644
--- a/src/tools/clangpchmanagerbackend/source/sourceentry.h
+++ b/src/tools/clangpchmanagerbackend/source/sourceentry.h
@@ -31,7 +31,7 @@
namespace ClangBackEnd {
-enum SourceType : unsigned char
+enum class SourceType : unsigned char
{
Any,
TopInclude,
@@ -56,7 +56,21 @@ public:
class SourceEntry
{
+ using int64 = long long;
public:
+ SourceEntry(int sourceId, int64 lastModified, int sourceType)
+ : lastModified(lastModified),
+ sourceId(sourceId),
+ sourceType(static_cast<SourceType>(sourceType))
+
+ {}
+
+ SourceEntry(FilePathId sourceId, SourceType sourceType, TimeStamp lastModified)
+ : lastModified(lastModified),
+ sourceId(sourceId),
+ sourceType(sourceType)
+ {}
+
friend
bool operator<(SourceEntry first, SourceEntry second)
{
@@ -66,13 +80,15 @@ public:
friend
bool operator==(SourceEntry first, SourceEntry second)
{
- return first.sourceId == second.sourceId;
+ return first.sourceId == second.sourceId
+ && first.sourceType == second.sourceType
+ && first.lastModified == second.lastModified ;
}
public:
+ TimeStamp lastModified;
FilePathId sourceId;
SourceType sourceType = SourceType::Any;
- TimeStamp lastModified;
};
using SourceEntries = std::vector<SourceEntry>;
diff --git a/src/tools/clangrefactoringbackend/source/clangquery.cpp b/src/tools/clangrefactoringbackend/source/clangquery.cpp
index 1524e36da5..21ebeb8367 100644
--- a/src/tools/clangrefactoringbackend/source/clangquery.cpp
+++ b/src/tools/clangrefactoringbackend/source/clangquery.cpp
@@ -101,7 +101,7 @@ namespace {
V2::SourceRangeContainer convertToContainer(const clang::ast_matchers::dynamic::SourceRange sourceRange)
{
- return V2::SourceRangeContainer({1, 0},
+ return V2::SourceRangeContainer(0,
sourceRange.Start.Line,
sourceRange.Start.Column,
0,
diff --git a/tests/unit/unittest/builddependenciesprovider-test.cpp b/tests/unit/unittest/builddependenciesprovider-test.cpp
index c9e29c0ad3..4f27ecb8c4 100644
--- a/tests/unit/unittest/builddependenciesprovider-test.cpp
+++ b/tests/unit/unittest/builddependenciesprovider-test.cpp
@@ -62,20 +62,20 @@ protected:
{"--yi"},
{{"YI","1"}},
{"/yi"},
- {{1, 1}},
- {{1, 2}}};
+ {1},
+ {2}};
ClangBackEnd::V2::ProjectPartContainer projectPart2{"ProjectPart2",
{"--er"},
{{"ER","2"}},
{"/er"},
- {{1, 1}},
- {{1, 2}, {1, 3}, {1, 4}}};
- SourceEntries firstSources{{{1, 1}, SourceType::Any, 1}, {{1, 2}, SourceType::Any, 1}, {{1, 10}, SourceType::Any, 1}};
- SourceEntries secondSources{{{1, 1}, SourceType::Any, 1}, {{1, 3}, SourceType::Any, 1}, {{1, 8}, SourceType::Any, 1}};
- SourceEntries thirdSources{{{1, 4}, SourceType::Any, 1}, {{1, 8}, SourceType::Any, 1}, {{1, 10}, SourceType::Any, 1}};
- UsedMacros firstUsedMacros{{"YI", {1, 1}}};
- UsedMacros secondUsedMacros{{"LIANG", {1, 2}}, {"ER", {1, 2}}};
- UsedMacros thirdUsedMacros{{"SAN", {1, 10}}};
+ {1},
+ {2, 3, 4}};
+ SourceEntries firstSources{{1, SourceType::Any, 1}, {2, SourceType::Any, 1}, {10, SourceType::Any, 1}};
+ SourceEntries secondSources{{1, SourceType::Any, 1}, {3, SourceType::Any, 1}, {8, SourceType::Any, 1}};
+ SourceEntries thirdSources{{4, SourceType::Any, 1}, {8, SourceType::Any, 1}, {10, SourceType::Any, 1}};
+ UsedMacros firstUsedMacros{{"YI", 1}};
+ UsedMacros secondUsedMacros{{"LIANG", 2}, {"ER", 2}};
+ UsedMacros thirdUsedMacros{{"SAN", 10}};
BuildDependency buildDependency{secondSources, {}, {}, {}};
};
@@ -83,7 +83,7 @@ TEST_F(BuildDependenciesProvider, CreateCallsFetchDependSourcesFromStorageIfTime
{
InSequence s;
- EXPECT_CALL(mockBuildDependenciesStorage, fetchDependSources(FilePathId{1, 2})).WillRepeatedly(Return(firstSources));
+ EXPECT_CALL(mockBuildDependenciesStorage, fetchDependSources({2})).WillRepeatedly(Return(firstSources));
EXPECT_CALL(mockModifiedTimeChecker, isUpToDate(firstSources)).WillRepeatedly(Return(true));
EXPECT_CALL(mockBuildDependenciesGenerator, create(projectPart1)).Times(0);
@@ -92,9 +92,9 @@ TEST_F(BuildDependenciesProvider, CreateCallsFetchDependSourcesFromStorageIfTime
TEST_F(BuildDependenciesProvider, FetchDependSourcesFromStorage)
{
- ON_CALL(mockBuildDependenciesStorage, fetchDependSources(FilePathId{1, 2})).WillByDefault(Return(firstSources));
- ON_CALL(mockBuildDependenciesStorage, fetchDependSources(FilePathId{1, 3})).WillByDefault(Return(secondSources));
- ON_CALL(mockBuildDependenciesStorage, fetchDependSources(FilePathId{1, 4})).WillByDefault(Return(thirdSources));
+ ON_CALL(mockBuildDependenciesStorage, fetchDependSources({2})).WillByDefault(Return(firstSources));
+ ON_CALL(mockBuildDependenciesStorage, fetchDependSources({3})).WillByDefault(Return(secondSources));
+ ON_CALL(mockBuildDependenciesStorage, fetchDependSources({4})).WillByDefault(Return(thirdSources));
ON_CALL(mockModifiedTimeChecker, isUpToDate(_)).WillByDefault(Return(true));
auto buildDependency = provider.create(projectPart2);
@@ -106,7 +106,7 @@ TEST_F(BuildDependenciesProvider, CreateCallsFetchDependSourcesFromGeneratorIfTi
{
InSequence s;
- EXPECT_CALL(mockBuildDependenciesStorage, fetchDependSources(FilePathId{1, 2})).WillRepeatedly(Return(firstSources));
+ EXPECT_CALL(mockBuildDependenciesStorage, fetchDependSources({2})).WillRepeatedly(Return(firstSources));
EXPECT_CALL(mockModifiedTimeChecker, isUpToDate(firstSources)).WillRepeatedly(Return(false));
EXPECT_CALL(mockBuildDependenciesGenerator, create(projectPart1));
@@ -115,7 +115,7 @@ TEST_F(BuildDependenciesProvider, CreateCallsFetchDependSourcesFromGeneratorIfTi
TEST_F(BuildDependenciesProvider, FetchDependSourcesFromGenerator)
{
- ON_CALL(mockBuildDependenciesStorage, fetchDependSources(FilePathId{1, 2})).WillByDefault(Return(firstSources));
+ ON_CALL(mockBuildDependenciesStorage, fetchDependSources({2})).WillByDefault(Return(firstSources));
ON_CALL(mockModifiedTimeChecker, isUpToDate(_)).WillByDefault(Return(false));
ON_CALL(mockBuildDependenciesGenerator, create(projectPart1)).WillByDefault(Return(buildDependency));
@@ -128,25 +128,25 @@ TEST_F(BuildDependenciesProvider, CreateCallsFetchUsedMacrosFromStorageIfTimeSta
{
InSequence s;
- EXPECT_CALL(mockBuildDependenciesStorage, fetchDependSources(FilePathId{1, 2})).WillRepeatedly(Return(firstSources));
+ EXPECT_CALL(mockBuildDependenciesStorage, fetchDependSources({2})).WillRepeatedly(Return(firstSources));
EXPECT_CALL(mockModifiedTimeChecker, isUpToDate(firstSources)).WillRepeatedly(Return(true));
- EXPECT_CALL(mockBuildDependenciesStorage, fetchUsedMacros(FilePathId{1, 1}));
- EXPECT_CALL(mockBuildDependenciesStorage, fetchUsedMacros(FilePathId{1, 2}));
- EXPECT_CALL(mockBuildDependenciesStorage, fetchUsedMacros(FilePathId{1, 10}));
+ EXPECT_CALL(mockBuildDependenciesStorage, fetchUsedMacros({1}));
+ EXPECT_CALL(mockBuildDependenciesStorage, fetchUsedMacros({2}));
+ EXPECT_CALL(mockBuildDependenciesStorage, fetchUsedMacros({10}));
provider.create(projectPart1);
}
TEST_F(BuildDependenciesProvider, FetchUsedMacrosFromStorageIfDependSourcesAreUpToDate)
{
- ON_CALL(mockBuildDependenciesStorage, fetchDependSources(FilePathId{1, 2})).WillByDefault(Return(firstSources));
+ ON_CALL(mockBuildDependenciesStorage, fetchDependSources({2})).WillByDefault(Return(firstSources));
ON_CALL(mockModifiedTimeChecker, isUpToDate(firstSources)).WillByDefault(Return(true));
- ON_CALL(mockBuildDependenciesStorage, fetchUsedMacros(FilePathId{1, 1})).WillByDefault(Return(firstUsedMacros));
- ON_CALL(mockBuildDependenciesStorage, fetchUsedMacros(FilePathId{1, 2})).WillByDefault(Return(secondUsedMacros));
- ON_CALL(mockBuildDependenciesStorage, fetchUsedMacros(FilePathId{1, 10})).WillByDefault(Return(thirdUsedMacros));
+ ON_CALL(mockBuildDependenciesStorage, fetchUsedMacros({1})).WillByDefault(Return(firstUsedMacros));
+ ON_CALL(mockBuildDependenciesStorage, fetchUsedMacros({2})).WillByDefault(Return(secondUsedMacros));
+ ON_CALL(mockBuildDependenciesStorage, fetchUsedMacros({10})).WillByDefault(Return(thirdUsedMacros));
auto buildDependency = provider.create(projectPart1);
- ASSERT_THAT(buildDependency.usedMacros, ElementsAre(UsedMacro{"YI", {1, 1}}, UsedMacro{"ER", {1, 2}}, UsedMacro{"LIANG", {1, 2}}, UsedMacro{"SAN", {1, 10}}));
+ ASSERT_THAT(buildDependency.usedMacros, ElementsAre(UsedMacro{"YI", 1}, UsedMacro{"ER", 2}, UsedMacro{"LIANG", 2}, UsedMacro{"SAN", 10}));
}
}
diff --git a/tests/unit/unittest/clangpathwatcher-test.cpp b/tests/unit/unittest/clangpathwatcher-test.cpp
index bdc20348bc..058ae8e96a 100644
--- a/tests/unit/unittest/clangpathwatcher-test.cpp
+++ b/tests/unit/unittest/clangpathwatcher-test.cpp
@@ -73,7 +73,7 @@ protected:
FilePathView path2{"/path/path2"};
QString path1QString = QString(path1.toStringView());
QString path2QString = QString(path2.toStringView());
- FilePathIds pathIds = {{1, 1}, {1, 2}};
+ FilePathIds pathIds = {1, 2};
std::vector<int> ids{watcher.idCache().stringIds({id1, id2, id3})};
WatcherEntry watcherEntry1{ids[0], pathIds[0]};
WatcherEntry watcherEntry2{ids[1], pathIds[0]};
diff --git a/tests/unit/unittest/clangqueryexamplehighlightmarker-test.cpp b/tests/unit/unittest/clangqueryexamplehighlightmarker-test.cpp
index 7d65e40025..8af631774f 100644
--- a/tests/unit/unittest/clangqueryexamplehighlightmarker-test.cpp
+++ b/tests/unit/unittest/clangqueryexamplehighlightmarker-test.cpp
@@ -66,7 +66,7 @@ TEST_F(ClangQueryExampleHighlightMarker, NoCallForNotSourceRanges)
TEST_F(ClangQueryExampleHighlightMarker, SingleLineSourceRange)
{
- SourceRanges sourceRanges{{{1, 1}, 1, 3, 3, 1, 10, 10, "function"}};
+ SourceRanges sourceRanges{{1, 1, 3, 3, 1, 10, 10, "function"}};
Marker marker(std::move(sourceRanges), highlighter, textFormats);
EXPECT_CALL(highlighter, setFormat(2, 7, textFormats[0]));
@@ -76,7 +76,7 @@ TEST_F(ClangQueryExampleHighlightMarker, SingleLineSourceRange)
TEST_F(ClangQueryExampleHighlightMarker, OtherSingleLineSourceRange)
{
- SourceRanges sourceRanges{{{1, 1}, 2, 5, 5, 2, 11, 11, "function"}};
+ SourceRanges sourceRanges{{1, 2, 5, 5, 2, 11, 11, "function"}};
Marker marker(std::move(sourceRanges), highlighter, textFormats);
marker.highlightBlock(1, "foo");
@@ -88,9 +88,9 @@ TEST_F(ClangQueryExampleHighlightMarker, OtherSingleLineSourceRange)
TEST_F(ClangQueryExampleHighlightMarker, CascadedSingleLineSourceRanges)
{
InSequence sequence;
- SourceRanges sourceRanges{{{1, 1}, 1, 2, 2, 1, 15, 15, "void function"},
- {{1, 1}, 1, 2, 2, 1, 6, 6, "void"},
- {{1, 1}, 1, 7, 7, 1, 15, 15, "function"}};
+ SourceRanges sourceRanges{{1, 1, 2, 2, 1, 15, 15, "void function"},
+ {1, 1, 2, 2, 1, 6, 6, "void"},
+ {1, 1, 7, 7, 1, 15, 15, "function"}};
Marker marker(std::move(sourceRanges), highlighter, textFormats);
EXPECT_CALL(highlighter, setFormat(1, 13, textFormats[0]));
@@ -103,7 +103,7 @@ TEST_F(ClangQueryExampleHighlightMarker, CascadedSingleLineSourceRanges)
TEST_F(ClangQueryExampleHighlightMarker, DualLineSourceRanges)
{
InSequence sequence;
- SourceRanges sourceRanges{{{1, 1}, 1, 2, 2, 2, 4, 20, "void f()\n {}"}};
+ SourceRanges sourceRanges{{1, 1, 2, 2, 2, 4, 20, "void f()\n {}"}};
Marker marker(std::move(sourceRanges), highlighter, textFormats);
EXPECT_CALL(highlighter, setFormat(1, 7, textFormats[0]));
@@ -116,7 +116,7 @@ TEST_F(ClangQueryExampleHighlightMarker, DualLineSourceRanges)
TEST_F(ClangQueryExampleHighlightMarker, MultipleLineSourceRanges)
{
InSequence sequence;
- SourceRanges sourceRanges{{{1, 1}, 1, 2, 2, 3, 3, 20, "void f()\n {\n }"}};
+ SourceRanges sourceRanges{{1, 1, 2, 2, 3, 3, 20, "void f()\n {\n }"}};
Marker marker(std::move(sourceRanges), highlighter, textFormats);
EXPECT_CALL(highlighter, setFormat(1, 7, textFormats[0]));
@@ -131,9 +131,9 @@ TEST_F(ClangQueryExampleHighlightMarker, MultipleLineSourceRanges)
TEST_F(ClangQueryExampleHighlightMarker, MoreMultipleLineSourceRanges)
{
InSequence sequence;
- SourceRanges sourceRanges{{{1, 1}, 1, 1, 0, 4, 2, 0, ""},
- {{1, 1}, 2, 2, 0, 2, 7, 0, ""},
- {{1, 1}, 3, 2, 0, 3, 7, 0, ""}};
+ SourceRanges sourceRanges{{1, 1, 1, 0, 4, 2, 0, ""},
+ {1, 2, 2, 0, 2, 7, 0, ""},
+ {1, 3, 2, 0, 3, 7, 0, ""}};
Marker marker(std::move(sourceRanges), highlighter, textFormats);
EXPECT_CALL(highlighter, setFormat(0, 10, textFormats[0]));
@@ -152,9 +152,9 @@ TEST_F(ClangQueryExampleHighlightMarker, MoreMultipleLineSourceRanges)
TEST_F(ClangQueryExampleHighlightMarker, CascadedMultipleLineSourceRanges)
{
InSequence sequence;
- SourceRanges sourceRanges{{{1, 1}, 1, 1, 0, 4, 2, 0, ""},
- {{1, 1}, 2, 2, 0, 3, 4, 0, ""},
- {{1, 1}, 2, 11, 0, 2, 16, 0, ""}};
+ SourceRanges sourceRanges{{1, 1, 1, 0, 4, 2, 0, ""},
+ {1, 2, 2, 0, 3, 4, 0, ""},
+ {1, 2, 11, 0, 2, 16, 0, ""}};
Marker marker(std::move(sourceRanges), highlighter, textFormats);
EXPECT_CALL(highlighter, setFormat(0, 9, textFormats[0]));
@@ -173,7 +173,7 @@ TEST_F(ClangQueryExampleHighlightMarker, CascadedMultipleLineSourceRanges)
TEST_F(ClangQueryExampleHighlightMarker, FormatSingle)
{
- SourceRange sourceRange{{1, 1}, 1, 3, 3, 1, 10, 10};
+ SourceRange sourceRange{1, 1, 3, 3, 1, 10, 10};
EXPECT_CALL(highlighter, setFormat(2, 7, textFormats[0]));
@@ -182,7 +182,7 @@ TEST_F(ClangQueryExampleHighlightMarker, FormatSingle)
TEST_F(ClangQueryExampleHighlightMarker, FormatMultipleStart)
{
- SourceRange sourceRange{{1, 1}, 1, 3, 3, 2, 9, 20};
+ SourceRange sourceRange{1, 1, 3, 3, 2, 9, 20};
EXPECT_CALL(highlighter, setFormat(2, 8, textFormats[0]));
@@ -191,7 +191,7 @@ TEST_F(ClangQueryExampleHighlightMarker, FormatMultipleStart)
TEST_F(ClangQueryExampleHighlightMarker, FormatMultipleEnd)
{
- SourceRange sourceRange{{1, 1}, 1, 3, 3, 2, 8, 20};
+ SourceRange sourceRange{1, 1, 3, 3, 2, 8, 20};
EXPECT_CALL(highlighter, setFormat(0, 7, textFormats[1]));
@@ -200,7 +200,7 @@ TEST_F(ClangQueryExampleHighlightMarker, FormatMultipleEnd)
TEST_F(ClangQueryExampleHighlightMarker, FormatMultipleMiddle)
{
- SourceRange sourceRange{{1, 1}, 1, 3, 3, 3, 8, 20};
+ SourceRange sourceRange{1, 1, 3, 3, 3, 8, 20};
EXPECT_CALL(highlighter, setFormat(0, 10, textFormats[2]));
diff --git a/tests/unit/unittest/clangqueryhighlightmarker-test.cpp b/tests/unit/unittest/clangqueryhighlightmarker-test.cpp
index 11efd1d519..05e657b9ea 100644
--- a/tests/unit/unittest/clangqueryhighlightmarker-test.cpp
+++ b/tests/unit/unittest/clangqueryhighlightmarker-test.cpp
@@ -74,10 +74,10 @@ TEST_F(ClangQueryHighlightMarker, NoCallForNoMessagesAndContexts)
TEST_F(ClangQueryHighlightMarker, CallForMessagesAndContextsForASingleLine)
{
InSequence sequence;
- Messages messages{{{{0, 1}, 1, 5, 0, 1, 10, 0}, ErrorType::RegistryMatcherNotFound, {}},
- {{{0, 1}, 1, 30, 0, 1, 40, 0}, ErrorType::RegistryMatcherNotFound, {}}};
- Contexts contexts{{{{0, 1}, 1, 2, 0, 1, 15, 0}, ContextType::MatcherArg, {}},
- {{{0, 1}, 1, 20, 0, 1, 50, 0}, ContextType::MatcherArg, {}}};
+ Messages messages{{{1, 1, 5, 0, 1, 10, 0}, ErrorType::RegistryMatcherNotFound, {}},
+ {{1, 1, 30, 0, 1, 40, 0}, ErrorType::RegistryMatcherNotFound, {}}};
+ Contexts contexts{{{1, 1, 2, 0, 1, 15, 0}, ContextType::MatcherArg, {}},
+ {{1, 1, 20, 0, 1, 50, 0}, ContextType::MatcherArg, {}}};
marker.setMessagesAndContexts(std::move(messages), std::move(contexts));
EXPECT_CALL(highlighter, setFormat(1, 13, contextTextFormat));
@@ -91,7 +91,7 @@ TEST_F(ClangQueryHighlightMarker, CallForMessagesAndContextsForASingleLine)
TEST_F(ClangQueryHighlightMarker, CallForMessagesForAMultiLine)
{
InSequence sequence;
- Messages messages{{{{0, 1}, 1, 5, 0, 3, 3, 0}, ErrorType::RegistryMatcherNotFound, {}}};
+ Messages messages{{{1, 1, 5, 0, 3, 3, 0}, ErrorType::RegistryMatcherNotFound, {}}};
Contexts contexts;
marker.setMessagesAndContexts(std::move(messages), std::move(contexts));
@@ -107,8 +107,8 @@ TEST_F(ClangQueryHighlightMarker, CallForMessagesForAMultiLine)
TEST_F(ClangQueryHighlightMarker, CallForMessagesAndContextForAMultiLine)
{
InSequence sequence;
- Messages messages{{{{1, 1}, 1, 5, 0, 3, 3, 0}, ErrorType::RegistryMatcherNotFound, {}}};
- Contexts contexts{{{{1, 1}, 1, 2, 0, 3, 4, 0}, ContextType::MatcherArg, {}}};
+ Messages messages{{{1, 1, 5, 0, 3, 3, 0}, ErrorType::RegistryMatcherNotFound, {}}};
+ Contexts contexts{{{1, 1, 2, 0, 3, 4, 0}, ContextType::MatcherArg, {}}};
marker.setMessagesAndContexts(std::move(messages), std::move(contexts));
EXPECT_CALL(highlighter, setFormat(1, 11, contextTextFormat));
@@ -136,7 +136,7 @@ TEST_F(ClangQueryHighlightMarker, NoMessagesIfEmpty)
TEST_F(ClangQueryHighlightMarker, NoMessagesForBeforePosition)
{
- Messages messages{{{{0, 1}, 1, 5, 0, 3, 3, 0},
+ Messages messages{{{1, 1, 5, 0, 3, 3, 0},
ErrorType::RegistryMatcherNotFound,
{"foo"}}};
Contexts contexts;
@@ -149,7 +149,7 @@ TEST_F(ClangQueryHighlightMarker, NoMessagesForBeforePosition)
TEST_F(ClangQueryHighlightMarker, NoMessagesForAfterPosition)
{
- Messages messages{{{{0, 1}, 1, 5, 0, 3, 3, 0},
+ Messages messages{{{1, 1, 5, 0, 3, 3, 0},
ErrorType::RegistryMatcherNotFound,
{"foo"}}};
Contexts contexts;
@@ -162,7 +162,7 @@ TEST_F(ClangQueryHighlightMarker, NoMessagesForAfterPosition)
TEST_F(ClangQueryHighlightMarker, OneMessagesForInsidePosition)
{
- Message message{{{0, 1}, 1, 5, 0, 3, 3, 0},
+ Message message{{1, 1, 5, 0, 3, 3, 0},
ErrorType::RegistryMatcherNotFound,
{"foo"}};
Messages messages{message.clone()};
@@ -176,7 +176,7 @@ TEST_F(ClangQueryHighlightMarker, OneMessagesForInsidePosition)
TEST_F(ClangQueryHighlightMarker, NoMessagesForOutsidePosition)
{
- Message message{{{0, 1}, 1, 5, 0, 3, 3, 0},
+ Message message{{1, 1, 5, 0, 3, 3, 0},
ErrorType::RegistryMatcherNotFound,
{"foo"}};
Messages messages{message.clone()};
@@ -190,7 +190,7 @@ TEST_F(ClangQueryHighlightMarker, NoMessagesForOutsidePosition)
TEST_F(ClangQueryHighlightMarker, AfterStartColumnBeforeLine)
{
- SourceRange sourceRange{{0, 1}, 2, 5, 0, 3, 3, 0};
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
bool isAfterStartColumn = marker.isInsideRange(sourceRange, 1, 6);
@@ -199,7 +199,7 @@ TEST_F(ClangQueryHighlightMarker, AfterStartColumnBeforeLine)
TEST_F(ClangQueryHighlightMarker, AfterStartColumnBeforeColumn)
{
- SourceRange sourceRange{{0, 1}, 2, 5, 0, 3, 3, 0};
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
bool isAfterStartColumn = marker.isInsideRange(sourceRange, 2, 4);
@@ -208,7 +208,7 @@ TEST_F(ClangQueryHighlightMarker, AfterStartColumnBeforeColumn)
TEST_F(ClangQueryHighlightMarker, AfterStartColumnAtColumn)
{
- SourceRange sourceRange{{0, 1}, 2, 5, 0, 3, 3, 0};
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
bool isAfterStartColumn = marker.isInsideRange(sourceRange, 2, 5);
@@ -217,7 +217,7 @@ TEST_F(ClangQueryHighlightMarker, AfterStartColumnAtColumn)
TEST_F(ClangQueryHighlightMarker, AfterStartColumnAfterColumn)
{
- SourceRange sourceRange{{0, 1}, 2, 5, 0, 3, 3, 0};
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
bool isAfterStartColumn = marker.isInsideRange(sourceRange, 2, 6);
@@ -226,7 +226,7 @@ TEST_F(ClangQueryHighlightMarker, AfterStartColumnAfterColumn)
TEST_F(ClangQueryHighlightMarker, BeforeEndColumnAfterLine)
{
- SourceRange sourceRange{{0, 1}, 2, 5, 0, 3, 3, 0};
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
bool isBeforeEndColumn = marker.isInsideRange(sourceRange, 4, 1);
@@ -235,7 +235,7 @@ TEST_F(ClangQueryHighlightMarker, BeforeEndColumnAfterLine)
TEST_F(ClangQueryHighlightMarker, BeforeEndColumnAfterColumn)
{
- SourceRange sourceRange{{0, 1}, 2, 5, 0, 3, 3, 0};
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
bool isBeforeEndColumn = marker.isInsideRange(sourceRange, 3, 4);
@@ -244,7 +244,7 @@ TEST_F(ClangQueryHighlightMarker, BeforeEndColumnAfterColumn)
TEST_F(ClangQueryHighlightMarker, BeforeEndColumnAtColumn)
{
- SourceRange sourceRange{{0, 1}, 2, 5, 0, 3, 3, 0};
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
bool isBeforeEndColumn = marker.isInsideRange(sourceRange, 3, 3);
@@ -253,7 +253,7 @@ TEST_F(ClangQueryHighlightMarker, BeforeEndColumnAtColumn)
TEST_F(ClangQueryHighlightMarker, BeforeEndColumnBeforeColumn)
{
- SourceRange sourceRange{{0, 1}, 2, 5, 0, 3, 3, 0};
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
bool isBeforeEndColumn = marker.isInsideRange(sourceRange, 3, 2);
@@ -262,7 +262,7 @@ TEST_F(ClangQueryHighlightMarker, BeforeEndColumnBeforeColumn)
TEST_F(ClangQueryHighlightMarker, InBetweenLineBeforeLine)
{
- SourceRange sourceRange{{0, 1}, 2, 5, 0, 3, 3, 0};
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
bool isInBetween = marker.isInsideRange(sourceRange, 1, 6);
@@ -271,7 +271,7 @@ TEST_F(ClangQueryHighlightMarker, InBetweenLineBeforeLine)
TEST_F(ClangQueryHighlightMarker, InBetweenLineAfterLine)
{
- SourceRange sourceRange{{0, 1}, 2, 5, 0, 4, 3, 0};
+ SourceRange sourceRange{1, 2, 5, 0, 4, 3, 0};
bool isInBetween = marker.isInsideRange(sourceRange, 5, 1);
@@ -280,7 +280,7 @@ TEST_F(ClangQueryHighlightMarker, InBetweenLineAfterLine)
TEST_F(ClangQueryHighlightMarker, InBetweenLine)
{
- SourceRange sourceRange{{0, 1}, 2, 5, 0, 4, 3, 0};
+ SourceRange sourceRange{1, 2, 5, 0, 4, 3, 0};
bool isInBetween = marker.isInsideRange(sourceRange, 3, 1);
@@ -289,7 +289,7 @@ TEST_F(ClangQueryHighlightMarker, InBetweenLine)
TEST_F(ClangQueryHighlightMarker, SingleLineBefore)
{
- SourceRange sourceRange{{0, 1}, 2, 5, 0, 2, 10, 0};
+ SourceRange sourceRange{1, 2, 5, 0, 2, 10, 0};
bool isInRange = marker.isInsideRange(sourceRange, 2, 4);
@@ -298,7 +298,7 @@ TEST_F(ClangQueryHighlightMarker, SingleLineBefore)
TEST_F(ClangQueryHighlightMarker, SingleLineAfter)
{
- SourceRange sourceRange{{0, 1}, 2, 5, 0, 2, 10, 0};
+ SourceRange sourceRange{1, 2, 5, 0, 2, 10, 0};
bool isInRange = marker.isInsideRange(sourceRange, 2, 11);
@@ -307,7 +307,7 @@ TEST_F(ClangQueryHighlightMarker, SingleLineAfter)
TEST_F(ClangQueryHighlightMarker, SingleLineInRange)
{
- SourceRange sourceRange{{0, 1}, 2, 5, 0, 2, 10, 0};
+ SourceRange sourceRange{1, 2, 5, 0, 2, 10, 0};
bool isInRange = marker.isInsideRange(sourceRange, 2, 6);
@@ -328,7 +328,7 @@ TEST_F(ClangQueryHighlightMarker, NoContextsIfEmpty)
TEST_F(ClangQueryHighlightMarker, NoContextsForBeforePosition)
{
Messages messages;
- Contexts contexts{{{{0, 1}, 1, 5, 0, 3, 3, 0},
+ Contexts contexts{{{1, 1, 5, 0, 3, 3, 0},
ContextType::MatcherArg,
{"foo"}}};
marker.setMessagesAndContexts(std::move(messages), std::move(contexts));
@@ -341,7 +341,7 @@ TEST_F(ClangQueryHighlightMarker, NoContextsForBeforePosition)
TEST_F(ClangQueryHighlightMarker, NoContextsForAfterPosition)
{
Messages messages;
- Contexts contexts{{{{0, 1}, 1, 5, 0, 3, 3, 0},
+ Contexts contexts{{{1, 1, 5, 0, 3, 3, 0},
ContextType::MatcherArg,
{"foo"}}};
marker.setMessagesAndContexts(std::move(messages), std::move(contexts));
@@ -353,7 +353,7 @@ TEST_F(ClangQueryHighlightMarker, NoContextsForAfterPosition)
TEST_F(ClangQueryHighlightMarker, OneContextsForInsidePosition)
{
- Context context{{{0, 1}, 1, 5, 0, 3, 3, 0},
+ Context context{{1, 1, 5, 0, 3, 3, 0},
ContextType::MatcherArg,
{"foo"}};
Messages messages;
@@ -367,7 +367,7 @@ TEST_F(ClangQueryHighlightMarker, OneContextsForInsidePosition)
TEST_F(ClangQueryHighlightMarker, NoContextsForOutsidePosition)
{
- Context context{{{0, 1}, 1, 5, 0, 3, 3, 0},
+ Context context{{1, 1, 5, 0, 3, 3, 0},
ContextType::MatcherArg,
{"foo"}};
Messages messages;
diff --git a/tests/unit/unittest/filepathcache-test.cpp b/tests/unit/unittest/filepathcache-test.cpp
index 282654ad7b..43b5b026bb 100644
--- a/tests/unit/unittest/filepathcache-test.cpp
+++ b/tests/unit/unittest/filepathcache-test.cpp
@@ -36,11 +36,28 @@ using Cache = ClangBackEnd::FilePathCache<NiceMock<MockFilePathStorage>>;
using ClangBackEnd::FilePathId;
using NFP = ClangBackEnd::FilePath;
using ClangBackEnd::FilePathView;
+using ClangBackEnd::Sources::SourceNameAndDirectoryId;
class FilePathCache : public testing::Test
{
protected:
- void SetUp();
+ void 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, fetchSourceNameAndDirectoryId(42))
+ .WillByDefault(Return(SourceNameAndDirectoryId("file.cpp", 5)));
+ }
protected:
NiceMock<MockFilePathStorage> mockStorage;
@@ -61,13 +78,6 @@ TEST_F(FilePathCache, FilePathIdWithOutAnyEntryCalls)
cache.filePathId(FilePathView("/path/to/file.cpp"));
}
-TEST_F(FilePathCache, DirectoryIdOfFilePathIdWithOutAnyEntry)
-{
- auto filePathId = cache.filePathId(FilePathView("/path/to/file.cpp"));
-
- ASSERT_THAT(filePathId.directoryId, 5);
-}
-
TEST_F(FilePathCache, FilePathIdOfFilePathIdWithOutAnyEntry)
{
auto filePathId = cache.filePathId(FilePathView("/path/to/file.cpp"));
@@ -113,24 +123,6 @@ TEST_F(FilePathCache, GetFilePathIdWithDirectoryIdCached)
ASSERT_THAT(filePathId.filePathId, 63);
}
-TEST_F(FilePathCache, GetDirectyIdWithCachedValue)
-{
- cache.filePathId(FilePathView("/path/to/file.cpp"));
-
- auto filePathId = cache.filePathId(FilePathView("/path/to/file2.cpp"));
-
- ASSERT_THAT(filePathId.directoryId, 5);
-}
-
-TEST_F(FilePathCache, GetDirectyIdWithDirectoryIdCached)
-{
- cache.filePathId(FilePathView("/path/to/file.cpp"));
-
- auto filePathId = cache.filePathId(FilePathView("/path/to/file2.cpp"));
-
- ASSERT_THAT(filePathId.directoryId, 5);
-}
-
TEST_F(FilePathCache, ThrowForGettingAFilePathWithAnInvalidId)
{
FilePathId filePathId;
@@ -149,7 +141,7 @@ TEST_F(FilePathCache, GetAFilePath)
TEST_F(FilePathCache, GetAFilePathWithCachedFilePathId)
{
- FilePathId filePathId{5, 42};
+ FilePathId filePathId{42};
auto filePath = cache.filePath(filePathId);
@@ -174,22 +166,4 @@ TEST_F(FilePathCache, DuplicateFilePathsAreEqual)
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))
- .WillByDefault(Return(Utils::SmallString("file.cpp")));
-}
-
}
diff --git a/tests/unit/unittest/filepathstorage-test.cpp b/tests/unit/unittest/filepathstorage-test.cpp
index 2692f9f79d..f94f3dfad2 100644
--- a/tests/unit/unittest/filepathstorage-test.cpp
+++ b/tests/unit/unittest/filepathstorage-test.cpp
@@ -43,7 +43,58 @@ using ClangBackEnd::Sources::Source;
class FilePathStorage : public testing::Test
{
protected:
- void SetUp();
+ void SetUp()
+ {
+ ON_CALL(selectDirectoryIdFromDirectoriesByDirectoryPath,
+ valueReturnInt32(_))
+ .WillByDefault(Return(Utils::optional<int>()));
+ ON_CALL(selectDirectoryIdFromDirectoriesByDirectoryPath,
+ valueReturnInt32(Utils::SmallStringView("")))
+ .WillByDefault(Return(Utils::optional<int>(0)));
+ ON_CALL(selectDirectoryIdFromDirectoriesByDirectoryPath,
+ valueReturnInt32(Utils::SmallStringView("/path/to")))
+ .WillByDefault(Return(Utils::optional<int>(5)));
+ ON_CALL(mockDatabase, lastInsertedRowId())
+ .WillByDefault(Return(12));
+ ON_CALL(selectAllDirectories,
+ valuesReturnStdVectorDirectory(_))
+ .WillByDefault(Return(std::vector<Directory>{{1, "/path/to"}, {2, "/other/path"}}));
+ ON_CALL(selectSourceIdFromSourcesByDirectoryIdAndSourceName,
+ valueReturnInt32(_, _))
+ .WillByDefault(Return(Utils::optional<int>()));
+ ON_CALL(selectSourceIdFromSourcesByDirectoryIdAndSourceName,
+ valueReturnInt32(0, Utils::SmallStringView("")))
+ .WillByDefault(Return(Utils::optional<int>(0)));
+ ON_CALL(selectSourceIdFromSourcesByDirectoryIdAndSourceName,
+ valueReturnInt32(5, Utils::SmallStringView("file.h")))
+ .WillByDefault(Return(Utils::optional<int>(42)));
+ ON_CALL(selectAllSources,
+ valuesReturnStdVectorSource(_))
+ .WillByDefault(Return(std::vector<Source>{{1, "file.h"}, {4, "file.cpp"}}));
+ ON_CALL(selectDirectoryPathFromDirectoriesByDirectoryId,
+ valueReturnPathString(5))
+ .WillByDefault(Return(Utils::optional<Utils::PathString>("/path/to")));
+ ON_CALL(selectSourceNameAndDirectoryIdFromSourcesBySourceId,
+ valueReturnSourceNameAndDirectoryId(42))
+ .WillByDefault(Return(Utils::optional<ClangBackEnd::Sources::SourceNameAndDirectoryId>({"file.cpp", 5})));
+
+ EXPECT_CALL(selectDirectoryIdFromDirectoriesByDirectoryPath, valueReturnInt32(_))
+ .Times(AnyNumber());
+ EXPECT_CALL(selectSourceIdFromSourcesByDirectoryIdAndSourceName, valueReturnInt32(_, _))
+ .Times(AnyNumber());
+ EXPECT_CALL(insertIntoDirectories, write(An<Utils::SmallStringView>()))
+ .Times(AnyNumber());
+ EXPECT_CALL(insertIntoSources, write(An<uint>(), A<Utils::SmallStringView>()))
+ .Times(AnyNumber());
+ EXPECT_CALL(selectAllDirectories, valuesReturnStdVectorDirectory(_))
+ .Times(AnyNumber());
+ EXPECT_CALL(selectAllSources, valuesReturnStdVectorSource(_))
+ .Times(AnyNumber());
+ EXPECT_CALL(selectDirectoryPathFromDirectoriesByDirectoryId, valueReturnPathString(_))
+ .Times(AnyNumber());
+ EXPECT_CALL(selectSourceNameAndDirectoryIdFromSourcesBySourceId, valueReturnSourceNameAndDirectoryId(_))
+ .Times(AnyNumber());
+ }
protected:
NiceMock<MockSqliteDatabase> mockDatabase;
@@ -51,7 +102,7 @@ protected:
MockSqliteReadStatement &selectDirectoryIdFromDirectoriesByDirectoryPath = factory.selectDirectoryIdFromDirectoriesByDirectoryPath;
MockSqliteReadStatement &selectSourceIdFromSourcesByDirectoryIdAndSourceName = factory.selectSourceIdFromSourcesByDirectoryIdAndSourceName;
MockSqliteReadStatement &selectDirectoryPathFromDirectoriesByDirectoryId = factory.selectDirectoryPathFromDirectoriesByDirectoryId;
- MockSqliteReadStatement &selectSourceNameFromSourcesBySourceId = factory.selectSourceNameFromSourcesBySourceId;
+ MockSqliteReadStatement &selectSourceNameAndDirectoryIdFromSourcesBySourceId = factory.selectSourceNameAndDirectoryIdFromSourcesBySourceId;
MockSqliteReadStatement &selectAllDirectories = factory.selectAllDirectories;
MockSqliteWriteStatement &insertIntoDirectories = factory.insertIntoDirectories;
MockSqliteWriteStatement &insertIntoSources = factory.insertIntoSources;
@@ -397,22 +448,23 @@ TEST_F(FilePathStorage, ThrowAsFetchingDirectoryPathForNonExistingId)
TEST_F(FilePathStorage, CallValueForFetchSoureNameForId)
{
EXPECT_CALL(mockDatabase, deferredBegin());
- EXPECT_CALL(selectSourceNameFromSourcesBySourceId, valueReturnSmallString(42));
+ EXPECT_CALL(selectSourceNameAndDirectoryIdFromSourcesBySourceId, valueReturnSourceNameAndDirectoryId(42));
EXPECT_CALL(mockDatabase, commit());
- storage.fetchSourceName(42);
+ storage.fetchSourceNameAndDirectoryId(42);
}
TEST_F(FilePathStorage, FetchSoureNameForId)
{
- auto path = storage.fetchSourceName(42);
+ auto entry = storage.fetchSourceNameAndDirectoryId(42);
- ASSERT_THAT(path, Eq("file.cpp"));
+ ASSERT_THAT(entry.sourceName, Eq("file.cpp"));
+ ASSERT_THAT(entry.directoryId, 5);
}
TEST_F(FilePathStorage, ThrowAsFetchingSourceNameForNonExistingId)
{
- ASSERT_THROW(storage.fetchSourceName(12), ClangBackEnd::SourceNameIdDoesNotExists);
+ ASSERT_THROW(storage.fetchSourceNameAndDirectoryId(12), ClangBackEnd::SourceNameIdDoesNotExists);
}
TEST_F(FilePathStorage, RestartFetchSourceNameIfTheDatabaseIsBusyInBegin)
@@ -425,11 +477,11 @@ TEST_F(FilePathStorage, RestartFetchSourceNameIfTheDatabaseIsBusyInBegin)
EXPECT_CALL(mockDatabase, unlock());
EXPECT_CALL(mockDatabase, lock());
EXPECT_CALL(mockDatabase, deferredBegin());
- EXPECT_CALL(selectSourceNameFromSourcesBySourceId, valueReturnSmallString(42));
+ EXPECT_CALL(selectSourceNameAndDirectoryIdFromSourcesBySourceId, valueReturnSourceNameAndDirectoryId(42));
EXPECT_CALL(mockDatabase, commit());
EXPECT_CALL(mockDatabase, unlock());
- storage.fetchSourceName(42);
+ storage.fetchSourceNameAndDirectoryId(42);
}
TEST_F(FilePathStorage, RestartFetchDirectoryPathIfTheDatabaseIsBusyInBegin)
@@ -483,56 +535,4 @@ TEST_F(FilePathStorage, RestartFetchAllSourcesIfBeginIsBusy)
storage.fetchAllSources();
}
-void FilePathStorage::SetUp()
-{
- ON_CALL(selectDirectoryIdFromDirectoriesByDirectoryPath,
- valueReturnInt32(_))
- .WillByDefault(Return(Utils::optional<int>()));
- ON_CALL(selectDirectoryIdFromDirectoriesByDirectoryPath,
- valueReturnInt32(Utils::SmallStringView("")))
- .WillByDefault(Return(Utils::optional<int>(0)));
- ON_CALL(selectDirectoryIdFromDirectoriesByDirectoryPath,
- valueReturnInt32(Utils::SmallStringView("/path/to")))
- .WillByDefault(Return(Utils::optional<int>(5)));
- ON_CALL(mockDatabase, lastInsertedRowId())
- .WillByDefault(Return(12));
- ON_CALL(selectAllDirectories,
- valuesReturnStdVectorDirectory(_))
- .WillByDefault(Return(std::vector<Directory>{{1, "/path/to"}, {2, "/other/path"}}));
- ON_CALL(selectSourceIdFromSourcesByDirectoryIdAndSourceName,
- valueReturnInt32(_, _))
- .WillByDefault(Return(Utils::optional<int>()));
- ON_CALL(selectSourceIdFromSourcesByDirectoryIdAndSourceName,
- valueReturnInt32(0, Utils::SmallStringView("")))
- .WillByDefault(Return(Utils::optional<int>(0)));
- ON_CALL(selectSourceIdFromSourcesByDirectoryIdAndSourceName,
- valueReturnInt32(5, Utils::SmallStringView("file.h")))
- .WillByDefault(Return(Utils::optional<int>(42)));
- ON_CALL(selectAllSources,
- valuesReturnStdVectorSource(_))
- .WillByDefault(Return(std::vector<Source>{{1, "file.h"}, {4, "file.cpp"}}));
- ON_CALL(selectDirectoryPathFromDirectoriesByDirectoryId,
- valueReturnPathString(5))
- .WillByDefault(Return(Utils::optional<Utils::PathString>("/path/to")));
- ON_CALL(selectSourceNameFromSourcesBySourceId,
- valueReturnSmallString(42))
- .WillByDefault(Return(Utils::optional<Utils::SmallString>("file.cpp")));
-
- EXPECT_CALL(selectDirectoryIdFromDirectoriesByDirectoryPath, valueReturnInt32(_))
- .Times(AnyNumber());
- EXPECT_CALL(selectSourceIdFromSourcesByDirectoryIdAndSourceName, valueReturnInt32(_, _))
- .Times(AnyNumber());
- EXPECT_CALL(insertIntoDirectories, write(An<Utils::SmallStringView>()))
- .Times(AnyNumber());
- EXPECT_CALL(insertIntoSources, write(An<uint>(), A<Utils::SmallStringView>()))
- .Times(AnyNumber());
- EXPECT_CALL(selectAllDirectories, valuesReturnStdVectorDirectory(_))
- .Times(AnyNumber());
- EXPECT_CALL(selectAllSources, valuesReturnStdVectorSource(_))
- .Times(AnyNumber());
- EXPECT_CALL(selectDirectoryPathFromDirectoriesByDirectoryId, valueReturnPathString(_))
- .Times(AnyNumber());
- EXPECT_CALL(selectSourceNameFromSourcesBySourceId, valueReturnSmallString(_))
- .Times(AnyNumber());
-}
}
diff --git a/tests/unit/unittest/filepathstoragesqlitestatementfactory-test.cpp b/tests/unit/unittest/filepathstoragesqlitestatementfactory-test.cpp
index 92ddc10a4a..ac902fa700 100644
--- a/tests/unit/unittest/filepathstoragesqlitestatementfactory-test.cpp
+++ b/tests/unit/unittest/filepathstoragesqlitestatementfactory-test.cpp
@@ -63,8 +63,8 @@ TEST_F(FilePathStorageSqliteStatementFactory, SelectSourceIdFromSourcesByDirecto
TEST_F(FilePathStorageSqliteStatementFactory, SelectSourceNameFromSourcesByDirectoryIdAndSourceId)
{
- ASSERT_THAT(factory.selectSourceNameFromSourcesBySourceId.sqlStatement,
- Eq("SELECT sourceName FROM sources WHERE sourceId = ?"));
+ ASSERT_THAT(factory.selectSourceNameAndDirectoryIdFromSourcesBySourceId.sqlStatement,
+ Eq("SELECT sourceName, directoryId FROM sources WHERE sourceId = ?"));
}
TEST_F(FilePathStorageSqliteStatementFactory, SelectAllDirectories)
diff --git a/tests/unit/unittest/gtest-creator-printing.cpp b/tests/unit/unittest/gtest-creator-printing.cpp
index 33bfe0de58..186858dc86 100644
--- a/tests/unit/unittest/gtest-creator-printing.cpp
+++ b/tests/unit/unittest/gtest-creator-printing.cpp
@@ -171,7 +171,7 @@ namespace ClangBackEnd {
std::ostream &operator<<(std::ostream &out, const FilePathId &id)
{
- return out << "(" << id.directoryId << ", " << id.filePathId << ")";
+ return out << "(" << id.filePathId << ")";
}
std::ostream &operator<<(std::ostream &out, const FilePathView &filePathView)
@@ -1086,8 +1086,8 @@ std::ostream &operator<<(std::ostream &out, const ProjectPartContainer &containe
std::ostream &operator<<(std::ostream &os, const SourceLocationContainer &container)
{
- os << "(("
- << container.filePathId.directoryId << ", " << container.filePathId.filePathId << "), "
+ os << "("
+ << container.filePathId.filePathId << ", "
<< container.line << ", "
<< container.column << ", "
<< container.offset
diff --git a/tests/unit/unittest/locatorfilter-test.cpp b/tests/unit/unittest/locatorfilter-test.cpp
index 00bdbbd1ae..1cc15b281c 100644
--- a/tests/unit/unittest/locatorfilter-test.cpp
+++ b/tests/unit/unittest/locatorfilter-test.cpp
@@ -69,7 +69,7 @@ protected:
int length = 0;
QString newText;
Utils::LineColumn lineColumn{4, 3};
- ClangBackEnd::FilePathId filePathId{42, 64};
+ ClangBackEnd::FilePathId filePathId{64};
ClangRefactoring::SourceLocation sourceLocation{filePathId, lineColumn};
};
diff --git a/tests/unit/unittest/mockfilepathstorage.h b/tests/unit/unittest/mockfilepathstorage.h
index b1114747b1..7056ee2480 100644
--- a/tests/unit/unittest/mockfilepathstorage.h
+++ b/tests/unit/unittest/mockfilepathstorage.h
@@ -27,6 +27,8 @@
#include "googletest.h"
+#include <filepathstoragesources.h>
+
class MockFilePathStorage
{
public:
@@ -36,7 +38,7 @@ public:
int (int directoryId, Utils::SmallStringView sourceName));
MOCK_METHOD1(fetchDirectoryPath,
Utils::PathString (int directoryId));
- MOCK_METHOD1(fetchSourceName,
- Utils::SmallString (int sourceId));
+ MOCK_METHOD1(fetchSourceNameAndDirectoryId,
+ ClangBackEnd::Sources::SourceNameAndDirectoryId (int sourceId));
};
diff --git a/tests/unit/unittest/mocksqlitereadstatement.cpp b/tests/unit/unittest/mocksqlitereadstatement.cpp
index eb114e3a47..a002fea177 100644
--- a/tests/unit/unittest/mocksqlitereadstatement.cpp
+++ b/tests/unit/unittest/mocksqlitereadstatement.cpp
@@ -27,7 +27,7 @@
template <>
SourceLocations
-MockSqliteReadStatement::values<SourceLocation, 4>(std::size_t reserveSize,
+MockSqliteReadStatement::values<SourceLocation, 3>(std::size_t reserveSize,
const int &sourceId,
const int &line,
const int &column)
@@ -158,7 +158,21 @@ MockSqliteReadStatement::value<Utils::SmallString>(const int &sourceId)
template <>
Utils::optional<SourceLocation>
-MockSqliteReadStatement::value<SourceLocation, 4>(const long long &symbolId, const int &locationKind)
+MockSqliteReadStatement::value<SourceLocation, 3>(const long long &symbolId, const int &locationKind)
{
return valueReturnSourceLocation(symbolId, locationKind);
}
+
+template <>
+SourceEntries
+MockSqliteReadStatement::values<SourceEntry, 3>(std::size_t reserveSize, const int &filePathId, const int &projectPartId)
+{
+ return valuesReturnSourceEntries(reserveSize, filePathId, projectPartId);
+}
+
+template <>
+Utils::optional<Sources::SourceNameAndDirectoryId>
+MockSqliteReadStatement::value<Sources::SourceNameAndDirectoryId, 2>(const int &id)
+{
+ return valueReturnSourceNameAndDirectoryId(id);
+}
diff --git a/tests/unit/unittest/mocksqlitereadstatement.h b/tests/unit/unittest/mocksqlitereadstatement.h
index 2ad17ee07f..2d2b3320c4 100644
--- a/tests/unit/unittest/mocksqlitereadstatement.h
+++ b/tests/unit/unittest/mocksqlitereadstatement.h
@@ -33,6 +33,7 @@
#include <stringcachefwd.h>
#include <projectpartartefact.h>
#include <projectpartpch.h>
+#include <sourceentry.h>
#include <symbol.h>
#include <cpptools/usages.h>
@@ -45,6 +46,8 @@
#include <vector>
using std::int64_t;
+using ClangBackEnd::SourceEntry;
+using ClangBackEnd::SourceEntries;
using ClangRefactoring::SourceLocation;
using ClangRefactoring::SourceLocations;
namespace Sources = ClangBackEnd::Sources;
@@ -73,6 +76,9 @@ public:
MOCK_METHOD1(valuesReturnStdVectorSource,
std::vector<Sources::Source>(std::size_t));
+ MOCK_METHOD3(valuesReturnSourceEntries,
+ SourceEntries(std::size_t, int, int));
+
MOCK_METHOD1(valueReturnInt32,
Utils::optional<int>(Utils::SmallStringView));
@@ -88,6 +94,9 @@ public:
MOCK_METHOD1(valueReturnSmallString,
Utils::optional<Utils::SmallString>(int));
+ MOCK_METHOD1(valueReturnSourceNameAndDirectoryId,
+ Utils::optional<Sources::SourceNameAndDirectoryId>(int));
+
MOCK_METHOD1(valueReturnProjectPartArtefact,
Utils::optional<ClangBackEnd::ProjectPartArtefact>(int));
@@ -137,7 +146,7 @@ public:
template <>
SourceLocations
-MockSqliteReadStatement::values<SourceLocation, 4>(
+MockSqliteReadStatement::values<SourceLocation, 3>(
std::size_t reserveSize,
const int &sourceId,
const int &line,
@@ -219,4 +228,12 @@ MockSqliteReadStatement::value<Utils::SmallString>(const int&);
template <>
Utils::optional<SourceLocation>
-MockSqliteReadStatement::value<SourceLocation, 4>(const long long &symbolId, const int &locationKind);
+MockSqliteReadStatement::value<SourceLocation, 3>(const long long &symbolId, const int &locationKind);
+
+template <>
+SourceEntries
+MockSqliteReadStatement::values<SourceEntry, 3>(std::size_t reserveSize, const int&, const int&);
+
+template <>
+Utils::optional<Sources::SourceNameAndDirectoryId>
+MockSqliteReadStatement::value<Sources::SourceNameAndDirectoryId, 2>(const int&);
diff --git a/tests/unit/unittest/mocksqlitewritestatement.h b/tests/unit/unittest/mocksqlitewritestatement.h
index 05d2404d91..8da4db8ef5 100644
--- a/tests/unit/unittest/mocksqlitewritestatement.h
+++ b/tests/unit/unittest/mocksqlitewritestatement.h
@@ -99,5 +99,11 @@ public:
MOCK_METHOD2(write,
void (uint, uint));
+ MOCK_METHOD2(write,
+ void (uchar, int));
+
+ MOCK_METHOD2(write,
+ void (long long, int));
+
Utils::SmallString sqlStatement;
};
diff --git a/tests/unit/unittest/pchmanagerserver-test.cpp b/tests/unit/unittest/pchmanagerserver-test.cpp
index 731960c4ed..443d6a37b2 100644
--- a/tests/unit/unittest/pchmanagerserver-test.cpp
+++ b/tests/unit/unittest/pchmanagerserver-test.cpp
@@ -78,7 +78,7 @@ protected:
PathString main2Path = TESTDATA_DIR "/includecollector_main2.cpp";
PathString header1Path = TESTDATA_DIR "/includecollector_header1.h";
PathString header2Path = TESTDATA_DIR "/includecollector_header2.h";
- ClangBackEnd::IdPaths idPath{projectPartId1, {{1, 1}, {1, 2}}};
+ ClangBackEnd::IdPaths idPath{projectPartId1, {1, 2}};
ProjectPartContainer projectPart1{projectPartId1.clone(),
{"-I", TESTDATA_DIR, "-Wno-pragma-once-outside-header"},
{{"DEFINE", "1"}},
diff --git a/tests/unit/unittest/pchtaskgenerator-test.cpp b/tests/unit/unittest/pchtaskgenerator-test.cpp
index ac5ed89cef..248803cc4b 100644
--- a/tests/unit/unittest/pchtaskgenerator-test.cpp
+++ b/tests/unit/unittest/pchtaskgenerator-test.cpp
@@ -49,7 +49,7 @@ protected:
{"/yi"},
{{1, 1}},
{{1, 2}}};
- SourceEntries firstSources{{{1, 1}, SourceType::Any, 1}, {{1, 2}, SourceType::Any, 1}, {{1, 10}, SourceType::Any, 1}};
+ SourceEntries firstSources{{1, SourceType::Any, 1}, {2, SourceType::Any, 1}, {10, SourceType::Any, 1}};
BuildDependency buildDependency{firstSources, {}, {}, {}};
};
diff --git a/tests/unit/unittest/projectpartqueue-test.cpp b/tests/unit/unittest/projectpartqueue-test.cpp
index 3ab0430e39..5956636b15 100644
--- a/tests/unit/unittest/projectpartqueue-test.cpp
+++ b/tests/unit/unittest/projectpartqueue-test.cpp
@@ -45,26 +45,26 @@ protected:
{"--yi"},
{{"YI","1"}},
{"/yi"},
- {{1, 1}},
- {{1, 2}}};
+ {1},
+ {2}};
ClangBackEnd::V2::ProjectPartContainer projectPart2{"ProjectPart2",
{"--er"},
{{"ER","2"}},
{"/bar"},
- {{2, 1}},
- {{2, 2}}};
+ {1},
+ {2}};
ClangBackEnd::V2::ProjectPartContainer projectPart2b{"ProjectPart2",
{"--liang"},
{{"LIANG","3"}},
{"/liang"},
- {{2, 3}},
- {{2, 2}, {2, 4}}};
+ {3},
+ {2, 4}};
ClangBackEnd::V2::ProjectPartContainer projectPart3{"ProjectPart3",
{"--san"},
{{"SAN","2"}},
{"/SAN"},
- {{3, 1}},
- {{3, 2}}};
+ {1},
+ {2}};
};
TEST_F(ProjectPartQueue, AddProjectPart)
diff --git a/tests/unit/unittest/projectparts-test.cpp b/tests/unit/unittest/projectparts-test.cpp
index 74d1c86338..405b955fed 100644
--- a/tests/unit/unittest/projectparts-test.cpp
+++ b/tests/unit/unittest/projectparts-test.cpp
@@ -42,11 +42,11 @@ class ProjectParts : public testing::Test
{
protected:
ClangBackEnd::ProjectParts projectParts;
- FilePathId firstHeader{1, 1};
- FilePathId secondHeader{1, 2};
- FilePathId firstSource{1, 11};
- FilePathId secondSource{1, 12};
- FilePathId thirdSource{1, 13};
+ FilePathId firstHeader{1};
+ FilePathId secondHeader{2};
+ FilePathId firstSource{11};
+ FilePathId secondSource{12};
+ FilePathId thirdSource{13};
ProjectPartContainer projectPartContainer1{"id",
{"-DUNIX", "-O2"},
{{"DEFINE", "1"}},
diff --git a/tests/unit/unittest/refactoringclient-test.cpp b/tests/unit/unittest/refactoringclient-test.cpp
index 36ce039221..ed203a1ec0 100644
--- a/tests/unit/unittest/refactoringclient-test.cpp
+++ b/tests/unit/unittest/refactoringclient-test.cpp
@@ -85,10 +85,10 @@ protected:
CppTools::ProjectPart::Ptr projectPart;
CppTools::ProjectFile projectFile{qStringFilePath, CppTools::ProjectFile::CXXSource};
SourceLocationsForRenamingMessage renameMessage{"symbol",
- {{{{1, 42}, 1, 1, 0}, {{1, 42}, 2, 5, 10}}},
+ {{{42, 1, 1, 0}, {42, 2, 5, 10}}},
1};
- SourceRangesForQueryMessage queryResultMessage{{{{{1, 42}, 1, 1, 0, 1, 5, 4, ""},
- {{1, 42}, 2, 1, 5, 2, 5, 10, ""}}}};
+ SourceRangesForQueryMessage queryResultMessage{{{{42, 1, 1, 0, 1, 5, 4, ""},
+ {42, 2, 1, 5, 2, 5, 10, ""}}}};
SourceRangesForQueryMessage emptyQueryResultMessage;
};
@@ -212,7 +212,7 @@ TEST_F(RefactoringClient, ResultCounterIsZeroAfterSettingExpectedResultCount)
TEST_F(RefactoringClient, XXX)
{
const Core::Search::TextRange textRange{{1,0,1},{1,0,1}};
- const ClangBackEnd::SourceRangeWithTextContainer sourceRange{{1, 1}, 1, 1, 1, 1, 1, 1, "function"};
+ const ClangBackEnd::SourceRangeWithTextContainer sourceRange{1, 1, 1, 1, 1, 1, 1, "function"};
EXPECT_CALL(mockSearchHandle, addResult(QString("/path/to/file"), QString("function"), textRange))
.Times(1);
@@ -234,9 +234,9 @@ void RefactoringClient::SetUp()
client.setSearchHandle(&mockSearchHandle);
client.setExpectedResultCount(1);
- ON_CALL(mockFilePathCaching, filePath(Eq(FilePathId{1, 1})))
+ ON_CALL(mockFilePathCaching, filePath(Eq(FilePathId{1})))
.WillByDefault(Return(FilePath(PathString("/path/to/file"))));
- ON_CALL(mockFilePathCaching, filePath(Eq(FilePathId{1, 42})))
+ ON_CALL(mockFilePathCaching, filePath(Eq(FilePathId{42})))
.WillByDefault(Return(clangBackEndFilePath));
}
diff --git a/tests/unit/unittest/sourcerangeextractor-test.cpp b/tests/unit/unittest/sourcerangeextractor-test.cpp
index 5e4da1e31b..ae9d670bf4 100644
--- a/tests/unit/unittest/sourcerangeextractor-test.cpp
+++ b/tests/unit/unittest/sourcerangeextractor-test.cpp
@@ -74,7 +74,7 @@ using SourceRangeExtractorSlowTest = SourceRangeExtractor;
TEST_F(SourceRangeExtractorSlowTest, ExtractSourceRangeContainer)
{
- SourceRangeWithTextContainer sourceRangeContainer{{1, 1}, 1, 1, 0, 1, 10, 9, Utils::SmallString("int value;")};
+ SourceRangeWithTextContainer sourceRangeContainer{1, 1, 1, 0, 1, 10, 9, Utils::SmallString("int value;")};
extractor.addSourceRange(sourceRange);
diff --git a/tests/unit/unittest/sourcerangefilter-test.cpp b/tests/unit/unittest/sourcerangefilter-test.cpp
index d59bd033e1..4b84f4b5f8 100644
--- a/tests/unit/unittest/sourcerangefilter-test.cpp
+++ b/tests/unit/unittest/sourcerangefilter-test.cpp
@@ -42,19 +42,19 @@ protected:
protected:
- SourceRangeWithTextContainers sourceRanges1{{{1, 1}, 1, 1, 1, 2, 1, 4, "foo"},
- {{1, 1}, 1, 1, 1, 2, 2, 5, "foo"},
- {{1, 2}, 1, 1, 1, 2, 1, 4, "foo"}};
- SourceRangeWithTextContainers sourceRanges2{{{1, 3}, 1, 1, 1, 2, 1, 4, "foo"},
- {{1, 1}, 1, 1, 1, 2, 1, 4, "foo"},
- {{1, 1}, 1, 1, 1, 2, 3, 6, "foo"}};
- SourceRangeWithTextContainers sourceRanges3{{{1, 1}, 1, 1, 1, 2, 3, 6, "foo"},
- {{1, 3}, 1, 1, 1, 2, 1, 4, "foo"}};
- SourceRangeWithTextContainers sourceRanges4{{{1, 1}, 1, 1, 1, 2, 3, 6, "foo"},
- {{1, 3}, 1, 1, 1, 2, 1, 4, "foo"},
- {{1, 3}, 1, 1, 1, 2, 1, 4, "foo"}};
- SourceRangeWithTextContainers sourceRanges5{{{1, 3}, 1, 1, 1, 2, 1, 4, "foo"},
- {{1, 1}, 1, 1, 1, 2, 3, 6, "foo"}};
+ SourceRangeWithTextContainers sourceRanges1{{1, 1, 1, 1, 2, 1, 4, "foo"},
+ {1, 1, 1, 1, 2, 2, 5, "foo"},
+ {2, 1, 1, 1, 2, 1, 4, "foo"}};
+ SourceRangeWithTextContainers sourceRanges2{{3, 1, 1, 1, 2, 1, 4, "foo"},
+ {1, 1, 1, 1, 2, 1, 4, "foo"},
+ {1, 1, 1, 1, 2, 3, 6, "foo"}};
+ SourceRangeWithTextContainers sourceRanges3{{1, 1, 1, 1, 2, 3, 6, "foo"},
+ {3, 1, 1, 1, 2, 1, 4, "foo"}};
+ SourceRangeWithTextContainers sourceRanges4{{1, 1, 1, 1, 2, 3, 6, "foo"},
+ {3, 1, 1, 1, 2, 1, 4, "foo"},
+ {3, 1, 1, 1, 2, 1, 4, "foo"}};
+ SourceRangeWithTextContainers sourceRanges5{{3, 1, 1, 1, 2, 1, 4, "foo"},
+ {1, 1, 1, 1, 2, 3, 6, "foo"}};
SourceRangesForQueryMessage message1{{Utils::clone(sourceRanges1)}};
SourceRangesForQueryMessage message2{{Utils::clone(sourceRanges2)}};
ClangBackEnd::SourceRangeFilter filter{3};
diff --git a/tests/unit/unittest/sourcesmanager-test.cpp b/tests/unit/unittest/sourcesmanager-test.cpp
index 9c149dac6e..290139e7cf 100644
--- a/tests/unit/unittest/sourcesmanager-test.cpp
+++ b/tests/unit/unittest/sourcesmanager-test.cpp
@@ -37,103 +37,103 @@ protected:
TEST_F(SourcesManager, TouchFilePathIdFirstTime)
{
- ASSERT_FALSE(sources.alreadyParsed({1, 1}, 56));
+ ASSERT_FALSE(sources.alreadyParsed(1, 56));
}
TEST_F(SourcesManager, TouchFilePathIdTwoTimesWithSameTime)
{
- sources.alreadyParsed({1, 1}, 56);
+ sources.alreadyParsed(1, 56);
- ASSERT_FALSE(sources.alreadyParsed({1, 1}, 56));
+ ASSERT_FALSE(sources.alreadyParsed(1, 56));
}
TEST_F(SourcesManager, TouchFilePathIdSecondTimeWithSameTime)
{
- sources.alreadyParsed({1, 1}, 56);
+ sources.alreadyParsed(1, 56);
sources.updateModifiedTimeStamps();
- ASSERT_TRUE(sources.alreadyParsed({1, 1}, 56));
+ ASSERT_TRUE(sources.alreadyParsed(1, 56));
}
TEST_F(SourcesManager, TouchFilePathIdSecondTimeWithOlderTime)
{
- sources.alreadyParsed({1, 1}, 56);
+ sources.alreadyParsed(1, 56);
sources.updateModifiedTimeStamps();
- ASSERT_TRUE(sources.alreadyParsed({1, 1}, 55));
+ ASSERT_TRUE(sources.alreadyParsed(1, 55));
}
TEST_F(SourcesManager, TouchFilePathIdSecondTimeWithNewerTime)
{
- sources.alreadyParsed({1, 1}, 56);
+ sources.alreadyParsed(1, 56);
sources.updateModifiedTimeStamps();
- ASSERT_FALSE(sources.alreadyParsed({1, 1}, 57));
+ ASSERT_FALSE(sources.alreadyParsed(1, 57));
}
TEST_F(SourcesManager, MultipleFileIds)
{
- sources.alreadyParsed({1, 1}, 455);
- sources.alreadyParsed({1, 4}, 56);
- sources.alreadyParsed({1, 3}, 85);
- sources.alreadyParsed({1, 6}, 56);
- sources.alreadyParsed({1, 2}, 45);
+ sources.alreadyParsed(1, 455);
+ sources.alreadyParsed(4, 56);
+ sources.alreadyParsed(3, 85);
+ sources.alreadyParsed(6, 56);
+ sources.alreadyParsed(2, 45);
sources.updateModifiedTimeStamps();
- ASSERT_TRUE(sources.alreadyParsed({1, 3}, 85));
+ ASSERT_TRUE(sources.alreadyParsed(3, 85));
}
TEST_F(SourcesManager, UpdateModifiedTimeStampsWithNewerTimeStamp)
{
- sources.alreadyParsed({1, 1}, 455);
- sources.alreadyParsed({1, 4}, 56);
- sources.alreadyParsed({1, 3}, 85);
- sources.alreadyParsed({1, 6}, 56);
- sources.alreadyParsed({1, 2}, 45);
+ sources.alreadyParsed(1, 455);
+ sources.alreadyParsed(4, 56);
+ sources.alreadyParsed(3, 85);
+ sources.alreadyParsed(6, 56);
+ sources.alreadyParsed(2, 45);
sources.updateModifiedTimeStamps();
- sources.alreadyParsed({1, 3}, 86);
+ sources.alreadyParsed(3, 86);
sources.updateModifiedTimeStamps();
- ASSERT_TRUE(sources.alreadyParsed({1, 3}, 86));
+ ASSERT_TRUE(sources.alreadyParsed(3, 86));
}
TEST_F(SourcesManager, DontUpdateModifiedTimeStampsWithOlderTimeStamp)
{
- sources.alreadyParsed({1, 1}, 455);
- sources.alreadyParsed({1, 4}, 56);
- sources.alreadyParsed({1, 3}, 85);
- sources.alreadyParsed({1, 6}, 56);
- sources.alreadyParsed({1, 2}, 45);
+ sources.alreadyParsed(1, 455);
+ sources.alreadyParsed(4, 56);
+ sources.alreadyParsed(3, 85);
+ sources.alreadyParsed(6, 56);
+ sources.alreadyParsed(2, 45);
sources.updateModifiedTimeStamps();
- sources.alreadyParsed({1, 3}, 84);
+ sources.alreadyParsed(3, 84);
sources.updateModifiedTimeStamps();
- ASSERT_TRUE(sources.alreadyParsed({1, 3}, 85));
+ ASSERT_TRUE(sources.alreadyParsed(3, 85));
}
TEST_F(SourcesManager, ZeroTime)
{
- sources.alreadyParsed({1, 1}, 0);
+ sources.alreadyParsed(1, 0);
sources.updateModifiedTimeStamps();
- ASSERT_TRUE(sources.alreadyParsed({1, 1}, 0));
+ ASSERT_TRUE(sources.alreadyParsed(1, 0));
}
TEST_F(SourcesManager, TimeIsUpdated)
{
- sources.alreadyParsed({1, 1}, 56);
- sources.alreadyParsed({1, 1}, 57);
+ sources.alreadyParsed(1, 56);
+ sources.alreadyParsed(1, 57);
sources.updateModifiedTimeStamps();
- ASSERT_TRUE(sources.alreadyParsed({1, 1}, 57));
+ ASSERT_TRUE(sources.alreadyParsed(1, 57));
}
TEST_F(SourcesManager, AnyDependFileIsNotModifiedAfterInitialization)
@@ -143,22 +143,22 @@ TEST_F(SourcesManager, AnyDependFileIsNotModifiedAfterInitialization)
TEST_F(SourcesManager, AnyDependFileIsModified)
{
- sources.alreadyParsed({1, 1}, 56);
+ sources.alreadyParsed(1, 56);
ASSERT_TRUE(sources.dependentFilesModified());
}
TEST_F(SourcesManager, AnyDependFileIsModifiedAfterParsingTwoTimesSameTimeStamp)
{
- sources.alreadyParsed({1, 1}, 56);
- sources.alreadyParsed({1, 1}, 56);
+ sources.alreadyParsed(1, 56);
+ sources.alreadyParsed(1, 56);
ASSERT_TRUE(sources.dependentFilesModified());
}
TEST_F(SourcesManager, AnyDependFileIsNotModifiedAfterUpdate)
{
- sources.alreadyParsed({1, 1}, 56);
+ sources.alreadyParsed(1, 56);
sources.updateModifiedTimeStamps();
ASSERT_FALSE(sources.dependentFilesModified());
@@ -166,68 +166,68 @@ TEST_F(SourcesManager, AnyDependFileIsNotModifiedAfterUpdate)
TEST_F(SourcesManager, AnyDependFileIsNotModifiedAfterNotAlreadyPared)
{
- sources.alreadyParsed({1, 1}, 56);
+ sources.alreadyParsed(1, 56);
sources.updateModifiedTimeStamps();
- sources.alreadyParsed({1, 1}, 56);
+ sources.alreadyParsed(1, 56);
ASSERT_FALSE(sources.dependentFilesModified());
}
TEST_F(SourcesManager, AnyDependFileIsNotModifiedAfterAlreadyPared)
{
- sources.alreadyParsed({1, 1}, 56);
+ sources.alreadyParsed(1, 56);
sources.updateModifiedTimeStamps();
- sources.alreadyParsed({1, 1}, 57);
+ sources.alreadyParsed(1, 57);
ASSERT_TRUE(sources.dependentFilesModified());
}
TEST_F(SourcesManager, AnyDependFileIsModifiedAfterUpdateNewTimeStamp)
{
- sources.alreadyParsed({1, 1}, 56);
- sources.alreadyParsed({1, 2}, 56);
+ sources.alreadyParsed(1, 56);
+ sources.alreadyParsed(2, 56);
sources.updateModifiedTimeStamps();
- sources.alreadyParsed({1, 1}, 57);
+ sources.alreadyParsed(1, 57);
- sources.alreadyParsed({1, 2}, 56);
+ sources.alreadyParsed(2, 56);
ASSERT_TRUE(sources.dependentFilesModified());
}
TEST_F(SourcesManager, AlreadyParsedWithDependencyAfterUpdateNewTimeStamp)
{
- sources.alreadyParsedAllDependentFiles({1, 1}, 56);
- sources.alreadyParsedAllDependentFiles({1, 2}, 56);
+ sources.alreadyParsedAllDependentFiles(1, 56);
+ sources.alreadyParsedAllDependentFiles(2, 56);
sources.updateModifiedTimeStamps();
- sources.alreadyParsedAllDependentFiles({1, 1}, 57);
+ sources.alreadyParsedAllDependentFiles(1, 57);
- bool alreadyParsed = sources.alreadyParsedAllDependentFiles({1, 2}, 56);
+ bool alreadyParsed = sources.alreadyParsedAllDependentFiles(2, 56);
ASSERT_FALSE(alreadyParsed);
}
TEST_F(SourcesManager, AlreadyParsedWithDependencyAfterUpdateNewSecondTimeStamp)
{
- sources.alreadyParsedAllDependentFiles({1, 1}, 56);
- sources.alreadyParsedAllDependentFiles({1, 2}, 56);
+ sources.alreadyParsedAllDependentFiles(1, 56);
+ sources.alreadyParsedAllDependentFiles(2, 56);
sources.updateModifiedTimeStamps();
- sources.alreadyParsedAllDependentFiles({1, 1}, 56);
+ sources.alreadyParsedAllDependentFiles(1, 56);
- bool alreadyParsed = sources.alreadyParsedAllDependentFiles({1, 2}, 57);
+ bool alreadyParsed = sources.alreadyParsedAllDependentFiles(2, 57);
ASSERT_FALSE(alreadyParsed);
}
TEST_F(SourcesManager, AlreadyParsedWithDependencyAfterUpdateSameTimeStamps)
{
- sources.alreadyParsedAllDependentFiles({1, 1}, 56);
- sources.alreadyParsedAllDependentFiles({1, 2}, 56);
+ sources.alreadyParsedAllDependentFiles(1, 56);
+ sources.alreadyParsedAllDependentFiles(2, 56);
sources.updateModifiedTimeStamps();
- sources.alreadyParsedAllDependentFiles({1, 1}, 56);
+ sources.alreadyParsedAllDependentFiles(1, 56);
- bool alreadyParsed = sources.alreadyParsedAllDependentFiles({1, 2}, 56);
+ bool alreadyParsed = sources.alreadyParsedAllDependentFiles(2, 56);
ASSERT_TRUE(alreadyParsed);
}
diff --git a/tests/unit/unittest/symbolindexer-test.cpp b/tests/unit/unittest/symbolindexer-test.cpp
index 4acf0a6a71..8b5e3e91c1 100644
--- a/tests/unit/unittest/symbolindexer-test.cpp
+++ b/tests/unit/unittest/symbolindexer-test.cpp
@@ -71,11 +71,11 @@ using ClangBackEnd::SourceLocationKind;
using ClangBackEnd::UsedMacros;
using OptionalProjectPartArtefact = Utils::optional<ClangBackEnd::ProjectPartArtefact>;
-MATCHER_P2(IsFileId, directoryId, fileNameId,
+MATCHER_P(IsFileId, fileNameId,
std::string(negation ? "isn't " : "is ")
- + PrintToString(ClangBackEnd::FilePathId(directoryId, fileNameId)))
+ + PrintToString(ClangBackEnd::FilePathId(fileNameId)))
{
- return arg == ClangBackEnd::FilePathId(directoryId, fileNameId);
+ return arg == ClangBackEnd::FilePathId(fileNameId);
}
struct Data
@@ -163,7 +163,7 @@ protected:
ClangBackEnd::FilePathId header2PathId{filePathId(TESTDATA_DIR "/symbolindexer_header1.h")};
ClangBackEnd::FilePathId header1PathId{filePathId(TESTDATA_DIR "/symbolindexer_header2.h")};
PathString generatedFileName = "includecollector_generated_file.h";
- ClangBackEnd::FilePathId generatedFilePathId{1, 21};
+ ClangBackEnd::FilePathId generatedFilePathId21;
ProjectPartContainer projectPart1{"project1",
{"-I", TESTDATA_DIR, "-Wno-pragma-once-outside-header"},
{{"BAR", "1"}, {"FOO", "1"}},
@@ -186,11 +186,11 @@ protected:
"void f();",
{}}};
SymbolEntries symbolEntries{{1, {"function", "function", SymbolKind::Function}}};
- SourceLocationEntries sourceLocations{{1, {1, 1}, {42, 23}, SourceLocationKind::Declaration}};
- FilePathIds sourceFileIds{{1, 1}, {42, 23}};
- UsedMacros usedMacros{{"Foo", {1, 1}}};
- FileStatuses fileStatus{{{1, 2}, 3, 4, false}};
- SourceDependencies sourceDependencies{{{1, 1}, {1, 2}}, {{1, 1}, {1, 3}}};
+ SourceLocationEntries sourceLocations{{1, 1, {42, 23}, SourceLocationKind::Declaration}};
+ FilePathIds sourceFileIds{1, 23};
+ UsedMacros usedMacros{{"Foo", 1}};
+ FileStatuses fileStatus{{2, 3, 4, false}};
+ SourceDependencies sourceDependencies{{1, 2}, {1, 3}};
ClangBackEnd::ProjectPartArtefact artefact{"[\"-DFOO\"]", "{\"FOO\":\"1\",\"BAR\":\"1\"}", "[\"/includes\"]", 74};
ClangBackEnd::ProjectPartArtefact emptyArtefact{"", "", "", 74};
Utils::optional<ClangBackEnd::ProjectPartArtefact > nullArtefact;
@@ -338,7 +338,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsUpdateProjectPartSourcesWithoutArti
ON_CALL(mockSymbolStorage, fetchProjectPartArtefact(TypedEq<Utils::SmallStringView>("project2"))).WillByDefault(Return(nullArtefact));
ON_CALL(mockSymbolStorage, insertOrUpdateProjectPart(Eq("project2"), _, _, _)).WillByDefault(Return(3));
- EXPECT_CALL(mockSymbolStorage, updateProjectPartSources(3, ElementsAre(IsFileId(1, 1), IsFileId(42, 23))));
+ EXPECT_CALL(mockSymbolStorage, updateProjectPartSources(3, ElementsAre(IsFileId(1), IsFileId(23))));
indexer.updateProjectParts({projectPart2});
}
diff --git a/tests/unit/unittest/symbolindexertaskqueue-test.cpp b/tests/unit/unittest/symbolindexertaskqueue-test.cpp
index 545f19f5b3..7ead4d4dbf 100644
--- a/tests/unit/unittest/symbolindexertaskqueue-test.cpp
+++ b/tests/unit/unittest/symbolindexertaskqueue-test.cpp
@@ -56,82 +56,82 @@ protected:
TEST_F(SymbolIndexerTaskQueue, AddTasks)
{
- queue.addOrUpdateTasks({{{1, 2}, 1, Callable{}},
- {{1, 4}, 1, Callable{}}});
+ queue.addOrUpdateTasks({{2, 1, Callable{}},
+ {4, 1, Callable{}}});
- queue.addOrUpdateTasks({{{1, 1}, 1, Callable{}},
- {{1, 3}, 1, Callable{}},
- {{1, 5}, 1, Callable{}}});
+ queue.addOrUpdateTasks({{1, 1, Callable{}},
+ {3, 1, Callable{}},
+ {5, 1, Callable{}}});
ASSERT_THAT(queue.tasks(),
- ElementsAre(IsTask(FilePathId{1, 1}, 1),
- IsTask(FilePathId{1, 2}, 1),
- IsTask(FilePathId{1, 3}, 1),
- IsTask(FilePathId{1, 4}, 1),
- IsTask(FilePathId{1, 5}, 1)));
+ ElementsAre(IsTask(1, 1),
+ IsTask(2, 1),
+ IsTask(3, 1),
+ IsTask(4, 1),
+ IsTask(5, 1)));
}
TEST_F(SymbolIndexerTaskQueue, ReplaceTask)
{
- queue.addOrUpdateTasks({{{1, 1}, 1, Callable{}},
- {{1, 3}, 1, Callable{}},
- {{1, 5}, 1, Callable{}}});
+ queue.addOrUpdateTasks({{1, 1, Callable{}},
+ {3, 1, Callable{}},
+ {5, 1, Callable{}}});
- queue.addOrUpdateTasks({{{1, 2}, 1, Callable{}},
- {{1, 3}, 1, Callable{}}});
+ queue.addOrUpdateTasks({{2, 1, Callable{}},
+ {3, 1, Callable{}}});
ASSERT_THAT(queue.tasks(),
- ElementsAre(IsTask(FilePathId{1, 1}, 1),
- IsTask(FilePathId{1, 2}, 1),
- IsTask(FilePathId{1, 3}, 1),
- IsTask(FilePathId{1, 5}, 1)));
+ ElementsAre(IsTask(1, 1),
+ IsTask(2, 1),
+ IsTask(3, 1),
+ IsTask(5, 1)));
}
TEST_F(SymbolIndexerTaskQueue, AddTaskWithDifferentProjectId)
{
- queue.addOrUpdateTasks({{{1, 1}, 1, Callable{}},
- {{1, 3}, 1, Callable{}},
- {{1, 5}, 1, Callable{}}});
+ queue.addOrUpdateTasks({{1, 1, Callable{}},
+ {3, 1, Callable{}},
+ {5, 1, Callable{}}});
- queue.addOrUpdateTasks({{{1, 2}, 2, Callable{}},
- {{1, 3}, 2, Callable{}}});
+ queue.addOrUpdateTasks({{2, 2, Callable{}},
+ {3, 2, Callable{}}});
ASSERT_THAT(queue.tasks(),
- ElementsAre(IsTask(FilePathId{1, 1}, 1),
- IsTask(FilePathId{1, 2}, 2),
- IsTask(FilePathId{1, 3}, 1),
- IsTask(FilePathId{1, 3}, 2),
- IsTask(FilePathId{1, 5}, 1)));
+ ElementsAre(IsTask(1, 1),
+ IsTask(2, 2),
+ IsTask(3, 1),
+ IsTask(3, 2),
+ IsTask(5, 1)));
}
TEST_F(SymbolIndexerTaskQueue, RemoveTaskByProjectParts)
{
- queue.addOrUpdateTasks({{{1, 1}, 1, Callable{}},
- {{1, 3}, 1, Callable{}},
- {{1, 5}, 1, Callable{}}});
- queue.addOrUpdateTasks({{{1, 2}, 2, Callable{}},
- {{1, 3}, 2, Callable{}}});
- queue.addOrUpdateTasks({{{1, 2}, 3, Callable{}},
- {{1, 3}, 3, Callable{}}});
- queue.addOrUpdateTasks({{{1, 2}, 4, Callable{}},
- {{1, 3}, 4, Callable{}}});
+ queue.addOrUpdateTasks({{1, 1, Callable{}},
+ {3, 1, Callable{}},
+ {5, 1, Callable{}}});
+ queue.addOrUpdateTasks({{2, 2, Callable{}},
+ {3, 2, Callable{}}});
+ queue.addOrUpdateTasks({{2, 3, Callable{}},
+ {3, 3, Callable{}}});
+ queue.addOrUpdateTasks({{2, 4, Callable{}},
+ {3, 4, Callable{}}});
queue.removeTasks({2, 3});
ASSERT_THAT(queue.tasks(),
- ElementsAre(IsTask(FilePathId{1, 1}, 1),
- IsTask(FilePathId{1, 2}, 4),
- IsTask(FilePathId{1, 3}, 1),
- IsTask(FilePathId{1, 3}, 4),
- IsTask(FilePathId{1, 5}, 1)));
+ ElementsAre(IsTask(1, 1),
+ IsTask(2, 4),
+ IsTask(3, 1),
+ IsTask(3, 4),
+ IsTask(5, 1)));
}
TEST_F(SymbolIndexerTaskQueue, ProcessTasksCallsFreeSlotsAndAddTasksInScheduler)
{
InSequence s;
- queue.addOrUpdateTasks({{{1, 1}, 1, Callable{}},
- {{1, 3}, 1, Callable{}},
- {{1, 5}, 1, Callable{}}});
+ queue.addOrUpdateTasks({{1, 1, Callable{}},
+ {3, 1, Callable{}},
+ {5, 1, Callable{}}});
EXPECT_CALL(mockTaskScheduler, freeSlots()).WillRepeatedly(Return(2));
EXPECT_CALL(mockTaskScheduler, addTasks(SizeIs(2)));
@@ -152,9 +152,9 @@ TEST_F(SymbolIndexerTaskQueue, ProcessTasksCallsFreeSlotsAndAddTasksWithNoTaskIn
TEST_F(SymbolIndexerTaskQueue, ProcessTasksCallsFreeSlotsAndMoveAllTasksInSchedulerIfMoreSlotsAreFree)
{
InSequence s;
- queue.addOrUpdateTasks({{{1, 1}, 1, Callable{}},
- {{1, 3}, 1, Callable{}},
- {{1, 5}, 1, Callable{}}});
+ queue.addOrUpdateTasks({{1, 1, Callable{}},
+ {3, 1, Callable{}},
+ {5, 1, Callable{}}});
EXPECT_CALL(mockTaskScheduler, freeSlots()).WillRepeatedly(Return(4));
EXPECT_CALL(mockTaskScheduler, addTasks(SizeIs(3)));
@@ -164,9 +164,9 @@ TEST_F(SymbolIndexerTaskQueue, ProcessTasksCallsFreeSlotsAndMoveAllTasksInSchedu
TEST_F(SymbolIndexerTaskQueue, ProcessTasksRemovesProcessedTasks)
{
- queue.addOrUpdateTasks({{{1, 1}, 1, Callable{}},
- {{1, 3}, 1, Callable{}},
- {{1, 5}, 1, Callable{}}});
+ queue.addOrUpdateTasks({{1, 1, Callable{}},
+ {3, 1, Callable{}},
+ {5, 1, Callable{}}});
ON_CALL(mockTaskScheduler, freeSlots()).WillByDefault(Return(2));
queue.processEntries();
diff --git a/tests/unit/unittest/symbolquery-test.cpp b/tests/unit/unittest/symbolquery-test.cpp
index 53eb9d1c68..c13b96fabe 100644
--- a/tests/unit/unittest/symbolquery-test.cpp
+++ b/tests/unit/unittest/symbolquery-test.cpp
@@ -61,12 +61,12 @@ protected:
MockSqliteReadStatement &selectSymbolsForKindAndStartsWith2 = mockStatementFactory.selectSymbolsForKindAndStartsWith2;
MockSqliteReadStatement &selectSymbolsForKindAndStartsWith3 = mockStatementFactory.selectSymbolsForKindAndStartsWith3;
MockSqliteReadStatement &selectLocationOfSymbol = mockStatementFactory.selectLocationOfSymbol;
- SourceLocations locations{{{1, 1}, 1, 1},
- {{1, 1}, 2, 3},
- {{1, 2}, 1, 1},
- {{1, 2}, 3, 1},
- {{1, 4}, 1, 1},
- {{1, 4}, 1, 3}};
+ SourceLocations locations{{1, 1, 1},
+ {1, 2, 3},
+ {2, 1, 1},
+ {2, 3, 1},
+ {4, 1, 1},
+ {4, 1, 3}};
MockQuery query{mockStatementFactory};
};
@@ -96,28 +96,28 @@ TEST_F(SymbolQuery, LocationsAtCallsValues)
{
EXPECT_CALL(selectLocationsForSymbolLocation, valuesReturnSourceLocations(_, 42, 14, 7));
- query.locationsAt({1, 42}, 14, 7);
+ query.locationsAt(42, 14, 7);
}
TEST_F(SymbolQuerySlowTest, LocationsAt)
{
- auto locations = query.locationsAt({1, 2}, 4, 6);
+ auto locations = query.locationsAt(2, 4, 6);
ASSERT_THAT(locations,
- UnorderedElementsAre(SourceLocation({1, 1}, 2, 3),
- SourceLocation({1, 2}, 4, 6)));
+ UnorderedElementsAre(SourceLocation(1, 2, 3),
+ SourceLocation(2, 4, 6)));
}
TEST_F(SymbolQuery, SourceUsagesAtCallsValues)
{
EXPECT_CALL(selectSourceUsagesForSymbolLocation, valuesReturnSourceUsages(_, 42, 14, 7));
- query.sourceUsagesAt({1, 42}, 14, 7);
+ query.sourceUsagesAt(42, 14, 7);
}
TEST_F(SymbolQuerySlowTest, SourceUsagesAt)
{
- auto usages = query.sourceUsagesAt({1, 2}, 4, 6);
+ auto usages = query.sourceUsagesAt(2, 4, 6);
ASSERT_THAT(usages,
UnorderedElementsAre(CppTools::Usage("/path/to/filename.h", 2, 3),
@@ -190,7 +190,7 @@ TEST_F(SymbolQuerySlowTest, LocationForSymbolId)
{
auto location = query.locationForSymbolId(1, SourceLocationKind::Definition);
- ASSERT_THAT(location.value(), Eq(SourceLocation({1, 2}, {4, 6})));
+ ASSERT_THAT(location.value(), Eq(SourceLocation(2, {4, 6})));
}
}
diff --git a/tests/unit/unittest/symbolstorage-test.cpp b/tests/unit/unittest/symbolstorage-test.cpp
index 1b7e7383a6..9949f464f9 100644
--- a/tests/unit/unittest/symbolstorage-test.cpp
+++ b/tests/unit/unittest/symbolstorage-test.cpp
@@ -76,8 +76,8 @@ protected:
SymbolEntries symbolEntries{{1, {"functionUSR", "function", SymbolKind::Function}},
{2, {"function2USR", "function2", SymbolKind::Function}}};
- SourceLocationEntries sourceLocations{{1, {1, 3}, {42, 23}, SourceLocationKind::Declaration},
- {2, {1, 4}, {7, 11}, SourceLocationKind::Definition}};
+ SourceLocationEntries sourceLocations{{1, 3, {42, 23}, SourceLocationKind::Declaration},
+ {2, 4, {7, 11}, SourceLocationKind::Definition}};
ClangBackEnd::ProjectPartArtefact artefact{"[\"-DFOO\"]", "{\"FOO\":\"1\"}", "[\"/includes\"]", 74};
};
@@ -213,7 +213,7 @@ TEST_F(SymbolStorage, UpdateProjectPartSources)
EXPECT_CALL(insertProjectPartSourcesStatement, write(TypedEq<int>(42), TypedEq<int>(1)));
EXPECT_CALL(insertProjectPartSourcesStatement, write(TypedEq<int>(42), TypedEq<int>(2)));
- storage.updateProjectPartSources(42, {{1, 1}, {1, 2}});
+ storage.updateProjectPartSources(42, {1, 2});
}
TEST_F(SymbolStorage, FetchProjectPartArtefactBySourceIdCallsValueInStatement)
@@ -221,7 +221,7 @@ TEST_F(SymbolStorage, FetchProjectPartArtefactBySourceIdCallsValueInStatement)
EXPECT_CALL(getProjectPartArtefactsBySourceId, valueReturnProjectPartArtefact(1))
.WillRepeatedly(Return(artefact));
- storage.fetchProjectPartArtefact({2, 1});
+ storage.fetchProjectPartArtefact(1);
}
TEST_F(SymbolStorage, FetchProjectPartArtefactBySourceIdReturnArtefact)
@@ -229,7 +229,7 @@ TEST_F(SymbolStorage, FetchProjectPartArtefactBySourceIdReturnArtefact)
EXPECT_CALL(getProjectPartArtefactsBySourceId, valueReturnProjectPartArtefact(1))
.WillRepeatedly(Return(artefact));
- auto result = storage.fetchProjectPartArtefact({2, 1});
+ auto result = storage.fetchProjectPartArtefact(1);
ASSERT_THAT(result, Eq(artefact));
}
@@ -239,7 +239,7 @@ TEST_F(SymbolStorage, FetchProjectPartArtefactByProjectNameCallsValueInStatement
EXPECT_CALL(getProjectPartArtefactsBySourceId, valueReturnProjectPartArtefact(1))
.WillRepeatedly(Return(artefact));
- storage.fetchProjectPartArtefact({2, 1});
+ storage.fetchProjectPartArtefact(1);
}
TEST_F(SymbolStorage, FetchProjectPartArtefactByProjectNameReturnArtefact)
@@ -247,7 +247,7 @@ TEST_F(SymbolStorage, FetchProjectPartArtefactByProjectNameReturnArtefact)
EXPECT_CALL(getProjectPartArtefactsBySourceId, valueReturnProjectPartArtefact(1))
.WillRepeatedly(Return(artefact));
- auto result = storage.fetchProjectPartArtefact({2, 1});
+ auto result = storage.fetchProjectPartArtefact(1);
ASSERT_THAT(result, Eq(artefact));
}
diff --git a/tests/unit/unittest/usedmacroandsourcestorage-test.cpp b/tests/unit/unittest/usedmacroandsourcestorage-test.cpp
index d9acc7f123..3db5423b54 100644
--- a/tests/unit/unittest/usedmacroandsourcestorage-test.cpp
+++ b/tests/unit/unittest/usedmacroandsourcestorage-test.cpp
@@ -79,7 +79,7 @@ TEST_F(UsedMacroAndSourceStorage, InsertOrUpdateUsedMacros)
EXPECT_CALL(deleteOutdatedUsedMacrosStatement, execute());
EXPECT_CALL(deleteNewUsedMacrosTableStatement, execute());
- storage.insertOrUpdateUsedMacros({{"FOO", {1, 42}}, {"BAR", {1, 43}}});
+ storage.insertOrUpdateUsedMacros({{"FOO", 42}, {"BAR", 43}});
}
TEST_F(UsedMacroAndSourceStorage, InsertFileStatuses)
@@ -87,7 +87,7 @@ TEST_F(UsedMacroAndSourceStorage, InsertFileStatuses)
EXPECT_CALL(insertFileStatuses, write(TypedEq<int>(42), TypedEq<off_t>(1), TypedEq<time_t>(2), TypedEq<bool>(false)));
EXPECT_CALL(insertFileStatuses, write(TypedEq<int>(43), TypedEq<off_t>(4), TypedEq<time_t>(5), TypedEq<bool>(true)));
- storage.insertFileStatuses({{{1, 42}, 1, 2, false}, {{1, 43}, 4, 5, true}});
+ storage.insertFileStatuses({{42, 1, 2, false}, {43, 4, 5, true}});
}
TEST_F(UsedMacroAndSourceStorage, InsertOrUpdateSourceDependencies)
@@ -100,7 +100,7 @@ TEST_F(UsedMacroAndSourceStorage, InsertOrUpdateSourceDependencies)
EXPECT_CALL(deleteOutdatedSourceDependenciesStatement, execute());
EXPECT_CALL(deleteNewSourceDependenciesStatement, execute());
- storage.insertOrUpdateSourceDependencies({{{1, 42}, {1, 1}}, {{1, 42}, {1, 2}}});
+ storage.insertOrUpdateSourceDependencies({{42, 1}, {42, 2}});
}
TEST_F(UsedMacroAndSourceStorage, AddTablesInConstructor)
@@ -122,7 +122,7 @@ TEST_F(UsedMacroAndSourceStorage, FetchLowestLastModifiedTimeIfNoModificationTim
{
EXPECT_CALL(getLowestLastModifiedTimeOfDependencies, valueReturnInt64(Eq(1)));
- auto lowestLastModified = storage.fetchLowestLastModifiedTime({1, 1});
+ auto lowestLastModified = storage.fetchLowestLastModifiedTime(1);
ASSERT_THAT(lowestLastModified, Eq(0));
}
@@ -132,7 +132,7 @@ TEST_F(UsedMacroAndSourceStorage, FetchLowestLastModifiedTime)
EXPECT_CALL(getLowestLastModifiedTimeOfDependencies, valueReturnInt64(Eq(21)))
.WillRepeatedly(Return(12));
- auto lowestLastModified = storage.fetchLowestLastModifiedTime({1, 21});
+ auto lowestLastModified = storage.fetchLowestLastModifiedTime(21);
ASSERT_THAT(lowestLastModified, Eq(12));
}