//===--- TweakTesting.h - Test helpers for refactoring actions ---*- 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 // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_TWEAKS_TWEAKTESTING_H #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_TWEAKS_TWEAKTESTING_H #include "ParsedAST.h" #include "index/Index.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/Testing/Annotations/Annotations.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include <memory> #include <string> namespace clang { namespace clangd { // Fixture base for testing tweaks. Intended to be subclassed for each tweak. // // Usage: // TWEAK_TEST(ExpandDeducedType); // // TEST_F(ExpandDeducedTypeTest, ShortensTypes) { // Header = R"cpp( // namespace foo { template<typename> class X{}; } // using namespace foo; // )cpp"; // Context = Function; // EXPECT_THAT(apply("[[auto]] X = foo<int>();"), // "foo<int> X = foo<int();"); // EXPECT_AVAILABLE("^a^u^t^o^ X = foo<int>();"); // EXPECT_UNAVAILABLE("auto ^X^ = ^foo<int>();"); // } class TweakTest : public ::testing::Test { … }; MATCHER_P2(FileWithContents, FileName, Contents, "") { … } #define TWEAK_TEST(TweakID) … #define EXPECT_AVAILABLE_(MarkedCode, Available) … #define EXPECT_AVAILABLE(MarkedCode) … #define EXPECT_UNAVAILABLE(MarkedCode) … } // namespace clangd } // namespace clang #endif