[clang] [clang-format] Break after string literals with trailing line breaks (PR #76795)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 5 16:17:35 PST 2024
================
@@ -2499,6 +2499,15 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
EXPECT_BRACE_KIND(Tokens[6], BK_Block);
}
+TEST_F(TokenAnnotatorTest, StreamOperator) {
+ auto Tokens = annotate("\"foo\\n\" << aux << \"foo\\n\" << \"foo\";");
+ ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+ EXPECT_FALSE(Tokens[1]->MustBreakBefore);
+ EXPECT_FALSE(Tokens[3]->MustBreakBefore);
+ // Only break between string literals if the former ends with \n.
+ EXPECT_TRUE(Tokens[5]->MustBreakBefore);
+}
+
----------------
owenca wrote:
I understand, but `TokenAnnotatorTest` is mainly for testing token types and has never been used for checking `MustBreakBefore` and other similar token attributes. @HazardyKnusperkeks @rymiel @mydeveloperday what do you think?
https://github.com/llvm/llvm-project/pull/76795
More information about the cfe-commits
mailing list