aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests
diff options
context:
space:
mode:
authorOwen Pan <owenpiano@gmail.com>2023-11-27 13:01:16 -0800
committerGitHub <noreply@github.com>2023-11-27 13:01:16 -0800
commit39faf13dde5502cdba7aff1b967c51cd0a93bb71 (patch)
tree77b3d3142be886a78d2569f2739f1df82ae1f6c6 /clang/unittests
parent9e8691962626e62382eb31da6fea49ddbb559750 (diff)
downloadllvm-39faf13dde5502cdba7aff1b967c51cd0a93bb71.zip
llvm-39faf13dde5502cdba7aff1b967c51cd0a93bb71.tar.gz
llvm-39faf13dde5502cdba7aff1b967c51cd0a93bb71.tar.bz2
[clang-format] Add BreakAdjacentStringLiterals option (#73432)
Closes #70451.
Diffstat (limited to 'clang/unittests')
-rw-r--r--clang/unittests/Format/ConfigParseTest.cpp1
-rw-r--r--clang/unittests/Format/FormatTest.cpp14
2 files changed, 15 insertions, 0 deletions
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index 3a6667d..0c9f68f 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -159,6 +159,7 @@ TEST(ConfigParseTest, ParsesConfigurationBools) {
CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
CHECK_PARSE_BOOL(BinPackArguments);
CHECK_PARSE_BOOL(BinPackParameters);
+ CHECK_PARSE_BOOL(BreakAdjacentStringLiterals);
CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
CHECK_PARSE_BOOL(BreakStringLiterals);
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index d095a2b..420afe5 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -26644,6 +26644,20 @@ TEST_F(FormatTest, StreamOutputOperator) {
verifyFormat("std::cout << \"foo\" << \"bar\" << baz;");
}
+TEST_F(FormatTest, BreakAdjacentStringLiterals) {
+ constexpr StringRef Code{
+ "return \"Code\" \"\\0\\52\\26\\55\\55\\0\" \"x013\" \"\\02\\xBA\";"};
+
+ verifyFormat("return \"Code\"\n"
+ " \"\\0\\52\\26\\55\\55\\0\"\n"
+ " \"x013\"\n"
+ " \"\\02\\xBA\";",
+ Code);
+
+ auto Style = getLLVMStyle();
+ Style.BreakAdjacentStringLiterals = false;
+ verifyFormat(Code, Style);
+}
} // namespace
} // namespace test
} // namespace format