r270971 - [clang-format] moved unit tests related to replacements cleaner from FormatTest.cpp to CleanUpTest.cpp.

Eric Liu via cfe-commits cfe-commits at lists.llvm.org
Fri May 27 01:20:07 PDT 2016


Author: ioeric
Date: Fri May 27 03:20:02 2016
New Revision: 270971

URL: http://llvm.org/viewvc/llvm-project?rev=270971&view=rev
Log:
[clang-format] moved unit tests related to replacements cleaner from FormatTest.cpp to CleanUpTest.cpp.

Modified:
    cfe/trunk/unittests/Format/CleanupTest.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/unittests/Format/CleanupTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/CleanupTest.cpp?rev=270971&r1=270970&r2=270971&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/CleanupTest.cpp (original)
+++ cfe/trunk/unittests/Format/CleanupTest.cpp Fri May 27 03:20:02 2016
@@ -9,6 +9,7 @@
 
 #include "clang/Format/Format.h"
 
+#include "../Tooling/RewriterTestContext.h"
 #include "clang/Tooling/Core/Replacement.h"
 
 #include "gtest/gtest.h"
@@ -240,6 +241,46 @@ TEST_F(CleanupTest, CtorInitializerInNam
   EXPECT_EQ(Expected, Result);
 }
 
+class CleanUpReplacementsTest : public ::testing::Test {
+protected:
+  tooling::Replacement createReplacement(SourceLocation Start, unsigned Length,
+                                         llvm::StringRef ReplacementText) {
+    return tooling::Replacement(Context.Sources, Start, Length,
+                                ReplacementText);
+  }
+
+  RewriterTestContext Context;
+};
+
+TEST_F(CleanUpReplacementsTest, FixOnlyAffectedCodeAfterReplacements) {
+  std::string Code = "namespace A {\n"
+                     "namespace B {\n"
+                     "  int x;\n"
+                     "} // namespace B\n"
+                     "} // namespace A\n"
+                     "\n"
+                     "namespace C {\n"
+                     "namespace D { int i; }\n"
+                     "inline namespace E { namespace { int y; } }\n"
+                     "int x=     0;"
+                     "}";
+  std::string Expected = "\n\nnamespace C {\n"
+                         "namespace D { int i; }\n\n"
+                         "int x=     0;"
+                         "}";
+  FileID ID = Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement(Context.Sources,
+                                       Context.getLocation(ID, 3, 3), 6, ""));
+  Replaces.insert(tooling::Replacement(Context.Sources,
+                                       Context.getLocation(ID, 9, 34), 6, ""));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto FinalReplaces = formatReplacements(
+      Code, cleanupAroundReplacements(Code, Replaces, Style), Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=270971&r1=270970&r2=270971&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri May 27 03:20:02 2016
@@ -11537,35 +11537,6 @@ TEST_F(ReplacementTest, FormatCodeAfterR
                           Code, formatReplacements(Code, Replaces, Style)));
 }
 
-TEST_F(ReplacementTest, FixOnlyAffectedCodeAfterReplacements) {
-  std::string Code = "namespace A {\n"
-                     "namespace B {\n"
-                     "  int x;\n"
-                     "} // namespace B\n"
-                     "} // namespace A\n"
-                     "\n"
-                     "namespace C {\n"
-                     "namespace D { int i; }\n"
-                     "inline namespace E { namespace { int y; } }\n"
-                     "int x=     0;"
-                     "}";
-  std::string Expected = "\n\nnamespace C {\n"
-                         "namespace D { int i; }\n\n"
-                         "int x=     0;"
-                         "}";
-  FileID ID = Context.createInMemoryFile("fix.cpp", Code);
-  tooling::Replacements Replaces;
-  Replaces.insert(tooling::Replacement(
-      Context.Sources, Context.getLocation(ID, 3, 3), 6, ""));
-  Replaces.insert(tooling::Replacement(
-      Context.Sources, Context.getLocation(ID, 9, 34), 6, ""));
-
-  format::FormatStyle Style = format::getLLVMStyle();
-  auto FinalReplaces = formatReplacements(
-      Code, cleanupAroundReplacements(Code, Replaces, Style), Style);
-  EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
-}
-
 TEST_F(ReplacementTest, SortIncludesAfterReplacement) {
   std::string Code = "#include \"a.h\"\n"
                      "#include \"c.h\"\n"




More information about the cfe-commits mailing list