clang-tools 20.0.0git
AnnotateHighlightingsTests.cpp
Go to the documentation of this file.
1//===-- AnnotateHighlightingsTests.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 "gtest/gtest.h"
11
12namespace clang {
13namespace clangd {
14namespace {
15
16TWEAK_TEST(AnnotateHighlightings);
17
18TEST_F(AnnotateHighlightingsTest, Test) {
19 EXPECT_AVAILABLE("^vo^id^ ^f(^) {^}^"); // available everywhere.
20 EXPECT_AVAILABLE("[[int a; int b;]]");
21 EXPECT_EQ("void /* Function [decl] [def] [globalScope] */f() {}",
22 apply("void ^f() {}"));
23
24 EXPECT_EQ(apply("[[int f1(); const int x = f1();]]"),
25 "int /* Function [decl] [globalScope] */f1(); "
26 "const int /* Variable [decl] [def] [readonly] [fileScope] */x = "
27 "/* Function [globalScope] */f1();");
28
29 // Only the targeted range is annotated.
30 EXPECT_EQ(apply("void f1(); void f2() {^}"),
31 "void f1(); "
32 "void /* Function [decl] [def] [globalScope] */f2() {}");
33}
34
35} // namespace
36} // namespace clangd
37} // namespace clang
#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++ -*-===//