Skip to content

Commit a27142b

Browse files
committed
[clangd] Fix windows buildbots
(cherry picked from commit 60adfb8)
1 parent 13553d5 commit a27142b

File tree

1 file changed

+43
-20
lines changed

1 file changed

+43
-20
lines changed

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

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,26 +1514,6 @@ TEST(Hover, All) {
15141514
HI.Name = "cls<cls<cls<int> > >";
15151515
HI.Documentation = "type of nested templates.";
15161516
}},
1517-
{
1518-
R"cpp(// sizeof expr
1519-
void foo() {
1520-
(void)[[size^of]](char);
1521-
})cpp",
1522-
[](HoverInfo &HI) {
1523-
HI.Name = "expression";
1524-
HI.Type = "unsigned long";
1525-
HI.Value = "1";
1526-
}},
1527-
{
1528-
R"cpp(// alignof expr
1529-
void foo() {
1530-
(void)[[align^of]](char);
1531-
})cpp",
1532-
[](HoverInfo &HI) {
1533-
HI.Name = "expression";
1534-
HI.Type = "unsigned long";
1535-
HI.Value = "1";
1536-
}},
15371517
};
15381518

15391519
// Create a tiny index, so tests above can verify documentation is fetched.
@@ -1794,6 +1774,49 @@ Value = val
17941774
17951775
def)pt");
17961776
}
1777+
1778+
TEST(Hover, ExprTests) {
1779+
struct {
1780+
const char *const Code;
1781+
const std::function<void(HoverInfo &)> ExpectedBuilder;
1782+
} Cases[] = {
1783+
{
1784+
R"cpp(// sizeof expr
1785+
void foo() {
1786+
(void)[[size^of]](char);
1787+
})cpp",
1788+
[](HoverInfo &HI) {
1789+
HI.Name = "expression";
1790+
HI.Type = "unsigned long";
1791+
HI.Value = "1";
1792+
}},
1793+
{
1794+
R"cpp(// alignof expr
1795+
void foo() {
1796+
(void)[[align^of]](char);
1797+
})cpp",
1798+
[](HoverInfo &HI) {
1799+
HI.Name = "expression";
1800+
HI.Type = "unsigned long";
1801+
HI.Value = "1";
1802+
}},
1803+
};
1804+
for (const auto &C : Cases) {
1805+
Annotations T(C.Code);
1806+
TestTU TU = TestTU::withCode(T.code());
1807+
auto AST = TU.build();
1808+
for (const auto &D : AST.getDiagnostics())
1809+
ADD_FAILURE() << D;
1810+
1811+
auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
1812+
ASSERT_TRUE(H);
1813+
HoverInfo ExpectedHover;
1814+
C.ExpectedBuilder(ExpectedHover);
1815+
// We don't check for Type as it might differ on different platforms.
1816+
EXPECT_EQ(H->Name, ExpectedHover.Name);
1817+
EXPECT_EQ(H->Value, ExpectedHover.Value);
1818+
}
1819+
}
17971820
} // namespace
17981821
} // namespace clangd
17991822
} // namespace clang

0 commit comments

Comments
 (0)