2020-12-09 16:22:10 +01:00
|
|
|
//===-- AnnotateHighlightingsTests.cpp --------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "TweakTesting.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace clangd {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
TWEAK_TEST(AnnotateHighlightings);
|
|
|
|
|
|
|
|
TEST_F(AnnotateHighlightingsTest, Test) {
|
|
|
|
EXPECT_AVAILABLE("^vo^id^ ^f(^) {^}^"); // available everywhere.
|
|
|
|
EXPECT_AVAILABLE("[[int a; int b;]]");
|
2022-10-17 17:12:39 -04:00
|
|
|
EXPECT_EQ("void /* Function [decl] [def] [globalScope] */f() {}",
|
2021-01-29 23:18:34 +01:00
|
|
|
apply("void ^f() {}"));
|
2020-12-09 16:22:10 +01:00
|
|
|
|
2021-01-29 23:18:34 +01:00
|
|
|
EXPECT_EQ(apply("[[int f1(); const int x = f1();]]"),
|
|
|
|
"int /* Function [decl] [globalScope] */f1(); "
|
2022-10-17 17:12:39 -04:00
|
|
|
"const int /* Variable [decl] [def] [readonly] [fileScope] */x = "
|
2021-01-29 23:18:34 +01:00
|
|
|
"/* Function [globalScope] */f1();");
|
2020-12-09 16:22:10 +01:00
|
|
|
|
2021-01-27 09:47:17 +01:00
|
|
|
// Only the targeted range is annotated.
|
2020-12-09 16:22:10 +01:00
|
|
|
EXPECT_EQ(apply("void f1(); void f2() {^}"),
|
|
|
|
"void f1(); "
|
2022-10-17 17:12:39 -04:00
|
|
|
"void /* Function [decl] [def] [globalScope] */f2() {}");
|
2020-12-09 16:22:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
} // namespace clangd
|
|
|
|
} // namespace clang
|