48 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "TweakTesting.h"10#include "gmock/gmock-matchers.h"11#include "gmock/gmock.h"12#include "gtest/gtest.h"13 14namespace clang {15namespace clangd {16namespace {17 18TWEAK_TEST(ShowSelectionTree);19 20TEST_F(ShowSelectionTreeTest, Test) {21 EXPECT_AVAILABLE("^int f^oo() { re^turn 2 ^+ 2; }");22 EXPECT_AVAILABLE("/*c^omment*/ int foo() { return 2 ^ + 2; }");23 24 const char *Output = R"(message:25 TranslationUnitDecl 26 VarDecl int x = fcall(2 + 2)27 .CallExpr fcall(2 + 2)28 ImplicitCastExpr fcall29 .DeclRefExpr fcall30 .BinaryOperator 2 + 231 *IntegerLiteral 232)";33 EXPECT_EQ(apply("int fcall(int); int x = fca[[ll(2 +]]2);"), Output);34 35 Output = R"(message:36 TranslationUnitDecl 37 FunctionDecl void x()38 CompoundStmt { …39 ForStmt for (;;) …40 *BreakStmt break;41)";42 EXPECT_EQ(apply("void x() { for (;;) br^eak; }"), Output);43}44 45} // namespace46} // namespace clangd47} // namespace clang48