================
@@ -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);
+}
+
----------------
kadircet wrote:

i added this test as it's more "unit" compared to the final formatting, which 
might be affected by all sorts of other things (column limits, bin-packing 
etc.). whereas this one particularly checks that we provide the "relevant" 
signal only in the case we care about.

we can't really have it in the FormatTest, as this is the file that has 
utilities for asserting on annotations of tokens.

if you think that isn't useful, i am happy to drop it completely, but i believe 
this is valuable for the reason i mentioned above.

https://github.com/llvm/llvm-project/pull/76795
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to