Skip to content

Commit e091335

Browse files
Tweak to test
1 parent 162b053 commit e091335

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ using ::testing::UnorderedElementsAre;
4545
// Helpers for matching call hierarchy data structures.
4646
MATCHER_P(withName, N, "") { return arg.name == N; }
4747
MATCHER_P(withDetail, N, "") { return arg.detail == N; }
48+
MATCHER_P(withFile, N, "") { return arg.uri.file() == N; }
4849
MATCHER_P(withSelectionRange, R, "") { return arg.selectionRange == R; }
4950

5051
template <class ItemMatcher>
@@ -387,10 +388,17 @@ TEST(CallHierarchy, MultiFileCpp) {
387388
bool IsDeclaration) {
388389
std::vector<CallHierarchyItem> Items =
389390
prepareCallHierarchy(AST, Pos, TUPath);
390-
ASSERT_THAT(Items, ElementsAre(withName("caller3")));
391+
ASSERT_THAT(
392+
Items,
393+
ElementsAre(AllOf(
394+
withName("caller3"),
395+
withFile(testPath(IsDeclaration ? "caller3.hh" : "caller3.cc")))));
391396
auto OutgoingLevel1 = outgoingCalls(Items[0], Index.get());
392397
ASSERT_THAT(
393398
OutgoingLevel1,
399+
// fromRanges are interpreted in the context of Items[0]'s file.
400+
// If that's the header, we can't get ranges from the implementation
401+
// file!
394402
ElementsAre(
395403
AllOf(to(AllOf(withName("caller1"), withDetail("nsa::caller1"))),
396404
IsDeclaration ? oFromRanges()

0 commit comments

Comments
 (0)