From 60adfb83cda883d9fc1079c89d2feaa681a41b90 Mon Sep 17 00:00:00 2001 From: Kadir Cetinkaya Date: Wed, 15 Jan 2020 16:22:24 +0100 Subject: [PATCH] [clangd] Fix windows buildbots --- clang-tools-extra/clangd/unittests/HoverTests.cpp | 63 ++++++++++++++++------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp b/clang-tools-extra/clangd/unittests/HoverTests.cpp index 0898b31..d30c9bf 100644 --- a/clang-tools-extra/clangd/unittests/HoverTests.cpp +++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -1514,26 +1514,6 @@ TEST(Hover, All) { HI.Name = "cls > >"; HI.Documentation = "type of nested templates."; }}, - { - R"cpp(// sizeof expr - void foo() { - (void)[[size^of]](char); - })cpp", - [](HoverInfo &HI) { - HI.Name = "expression"; - HI.Type = "unsigned long"; - HI.Value = "1"; - }}, - { - R"cpp(// alignof expr - void foo() { - (void)[[align^of]](char); - })cpp", - [](HoverInfo &HI) { - HI.Name = "expression"; - HI.Type = "unsigned long"; - HI.Value = "1"; - }}, }; // Create a tiny index, so tests above can verify documentation is fetched. @@ -1794,6 +1774,49 @@ Value = val def)pt"); } + +TEST(Hover, ExprTests) { + struct { + const char *const Code; + const std::function ExpectedBuilder; + } Cases[] = { + { + R"cpp(// sizeof expr + void foo() { + (void)[[size^of]](char); + })cpp", + [](HoverInfo &HI) { + HI.Name = "expression"; + HI.Type = "unsigned long"; + HI.Value = "1"; + }}, + { + R"cpp(// alignof expr + void foo() { + (void)[[align^of]](char); + })cpp", + [](HoverInfo &HI) { + HI.Name = "expression"; + HI.Type = "unsigned long"; + HI.Value = "1"; + }}, + }; + for (const auto &C : Cases) { + Annotations T(C.Code); + TestTU TU = TestTU::withCode(T.code()); + auto AST = TU.build(); + for (const auto &D : AST.getDiagnostics()) + ADD_FAILURE() << D; + + auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr); + ASSERT_TRUE(H); + HoverInfo ExpectedHover; + C.ExpectedBuilder(ExpectedHover); + // We don't check for Type as it might differ on different platforms. + EXPECT_EQ(H->Name, ExpectedHover.Name); + EXPECT_EQ(H->Value, ExpectedHover.Value); + } +} } // namespace } // namespace clangd } // namespace clang -- 2.7.4