Skip to content

Commit cf814fc

Browse files
committed
[clangd] Add test for structured-binding completion. NFC
1 parent 87a2321 commit cf814fc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2579,6 +2579,29 @@ TEST(CompletionTest, Lambda) {
25792579
EXPECT_EQ(A.SnippetSuffix, "(${1:int a}, ${2:const double &b})");
25802580
}
25812581

2582+
TEST(CompletionTest, StructuredBinding) {
2583+
clangd::CodeCompleteOptions Opts = {};
2584+
2585+
auto Results = completions(R"cpp(
2586+
struct S {
2587+
using Float = float;
2588+
int x;
2589+
Float y;
2590+
};
2591+
void function() {
2592+
const auto &[xxx, yyy] = S{};
2593+
yyy^
2594+
}
2595+
)cpp",
2596+
{}, Opts);
2597+
2598+
ASSERT_EQ(Results.Completions.size(), 1u);
2599+
const auto &A = Results.Completions.front();
2600+
EXPECT_EQ(A.Name, "yyy");
2601+
EXPECT_EQ(A.Kind, CompletionItemKind::Variable);
2602+
EXPECT_EQ(A.ReturnType, "const Float");
2603+
}
2604+
25822605
TEST(CompletionTest, ObjectiveCMethodNoArguments) {
25832606
auto Results = completions(R"objc(
25842607
@interface Foo

0 commit comments

Comments
 (0)