brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 0b92118 Raw
50 lines · cpp
1//===- clang-apply-replacements/ApplyReplacementsTest.cpp2//----------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#include "clang-apply-replacements/Tooling/ApplyReplacements.h"11#include "clang/Format/Format.h"12#include "gtest/gtest.h"13 14using namespace clang::replace;15using namespace llvm;16 17namespace clang {18namespace tooling {19 20static TUDiagnostics21makeTUDiagnostics(const std::string &MainSourceFile, StringRef DiagnosticName,22                  const DiagnosticMessage &Message,23                  const StringMap<Replacements> &Replacements,24                  StringRef BuildDirectory) {25  TUDiagnostics TUs;26  TUs.push_back(27      {MainSourceFile,28       {{DiagnosticName, Message, {}, Diagnostic::Warning, BuildDirectory}}});29  return TUs;30}31 32// Test to ensure diagnostics with no fixes, will be merged correctly33// before applying.34TEST(ApplyReplacementsTest, mergeDiagnosticsWithNoFixes) {35  DiagnosticOptions DiagOpts;36  DiagnosticsEngine Diagnostics(DiagnosticIDs::create(), DiagOpts);37  FileManager Files((FileSystemOptions()));38  SourceManager SM(Diagnostics, Files);39  TUReplacements TURs;40  TUDiagnostics TUs =41      makeTUDiagnostics("path/to/source.cpp", "diagnostic", {}, {}, "path/to");42  FileToChangesMap ReplacementsMap;43 44  EXPECT_TRUE(mergeAndDeduplicate(TURs, TUs, ReplacementsMap, SM));45  EXPECT_TRUE(ReplacementsMap.empty());46}47 48} // end namespace tooling49} // end namespace clang50