summaryrefslogtreecommitdiff
path: root/unittests/Format/FormatTestSelective.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-07-23 20:44:14 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-07-23 20:44:14 +0000
commit2b6b257f4e5503a7a2675bdb8735693db769f75c (patch)
treee85e046ae7003fe3bcc8b5454cd0fa3f7407b470 /unittests/Format/FormatTestSelective.cpp
parentb4348ed0b7e90c0831b925fbee00b5f179a99796 (diff)
Notes
Diffstat (limited to 'unittests/Format/FormatTestSelective.cpp')
-rw-r--r--unittests/Format/FormatTestSelective.cpp37
1 files changed, 33 insertions, 4 deletions
diff --git a/unittests/Format/FormatTestSelective.cpp b/unittests/Format/FormatTestSelective.cpp
index 699600c42d9fe..2bc60fd1e0d33 100644
--- a/unittests/Format/FormatTestSelective.cpp
+++ b/unittests/Format/FormatTestSelective.cpp
@@ -28,10 +28,10 @@ protected:
tooling::Replacements Replaces =
reformat(Style, Code, Ranges, "<stdin>", &IncompleteFormat);
EXPECT_FALSE(IncompleteFormat) << Code << "\n\n";
- std::string Result = applyAllReplacements(Code, Replaces);
- EXPECT_NE("", Result);
- DEBUG(llvm::errs() << "\n" << Result << "\n\n");
- return Result;
+ auto Result = applyAllReplacements(Code, Replaces);
+ EXPECT_TRUE(static_cast<bool>(Result));
+ DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
+ return *Result;
}
FormatStyle Style = getLLVMStyle();
@@ -278,6 +278,23 @@ TEST_F(FormatTestSelective, IndividualStatementsOfNestedBlocks) {
" };\n"
"});",
0, 0));
+ EXPECT_EQ("SomeFunction(\n"
+ " [] {\n"
+ " int i;\n"
+ " return i;\n" // Format this line.
+ " },\n"
+ " [] {\n"
+ " return 2;\n" // Don't fix this.
+ " });",
+ format("SomeFunction(\n"
+ " [] {\n"
+ " int i;\n"
+ " return i;\n" // Format this line.
+ " },\n"
+ " [] {\n"
+ " return 2;\n" // Don't fix this.
+ " });",
+ 40, 0));
}
TEST_F(FormatTestSelective, WrongIndent) {
@@ -495,6 +512,18 @@ TEST_F(FormatTestSelective, StopFormattingWhenLeavingScope) {
15, 0));
}
+TEST_F(FormatTestSelective, SelectivelyRequoteJavaScript) {
+ Style = getGoogleStyle(FormatStyle::LK_JavaScript);
+ EXPECT_EQ(
+ "var x = \"a\";\n"
+ "var x = 'a';\n"
+ "var x = \"a\";",
+ format("var x = \"a\";\n"
+ "var x = \"a\";\n"
+ "var x = \"a\";",
+ 20, 0));
+}
+
} // end namespace
} // end namespace format
} // end namespace clang