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 12 namespace clang { 13 namespace clangd { 14 namespace { 15 16 TWEAK_TEST(AnnotateHighlightings); 17 TEST_F(AnnotateHighlightingsTest,Test)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 38