diff options
Diffstat (limited to 'clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp')
-rw-r--r-- | clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp b/clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp index 972f4efed51..8926d8849f6 100644 --- a/clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp +++ b/clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp @@ -30,45 +30,6 @@ using ::testing::ElementsAre; using ::testing::ElementsAreArray; using ::testing::AllOf; -TEST(ClangdUnitTest, GetBeginningOfIdentifier) { - std::string Preamble = R"cpp( -struct Bar { int func(); }; -#define MACRO(X) void f() { X; } -Bar* bar; - )cpp"; - // First ^ is the expected beginning, last is the search position. - for (std::string Text : std::vector<std::string>{ - "int ^f^oo();", // inside identifier - "int ^foo();", // beginning of identifier - "int ^foo^();", // end of identifier - "int foo(^);", // non-identifier - "^int foo();", // beginning of file (can't back up) - "int ^f0^0();", // after a digit (lexing at N-1 is wrong) - "int ^λλ^λ();", // UTF-8 handled properly when backing up - - // identifier in macro arg - "MACRO(bar->^func())", // beginning of identifier - "MACRO(bar->^fun^c())", // inside identifier - "MACRO(bar->^func^())", // end of identifier - "MACRO(^bar->func())", // begin identifier - "MACRO(^bar^->func())", // end identifier - "^MACRO(bar->func())", // beginning of macro name - "^MAC^RO(bar->func())", // inside macro name - "^MACRO^(bar->func())", // end of macro name - }) { - std::string WithPreamble = Preamble + Text; - Annotations TestCase(WithPreamble); - auto AST = TestTU::withCode(TestCase.code()).build(); - const auto &SourceMgr = AST.getSourceManager(); - SourceLocation Actual = getBeginningOfIdentifier( - AST, TestCase.points().back(), SourceMgr.getMainFileID()); - Position ActualPos = offsetToPosition( - TestCase.code(), - SourceMgr.getFileOffset(SourceMgr.getSpellingLoc(Actual))); - EXPECT_EQ(TestCase.points().front(), ActualPos) << Text; - } -} - MATCHER_P(DeclNamed, Name, "") { if (NamedDecl *ND = dyn_cast<NamedDecl>(arg)) if (ND->getName() == Name) |