clang-tools 20.0.0git
ShowSelectionTreeTests.cpp
Go to the documentation of this file.
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 "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 fcall
29 .DeclRefExpr fcall
30 .BinaryOperator 2 + 2
31 *IntegerLiteral 2
32)";
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} // namespace
46} // namespace clangd
47} // namespace clang
std::string Output
Definition: TraceTests.cpp:159
#define TWEAK_TEST(TweakID)
Definition: TweakTesting.h:107
#define EXPECT_AVAILABLE(MarkedCode)
Definition: TweakTesting.h:123
TEST_F(BackgroundIndexTest, NoCrashOnErrorFile)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//