1 //===-- ShowSelectionTreeTests.cpp ------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "TestTU.h" 10 #include "TweakTesting.h" 11 #include "gmock/gmock-matchers.h" 12 #include "gmock/gmock.h" 13 #include "gtest/gtest.h" 14 15 namespace clang { 16 namespace clangd { 17 namespace { 18 19 TWEAK_TEST(ShowSelectionTree); 20 TEST_F(ShowSelectionTreeTest,Test)21TEST_F(ShowSelectionTreeTest, Test) { 22 EXPECT_AVAILABLE("^int f^oo() { re^turn 2 ^+ 2; }"); 23 EXPECT_AVAILABLE("/*c^omment*/ int foo() { return 2 ^ + 2; }"); 24 25 const char *Output = R"(message: 26 TranslationUnitDecl 27 VarDecl int x = fcall(2 + 2) 28 .CallExpr fcall(2 + 2) 29 ImplicitCastExpr fcall 30 .DeclRefExpr fcall 31 .BinaryOperator 2 + 2 32 *IntegerLiteral 2 33 )"; 34 EXPECT_EQ(apply("int fcall(int); int x = fca[[ll(2 +]]2);"), Output); 35 36 Output = R"(message: 37 TranslationUnitDecl 38 FunctionDecl void x() 39 CompoundStmt { … 40 ForStmt for (;;) … 41 *BreakStmt break; 42 )"; 43 EXPECT_EQ(apply("void x() { for (;;) br^eak; }"), Output); 44 } 45 46 } // namespace 47 } // namespace clangd 48 } // namespace clang 49