From: Sam McCall Date: Mon, 19 Oct 2020 14:45:32 +0000 (+0200) Subject: [clangd] Add test for structured-binding completion. NFC X-Git-Tag: llvmorg-13-init~8877 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cf814fcd3939a705f8bdf67bcf54cbf821aa6f75;p=platform%2Fupstream%2Fllvm.git [clangd] Add test for structured-binding completion. NFC --- diff --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp index 510f358..15576ed 100644 --- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp +++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp @@ -2579,6 +2579,29 @@ TEST(CompletionTest, Lambda) { EXPECT_EQ(A.SnippetSuffix, "(${1:int a}, ${2:const double &b})"); } +TEST(CompletionTest, StructuredBinding) { + clangd::CodeCompleteOptions Opts = {}; + + auto Results = completions(R"cpp( + struct S { + using Float = float; + int x; + Float y; + }; + void function() { + const auto &[xxx, yyy] = S{}; + yyy^ + } + )cpp", + {}, Opts); + + ASSERT_EQ(Results.Completions.size(), 1u); + const auto &A = Results.Completions.front(); + EXPECT_EQ(A.Name, "yyy"); + EXPECT_EQ(A.Kind, CompletionItemKind::Variable); + EXPECT_EQ(A.ReturnType, "const Float"); +} + TEST(CompletionTest, ObjectiveCMethodNoArguments) { auto Results = completions(R"objc( @interface Foo