clang-tools  9.0.0
ASTTests.cpp
Go to the documentation of this file.
1 //===-- ASTTests.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 "AST.h"
10 #include "gtest/gtest.h"
11 
12 namespace clang {
13 namespace clangd {
14 namespace {
15 
16 TEST(ExpandAutoType, ShortenNamespace) {
17  ASSERT_EQ("TestClass", shortenNamespace("TestClass", ""));
18 
19  ASSERT_EQ("TestClass", shortenNamespace(
20  "testnamespace::TestClass", "testnamespace"));
21 
22  ASSERT_EQ(
23  "namespace1::TestClass",
24  shortenNamespace("namespace1::TestClass", "namespace2"));
25 
26  ASSERT_EQ("TestClass",
27  shortenNamespace("testns1::testns2::TestClass",
28  "testns1::testns2"));
29 
30  ASSERT_EQ(
31  "testns2::TestClass",
32  shortenNamespace("testns1::testns2::TestClass", "testns1"));
33 
34  ASSERT_EQ("TestClass<testns1::OtherClass>",
36  "testns1::TestClass<testns1::OtherClass>", "testns1"));
37 }
38 
39 
40 } // namespace
41 } // namespace clangd
42 } // namespace clang
TEST(BackgroundQueueTest, Priority)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::string shortenNamespace(const llvm::StringRef OriginalName, const llvm::StringRef CurrentNamespace)
Try to shorten the OriginalName by removing namespaces from the left of the string that are redundant...
Definition: AST.cpp:172