Lines Matching full:n
34 DEBUG(llvm::errs() << "---\n"); in format()
35 DEBUG(llvm::errs() << Code << "\n\n"); in format()
42 EXPECT_EQ(ExpectedIncompleteFormat, IncompleteFormat) << Code << "\n\n"; in format()
47 DEBUG(llvm::errs() << "\n" << Result << "\n\n"); in format()
94 EXPECT_EQ("1 2 3\n", test::messUp("1\n2\n3\n")); in TEST_F()
95 EXPECT_EQ("a\n//b\nc", test::messUp("a\n//b\nc")); in TEST_F()
96 EXPECT_EQ("a\n#b\nc", test::messUp("a\n#b\nc")); in TEST_F()
97 EXPECT_EQ("a\n#b c d\ne", test::messUp("a\n#b\\\nc\\\nd\ne")); in TEST_F()
110 EXPECT_EQ("\nint i;", format(" \n\t \v \f int i;")); in TEST_F()
112 EXPECT_EQ("int i;\nint j;", format(" int i;\n int j;")); in TEST_F()
120 EXPECT_EQ("{\n {\n {}\n }\n}", format("{{{}}}")); in TEST_F()
137 EXPECT_EQ("if (a) {\n" in TEST_F()
138 " f();\n" in TEST_F()
142 EXPECT_EQ("if (a) {\n" in TEST_F()
143 " f();\n" in TEST_F()
145 format("if (a) {\n" in TEST_F()
146 " f();\n" in TEST_F()
149 EXPECT_EQ("/*\r\n" in TEST_F()
150 "\r\n" in TEST_F()
151 "*/\r\n", in TEST_F()
152 format("/*\r\n" in TEST_F()
153 "\r\n" in TEST_F()
154 "*/\r\n")); in TEST_F()
159 EXPECT_EQ("class C {\n" in TEST_F()
160 " int i;\n" in TEST_F()
162 format("class C {\n" in TEST_F()
163 " int i;\n" in TEST_F()
164 "\n" in TEST_F()
168 EXPECT_EQ("namespace N {\n" in TEST_F()
169 "\n" in TEST_F()
170 "int i;\n" in TEST_F()
172 format("namespace N {\n" in TEST_F()
173 "\n" in TEST_F()
174 "int i;\n" in TEST_F()
177 EXPECT_EQ("extern /**/ \"C\" /**/ {\n" in TEST_F()
178 "\n" in TEST_F()
179 "int i;\n" in TEST_F()
181 format("extern /**/ \"C\" /**/ {\n" in TEST_F()
182 "\n" in TEST_F()
183 "int i;\n" in TEST_F()
190 EXPECT_EQ("extern \"C\" int f() {\n" in TEST_F()
191 " int i = 42;\n" in TEST_F()
192 " return i;\n" in TEST_F()
194 format("extern \"C\" int f() {\n" in TEST_F()
195 "\n" in TEST_F()
196 " int i = 42;\n" in TEST_F()
197 " return i;\n" in TEST_F()
202 EXPECT_EQ("void f() {\n" in TEST_F()
203 "\n" in TEST_F()
204 " if (a) {\n" in TEST_F()
205 "\n" in TEST_F()
206 " f();\n" in TEST_F()
207 " }\n" in TEST_F()
209 format("void f() {\n" in TEST_F()
210 "\n" in TEST_F()
211 " if (a) {\n" in TEST_F()
212 "\n" in TEST_F()
213 " f();\n" in TEST_F()
214 "\n" in TEST_F()
215 " }\n" in TEST_F()
216 "\n" in TEST_F()
219 EXPECT_EQ("void f() {\n" in TEST_F()
220 " if (a) {\n" in TEST_F()
221 " f();\n" in TEST_F()
222 " }\n" in TEST_F()
224 format("void f() {\n" in TEST_F()
225 "\n" in TEST_F()
226 " if (a) {\n" in TEST_F()
227 "\n" in TEST_F()
228 " f();\n" in TEST_F()
229 "\n" in TEST_F()
230 " }\n" in TEST_F()
231 "\n" in TEST_F()
236 EXPECT_EQ("void f() {\n" in TEST_F()
237 " if (a) {\n" in TEST_F()
238 " f();\n" in TEST_F()
239 "\n" in TEST_F()
240 " } else if (b) {\n" in TEST_F()
241 " f();\n" in TEST_F()
242 " }\n" in TEST_F()
244 format("void f() {\n" in TEST_F()
245 " if (a) {\n" in TEST_F()
246 " f();\n" in TEST_F()
247 "\n" in TEST_F()
248 " } else if (b) {\n" in TEST_F()
249 " f();\n" in TEST_F()
250 "\n" in TEST_F()
251 " }\n" in TEST_F()
252 "\n" in TEST_F()
256 EXPECT_EQ("namespace {\n" in TEST_F()
257 "int i;\n" in TEST_F()
259 format("namespace {\n" in TEST_F()
260 "int i;\n" in TEST_F()
261 "\n" in TEST_F()
263 EXPECT_EQ("namespace {\n" in TEST_F()
264 "int i;\n" in TEST_F()
265 "\n" in TEST_F()
267 format("namespace {\n" in TEST_F()
268 "int i;\n" in TEST_F()
269 "\n" in TEST_F()
289 verifyFormat("if (true)\n f();\ng();"); in TEST_F()
290 verifyFormat("if (a)\n if (b)\n if (c)\n g();\nh();"); in TEST_F()
291 verifyFormat("if (a)\n if (b) {\n f();\n }\ng();"); in TEST_F()
295 verifyFormat("if (a)\n" in TEST_F()
296 " // comment\n" in TEST_F()
299 verifyFormat("if (a)\n" in TEST_F()
302 verifyFormat("if (a)\n" in TEST_F()
306 verifyFormat("if (a) // Can't merge this\n" in TEST_F()
307 " f();\n", in TEST_F()
309 verifyFormat("if (a) /* still don't merge */\n" in TEST_F()
312 verifyFormat("if (a) { // Never merge this\n" in TEST_F()
313 " f();\n" in TEST_F()
316 verifyFormat("if (a) { /* Never merge this */\n" in TEST_F()
317 " f();\n" in TEST_F()
323 verifyFormat("if (aaaaaaaaa)\n" in TEST_F()
328 verifyFormat("if (a)\n return;", AllowsMergedIf); in TEST_F()
337 verifyFormat("while (true)\n" in TEST_F()
340 verifyFormat("for (;;)\n" in TEST_F()
343 verifyFormat("for (;;)\n" in TEST_F()
346 verifyFormat("for (;;) // Can't merge this\n" in TEST_F()
349 verifyFormat("for (;;) /* still don't merge */\n" in TEST_F()
367 verifyFormat("if (true) { //\n" in TEST_F()
368 " f();\n" in TEST_F()
371 verifyFormat("if (true) {\n" in TEST_F()
372 " f();\n" in TEST_F()
373 " f();\n" in TEST_F()
376 verifyFormat("if (true) {\n" in TEST_F()
377 " f();\n" in TEST_F()
378 "} else {\n" in TEST_F()
379 " f();\n" in TEST_F()
383 verifyFormat("template <int> struct A2 {\n" in TEST_F()
384 " struct B {};\n" in TEST_F()
389 verifyFormat("if (true) {\n" in TEST_F()
390 " f();\n" in TEST_F()
393 verifyFormat("if (true) {\n" in TEST_F()
394 " f();\n" in TEST_F()
395 "} else {\n" in TEST_F()
396 " f();\n" in TEST_F()
401 verifyFormat("while (true) {\n" in TEST_F()
402 " f();\n" in TEST_F()
405 verifyFormat("for (;;) {\n" in TEST_F()
406 " f();\n" in TEST_F()
412 verifyFormat("if (true)\n" in TEST_F()
413 " if (true)\n" in TEST_F()
414 " if (true)\n" in TEST_F()
415 " f();\n" in TEST_F()
416 " else\n" in TEST_F()
417 " g();\n" in TEST_F()
418 " else\n" in TEST_F()
419 " h();\n" in TEST_F()
420 "else\n" in TEST_F()
422 verifyFormat("if (true)\n" in TEST_F()
423 " if (true)\n" in TEST_F()
424 " if (true) {\n" in TEST_F()
425 " if (true)\n" in TEST_F()
426 " f();\n" in TEST_F()
427 " } else {\n" in TEST_F()
428 " g();\n" in TEST_F()
429 " }\n" in TEST_F()
430 " else\n" in TEST_F()
431 " h();\n" in TEST_F()
432 "else {\n" in TEST_F()
433 " i();\n" in TEST_F()
435 verifyFormat("void f() {\n" in TEST_F()
436 " if (a) {\n" in TEST_F()
437 " } else {\n" in TEST_F()
438 " }\n" in TEST_F()
443 verifyFormat("if (a) {\n} else if (b) {\n}"); in TEST_F()
444 verifyFormat("if (a)\n" in TEST_F()
445 " f();\n" in TEST_F()
446 "else if (b)\n" in TEST_F()
447 " g();\n" in TEST_F()
448 "else\n" in TEST_F()
450 verifyFormat("if (a) {\n" in TEST_F()
451 " f();\n" in TEST_F()
452 "}\n" in TEST_F()
453 "// or else ..\n" in TEST_F()
454 "else {\n" in TEST_F()
455 " g()\n" in TEST_F()
458 verifyFormat("if (a) {\n" in TEST_F()
459 "} else if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
460 " aaaaaaaaaaaaaaaaaaaaaaaaaaaa)) {\n" in TEST_F()
462 verifyFormat("if (a) {\n" in TEST_F()
463 "} else if (\n" in TEST_F()
464 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n" in TEST_F()
471 "for (int VeryVeryLongLoopVariable = 0; VeryVeryLongLoopVariable < 10;\n" in TEST_F()
472 " ++VeryVeryLongLoopVariable)\n" in TEST_F()
474 verifyFormat("for (;;)\n" in TEST_F()
476 verifyFormat("for (;;) {\n}"); in TEST_F()
477 verifyFormat("for (;;) {\n" in TEST_F()
478 " f();\n" in TEST_F()
480 verifyFormat("for (int i = 0; (i < 10); ++i) {\n}"); in TEST_F()
483 "for (std::vector<UnwrappedLine>::iterator I = UnwrappedLines.begin(),\n" in TEST_F()
484 " E = UnwrappedLines.end();\n" in TEST_F()
485 " I != E; ++I) {\n}"); in TEST_F()
488 "for (MachineFun::iterator IIII = PrevIt, EEEE = F.end(); IIII != EEEE;\n" in TEST_F()
489 " ++IIIII) {\n}"); in TEST_F()
490 verifyFormat("for (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaa =\n" in TEST_F()
491 " aaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaa;\n" in TEST_F()
492 " aaaaaaaaaaa != aaaaaaaaaaaaaaaaaaa; ++aaaaaaaaaaa) {\n}"); in TEST_F()
493 verifyFormat("for (llvm::ArrayRef<NamedDecl *>::iterator\n" in TEST_F()
494 " I = FD->getDeclsInPrototypeScope().begin(),\n" in TEST_F()
495 " E = FD->getDeclsInPrototypeScope().end();\n" in TEST_F()
496 " I != E; ++I) {\n}"); in TEST_F()
497 verifyFormat("for (SmallVectorImpl<TemplateIdAnnotationn *>::iterator\n" in TEST_F()
498 " I = Container.begin(),\n" in TEST_F()
499 " E = Container.end();\n" in TEST_F()
500 " I != E; ++I) {\n}", in TEST_F()
504 "for (aaaaaaaaaaaaaaaaa aaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;\n" in TEST_F()
505 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa !=\n" in TEST_F()
506 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
507 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);\n" in TEST_F()
508 " ++aaaaaaaaaaa) {\n}"); in TEST_F()
509 verifyFormat("for (int i = 0; i < aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n" in TEST_F()
510 " bbbbbbbbbbbbbbbbbbbb < ccccccccccccccc;\n" in TEST_F()
511 " ++i) {\n}"); in TEST_F()
512 verifyFormat("for (int aaaaaaaaaaa = 1; aaaaaaaaaaa <= bbbbbbbbbbbbbbb;\n" in TEST_F()
513 " aaaaaaaaaaa++, bbbbbbbbbbbbbbbbb++) {\n" in TEST_F()
515 verifyFormat("for (some_namespace::SomeIterator iter( // force break\n" in TEST_F()
516 " aaaaaaaaaa);\n" in TEST_F()
517 " iter; ++iter) {\n" in TEST_F()
519 verifyFormat("for (auto aaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
520 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);\n" in TEST_F()
521 " aaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbbbbbbb;\n" in TEST_F()
526 verifyFormat("for (int aaaaaaaaaaa = 1;\n" in TEST_F()
527 " aaaaaaaaaaa <= aaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaa,\n" in TEST_F()
528 " aaaaaaaaaaaaaaaa,\n" in TEST_F()
529 " aaaaaaaaaaaaaaaa,\n" in TEST_F()
530 " aaaaaaaaaaaaaaaa);\n" in TEST_F()
531 " aaaaaaaaaaa++, bbbbbbbbbbbbbbbbb++) {\n" in TEST_F()
535 "for (std::vector<UnwrappedLine>::iterator I = UnwrappedLines.begin(),\n" in TEST_F()
536 " E = UnwrappedLines.end();\n" in TEST_F()
537 " I != E;\n" in TEST_F()
538 " ++I) {\n}", in TEST_F()
543 verifyFormat("for (auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa :\n" in TEST_F()
544 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n}"); in TEST_F()
545 verifyFormat("for (auto aaaaaaaaaaaaaaaaaaaaa :\n" in TEST_F()
546 " aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaa, aaaaaaaaaaaaa)) {\n}"); in TEST_F()
547 verifyFormat("for (const aaaaaaaaaaaaaaaaaaaaa &aaaaaaaaa :\n" in TEST_F()
548 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n}"); in TEST_F()
549 verifyFormat("for (aaaaaaaaa aaaaaaaaaaaaaaaaaaaaa :\n" in TEST_F()
550 " aaaaaaaaaaaa.aaaaaaaaaaaa().aaaaaaaaa().a()) {\n}"); in TEST_F()
554 verifyFormat("void f() {\n" in TEST_F()
555 " foreach (Item *item, itemlist) {}\n" in TEST_F()
556 " Q_FOREACH (Item *item, itemlist) {}\n" in TEST_F()
557 " BOOST_FOREACH (Item *item, itemlist) {}\n" in TEST_F()
558 " UNKNOWN_FORACH(Item * item, itemlist) {}\n" in TEST_F()
562 verifyFormat("#define foreach(x, y)\n" in TEST_F()
563 "#define Q_FOREACH(x, y)\n" in TEST_F()
564 "#define BOOST_FOREACH(x, y)\n" in TEST_F()
565 "#define UNKNOWN_FOREACH(x, y)\n"); in TEST_F()
568 verifyFormat("#define foreach (x, y)\n" in TEST_F()
569 "#define Q_FOREACH (x, y)\n" in TEST_F()
570 "#define BOOST_FOREACH (x, y)\n" in TEST_F()
571 "#define UNKNOWN_FOREACH (x, y)\n"); in TEST_F()
575 verifyFormat("while (true) {\n}"); in TEST_F()
576 verifyFormat("while (true)\n" in TEST_F()
578 verifyFormat("while () {\n}"); in TEST_F()
579 verifyFormat("while () {\n" in TEST_F()
580 " f();\n" in TEST_F()
585 verifyFormat("do {\n" in TEST_F()
586 " do_something();\n" in TEST_F()
588 verifyFormat("do\n" in TEST_F()
589 " do_something();\n" in TEST_F()
594 verifyFormat("switch (x) {\n" in TEST_F()
595 "case 1:\n" in TEST_F()
596 " f();\n" in TEST_F()
597 " break;\n" in TEST_F()
598 "case kFoo:\n" in TEST_F()
599 "case ns::kBar:\n" in TEST_F()
600 "case kBaz:\n" in TEST_F()
601 " break;\n" in TEST_F()
602 "default:\n" in TEST_F()
603 " g();\n" in TEST_F()
604 " break;\n" in TEST_F()
606 verifyFormat("switch (x) {\n" in TEST_F()
607 "case 1: {\n" in TEST_F()
608 " f();\n" in TEST_F()
609 " break;\n" in TEST_F()
610 "}\n" in TEST_F()
611 "case 2: {\n" in TEST_F()
612 " break;\n" in TEST_F()
613 "}\n" in TEST_F()
615 verifyFormat("switch (x) {\n" in TEST_F()
616 "case 1: {\n" in TEST_F()
617 " f();\n" in TEST_F()
618 " {\n" in TEST_F()
619 " g();\n" in TEST_F()
620 " h();\n" in TEST_F()
621 " }\n" in TEST_F()
622 " break;\n" in TEST_F()
623 "}\n" in TEST_F()
625 verifyFormat("switch (x) {\n" in TEST_F()
626 "case 1: {\n" in TEST_F()
627 " f();\n" in TEST_F()
628 " if (foo) {\n" in TEST_F()
629 " g();\n" in TEST_F()
630 " h();\n" in TEST_F()
631 " }\n" in TEST_F()
632 " break;\n" in TEST_F()
633 "}\n" in TEST_F()
635 verifyFormat("switch (x) {\n" in TEST_F()
636 "case 1: {\n" in TEST_F()
637 " f();\n" in TEST_F()
638 " g();\n" in TEST_F()
639 "} break;\n" in TEST_F()
641 verifyFormat("switch (test)\n" in TEST_F()
643 verifyFormat("switch (x) {\n" in TEST_F()
644 "default: {\n" in TEST_F()
645 " // Do nothing.\n" in TEST_F()
646 "}\n" in TEST_F()
648 verifyFormat("switch (x) {\n" in TEST_F()
649 "// comment\n" in TEST_F()
650 "// if 1, do f()\n" in TEST_F()
651 "case 1:\n" in TEST_F()
652 " f();\n" in TEST_F()
654 verifyFormat("switch (x) {\n" in TEST_F()
655 "case 1:\n" in TEST_F()
656 " // Do amazing stuff\n" in TEST_F()
657 " {\n" in TEST_F()
658 " f();\n" in TEST_F()
659 " g();\n" in TEST_F()
660 " }\n" in TEST_F()
661 " break;\n" in TEST_F()
663 verifyFormat("#define A \\\n" in TEST_F()
664 " switch (x) { \\\n" in TEST_F()
665 " case a: \\\n" in TEST_F()
666 " foo = b; \\\n" in TEST_F()
669 verifyFormat("#define OPERATION_CASE(name) \\\n" in TEST_F()
670 " case OP_name: \\\n" in TEST_F()
671 " return operations::Operation##name\n", in TEST_F()
673 verifyFormat("switch (x) {\n" in TEST_F()
674 "case 1:;\n" in TEST_F()
675 "default:;\n" in TEST_F()
676 " int i;\n" in TEST_F()
679 verifyGoogleFormat("switch (x) {\n" in TEST_F()
680 " case 1:\n" in TEST_F()
681 " f();\n" in TEST_F()
682 " break;\n" in TEST_F()
683 " case kFoo:\n" in TEST_F()
684 " case ns::kBar:\n" in TEST_F()
685 " case kBaz:\n" in TEST_F()
686 " break;\n" in TEST_F()
687 " default:\n" in TEST_F()
688 " g();\n" in TEST_F()
689 " break;\n" in TEST_F()
691 verifyGoogleFormat("switch (x) {\n" in TEST_F()
692 " case 1: {\n" in TEST_F()
693 " f();\n" in TEST_F()
694 " break;\n" in TEST_F()
695 " }\n" in TEST_F()
697 verifyGoogleFormat("switch (test)\n" in TEST_F()
700 verifyGoogleFormat("#define OPERATION_CASE(name) \\\n" in TEST_F()
701 " case OP_name: \\\n" in TEST_F()
702 " return operations::Operation##name\n"); in TEST_F()
703 verifyGoogleFormat("Operation codeToOperation(OperationCode OpCode) {\n" in TEST_F()
704 " // Get the correction operation class.\n" in TEST_F()
705 " switch (OpCode) {\n" in TEST_F()
706 " CASE(Add);\n" in TEST_F()
707 " CASE(Subtract);\n" in TEST_F()
708 " default:\n" in TEST_F()
709 " return operations::Unknown;\n" in TEST_F()
710 " }\n" in TEST_F()
711 "#undef OPERATION_CASE\n" in TEST_F()
713 verifyFormat("DEBUG({\n" in TEST_F()
714 " switch (x) {\n" in TEST_F()
715 " case A:\n" in TEST_F()
716 " f();\n" in TEST_F()
717 " break;\n" in TEST_F()
718 " // On B:\n" in TEST_F()
719 " case B:\n" in TEST_F()
720 " g();\n" in TEST_F()
721 " break;\n" in TEST_F()
722 " }\n" in TEST_F()
724 verifyFormat("switch (a) {\n" in TEST_F()
725 "case (b):\n" in TEST_F()
726 " return;\n" in TEST_F()
729 verifyFormat("switch (a) {\n" in TEST_F()
730 "case some_namespace::\n" in TEST_F()
731 " some_constant:\n" in TEST_F()
732 " return;\n" in TEST_F()
738 verifyFormat("switch (x) {\n" in TEST_F()
739 "case 'A' ... 'Z':\n" in TEST_F()
740 "case 1 ... 5:\n" in TEST_F()
741 " break;\n" in TEST_F()
748 verifyFormat("switch (a) {\n" in TEST_F()
749 "case 1: x = 1; break;\n" in TEST_F()
750 "case 2: return;\n" in TEST_F()
751 "case 3:\n" in TEST_F()
752 "case 4:\n" in TEST_F()
753 "case 5: return;\n" in TEST_F()
754 "case 6: // comment\n" in TEST_F()
755 " return;\n" in TEST_F()
756 "case 7:\n" in TEST_F()
757 " // comment\n" in TEST_F()
758 " return;\n" in TEST_F()
759 "case 8:\n" in TEST_F()
760 " x = 8; // comment\n" in TEST_F()
761 " break;\n" in TEST_F()
762 "default: y = 1; break;\n" in TEST_F()
765 verifyFormat("switch (a) {\n" in TEST_F()
766 "#if FOO\n" in TEST_F()
767 "case 0: return 0;\n" in TEST_F()
768 "#endif\n" in TEST_F()
771 verifyFormat("switch (a) {\n" in TEST_F()
772 "case 1: {\n" in TEST_F()
773 "}\n" in TEST_F()
774 "case 2: {\n" in TEST_F()
775 " return;\n" in TEST_F()
776 "}\n" in TEST_F()
777 "case 3: {\n" in TEST_F()
778 " x = 1;\n" in TEST_F()
779 " return;\n" in TEST_F()
780 "}\n" in TEST_F()
781 "case 4:\n" in TEST_F()
782 " if (x)\n" in TEST_F()
783 " return;\n" in TEST_F()
787 verifyFormat("switch (a) {\n" in TEST_F()
788 "case 1: x = 1; break;\n" in TEST_F()
789 "case 2: return;\n" in TEST_F()
790 "case 3:\n" in TEST_F()
791 "case 4:\n" in TEST_F()
792 "case 5: return;\n" in TEST_F()
793 "default:\n" in TEST_F()
794 " y = 1;\n" in TEST_F()
795 " break;\n" in TEST_F()
801 verifyFormat("void f() {\n" in TEST_F()
802 " some_code();\n" in TEST_F()
803 "test_label:\n" in TEST_F()
804 " some_other_code();\n" in TEST_F()
805 " {\n" in TEST_F()
806 " some_more_code();\n" in TEST_F()
807 " another_label:\n" in TEST_F()
808 " some_more_code();\n" in TEST_F()
809 " }\n" in TEST_F()
811 verifyFormat("{\n" in TEST_F()
812 " some_code();\n" in TEST_F()
813 "test_label:\n" in TEST_F()
814 " some_other_code();\n" in TEST_F()
816 verifyFormat("{\n" in TEST_F()
817 " some_code();\n" in TEST_F()
818 "test_label:;\n" in TEST_F()
819 " int i = 0;\n" in TEST_F()
829 verifyFormat("// line 1\n" in TEST_F()
830 "// line 2\n" in TEST_F()
831 "void f() {}\n"); in TEST_F()
833 verifyFormat("void f() {\n" in TEST_F()
834 " // Doesn't do anything\n" in TEST_F()
836 verifyFormat("SomeObject\n" in TEST_F()
837 " // Calling someFunction on SomeObject\n" in TEST_F()
839 verifyFormat("auto result = SomeObject\n" in TEST_F()
840 " // Calling someFunction on SomeObject\n" in TEST_F()
842 verifyFormat("void f(int i, // some comment (probably for i)\n" in TEST_F()
843 " int j, // some comment (probably for j)\n" in TEST_F()
845 verifyFormat("void f(int i,\n" in TEST_F()
846 " // some comment (probably for j)\n" in TEST_F()
847 " int j,\n" in TEST_F()
848 " // some comment (probably for k)\n" in TEST_F()
851 verifyFormat("int i // This is a fancy variable\n" in TEST_F()
854 verifyFormat("// Leading comment.\n" in TEST_F()
856 verifyFormat("int a; // Trailing comment\n" in TEST_F()
857 " // on 2\n" in TEST_F()
858 " // or 3 lines.\n" in TEST_F()
860 verifyFormat("int a; // Trailing comment\n" in TEST_F()
861 "\n" in TEST_F()
862 "// Leading comment.\n" in TEST_F()
864 verifyFormat("int a; // Comment.\n" in TEST_F()
865 " // More details.\n" in TEST_F()
868 "int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; // comment\n" in TEST_F()
869 "int bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; // comment\n" in TEST_F()
870 "int cccccccccccccccccccccccccccccc; // comment\n" in TEST_F()
871 "int ddd; // looooooooooooooooooooooooong comment\n" in TEST_F()
872 "int aaaaaaaaaaaaaaaaaaaaaaa; // comment\n" in TEST_F()
873 "int bbbbbbbbbbbbbbbbbbbbb; // comment\n" in TEST_F()
876 verifyFormat("#include \"a\" // comment\n" in TEST_F()
878 verifyFormat("#include <a> // comment\n" in TEST_F()
880 EXPECT_EQ("#include \"a\" // comment\n" in TEST_F()
882 format("#include \\\n" in TEST_F()
883 " \"a\" // comment\n" in TEST_F()
886 verifyFormat("enum E {\n" in TEST_F()
887 " // comment\n" in TEST_F()
888 " VAL_A, // comment\n" in TEST_F()
889 " VAL_B\n" in TEST_F()
893 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n" in TEST_F()
895 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n" in TEST_F()
896 " // Comment inside a statement.\n" in TEST_F()
898 verifyFormat("SomeFunction(a,\n" in TEST_F()
899 " // comment\n" in TEST_F()
901 verifyFormat("SomeFunction(a, a,\n" in TEST_F()
902 " // comment\n" in TEST_F()
905 "bool aaaaaaaaaaaaa = // comment\n" in TEST_F()
906 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n" in TEST_F()
909 verifyFormat("int aaaa; // aaaaa\n" in TEST_F()
913 EXPECT_EQ("void f() { // This does something ..\n" in TEST_F()
914 "}\n" in TEST_F()
916 format("void f() { // This does something ..\n" in TEST_F()
917 " }\n" in TEST_F()
919 EXPECT_EQ("class C {\n" in TEST_F()
920 " void f() { // This does something ..\n" in TEST_F()
921 " } // awesome..\n" in TEST_F()
922 "\n" in TEST_F()
923 " int a; // This is unrelated\n" in TEST_F()
925 format("class C{void f() { // This does something ..\n" in TEST_F()
926 " } // awesome..\n" in TEST_F()
927 " \n" in TEST_F()
928 "int a; // This is unrelated\n" in TEST_F()
932 format("int i;\\\n// single line trailing comment")); in TEST_F()
936 verifyFormat("someFunction(anotherFunction( // Force break.\n" in TEST_F()
941 verifyFormat("const char *test[] = {\n" in TEST_F()
942 " // A\n" in TEST_F()
943 " \"aaaa\",\n" in TEST_F()
944 " // B\n" in TEST_F()
947 "aaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
949 EXPECT_EQ("D(a, {\n" in TEST_F()
950 " // test\n" in TEST_F()
951 " int a;\n" in TEST_F()
953 format("D(a, {\n" in TEST_F()
954 "// test\n" in TEST_F()
955 "int a;\n" in TEST_F()
958 EXPECT_EQ("lineWith(); // comment\n" in TEST_F()
959 "// at start\n" in TEST_F()
961 format("lineWith(); // comment\n" in TEST_F()
962 "// at start\n" in TEST_F()
964 EXPECT_EQ("lineWith(); // comment\n" in TEST_F()
965 " // at start\n" in TEST_F()
967 format("lineWith(); // comment\n" in TEST_F()
968 " // at start\n" in TEST_F()
971 EXPECT_EQ("lineWith(); // comment\n" in TEST_F()
972 "// at start\n" in TEST_F()
974 format("lineWith(); // comment\n" in TEST_F()
975 "// at start\n" in TEST_F()
977 EXPECT_EQ("lineWith();\n" in TEST_F()
978 "// at start\n" in TEST_F()
980 format("lineWith();\n" in TEST_F()
981 " // at start\n" in TEST_F()
983 EXPECT_EQ("// first\n" in TEST_F()
984 "// at start\n" in TEST_F()
986 format("// first\n" in TEST_F()
987 " // at start\n" in TEST_F()
989 EXPECT_EQ("f();\n" in TEST_F()
990 "// first\n" in TEST_F()
991 "// at start\n" in TEST_F()
993 format("f();\n" in TEST_F()
994 "// first\n" in TEST_F()
995 " // at start\n" in TEST_F()
997 verifyFormat("f(); // comment\n" in TEST_F()
998 "// first\n" in TEST_F()
999 "// at start\n" in TEST_F()
1001 EXPECT_EQ("f(); // comment\n" in TEST_F()
1002 "// first\n" in TEST_F()
1003 "// at start\n" in TEST_F()
1005 format("f(); // comment\n" in TEST_F()
1006 "// first\n" in TEST_F()
1007 " // at start\n" in TEST_F()
1009 EXPECT_EQ("f(); // comment\n" in TEST_F()
1010 " // first\n" in TEST_F()
1011 "// at start\n" in TEST_F()
1013 format("f(); // comment\n" in TEST_F()
1014 " // first\n" in TEST_F()
1015 "// at start\n" in TEST_F()
1017 EXPECT_EQ("void f() {\n" in TEST_F()
1018 " lineWith(); // comment\n" in TEST_F()
1019 " // at start\n" in TEST_F()
1021 format("void f() {\n" in TEST_F()
1022 " lineWith(); // comment\n" in TEST_F()
1023 " // at start\n" in TEST_F()
1026 verifyFormat("#define A \\\n" in TEST_F()
1027 " int i; /* iiiiiiiiiiiiiiiiiiiii */ \\\n" in TEST_F()
1031 "#define A \\\n" in TEST_F()
1032 " int i; /* iiiiiiiiiiiiiiiiiiiii */ \\\n" in TEST_F()
1036 verifyFormat("if ( // This is some comment\n" in TEST_F()
1037 " x + 3) {\n" in TEST_F()
1039 EXPECT_EQ("if ( // This is some comment\n" in TEST_F()
1040 " // spanning two lines\n" in TEST_F()
1041 " x + 3) {\n" in TEST_F()
1043 format("if( // This is some comment\n" in TEST_F()
1044 " // spanning two lines\n" in TEST_F()
1045 " x + 3) {\n" in TEST_F()
1048 verifyNoCrash("/\\\n/"); in TEST_F()
1049 verifyNoCrash("/\\\n* */"); in TEST_F()
1051 verifyNoCrash(StringRef("/*\\\0\n/", 6)); in TEST_F()
1055 EXPECT_EQ("SomeFunction(a,\n" in TEST_F()
1056 " b, // comment\n" in TEST_F()
1058 format("SomeFunction(a,\n" in TEST_F()
1059 " b, // comment\n" in TEST_F()
1061 EXPECT_EQ("SomeFunction(a, b,\n" in TEST_F()
1062 " // comment\n" in TEST_F()
1064 format("SomeFunction(a,\n" in TEST_F()
1065 " b,\n" in TEST_F()
1066 " // comment\n" in TEST_F()
1068 EXPECT_EQ("SomeFunction(a, b, // comment (unclear relation)\n" in TEST_F()
1070 format("SomeFunction(a, b, // comment (unclear relation)\n" in TEST_F()
1072 EXPECT_EQ("SomeFunction(a, // comment\n" in TEST_F()
1073 " b,\n" in TEST_F()
1075 format("SomeFunction(a, // comment\n" in TEST_F()
1076 " b,\n" in TEST_F()
1085 EXPECT_EQ("// comment\\\n", format("// comment\\\n \t \v \f ")); in TEST_F()
1086 EXPECT_EQ("// comment \\\n", format("// comment \\\n \t \v \f ")); in TEST_F()
1092 EXPECT_EQ("f(aaaaaaaaaaaaaaaaaaaaaaaaa, /* Trailing comment for aa... */\n" in TEST_F()
1094 format("f(aaaaaaaaaaaaaaaaaaaaaaaaa , \\\n" in TEST_F()
1095 "/* Trailing comment for aa... */\n" in TEST_F()
1098 "f(aaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
1100 format("f(aaaaaaaaaaaaaaaaaaaaaaaaa , \n" in TEST_F()
1103 "void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
1104 " aaaaaaaaaaaaaaaaaa,\n" in TEST_F()
1105 " aaaaaaaaaaaaaaaaaa) { /*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*/\n" in TEST_F()
1107 format("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
1108 " aaaaaaaaaaaaaaaaaa ,\n" in TEST_F()
1109 " aaaaaaaaaaaaaaaaaa) { /*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*/\n" in TEST_F()
1114 verifyFormat("aaaaaaaa(/* parameter 1 */ aaaaaa,\n" in TEST_F()
1115 " /* parameter 2 */ aaaaaa,\n" in TEST_F()
1116 " /* parameter 3 */ aaaaaa,\n" in TEST_F()
1121 verifyGoogleFormat("#define A \\\n" in TEST_F()
1122 " int i; /*a*/ \\\n" in TEST_F()
1127 EXPECT_EQ("/*\n" in TEST_F()
1128 " * Really multi-line\n" in TEST_F()
1129 " * comment.\n" in TEST_F()
1130 " */\n" in TEST_F()
1132 format(" /*\n" in TEST_F()
1133 " * Really multi-line\n" in TEST_F()
1134 " * comment.\n" in TEST_F()
1135 " */\n" in TEST_F()
1137 EXPECT_EQ("class C {\n" in TEST_F()
1138 " /*\n" in TEST_F()
1139 " * Another multi-line\n" in TEST_F()
1140 " * comment.\n" in TEST_F()
1141 " */\n" in TEST_F()
1142 " void f() {}\n" in TEST_F()
1144 format("class C {\n" in TEST_F()
1145 "/*\n" in TEST_F()
1146 " * Another multi-line\n" in TEST_F()
1147 " * comment.\n" in TEST_F()
1148 " */\n" in TEST_F()
1149 "void f() {}\n" in TEST_F()
1151 EXPECT_EQ("/*\n" in TEST_F()
1152 " 1. This is a comment with non-trivial formatting.\n" in TEST_F()
1153 " 1.1. We have to indent/outdent all lines equally\n" in TEST_F()
1154 " 1.1.1. to keep the formatting.\n" in TEST_F()
1156 format(" /*\n" in TEST_F()
1157 " 1. This is a comment with non-trivial formatting.\n" in TEST_F()
1158 " 1.1. We have to indent/outdent all lines equally\n" in TEST_F()
1159 " 1.1.1. to keep the formatting.\n" in TEST_F()
1161 EXPECT_EQ("/*\n" in TEST_F()
1162 "Don't try to outdent if there's not enough indentation.\n" in TEST_F()
1164 format(" /*\n" in TEST_F()
1165 " Don't try to outdent if there's not enough indentation.\n" in TEST_F()
1168 EXPECT_EQ("int i; /* Comment with empty...\n" in TEST_F()
1169 " *\n" in TEST_F()
1171 format("int i; /* Comment with empty...\n" in TEST_F()
1172 " *\n" in TEST_F()
1174 EXPECT_EQ("int foobar = 0; /* comment */\n" in TEST_F()
1175 "int bar = 0; /* multiline\n" in TEST_F()
1176 " comment 1 */\n" in TEST_F()
1177 "int baz = 0; /* multiline\n" in TEST_F()
1178 " comment 2 */\n" in TEST_F()
1179 "int bzz = 0; /* multiline\n" in TEST_F()
1181 format("int foobar = 0; /* comment */\n" in TEST_F()
1182 "int bar = 0; /* multiline\n" in TEST_F()
1183 " comment 1 */\n" in TEST_F()
1184 "int baz = 0; /* multiline\n" in TEST_F()
1185 " comment 2 */\n" in TEST_F()
1186 "int bzz = 0; /* multiline\n" in TEST_F()
1188 EXPECT_EQ("int foobar = 0; /* comment */\n" in TEST_F()
1189 "int bar = 0; /* multiline\n" in TEST_F()
1190 " comment */\n" in TEST_F()
1191 "int baz = 0; /* multiline\n" in TEST_F()
1193 format("int foobar = 0; /* comment */\n" in TEST_F()
1194 "int bar = 0; /* multiline\n" in TEST_F()
1195 "comment */\n" in TEST_F()
1196 "int baz = 0; /* multiline\n" in TEST_F()
1208 EXPECT_EQ("double *x; /* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
1210 format("double *x; /* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
1213 "void ffffffffffff(\n" in TEST_F()
1214 " int aaaaaaaa, int bbbbbbbb,\n" in TEST_F()
1215 " int cccccccccccc) { /*\n" in TEST_F()
1216 " aaaaaaaaaa\n" in TEST_F()
1217 " aaaaaaaaaaaaa\n" in TEST_F()
1218 " bbbbbbbbbbbbbb\n" in TEST_F()
1219 " bbbbbbbbbb\n" in TEST_F()
1220 " */\n" in TEST_F()
1222 format("void ffffffffffff(int aaaaaaaa, int bbbbbbbb, int cccccccccccc)\n" in TEST_F()
1223 "{ /*\n" in TEST_F()
1224 " aaaaaaaaaa aaaaaaaaaaaaa\n" in TEST_F()
1225 " bbbbbbbbbbbbbb bbbbbbbbbb\n" in TEST_F()
1226 " */\n" in TEST_F()
1232 EXPECT_EQ("void ffffffffff(\n" in TEST_F()
1239 EXPECT_EQ("// A comment that\n" in TEST_F()
1240 "// doesn't fit on\n" in TEST_F()
1244 EXPECT_EQ("/// A comment that\n" in TEST_F()
1245 "/// doesn't fit on\n" in TEST_F()
1249 EXPECT_EQ("//! A comment that\n" in TEST_F()
1250 "//! doesn't fit on\n" in TEST_F()
1254 EXPECT_EQ("// a b c d\n" in TEST_F()
1255 "// e f g\n" in TEST_F()
1259 "// a b c d\n" in TEST_F()
1260 "// e f g\n" in TEST_F()
1262 format("\\\n// a b c d e f g h i j k", getLLVMStyleWithColumns(10))); in TEST_F()
1263 EXPECT_EQ("if (true) // A comment that\n" in TEST_F()
1264 " // doesn't fit on\n" in TEST_F()
1271 EXPECT_EQ("// Add leading\n" in TEST_F()
1274 EXPECT_EQ("/// Add leading\n" in TEST_F()
1277 EXPECT_EQ("//! Add leading\n" in TEST_F()
1281 EXPECT_EQ("// Even if it makes the line exceed the column\n" in TEST_F()
1291 EXPECT_EQ("// A comment before\n" in TEST_F()
1292 "// a macro\n" in TEST_F()
1293 "// definition\n" in TEST_F()
1295 format("// A comment before a macro definition\n" in TEST_F()
1298 EXPECT_EQ("void ffffff(\n" in TEST_F()
1299 " int aaaaaaaaa, // wwww\n" in TEST_F()
1300 " int bbbbbbbbbb, // xxxxxxx\n" in TEST_F()
1301 " // yyyyyyyyyy\n" in TEST_F()
1303 format("void ffffff(\n" in TEST_F()
1304 " int aaaaaaaaa, // wwww\n" in TEST_F()
1305 " int bbbbbbbbbb, // xxxxxxx yyyyyyyyyy\n" in TEST_F()
1312 "#define XXX // a b c d\n" in TEST_F()
1316 "#define XXX // q w e r\n" in TEST_F()
1322 EXPECT_EQ("// A comment\n" in TEST_F()
1323 "// that doesn't\n" in TEST_F()
1324 "// fit on one\n" in TEST_F()
1328 EXPECT_EQ("/// A comment\n" in TEST_F()
1329 "/// that doesn't\n" in TEST_F()
1330 "/// fit on one\n" in TEST_F()
1337 EXPECT_EQ("// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\\n" in TEST_F()
1338 "// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\\n" in TEST_F()
1340 format("// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\\n" in TEST_F()
1341 "// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\\n" in TEST_F()
1343 EXPECT_EQ("int a; // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\n" in TEST_F()
1344 " // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\n" in TEST_F()
1346 format("int a; // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\n" in TEST_F()
1347 " // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\n" in TEST_F()
1352 EXPECT_EQ("double\n" in TEST_F()
1353 " a; // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\n" in TEST_F()
1354 " // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\n" in TEST_F()
1356 format("double a; // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\n" in TEST_F()
1357 " // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\n" in TEST_F()
1374 EXPECT_EQ("if (xxx ==\n" in TEST_F()
1375 " yyy && // aaaaaaaaaaaa bbbbbbbbb\n" in TEST_F()
1376 " zzz)\n" in TEST_F()
1378 format("if (xxx == yyy && // aaaaaaaaaaaa bbbbbbbbb\n" in TEST_F()
1381 EXPECT_EQ("if (xxxxxxxxxx ==\n" in TEST_F()
1382 " yyy && // aaaaaa bbbbbbbb cccc\n" in TEST_F()
1383 " zzz)\n" in TEST_F()
1385 format("if (xxxxxxxxxx == yyy && // aaaaaa bbbbbbbb cccc\n" in TEST_F()
1388 EXPECT_EQ("if (xxxxxxxxxx &&\n" in TEST_F()
1389 " yyy || // aaaaaa bbbbbbbb cccc\n" in TEST_F()
1390 " zzz)\n" in TEST_F()
1392 format("if (xxxxxxxxxx && yyy || // aaaaaa bbbbbbbb cccc\n" in TEST_F()
1395 EXPECT_EQ("fffffffff(\n" in TEST_F()
1396 " &xxx, // aaaaaaaaaaaa bbbbbbbbbbb\n" in TEST_F()
1398 format("fffffffff(&xxx, // aaaaaaaaaaaa bbbbbbbbbbb\n" in TEST_F()
1404 EXPECT_EQ("#define A(x) /* \\\n" in TEST_F()
1405 " a comment \\\n" in TEST_F()
1406 " inside */ \\\n" in TEST_F()
1408 format("#define A(x) /* \\\n" in TEST_F()
1409 " a comment \\\n" in TEST_F()
1410 " inside */ \\\n" in TEST_F()
1413 EXPECT_EQ("#define A( \\\n" in TEST_F()
1414 " x) /* \\\n" in TEST_F()
1415 " a comment \\\n" in TEST_F()
1416 " inside */ \\\n" in TEST_F()
1418 format("#define A( \\\n" in TEST_F()
1419 " x) /* \\\n" in TEST_F()
1420 " a comment \\\n" in TEST_F()
1421 " inside */ \\\n" in TEST_F()
1427 EXPECT_EQ("namespace {}\n// Test\n#define A", in TEST_F()
1428 format("namespace {}\n // Test\n#define A")); in TEST_F()
1429 EXPECT_EQ("namespace {}\n/* Test */\n#define A", in TEST_F()
1430 format("namespace {}\n /* Test */\n#define A")); in TEST_F()
1431 EXPECT_EQ("namespace {}\n/* Test */ #define A", in TEST_F()
1432 format("namespace {}\n /* Test */ #define A")); in TEST_F()
1436 EXPECT_EQ("/* This is a long\n" in TEST_F()
1437 " * comment that\n" in TEST_F()
1438 " * doesn't\n" in TEST_F()
1439 " * fit on one line.\n" in TEST_F()
1448 "/* a b c d\n" in TEST_F()
1449 " * e f g\n" in TEST_F()
1450 " * h i j k\n" in TEST_F()
1454 "/* a b c d\n" in TEST_F()
1455 " * e f g\n" in TEST_F()
1456 " * h i j k\n" in TEST_F()
1458 format("\\\n/* a b c d e f g h i j k */", getLLVMStyleWithColumns(10))); in TEST_F()
1459 EXPECT_EQ("/*\n" in TEST_F()
1460 "This is a long\n" in TEST_F()
1461 "comment that doesn't\n" in TEST_F()
1462 "fit on one line.\n" in TEST_F()
1464 format("/*\n" in TEST_F()
1467 "fit on one line. \n" in TEST_F()
1470 EXPECT_EQ("/*\n" in TEST_F()
1471 " * This is a long\n" in TEST_F()
1472 " * comment that\n" in TEST_F()
1473 " * doesn't fit on\n" in TEST_F()
1474 " * one line.\n" in TEST_F()
1476 format("/* \n" in TEST_F()
1480 " one line. \n" in TEST_F()
1483 EXPECT_EQ("/*\n" in TEST_F()
1484 " * This_is_a_comment_with_words_that_dont_fit_on_one_line\n" in TEST_F()
1485 " * so_it_should_be_broken\n" in TEST_F()
1486 " * wherever_a_space_occurs\n" in TEST_F()
1488 format("/*\n" in TEST_F()
1491 " wherever_a_space_occurs \n" in TEST_F()
1494 EXPECT_EQ("/*\n" in TEST_F()
1495 " * This_comment_can_not_be_broken_into_lines\n" in TEST_F()
1497 format("/*\n" in TEST_F()
1498 " * This_comment_can_not_be_broken_into_lines\n" in TEST_F()
1501 EXPECT_EQ("{\n" in TEST_F()
1502 " /*\n" in TEST_F()
1503 " This is another\n" in TEST_F()
1504 " long comment that\n" in TEST_F()
1505 " doesn't fit on one\n" in TEST_F()
1506 " line 1234567890\n" in TEST_F()
1507 " */\n" in TEST_F()
1509 format("{\n" in TEST_F()
1510 "/*\n" in TEST_F()
1514 " line 1234567890\n" in TEST_F()
1515 "*/\n" in TEST_F()
1518 EXPECT_EQ("{\n" in TEST_F()
1519 " /*\n" in TEST_F()
1520 " * This i s\n" in TEST_F()
1521 " * another comment\n" in TEST_F()
1522 " * t hat doesn' t\n" in TEST_F()
1523 " * fit on one l i\n" in TEST_F()
1524 " * n e\n" in TEST_F()
1525 " */\n" in TEST_F()
1527 format("{\n" in TEST_F()
1528 "/*\n" in TEST_F()
1533 " n e\n" in TEST_F()
1534 " */\n" in TEST_F()
1537 EXPECT_EQ("/*\n" in TEST_F()
1538 " * This is a long\n" in TEST_F()
1539 " * comment that\n" in TEST_F()
1540 " * doesn't fit on\n" in TEST_F()
1541 " * one line\n" in TEST_F()
1543 format(" /*\n" in TEST_F()
1544 " * This is a long comment that doesn't fit on one line\n" in TEST_F()
1547 EXPECT_EQ("{\n" in TEST_F()
1548 " if (something) /* This is a\n" in TEST_F()
1549 " long\n" in TEST_F()
1550 " comment */\n" in TEST_F()
1551 " ;\n" in TEST_F()
1553 format("{\n" in TEST_F()
1554 " if (something) /* This is a long comment */\n" in TEST_F()
1555 " ;\n" in TEST_F()
1559 EXPECT_EQ("/* A comment before\n" in TEST_F()
1560 " * a macro\n" in TEST_F()
1561 " * definition */\n" in TEST_F()
1563 format("/* A comment before a macro definition */\n" in TEST_F()
1567 EXPECT_EQ("/* some comment\n" in TEST_F()
1568 " * a comment\n" in TEST_F()
1569 "* that we break\n" in TEST_F()
1570 " * another comment\n" in TEST_F()
1571 "* we have to break\n" in TEST_F()
1572 "* a left comment\n" in TEST_F()
1574 format(" /* some comment\n" in TEST_F()
1575 " * a comment that we break\n" in TEST_F()
1576 " * another comment we have to break\n" in TEST_F()
1577 "* a left comment\n" in TEST_F()
1581 EXPECT_EQ("/**\n" in TEST_F()
1582 " * multiline block\n" in TEST_F()
1583 " * comment\n" in TEST_F()
1584 " *\n" in TEST_F()
1586 format("/**\n" in TEST_F()
1587 " * multiline block comment\n" in TEST_F()
1588 " *\n" in TEST_F()
1592 EXPECT_EQ("/*\n" in TEST_F()
1593 "\n" in TEST_F()
1594 "\n" in TEST_F()
1595 " */\n", in TEST_F()
1596 format(" /* \n" in TEST_F()
1597 " \n" in TEST_F()
1598 " \n" in TEST_F()
1599 " */\n")); in TEST_F()
1605 EXPECT_EQ("/* aaa aaa\n" in TEST_F()
1608 EXPECT_EQ("/* aaa aaa\n" in TEST_F()
1614 EXPECT_EQ("#define X \\\n" in TEST_F()
1615 " /* \\\n" in TEST_F()
1616 " Test \\\n" in TEST_F()
1617 " Macro comment \\\n" in TEST_F()
1618 " with a long \\\n" in TEST_F()
1619 " line \\\n" in TEST_F()
1620 " */ \\\n" in TEST_F()
1622 format("#define X \\\n" in TEST_F()
1623 " /*\n" in TEST_F()
1624 " Test\n" in TEST_F()
1625 " Macro comment with a long line\n" in TEST_F()
1626 " */ \\\n" in TEST_F()
1629 EXPECT_EQ("#define X \\\n" in TEST_F()
1630 " /* Macro comment \\\n" in TEST_F()
1631 " with a long \\\n" in TEST_F()
1632 " line */ \\\n" in TEST_F()
1634 format("#define X \\\n" in TEST_F()
1635 " /* Macro comment with a long\n" in TEST_F()
1636 " line */ \\\n" in TEST_F()
1639 EXPECT_EQ("#define X \\\n" in TEST_F()
1640 " /* Macro comment \\\n" in TEST_F()
1641 " * with a long \\\n" in TEST_F()
1642 " * line */ \\\n" in TEST_F()
1644 format("#define X \\\n" in TEST_F()
1645 " /* Macro comment with a long line */ \\\n" in TEST_F()
1652 "static SomeType type = {aaaaaaaaaaaaaaaaaaaa, /* comment */\n" in TEST_F()
1653 " aaaaaaaaaaaaaaaaaaaa /* comment */,\n" in TEST_F()
1654 " /* comment */ aaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
1655 " aaaaaaaaaaaaaaaaaaaa, // comment\n" in TEST_F()
1657 format("static SomeType type = { aaaaaaaaaaaaaaaaaaaa , /* comment */\n" in TEST_F()
1658 " aaaaaaaaaaaaaaaaaaaa /* comment */ ,\n" in TEST_F()
1659 " /* comment */ aaaaaaaaaaaaaaaaaaaa ,\n" in TEST_F()
1660 " aaaaaaaaaaaaaaaaaaaa , // comment\n" in TEST_F()
1662 verifyFormat("static SomeType type = {aaaaaaaaaaa, // comment for aa...\n" in TEST_F()
1664 verifyFormat("static SomeType type = {aaaaaaaaaaa,\n" in TEST_F()
1665 " // comment for bb....\n" in TEST_F()
1668 "static SomeType type = {aaaaaaaaaaa, // comment for aa...\n" in TEST_F()
1670 verifyGoogleFormat("static SomeType type = {aaaaaaaaaaa,\n" in TEST_F()
1671 " // comment for bb....\n" in TEST_F()
1674 verifyFormat("S s = {{a, b, c}, // Group #1\n" in TEST_F()
1675 " {d, e, f}, // Group #2\n" in TEST_F()
1677 verifyFormat("S s = {{// Group #1\n" in TEST_F()
1678 " a, b, c},\n" in TEST_F()
1679 " {// Group #2\n" in TEST_F()
1680 " d, e, f},\n" in TEST_F()
1681 " {// Group #3\n" in TEST_F()
1684 EXPECT_EQ("S s = {\n" in TEST_F()
1685 " // Some comment\n" in TEST_F()
1686 " a,\n" in TEST_F()
1687 "\n" in TEST_F()
1688 " // Comment after empty line\n" in TEST_F()
1690 format("S s = {\n" in TEST_F()
1691 " // Some comment\n" in TEST_F()
1692 " a,\n" in TEST_F()
1693 " \n" in TEST_F()
1694 " // Comment after empty line\n" in TEST_F()
1695 " b\n" in TEST_F()
1697 EXPECT_EQ("S s = {\n" in TEST_F()
1698 " /* Some comment */\n" in TEST_F()
1699 " a,\n" in TEST_F()
1700 "\n" in TEST_F()
1701 " /* Comment after empty line */\n" in TEST_F()
1703 format("S s = {\n" in TEST_F()
1704 " /* Some comment */\n" in TEST_F()
1705 " a,\n" in TEST_F()
1706 " \n" in TEST_F()
1707 " /* Comment after empty line */\n" in TEST_F()
1708 " b\n" in TEST_F()
1710 verifyFormat("const uint8_t aaaaaaaaaaaaaaaaaaaaaa[0] = {\n" in TEST_F()
1711 " 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // comment\n" in TEST_F()
1712 " 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // comment\n" in TEST_F()
1713 " 0x00, 0x00, 0x00, 0x00}; // comment\n"); in TEST_F()
1717 EXPECT_EQ("#if 0\n" in TEST_F()
1718 "}{)(&*(^%%#%@! fsadj f;ldjs ,:;| <<<>>>][)(][\n" in TEST_F()
1719 "#endif\n" in TEST_F()
1721 format("#if 0\n" in TEST_F()
1722 "}{)(&*(^%%#%@! fsadj f;ldjs ,:;| <<<>>>][)(][\n" in TEST_F()
1723 "#endif\n" in TEST_F()
1725 EXPECT_EQ("#if false\n" in TEST_F()
1726 "void f( ) { }\n" in TEST_F()
1727 "#endif\n" in TEST_F()
1728 "void g() {}\n", in TEST_F()
1729 format("#if false\n" in TEST_F()
1730 "void f( ) { }\n" in TEST_F()
1731 "#endif\n" in TEST_F()
1732 "void g( ) { }\n")); in TEST_F()
1733 EXPECT_EQ("enum E {\n" in TEST_F()
1734 " One,\n" in TEST_F()
1735 " Two,\n" in TEST_F()
1736 "#if 0\n" in TEST_F()
1737 "Three,\n" in TEST_F()
1738 " Four,\n" in TEST_F()
1739 "#endif\n" in TEST_F()
1740 " Five\n" in TEST_F()
1742 format("enum E {\n" in TEST_F()
1743 " One,Two,\n" in TEST_F()
1744 "#if 0\n" in TEST_F()
1745 "Three,\n" in TEST_F()
1746 " Four,\n" in TEST_F()
1747 "#endif\n" in TEST_F()
1749 EXPECT_EQ("enum F {\n" in TEST_F()
1750 " One,\n" in TEST_F()
1751 "#if 1\n" in TEST_F()
1752 " Two,\n" in TEST_F()
1753 "#if 0\n" in TEST_F()
1754 "Three,\n" in TEST_F()
1755 " Four,\n" in TEST_F()
1756 "#endif\n" in TEST_F()
1757 " Five\n" in TEST_F()
1758 "#endif\n" in TEST_F()
1760 format("enum F {\n" in TEST_F()
1761 "One,\n" in TEST_F()
1762 "#if 1\n" in TEST_F()
1763 "Two,\n" in TEST_F()
1764 "#if 0\n" in TEST_F()
1765 "Three,\n" in TEST_F()
1766 " Four,\n" in TEST_F()
1767 "#endif\n" in TEST_F()
1768 "Five\n" in TEST_F()
1769 "#endif\n" in TEST_F()
1771 EXPECT_EQ("enum G {\n" in TEST_F()
1772 " One,\n" in TEST_F()
1773 "#if 0\n" in TEST_F()
1774 "Two,\n" in TEST_F()
1775 "#else\n" in TEST_F()
1776 " Three,\n" in TEST_F()
1777 "#endif\n" in TEST_F()
1778 " Four\n" in TEST_F()
1780 format("enum G {\n" in TEST_F()
1781 "One,\n" in TEST_F()
1782 "#if 0\n" in TEST_F()
1783 "Two,\n" in TEST_F()
1784 "#else\n" in TEST_F()
1785 "Three,\n" in TEST_F()
1786 "#endif\n" in TEST_F()
1787 "Four\n" in TEST_F()
1789 EXPECT_EQ("enum H {\n" in TEST_F()
1790 " One,\n" in TEST_F()
1791 "#if 0\n" in TEST_F()
1792 "#ifdef Q\n" in TEST_F()
1793 "Two,\n" in TEST_F()
1794 "#else\n" in TEST_F()
1795 "Three,\n" in TEST_F()
1796 "#endif\n" in TEST_F()
1797 "#endif\n" in TEST_F()
1798 " Four\n" in TEST_F()
1800 format("enum H {\n" in TEST_F()
1801 "One,\n" in TEST_F()
1802 "#if 0\n" in TEST_F()
1803 "#ifdef Q\n" in TEST_F()
1804 "Two,\n" in TEST_F()
1805 "#else\n" in TEST_F()
1806 "Three,\n" in TEST_F()
1807 "#endif\n" in TEST_F()
1808 "#endif\n" in TEST_F()
1809 "Four\n" in TEST_F()
1811 EXPECT_EQ("enum I {\n" in TEST_F()
1812 " One,\n" in TEST_F()
1813 "#if /* test */ 0 || 1\n" in TEST_F()
1814 "Two,\n" in TEST_F()
1815 "Three,\n" in TEST_F()
1816 "#endif\n" in TEST_F()
1817 " Four\n" in TEST_F()
1819 format("enum I {\n" in TEST_F()
1820 "One,\n" in TEST_F()
1821 "#if /* test */ 0 || 1\n" in TEST_F()
1822 "Two,\n" in TEST_F()
1823 "Three,\n" in TEST_F()
1824 "#endif\n" in TEST_F()
1825 "Four\n" in TEST_F()
1827 EXPECT_EQ("enum J {\n" in TEST_F()
1828 " One,\n" in TEST_F()
1829 "#if 0\n" in TEST_F()
1830 "#if 0\n" in TEST_F()
1831 "Two,\n" in TEST_F()
1832 "#else\n" in TEST_F()
1833 "Three,\n" in TEST_F()
1834 "#endif\n" in TEST_F()
1835 "Four,\n" in TEST_F()
1836 "#endif\n" in TEST_F()
1837 " Five\n" in TEST_F()
1839 format("enum J {\n" in TEST_F()
1840 "One,\n" in TEST_F()
1841 "#if 0\n" in TEST_F()
1842 "#if 0\n" in TEST_F()
1843 "Two,\n" in TEST_F()
1844 "#else\n" in TEST_F()
1845 "Three,\n" in TEST_F()
1846 "#endif\n" in TEST_F()
1847 "Four,\n" in TEST_F()
1848 "#endif\n" in TEST_F()
1849 "Five\n" in TEST_F()
1862 verifyFormat("class A {\n" in TEST_F()
1863 "public:\n" in TEST_F()
1864 "public: // comment\n" in TEST_F()
1865 "protected:\n" in TEST_F()
1866 "private:\n" in TEST_F()
1867 " void f() {}\n" in TEST_F()
1869 verifyGoogleFormat("class A {\n" in TEST_F()
1870 " public:\n" in TEST_F()
1871 " protected:\n" in TEST_F()
1872 " private:\n" in TEST_F()
1873 " void f() {}\n" in TEST_F()
1875 verifyFormat("class A {\n" in TEST_F()
1876 "public slots:\n" in TEST_F()
1877 " void f1() {}\n" in TEST_F()
1878 "public Q_SLOTS:\n" in TEST_F()
1879 " void f2() {}\n" in TEST_F()
1880 "protected slots:\n" in TEST_F()
1881 " void f3() {}\n" in TEST_F()
1882 "protected Q_SLOTS:\n" in TEST_F()
1883 " void f4() {}\n" in TEST_F()
1884 "private slots:\n" in TEST_F()
1885 " void f5() {}\n" in TEST_F()
1886 "private Q_SLOTS:\n" in TEST_F()
1887 " void f6() {}\n" in TEST_F()
1888 "signals:\n" in TEST_F()
1889 " void g1();\n" in TEST_F()
1890 "Q_SIGNALS:\n" in TEST_F()
1891 " void g2();\n" in TEST_F()
1896 verifyFormat("for (Signals signals : f()) {\n}"); in TEST_F()
1897 verifyFormat("{\n" in TEST_F()
1898 " signals.set(); // This needs indentation.\n" in TEST_F()
1903 EXPECT_EQ("class A {\n" in TEST_F()
1904 "public:\n" in TEST_F()
1905 " void f();\n" in TEST_F()
1906 "\n" in TEST_F()
1907 "private:\n" in TEST_F()
1908 " void g() {}\n" in TEST_F()
1909 " // test\n" in TEST_F()
1910 "protected:\n" in TEST_F()
1911 " int h;\n" in TEST_F()
1913 format("class A {\n" in TEST_F()
1914 "public:\n" in TEST_F()
1915 "void f();\n" in TEST_F()
1916 "private:\n" in TEST_F()
1917 "void g() {}\n" in TEST_F()
1918 "// test\n" in TEST_F()
1919 "protected:\n" in TEST_F()
1920 "int h;\n" in TEST_F()
1922 EXPECT_EQ("class A {\n" in TEST_F()
1923 "protected:\n" in TEST_F()
1924 "public:\n" in TEST_F()
1925 " void f();\n" in TEST_F()
1927 format("class A {\n" in TEST_F()
1928 "protected:\n" in TEST_F()
1929 "\n" in TEST_F()
1930 "public:\n" in TEST_F()
1931 "\n" in TEST_F()
1932 " void f();\n" in TEST_F()
1936 EXPECT_EQ("#define B \\\n" in TEST_F()
1937 " class A { \\\n" in TEST_F()
1938 " protected: \\\n" in TEST_F()
1939 " public: \\\n" in TEST_F()
1940 " void f(); \\\n" in TEST_F()
1942 format("#define B \\\n" in TEST_F()
1943 " class A { \\\n" in TEST_F()
1944 " protected: \\\n" in TEST_F()
1945 " \\\n" in TEST_F()
1946 " public: \\\n" in TEST_F()
1947 " \\\n" in TEST_F()
1948 " void f(); \\\n" in TEST_F()
1952 EXPECT_EQ("#define A private:\n" in TEST_F()
1953 "\n" in TEST_F()
1955 format("#define A private:\n" in TEST_F()
1956 "\n" in TEST_F()
1965 "class AAAAAAAAAAAAAAAAAAAA : public BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,\n" in TEST_F()
1967 verifyFormat("class AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n" in TEST_F()
1968 " : public BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,\n" in TEST_F()
1972 verifyFormat("class AAAAAAAAAAAA : public B,\n" in TEST_F()
1973 " public C,\n" in TEST_F()
1974 " public D,\n" in TEST_F()
1975 " public E,\n" in TEST_F()
1976 " public F,\n" in TEST_F()
1979 verifyFormat("class\n" in TEST_F()
1980 " ReallyReallyLongClassName {\n" in TEST_F()
1981 " int i;\n" in TEST_F()
1984 verifyFormat("struct aaaaaaaaaaaaa : public aaaaaaaaaaaaaaaaaaa< // break\n" in TEST_F()
1986 verifyFormat("struct aaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
1987 " : public aaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
1989 verifyFormat("template <class R, class C>\n" in TEST_F()
1990 "struct Aaaaaaaaaaaaaaaaa<R (C::*)(int) const>\n" in TEST_F()
1996 verifyFormat("class A {\n} a, b;"); in TEST_F()
1997 verifyFormat("struct A {\n} a, b;"); in TEST_F()
1998 verifyFormat("union A {\n} a;"); in TEST_F()
2002 verifyFormat("enum {\n" in TEST_F()
2003 " Zero,\n" in TEST_F()
2004 " One = 1,\n" in TEST_F()
2005 " Two = One + 1,\n" in TEST_F()
2006 " Three = (One + Two),\n" in TEST_F()
2007 " Four = (Zero && (One ^ Two)) | (One << Two),\n" in TEST_F()
2008 " Five = (One, Two, Three, Four, 5)\n" in TEST_F()
2010 verifyGoogleFormat("enum {\n" in TEST_F()
2011 " Zero,\n" in TEST_F()
2012 " One = 1,\n" in TEST_F()
2013 " Two = One + 1,\n" in TEST_F()
2014 " Three = (One + Two),\n" in TEST_F()
2015 " Four = (Zero && (One ^ Two)) | (One << Two),\n" in TEST_F()
2016 " Five = (One, Two, Three, Four, 5)\n" in TEST_F()
2023 verifyFormat("enum {\n" in TEST_F()
2024 " Bar = Foo<int, int>::value\n" in TEST_F()
2031 EXPECT_EQ("enum KeepEmptyLines {\n" in TEST_F()
2032 " ONE,\n" in TEST_F()
2033 "\n" in TEST_F()
2034 " TWO,\n" in TEST_F()
2035 "\n" in TEST_F()
2036 " THREE\n" in TEST_F()
2038 format("enum KeepEmptyLines {\n" in TEST_F()
2039 " ONE,\n" in TEST_F()
2040 "\n" in TEST_F()
2041 " TWO,\n" in TEST_F()
2042 "\n" in TEST_F()
2043 "\n" in TEST_F()
2044 " THREE\n" in TEST_F()
2046 verifyFormat("enum E { // comment\n" in TEST_F()
2047 " ONE,\n" in TEST_F()
2048 " TWO\n" in TEST_F()
2049 "};\n" in TEST_F()
2052 verifyFormat("enum X f() {\n" in TEST_F()
2053 " a();\n" in TEST_F()
2054 " return 42;\n" in TEST_F()
2056 verifyFormat("enum X Type::f() {\n" in TEST_F()
2057 " a();\n" in TEST_F()
2058 " return 42;\n" in TEST_F()
2060 verifyFormat("enum ::X f() {\n" in TEST_F()
2061 " a();\n" in TEST_F()
2062 " return 42;\n" in TEST_F()
2064 verifyFormat("enum ns::X f() {\n" in TEST_F()
2065 " a();\n" in TEST_F()
2066 " return 42;\n" in TEST_F()
2071 verifyFormat("enum Type {\n" in TEST_F()
2072 " One = 0; // These semicolons should be commas.\n" in TEST_F()
2073 " Two = 1;\n" in TEST_F()
2075 verifyFormat("namespace n {\n" in TEST_F()
2076 "enum Type {\n" in TEST_F()
2077 " One,\n" in TEST_F()
2078 " Two, // missing };\n" in TEST_F()
2079 " int i;\n" in TEST_F()
2080 "}\n" in TEST_F()
2085 verifyFormat("enum struct {\n" in TEST_F()
2086 " Zero,\n" in TEST_F()
2087 " One = 1,\n" in TEST_F()
2088 " Two = One + 1,\n" in TEST_F()
2089 " Three = (One + Two),\n" in TEST_F()
2090 " Four = (Zero && (One ^ Two)) | (One << Two),\n" in TEST_F()
2091 " Five = (One, Two, Three, Four, 5)\n" in TEST_F()
2098 verifyFormat("enum struct X f() {\n a();\n return 42;\n}"); in TEST_F()
2102 verifyFormat("enum class {\n" in TEST_F()
2103 " Zero,\n" in TEST_F()
2104 " One = 1,\n" in TEST_F()
2105 " Two = One + 1,\n" in TEST_F()
2106 " Three = (One + Two),\n" in TEST_F()
2107 " Four = (Zero && (One ^ Two)) | (One << Two),\n" in TEST_F()
2108 " Five = (One, Two, Three, Four, 5)\n" in TEST_F()
2115 verifyFormat("enum class X f() {\n a();\n return 42;\n}"); in TEST_F()
2119 verifyFormat("enum X : int {\n" in TEST_F()
2120 " A, // Force multiple lines.\n" in TEST_F()
2121 " B\n" in TEST_F()
2129 verifyGoogleFormat("typedef NS_ENUM(NSInteger, MyType) {\n" in TEST_F()
2130 " // Information about someDecentlyLongValue.\n" in TEST_F()
2131 " someDecentlyLongValue,\n" in TEST_F()
2132 " // Information about anotherDecentlyLongValue.\n" in TEST_F()
2133 " anotherDecentlyLongValue,\n" in TEST_F()
2134 " // Information about aThirdDecentlyLongValue.\n" in TEST_F()
2135 " aThirdDecentlyLongValue\n" in TEST_F()
2137 verifyGoogleFormat("typedef NS_OPTIONS(NSInteger, MyType) {\n" in TEST_F()
2138 " a = 1,\n" in TEST_F()
2139 " b = 2,\n" in TEST_F()
2140 " c = 3,\n" in TEST_F()
2142 verifyGoogleFormat("typedef CF_ENUM(NSInteger, MyType) {\n" in TEST_F()
2143 " a = 1,\n" in TEST_F()
2144 " b = 2,\n" in TEST_F()
2145 " c = 3,\n" in TEST_F()
2147 verifyGoogleFormat("typedef CF_OPTIONS(NSInteger, MyType) {\n" in TEST_F()
2148 " a = 1,\n" in TEST_F()
2149 " b = 2,\n" in TEST_F()
2150 " c = 3,\n" in TEST_F()
2155 verifyFormat("struct Bitfields {\n" in TEST_F()
2156 " unsigned sClass : 8;\n" in TEST_F()
2157 " unsigned ValueKind : 2;\n" in TEST_F()
2159 verifyFormat("struct A {\n" in TEST_F()
2160 " int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa : 1,\n" in TEST_F()
2161 " bbbbbbbbbbbbbbbbbbbbbbbbb;\n" in TEST_F()
2163 verifyFormat("struct MyStruct {\n" in TEST_F()
2164 " uchar data;\n" in TEST_F()
2165 " uchar : 8;\n" in TEST_F()
2166 " uchar : 8;\n" in TEST_F()
2167 " uchar other;\n" in TEST_F()
2172 verifyFormat("namespace some_namespace {\n" in TEST_F()
2173 "class A {};\n" in TEST_F()
2174 "void f() { f(); }\n" in TEST_F()
2176 verifyFormat("namespace {\n" in TEST_F()
2177 "class A {};\n" in TEST_F()
2178 "void f() { f(); }\n" in TEST_F()
2180 verifyFormat("inline namespace X {\n" in TEST_F()
2181 "class A {};\n" in TEST_F()
2182 "void f() { f(); }\n" in TEST_F()
2184 verifyFormat("using namespace some_namespace;\n" in TEST_F()
2185 "class A {};\n" in TEST_F()
2192 verifyFormat("namespace {\n" in TEST_F()
2193 "class A {};\n" in TEST_F()
2196 verifyFormat("namespace {\n" in TEST_F()
2197 "int SomeVariable = 0; // comment\n" in TEST_F()
2199 EXPECT_EQ("#ifndef HEADER_GUARD\n" in TEST_F()
2200 "#define HEADER_GUARD\n" in TEST_F()
2201 "namespace my_namespace {\n" in TEST_F()
2202 "int i;\n" in TEST_F()
2203 "} // my_namespace\n" in TEST_F()
2205 format("#ifndef HEADER_GUARD\n" in TEST_F()
2206 " #define HEADER_GUARD\n" in TEST_F()
2207 " namespace my_namespace {\n" in TEST_F()
2208 "int i;\n" in TEST_F()
2209 "} // my_namespace\n" in TEST_F()
2212 EXPECT_EQ("namespace A::B {\n" in TEST_F()
2213 "class C {};\n" in TEST_F()
2215 format("namespace A::B {\n" in TEST_F()
2216 "class C {};\n" in TEST_F()
2221 EXPECT_EQ("namespace out {\n" in TEST_F()
2222 " int i;\n" in TEST_F()
2223 " namespace in {\n" in TEST_F()
2224 " int i;\n" in TEST_F()
2225 " } // namespace\n" in TEST_F()
2227 format("namespace out {\n" in TEST_F()
2228 "int i;\n" in TEST_F()
2229 "namespace in {\n" in TEST_F()
2230 "int i;\n" in TEST_F()
2231 "} // namespace\n" in TEST_F()
2236 EXPECT_EQ("namespace out {\n" in TEST_F()
2237 "int i;\n" in TEST_F()
2238 "namespace in {\n" in TEST_F()
2239 " int i;\n" in TEST_F()
2240 "} // namespace\n" in TEST_F()
2242 format("namespace out {\n" in TEST_F()
2243 "int i;\n" in TEST_F()
2244 "namespace in {\n" in TEST_F()
2245 "int i;\n" in TEST_F()
2246 "} // namespace\n" in TEST_F()
2257 "asm(\"movq\\t%%rbx, %%rsi\\n\\t\"\n" in TEST_F()
2258 " \"cpuid\\n\\t\"\n" in TEST_F()
2259 " \"xchgq\\t%%rbx, %%rsi\\n\\t\"\n" in TEST_F()
2260 " : \"=a\"(*rEAX), \"=S\"(*rEBX), \"=c\"(*rECX), \"=d\"(*rEDX)\n" in TEST_F()
2263 "void NS_InvokeByIndex(void *that, unsigned int methodIndex) {\n" in TEST_F()
2264 " __asm {\n" in TEST_F()
2265 " mov edx,[that] // vtable in edx\n" in TEST_F()
2266 " mov eax,methodIndex\n" in TEST_F()
2267 " call [edx][eax*4] // stdcall\n" in TEST_F()
2268 " }\n" in TEST_F()
2270 format("void NS_InvokeByIndex(void *that, unsigned int methodIndex) {\n" in TEST_F()
2271 " __asm {\n" in TEST_F()
2272 " mov edx,[that] // vtable in edx\n" in TEST_F()
2273 " mov eax,methodIndex\n" in TEST_F()
2274 " call [edx][eax*4] // stdcall\n" in TEST_F()
2275 " }\n" in TEST_F()
2277 EXPECT_EQ("_asm {\n" in TEST_F()
2278 " xor eax, eax;\n" in TEST_F()
2279 " cpuid;\n" in TEST_F()
2281 format("_asm {\n" in TEST_F()
2282 " xor eax, eax;\n" in TEST_F()
2283 " cpuid;\n" in TEST_F()
2285 verifyFormat("void function() {\n" in TEST_F()
2286 " // comment\n" in TEST_F()
2287 " asm(\"\");\n" in TEST_F()
2289 EXPECT_EQ("__asm {\n" in TEST_F()
2290 "}\n" in TEST_F()
2292 format("__asm {\n" in TEST_F()
2293 "}\n" in TEST_F()
2298 verifyFormat("try {\n" in TEST_F()
2299 " throw a * b;\n" in TEST_F()
2300 "} catch (int a) {\n" in TEST_F()
2301 " // Do nothing.\n" in TEST_F()
2302 "} catch (...) {\n" in TEST_F()
2303 " exit(42);\n" in TEST_F()
2307 verifyFormat("int f() try { return 4; } catch (...) {\n" in TEST_F()
2308 " return 5;\n" in TEST_F()
2310 verifyFormat("class A {\n" in TEST_F()
2311 " int a;\n" in TEST_F()
2312 " A() try : a(0) {\n" in TEST_F()
2313 " } catch (...) {\n" in TEST_F()
2314 " throw;\n" in TEST_F()
2315 " }\n" in TEST_F()
2316 "};\n"); in TEST_F()
2323 verifyFormat("__try {\n" in TEST_F()
2324 " int a = b * c;\n" in TEST_F()
2325 "} __except (EXCEPTION_EXECUTE_HANDLER) {\n" in TEST_F()
2326 " // Do nothing.\n" in TEST_F()
2329 verifyFormat("__try {\n" in TEST_F()
2330 " int a = b * c;\n" in TEST_F()
2331 "} __finally {\n" in TEST_F()
2332 " // Do nothing.\n" in TEST_F()
2335 verifyFormat("DEBUG({\n" in TEST_F()
2336 " __try {\n" in TEST_F()
2337 " } __finally {\n" in TEST_F()
2338 " }\n" in TEST_F()
2339 "});\n"); in TEST_F()
2343 verifyFormat("try {\n" in TEST_F()
2344 " f();\n" in TEST_F()
2345 "} catch {\n" in TEST_F()
2346 " g();\n" in TEST_F()
2348 verifyFormat("try {\n" in TEST_F()
2349 " f();\n" in TEST_F()
2350 "} catch (A a) MACRO(x) {\n" in TEST_F()
2351 " g();\n" in TEST_F()
2352 "} catch (B b) MACRO(x) {\n" in TEST_F()
2353 " g();\n" in TEST_F()
2362 verifyFormat("try {\n" in TEST_F()
2363 " // something\n" in TEST_F()
2364 "} catch (...) {\n" in TEST_F()
2365 " // something\n" in TEST_F()
2370 verifyFormat("try {\n" in TEST_F()
2371 " // something\n" in TEST_F()
2372 "}\n" in TEST_F()
2373 "catch (...) {\n" in TEST_F()
2374 " // something\n" in TEST_F()
2377 verifyFormat("__try {\n" in TEST_F()
2378 " // something\n" in TEST_F()
2379 "}\n" in TEST_F()
2380 "__finally {\n" in TEST_F()
2381 " // something\n" in TEST_F()
2384 verifyFormat("@try {\n" in TEST_F()
2385 " // something\n" in TEST_F()
2386 "}\n" in TEST_F()
2387 "@finally {\n" in TEST_F()
2388 " // something\n" in TEST_F()
2392 verifyFormat("try\n" in TEST_F()
2393 "{\n" in TEST_F()
2394 " // something\n" in TEST_F()
2395 "}\n" in TEST_F()
2396 "catch (...)\n" in TEST_F()
2397 "{\n" in TEST_F()
2398 " // something\n" in TEST_F()
2402 verifyFormat("try\n" in TEST_F()
2403 " {\n" in TEST_F()
2404 " // something\n" in TEST_F()
2405 " }\n" in TEST_F()
2406 "catch (...)\n" in TEST_F()
2407 " {\n" in TEST_F()
2408 " // something\n" in TEST_F()
2413 verifyFormat("try {\n" in TEST_F()
2414 " // something\n" in TEST_F()
2415 "}\n" in TEST_F()
2416 "catch (...) {\n" in TEST_F()
2417 " // something\n" in TEST_F()
2423 verifyFormat("@try {\n" in TEST_F()
2424 " f();\n" in TEST_F()
2425 "} @catch (NSException e) {\n" in TEST_F()
2426 " @throw;\n" in TEST_F()
2427 "} @finally {\n" in TEST_F()
2428 " exit(42);\n" in TEST_F()
2430 verifyFormat("DEBUG({\n" in TEST_F()
2431 " @try {\n" in TEST_F()
2432 " } @finally {\n" in TEST_F()
2433 " }\n" in TEST_F()
2434 "});\n"); in TEST_F()
2439 verifyFormat("@autoreleasepool {\n" in TEST_F()
2440 " f();\n" in TEST_F()
2441 "}\n" in TEST_F()
2442 "@autoreleasepool {\n" in TEST_F()
2443 " f();\n" in TEST_F()
2444 "}\n", in TEST_F()
2447 verifyFormat("@autoreleasepool\n" in TEST_F()
2448 "{\n" in TEST_F()
2449 " f();\n" in TEST_F()
2450 "}\n" in TEST_F()
2451 "@autoreleasepool\n" in TEST_F()
2452 "{\n" in TEST_F()
2453 " f();\n" in TEST_F()
2454 "}\n", in TEST_F()
2461 verifyFormat("static SomeClass WithALoooooooooooooooooooongName = {\n" in TEST_F()
2466 verifyFormat("static int LooooooooooooooooooooooooongVariable[1] = {\n" in TEST_F()
2468 EXPECT_EQ("S s = {a,\n" in TEST_F()
2469 "\n" in TEST_F()
2471 format("S s = {\n" in TEST_F()
2472 " a,\n" in TEST_F()
2473 "\n" in TEST_F()
2474 " b\n" in TEST_F()
2480 verifyFormat("static int Variable[1] = {\n" in TEST_F()
2487 verifyFormat("const struct A a = {.aaaaaaaaaa = 1,\n" in TEST_F()
2488 " .bbbbbbbbbb = 2,\n" in TEST_F()
2489 " .cccccccccc = 3,\n" in TEST_F()
2490 " .dddddddddd = 4,\n" in TEST_F()
2492 verifyFormat("const struct Aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa = {\n" in TEST_F()
2493 " .aaaaaaaaaaaaaaaaaaaaaaaaaaa = 1,\n" in TEST_F()
2494 " .bbbbbbbbbbbbbbbbbbbbbbbbbbb = 2,\n" in TEST_F()
2495 " .ccccccccccccccccccccccccccc = 3,\n" in TEST_F()
2496 " .ddddddddddddddddddddddddddd = 4,\n" in TEST_F()
2503 verifyFormat("static A x = {{{}}};\n"); in TEST_F()
2504 verifyFormat("static A x = {{{init1, init2, init3, init4},\n" in TEST_F()
2508 verifyFormat("somes Status::global_reps[3] = {\n" in TEST_F()
2509 " {kGlobalRef, OK_CODE, NULL, NULL, NULL},\n" in TEST_F()
2510 " {kGlobalRef, CANCELLED_CODE, NULL, NULL, NULL},\n" in TEST_F()
2513 verifyGoogleFormat("SomeType Status::global_reps[3] = {\n" in TEST_F()
2514 " {kGlobalRef, OK_CODE, NULL, NULL, NULL},\n" in TEST_F()
2515 " {kGlobalRef, CANCELLED_CODE, NULL, NULL, NULL},\n" in TEST_F()
2517 verifyFormat("CGRect cg_rect = {{rect.fLeft, rect.fTop},\n" in TEST_F()
2522 "SomeArrayOfSomeType a = {\n" in TEST_F()
2523 " {{1, 2, 3},\n" in TEST_F()
2524 " {1, 2, 3},\n" in TEST_F()
2525 " {111111111111111111111111111111, 222222222222222222222222222222,\n" in TEST_F()
2526 " 333333333333333333333333333333},\n" in TEST_F()
2527 " {1, 2, 3},\n" in TEST_F()
2530 "SomeArrayOfSomeType a = {\n" in TEST_F()
2531 " {{1, 2, 3}},\n" in TEST_F()
2532 " {{1, 2, 3}},\n" in TEST_F()
2533 " {{111111111111111111111111111111, 222222222222222222222222222222,\n" in TEST_F()
2534 " 333333333333333333333333333333}},\n" in TEST_F()
2535 " {{1, 2, 3}},\n" in TEST_F()
2538 verifyFormat("struct {\n" in TEST_F()
2539 " unsigned bit;\n" in TEST_F()
2540 " const char *const name;\n" in TEST_F()
2541 "} kBitsToOs[] = {{kOsMac, \"Mac\"},\n" in TEST_F()
2542 " {kOsWin, \"Windows\"},\n" in TEST_F()
2543 " {kOsLinux, \"Linux\"},\n" in TEST_F()
2545 verifyFormat("struct {\n" in TEST_F()
2546 " unsigned bit;\n" in TEST_F()
2547 " const char *const name;\n" in TEST_F()
2548 "} kBitsToOs[] = {\n" in TEST_F()
2549 " {kOsMac, \"Mac\"},\n" in TEST_F()
2550 " {kOsWin, \"Windows\"},\n" in TEST_F()
2551 " {kOsLinux, \"Linux\"},\n" in TEST_F()
2552 " {kOsCrOS, \"Chrome OS\"},\n" in TEST_F()
2558 " \\\n" in TEST_F()
2563 verifyFormat("virtual void write(ELFWriter *writerrr,\n" in TEST_F()
2567 verifyFormat("virtual void ~Deeeeeeeestructor() =\n" in TEST_F()
2570 verifyFormat("virtual void ~Deeeeeeeestructor() =\n" in TEST_F()
2580 EXPECT_EQ("#define Q \\\n" in TEST_F()
2581 " \"/aaaaaaaaa/aaaaaaaaaaaaaaaaaaa/\" \\\n" in TEST_F()
2594 verifyFormat("#\n;\n;\n;"); in TEST_F()
2598 EXPECT_EQ("#line 42 \"test\"\n", in TEST_F()
2599 format("# \\\n line \\\n 42 \\\n \"test\"\n")); in TEST_F()
2600 EXPECT_EQ("#define A B\n", format("# \\\n define \\\n A \\\n B\n", in TEST_F()
2606 format("# \\\n line \\\n 42 \\\n \"test\"")); in TEST_F()
2607 EXPECT_EQ("#define A B", format("# \\\n define \\\n A \\\n B")); in TEST_F()
2618 EXPECT_EQ("const char *c = STRINGIFY(\n" in TEST_F()
2620 format("const char * c = STRINGIFY(\n" in TEST_F()
2630 verifyFormat("#define A( \\\n BB)", getLLVMStyleWithColumns(12)); in TEST_F()
2631 verifyFormat("#define A( \\\n A, B)", getLLVMStyleWithColumns(12)); in TEST_F()
2633 verifyFormat("#define AA( \\\n B)", getLLVMStyleWithColumns(12)); in TEST_F()
2635 verifyFormat("#define A A\n#define A A"); in TEST_F()
2636 verifyFormat("#define A(X) A\n#define A A"); in TEST_F()
2639 verifyFormat("#define Something \\\n Other", getLLVMStyleWithColumns(22)); in TEST_F()
2643 EXPECT_EQ("// somecomment\n" in TEST_F()
2644 "#include \"a.h\"\n" in TEST_F()
2645 "#define A( \\\n" in TEST_F()
2646 " A, B)\n" in TEST_F()
2647 "#include \"b.h\"\n" in TEST_F()
2648 "// somecomment\n", in TEST_F()
2649 format(" // somecomment\n" in TEST_F()
2650 " #include \"a.h\"\n" in TEST_F()
2651 "#define A(A,\\\n" in TEST_F()
2652 " B)\n" in TEST_F()
2653 " #include \"b.h\"\n" in TEST_F()
2654 " // somecomment\n", in TEST_F()
2661 EXPECT_EQ("#define A \\\n" in TEST_F()
2662 " c; \\\n" in TEST_F()
2663 " e;\n" in TEST_F()
2665 format("#define A c; e;\n" in TEST_F()
2673 EXPECT_EQ("int x,\n" in TEST_F()
2674 "#define A\n" in TEST_F()
2676 format("int x,\n#define A\ny;")); in TEST_F()
2681 verifyFormat("#define A \\\n b #c;", getLLVMStyleWithColumns(11)); in TEST_F()
2682 verifyFormat("#define A \\\n" in TEST_F()
2683 " { \\\n" in TEST_F()
2684 " f(#c); \\\n" in TEST_F()
2688 verifyFormat("#define A(X) \\\n" in TEST_F()
2692 verifyFormat("#define A(a, b, c) \\\n" in TEST_F()
2705 EXPECT_EQ("#define A b;", format("#define A \\\n" in TEST_F()
2706 " \\\n" in TEST_F()
2709 EXPECT_EQ("#define A \\\n" in TEST_F()
2710 " \\\n" in TEST_F()
2711 " a; \\\n" in TEST_F()
2713 format("#define A \\\n" in TEST_F()
2714 " \\\n" in TEST_F()
2715 " a; \\\n" in TEST_F()
2718 EXPECT_EQ("#define A \\\n" in TEST_F()
2719 " a; \\\n" in TEST_F()
2720 " \\\n" in TEST_F()
2722 format("#define A \\\n" in TEST_F()
2723 " a; \\\n" in TEST_F()
2724 " \\\n" in TEST_F()
2731 verifyFormat("#define SOMECASES \\\n" in TEST_F()
2732 " case 1: \\\n" in TEST_F()
2733 " case 2\n", in TEST_F()
2736 verifyIncompleteFormat("#define STR(x) #x\n" in TEST_F()
2738 verifyFormat("#pragma omp threadprivate( \\\n" in TEST_F()
2743 verifyIncompleteFormat("({\n" in TEST_F()
2744 "#define b \\\n" in TEST_F()
2745 " } \\\n" in TEST_F()
2746 " a\n" in TEST_F()
2749 verifyFormat("#define A \\\n" in TEST_F()
2750 " { \\\n" in TEST_F()
2751 " {\n" in TEST_F()
2752 "#define B \\\n" in TEST_F()
2753 " } \\\n" in TEST_F()
2756 verifyNoCrash("#if a\na(\n#else\n#endif\n{a"); in TEST_F()
2757 verifyNoCrash("a={0,1\n#if a\n#else\n;\n#endif\n}"); in TEST_F()
2758 verifyNoCrash("#if a\na(\n#else\n#endif\n) a {a,b,c,d,f,g};"); in TEST_F()
2759 verifyNoCrash("#ifdef A\n a(\n #else\n #endif\n) = []() { \n)}"); in TEST_F()
2764 EXPECT_EQ("class A : public QObject {\n" in TEST_F()
2765 " Q_OBJECT\n" in TEST_F()
2766 "\n" in TEST_F()
2767 " A() {}\n" in TEST_F()
2769 format("class A : public QObject {\n" in TEST_F()
2770 " Q_OBJECT\n" in TEST_F()
2771 "\n" in TEST_F()
2772 " A() {\n}\n" in TEST_F()
2774 EXPECT_EQ("MACRO\n" in TEST_F()
2776 format("MACRO\n" in TEST_F()
2778 EXPECT_EQ("SOME_MACRO\n" in TEST_F()
2779 "namespace {\n" in TEST_F()
2780 "void f();\n" in TEST_F()
2782 format("SOME_MACRO\n" in TEST_F()
2783 " namespace {\n" in TEST_F()
2784 "void f( );\n" in TEST_F()
2790 EXPECT_EQ("class A : public QObject {\n" in TEST_F()
2791 " Q_Object A() {}\n" in TEST_F()
2793 format("class A : public QObject {\n" in TEST_F()
2794 " Q_Object\n" in TEST_F()
2795 " A() {\n}\n" in TEST_F()
2800 format("SOME_WEIRD_LOG_MACRO\n" in TEST_F()
2803 verifyFormat("VISIT_GL_CALL(GenBuffers, void, (GLsizei n, GLuint* buffers), " in TEST_F()
2804 "(n, buffers))\n", in TEST_F()
2809 EXPECT_EQ("INITIALIZE_PASS_BEGIN(ScopDetection, \"polly-detect\")\n" in TEST_F()
2810 "INITIALIZE_AG_DEPENDENCY(AliasAnalysis)\n" in TEST_F()
2811 "INITIALIZE_PASS_DEPENDENCY(DominatorTree)\n" in TEST_F()
2812 "class X {};\n" in TEST_F()
2813 "INITIALIZE_PASS_END(ScopDetection, \"polly-detect\")\n" in TEST_F()
2815 format(" INITIALIZE_PASS_BEGIN(ScopDetection, \"polly-detect\")\n" in TEST_F()
2816 " INITIALIZE_AG_DEPENDENCY(AliasAnalysis)\n" in TEST_F()
2817 " INITIALIZE_PASS_DEPENDENCY(DominatorTree)\n" in TEST_F()
2818 " class X {};\n" in TEST_F()
2819 " INITIALIZE_PASS_END(ScopDetection, \"polly-detect\")\n" in TEST_F()
2823 EXPECT_EQ("int q() {\n" in TEST_F()
2824 " IPC_BEGIN_MESSAGE_MAP(WebKitTestController, message)\n" in TEST_F()
2825 " IPC_MESSAGE_HANDLER(xxx, qqq)\n" in TEST_F()
2826 " IPC_END_MESSAGE_MAP()\n" in TEST_F()
2828 format("int q() {\n" in TEST_F()
2829 " IPC_BEGIN_MESSAGE_MAP(WebKitTestController, message)\n" in TEST_F()
2830 " IPC_MESSAGE_HANDLER(xxx, qqq)\n" in TEST_F()
2831 " IPC_END_MESSAGE_MAP()\n" in TEST_F()
2835 EXPECT_EQ("#define LIST(L) \\\n" in TEST_F()
2836 " L(A) \\\n" in TEST_F()
2837 " L(B) \\\n" in TEST_F()
2839 format("#define LIST(L) \\\n" in TEST_F()
2840 " L(A) \\\n" in TEST_F()
2841 " L(B) \\\n" in TEST_F()
2846 EXPECT_EQ("int q() {\n" in TEST_F()
2847 " f(x);\n" in TEST_F()
2848 " f(x) {}\n" in TEST_F()
2849 " f(x)->g();\n" in TEST_F()
2850 " f(x)->*g();\n" in TEST_F()
2851 " f(x).g();\n" in TEST_F()
2852 " f(x) = x;\n" in TEST_F()
2853 " f(x) += x;\n" in TEST_F()
2854 " f(x) -= x;\n" in TEST_F()
2855 " f(x) *= x;\n" in TEST_F()
2856 " f(x) /= x;\n" in TEST_F()
2857 " f(x) %= x;\n" in TEST_F()
2858 " f(x) &= x;\n" in TEST_F()
2859 " f(x) |= x;\n" in TEST_F()
2860 " f(x) ^= x;\n" in TEST_F()
2861 " f(x) >>= x;\n" in TEST_F()
2862 " f(x) <<= x;\n" in TEST_F()
2863 " f(x)[y].z();\n" in TEST_F()
2864 " LOG(INFO) << x;\n" in TEST_F()
2865 " ifstream(x) >> x;\n" in TEST_F()
2866 "}\n", in TEST_F()
2867 format("int q() {\n" in TEST_F()
2868 " f(x)\n;\n" in TEST_F()
2869 " f(x)\n {}\n" in TEST_F()
2870 " f(x)\n->g();\n" in TEST_F()
2871 " f(x)\n->*g();\n" in TEST_F()
2872 " f(x)\n.g();\n" in TEST_F()
2873 " f(x)\n = x;\n" in TEST_F()
2874 " f(x)\n += x;\n" in TEST_F()
2875 " f(x)\n -= x;\n" in TEST_F()
2876 " f(x)\n *= x;\n" in TEST_F()
2877 " f(x)\n /= x;\n" in TEST_F()
2878 " f(x)\n %= x;\n" in TEST_F()
2879 " f(x)\n &= x;\n" in TEST_F()
2880 " f(x)\n |= x;\n" in TEST_F()
2881 " f(x)\n ^= x;\n" in TEST_F()
2882 " f(x)\n >>= x;\n" in TEST_F()
2883 " f(x)\n <<= x;\n" in TEST_F()
2884 " f(x)\n[y].z();\n" in TEST_F()
2885 " LOG(INFO)\n << x;\n" in TEST_F()
2886 " ifstream(x)\n >> x;\n" in TEST_F()
2887 "}\n")); in TEST_F()
2888 EXPECT_EQ("int q() {\n" in TEST_F()
2889 " F(x)\n" in TEST_F()
2890 " if (1) {\n" in TEST_F()
2891 " }\n" in TEST_F()
2892 " F(x)\n" in TEST_F()
2893 " while (1) {\n" in TEST_F()
2894 " }\n" in TEST_F()
2895 " F(x)\n" in TEST_F()
2896 " G(x);\n" in TEST_F()
2897 " F(x)\n" in TEST_F()
2898 " try {\n" in TEST_F()
2899 " Q();\n" in TEST_F()
2900 " } catch (...) {\n" in TEST_F()
2901 " }\n" in TEST_F()
2902 "}\n", in TEST_F()
2903 format("int q() {\n" in TEST_F()
2904 "F(x)\n" in TEST_F()
2905 "if (1) {}\n" in TEST_F()
2906 "F(x)\n" in TEST_F()
2907 "while (1) {}\n" in TEST_F()
2908 "F(x)\n" in TEST_F()
2909 "G(x);\n" in TEST_F()
2910 "F(x)\n" in TEST_F()
2911 "try { Q(); } catch (...) {}\n" in TEST_F()
2912 "}\n")); in TEST_F()
2913 EXPECT_EQ("class A {\n" in TEST_F()
2914 " A() : t(0) {}\n" in TEST_F()
2915 " A(int i) noexcept() : {}\n" in TEST_F()
2916 " A(X x)\n" // FIXME: function-level try blocks are broken. in TEST_F()
2917 " try : t(0) {\n" in TEST_F()
2918 " } catch (...) {\n" in TEST_F()
2919 " }\n" in TEST_F()
2921 format("class A {\n" in TEST_F()
2922 " A()\n : t(0) {}\n" in TEST_F()
2923 " A(int i)\n noexcept() : {}\n" in TEST_F()
2924 " A(X x)\n" in TEST_F()
2925 " try : t(0) {} catch (...) {}\n" in TEST_F()
2927 EXPECT_EQ("class SomeClass {\n" in TEST_F()
2928 "public:\n" in TEST_F()
2929 " SomeClass() EXCLUSIVE_LOCK_FUNCTION(mu_);\n" in TEST_F()
2931 format("class SomeClass {\n" in TEST_F()
2932 "public:\n" in TEST_F()
2933 " SomeClass()\n" in TEST_F()
2934 " EXCLUSIVE_LOCK_FUNCTION(mu_);\n" in TEST_F()
2936 EXPECT_EQ("class SomeClass {\n" in TEST_F()
2937 "public:\n" in TEST_F()
2938 " SomeClass()\n" in TEST_F()
2939 " EXCLUSIVE_LOCK_FUNCTION(mu_);\n" in TEST_F()
2941 format("class SomeClass {\n" in TEST_F()
2942 "public:\n" in TEST_F()
2943 " SomeClass()\n" in TEST_F()
2944 " EXCLUSIVE_LOCK_FUNCTION(mu_);\n" in TEST_F()
2952 verifyFormat("#define A \\\n" in TEST_F()
2953 " f({ \\\n" in TEST_F()
2954 " g(); \\\n" in TEST_F()
2960 EXPECT_EQ("{\n {\n#define A\n }\n}", format("{{\n#define A\n}}")); in TEST_F()
2964 verifyFormat("{\n { a #c; }\n}"); in TEST_F()
2968 EXPECT_EQ("#define A \\\n { \\\n {\nint i;", in TEST_F()
2970 EXPECT_EQ("#define A \\\n } \\\n }\nint i;", in TEST_F()
2976 "#define A \\\n int i; \\\n int j;", in TEST_F()
2977 format("#define A \\\nint i;\\\n int j;", getLLVMStyleWithColumns(11))); in TEST_F()
2978 EXPECT_EQ("#define A\n\nint i;", format("#define A \\\n\n int i;")); in TEST_F()
2980 EXPECT_EQ("/* \\ \\ \\\n*/", format("\\\n/* \\ \\ \\\n*/")); in TEST_F()
2981 EXPECT_EQ("<a\n\\\\\n>", format("<a\n\\\\\n>")); in TEST_F()
2987 "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\n" in TEST_F()
2988 "zzzzzz\n" in TEST_F()
2991 "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy zzzzzz\n" in TEST_F()
2996 verifyFormat("#define A \\\n" in TEST_F()
2997 " int v( \\\n" in TEST_F()
2998 " a); \\\n" in TEST_F()
3006 " \\\n" in TEST_F()
3007 " aLoooooooooooooooooooooooongFuuuuuuuuuuuuuunctiooooooooo)\n" in TEST_F()
3008 "\n" in TEST_F()
3009 "AlooooooooooooooooooooooooooooooooooooooongCaaaaaaaaaal(\n" in TEST_F()
3010 " aLooooooooooooooooooooooonPaaaaaaaaaaaaaaaaaaaaarmmmm);\n", in TEST_F()
3012 "\\\n" in TEST_F()
3013 "aLoooooooooooooooooooooooongFuuuuuuuuuuuuuunctiooooooooo)\n" in TEST_F()
3014 " \n" in TEST_F()
3015 " AlooooooooooooooooooooooooooooooooooooooongCaaaaaaaaaal(\n" in TEST_F()
3016 " aLooooooooooooooooooooooonPaaaaaaaaaaaaaaaaaaaaarmmmm);\n")); in TEST_F()
3020 EXPECT_EQ("int\n" in TEST_F()
3021 "#define A\n" in TEST_F()
3023 format("int\n#define A\na;")); in TEST_F()
3024 verifyFormat("functionCallTo(\n" in TEST_F()
3025 " someOtherFunction(\n" in TEST_F()
3026 " withSomeParameters, whichInSequence,\n" in TEST_F()
3027 " areLongerThanALine(andAnotherCall,\n" in TEST_F()
3028 "#define A B\n" in TEST_F()
3029 " withMoreParamters,\n" in TEST_F()
3030 " whichStronglyInfluenceTheLayout),\n" in TEST_F()
3031 " andMoreParameters),\n" in TEST_F()
3034 verifyFormat("Foo::Foo()\n" in TEST_F()
3035 "#ifdef BAR\n" in TEST_F()
3036 " : baz(0)\n" in TEST_F()
3037 "#endif\n" in TEST_F()
3038 "{\n" in TEST_F()
3040 verifyFormat("void f() {\n" in TEST_F()
3041 " if (true)\n" in TEST_F()
3042 "#ifdef A\n" in TEST_F()
3043 " f(42);\n" in TEST_F()
3044 " x();\n" in TEST_F()
3045 "#else\n" in TEST_F()
3046 " g();\n" in TEST_F()
3047 " x();\n" in TEST_F()
3048 "#endif\n" in TEST_F()
3050 verifyFormat("void f(param1, param2,\n" in TEST_F()
3051 " param3,\n" in TEST_F()
3052 "#ifdef A\n" in TEST_F()
3053 " param4(param5,\n" in TEST_F()
3054 "#ifdef A1\n" in TEST_F()
3055 " param6,\n" in TEST_F()
3056 "#ifdef A2\n" in TEST_F()
3057 " param7),\n" in TEST_F()
3058 "#else\n" in TEST_F()
3059 " param8),\n" in TEST_F()
3060 " param9,\n" in TEST_F()
3061 "#endif\n" in TEST_F()
3062 " param10,\n" in TEST_F()
3063 "#endif\n" in TEST_F()
3064 " param11)\n" in TEST_F()
3065 "#else\n" in TEST_F()
3066 " param12)\n" in TEST_F()
3067 "#endif\n" in TEST_F()
3068 "{\n" in TEST_F()
3069 " x();\n" in TEST_F()
3072 verifyFormat("#if 1\n" in TEST_F()
3074 verifyFormat("#if 1\n" in TEST_F()
3075 "#endif\n" in TEST_F()
3076 "#if 1\n" in TEST_F()
3077 "#else\n" in TEST_F()
3078 "#endif\n"); in TEST_F()
3079 verifyFormat("DEBUG({\n" in TEST_F()
3080 " return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
3081 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;\n" in TEST_F()
3082 "});\n" in TEST_F()
3083 "#if a\n" in TEST_F()
3084 "#else\n" in TEST_F()
3087 verifyIncompleteFormat("void f(\n" in TEST_F()
3088 "#if A\n" in TEST_F()
3089 " );\n" in TEST_F()
3090 "#else\n" in TEST_F()
3095 verifyFormat("#endif\n" in TEST_F()
3102 verifyFormat("#if 0\n" in TEST_F()
3103 "#elif 1\n" in TEST_F()
3104 "#endif\n" in TEST_F()
3105 "void foo() {\n" in TEST_F()
3106 " if (test) foo2();\n" in TEST_F()
3113 verifyFormat("functionCall({\n" in TEST_F()
3114 " int i;\n" in TEST_F()
3115 " int j;\n" in TEST_F()
3117 verifyFormat("functionCall(\n" in TEST_F()
3118 " {\n" in TEST_F()
3119 " int i;\n" in TEST_F()
3120 " int j;\n" in TEST_F()
3121 " },\n" in TEST_F()
3123 verifyFormat("functionA(functionB({\n" in TEST_F()
3124 " int i;\n" in TEST_F()
3125 " int j;\n" in TEST_F()
3126 " }),\n" in TEST_F()
3128 verifyFormat("functionCall(\n" in TEST_F()
3129 " {\n" in TEST_F()
3130 " int i;\n" in TEST_F()
3131 " int j;\n" in TEST_F()
3132 " },\n" in TEST_F()
3133 " aaaa, bbbb, // comment\n" in TEST_F()
3135 verifyFormat("functionA(functionB({\n" in TEST_F()
3136 " int i;\n" in TEST_F()
3137 " int j;\n" in TEST_F()
3138 " }),\n" in TEST_F()
3139 " aaaa, bbbb, // comment\n" in TEST_F()
3142 verifyFormat("functionCall(aaaa, bbbb, {\n" in TEST_F()
3143 " int i;\n" in TEST_F()
3144 " int j;\n" in TEST_F()
3147 "Aaa(\n" // FIXME: There shouldn't be a linebreak here. in TEST_F()
3148 " {\n" in TEST_F()
3149 " int i; // break\n" in TEST_F()
3150 " },\n" in TEST_F()
3151 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,\n" in TEST_F()
3153 verifyFormat("DEBUG({\n" in TEST_F()
3154 " if (a)\n" in TEST_F()
3155 " f();\n" in TEST_F()
3160 EXPECT_EQ("SOME_MACRO { int i; }\n" in TEST_F()
3166 verifyFormat("void AddOsStrings(unsigned bitmask) {\n" in TEST_F()
3167 " struct s {\n" in TEST_F()
3168 " int i;\n" in TEST_F()
3169 " };\n" in TEST_F()
3170 " s kBitsToOs[] = {{10}};\n" in TEST_F()
3171 " for (int i = 0; i < 10; ++i)\n" in TEST_F()
3172 " return;\n" in TEST_F()
3174 verifyFormat("call(parameter, {\n" in TEST_F()
3175 " something();\n" in TEST_F()
3176 " // Comment using all columns.\n" in TEST_F()
3177 " somethingelse();\n" in TEST_F()
3180 verifyFormat("DEBUG( //\n" in TEST_F()
3182 verifyFormat("DEBUG( //\n" in TEST_F()
3183 " {\n" in TEST_F()
3184 " f(); //\n" in TEST_F()
3185 " },\n" in TEST_F()
3188 EXPECT_EQ("call(parameter, {\n" in TEST_F()
3189 " something();\n" in TEST_F()
3190 " // Comment too\n" in TEST_F()
3191 " // looooooooooong.\n" in TEST_F()
3192 " somethingElse();\n" in TEST_F()
3194 format("call(parameter, {\n" in TEST_F()
3195 " something();\n" in TEST_F()
3196 " // Comment too looooooooooong.\n" in TEST_F()
3197 " somethingElse();\n" in TEST_F()
3201 EXPECT_EQ("DEBUG({ // comment\n" in TEST_F()
3202 " int i;\n" in TEST_F()
3204 format("DEBUG({ // comment\n" in TEST_F()
3205 "int i;\n" in TEST_F()
3207 EXPECT_EQ("DEBUG({\n" in TEST_F()
3208 " int i;\n" in TEST_F()
3209 "\n" in TEST_F()
3210 " // comment\n" in TEST_F()
3211 " int j;\n" in TEST_F()
3213 format("DEBUG({\n" in TEST_F()
3214 " int i;\n" in TEST_F()
3215 "\n" in TEST_F()
3216 " // comment\n" in TEST_F()
3217 " int j;\n" in TEST_F()
3220 verifyFormat("DEBUG({\n" in TEST_F()
3221 " if (a)\n" in TEST_F()
3222 " return;\n" in TEST_F()
3224 verifyGoogleFormat("DEBUG({\n" in TEST_F()
3225 " if (a) return;\n" in TEST_F()
3229 verifyFormat("Debug(aaaaa,\n" in TEST_F()
3230 " {\n" in TEST_F()
3231 " if (aaaaaaaaaaaaaaaaaaaaaaaa) return;\n" in TEST_F()
3232 " },\n" in TEST_F()
3242 EXPECT_EQ("#define MACRO() \\\n" in TEST_F()
3243 " Debug(aaa, /* force line break */ \\\n" in TEST_F()
3244 " { \\\n" in TEST_F()
3245 " int i; \\\n" in TEST_F()
3246 " int j; \\\n" in TEST_F()
3248 format("#define MACRO() Debug(aaa, /* force line break */ \\\n" in TEST_F()
3252 EXPECT_EQ("#define A \\\n" in TEST_F()
3253 " [] { \\\n" in TEST_F()
3254 " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx( \\\n" in TEST_F()
3255 " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx); \\\n" in TEST_F()
3257 format("#define A [] { xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx( \\\n" in TEST_F()
3272 verifyFormat("FOO_BEGIN\n" in TEST_F()
3273 " FOO_ENTRY\n" in TEST_F()
3275 verifyFormat("FOO_BEGIN\n" in TEST_F()
3276 " NESTED_FOO_BEGIN\n" in TEST_F()
3277 " NESTED_FOO_ENTRY\n" in TEST_F()
3278 " NESTED_FOO_END\n" in TEST_F()
3280 verifyFormat("FOO_BEGIN(Foo, Bar)\n" in TEST_F()
3281 " int x;\n" in TEST_F()
3282 " x = 1;\n" in TEST_F()
3292 "void f() {\n" in TEST_F()
3293 " SomeLongMethodName(SomeReallyLongMethod(CallOtherReallyLongMethod(\n" in TEST_F()
3294 " parameter, parameter, parameter)),\n" in TEST_F()
3295 " SecondLongCall(parameter));\n" in TEST_F()
3298 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
3299 " aaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
3300 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa),\n" in TEST_F()
3303 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3304 " [aaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3305 " [aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]\n" in TEST_F()
3308 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<\n" in TEST_F()
3309 " aaaaaaaaaaaaaaaaaaaaaaaa<\n" in TEST_F()
3310 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>,\n" in TEST_F()
3312 verifyFormat("int a = bbbb && ccc && fffff(\n" in TEST_F()
3313 "#define A Just forcing a new line\n" in TEST_F()
3319 "bool aaaaaaa =\n" in TEST_F()
3320 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaa).aaaaaaaaaaaaaaaaaaa() ||\n" in TEST_F()
3323 "bool aaaaaaa =\n" in TEST_F()
3324 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaa).aaaaaaaaaaaaaaaaaaa() or\n" in TEST_F()
3327 verifyFormat("bool aaaaaaaaaaaaaaaaaaaaa =\n" in TEST_F()
3328 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbb &&\n" in TEST_F()
3330 verifyFormat("bool aaaaaaaaaaaaaaaaaaaaa =\n" in TEST_F()
3331 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbb and\n" in TEST_F()
3334 "bool aaaaaaaaaaaaaaaaaaaaa =\n" in TEST_F()
3335 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa not_eq bbbbbbbbbbbbbbbbbb and\n" in TEST_F()
3338 verifyFormat("aaaaaa = aaaaaaa(aaaaaaa, // break\n" in TEST_F()
3339 " aaaaaa) &&\n" in TEST_F()
3341 verifyFormat("aaaaaa = aaaaaaa(aaaaaaa, // break\n" in TEST_F()
3342 " aaaaaa) >>\n" in TEST_F()
3344 verifyFormat("aa = Whitespaces.addUntouchableComment(\n" in TEST_F()
3345 " SourceMgr.getSpellingColumnNumber(\n" in TEST_F()
3346 " TheLine.Last->FormatTok.Tok.getLocation()) -\n" in TEST_F()
3349 verifyFormat("if ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n" in TEST_F()
3350 " bbbbbbbbbbbbbbbbbb) && // aaaaaaaaaaaaaaaa\n" in TEST_F()
3351 " cccccc) {\n}"); in TEST_F()
3352 verifyFormat("b = a &&\n" in TEST_F()
3353 " // Comment\n" in TEST_F()
3359 "if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
3360 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) > 5) {\n" in TEST_F()
3363 "if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
3364 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) == 5) {\n" in TEST_F()
3367 "if (aaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
3368 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) == 5) {\n" in TEST_F()
3372 verifyFormat("if ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
3373 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) == 5) {\n" in TEST_F()
3377 "if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
3378 " aaaaaaaaaaaaaaa) > aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
3379 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n" in TEST_F()
3385 verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
3386 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==\n" in TEST_F()
3387 " 5) {\n" in TEST_F()
3393 "if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n" in TEST_F()
3394 " aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n" in TEST_F()
3395 " aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n}", in TEST_F()
3400 verifyFormat("bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
3401 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
3402 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==\n" in TEST_F()
3403 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *\n" in TEST_F()
3404 " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +\n" in TEST_F()
3405 " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb &&\n" in TEST_F()
3406 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *\n" in TEST_F()
3407 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >\n" in TEST_F()
3409 verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *\n" in TEST_F()
3410 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
3411 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==\n" in TEST_F()
3412 " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n}"); in TEST_F()
3413 verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
3414 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *\n" in TEST_F()
3415 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==\n" in TEST_F()
3416 " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n}"); in TEST_F()
3417 verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==\n" in TEST_F()
3418 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *\n" in TEST_F()
3419 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
3420 " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n}"); in TEST_F()
3421 verifyFormat("if () {\n" in TEST_F()
3422 "} else if (aaaaa &&\n" in TEST_F()
3423 " bbbbb > // break\n" in TEST_F()
3424 " ccccc) {\n" in TEST_F()
3428 verifyFormat("return aaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
3429 " b;\n" in TEST_F()
3430 "return aaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
3444 "bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3445 " + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3446 " + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3447 " == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3448 " * bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n" in TEST_F()
3449 " + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n" in TEST_F()
3450 " && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3451 " * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3454 verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3455 " * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3456 " + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3457 " == bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n}", in TEST_F()
3459 verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3460 " + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3461 " * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3462 " == bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n}", in TEST_F()
3464 verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3465 " == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3466 " * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3467 " + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n}", in TEST_F()
3469 verifyFormat("if () {\n" in TEST_F()
3470 "} else if (aaaaa\n" in TEST_F()
3471 " && bbbbb // break\n" in TEST_F()
3472 " > ccccc) {\n" in TEST_F()
3475 verifyFormat("return (a)\n" in TEST_F()
3476 " // comment\n" in TEST_F()
3480 "int aaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3481 " * bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n" in TEST_F()
3485 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3491 "unsigned ContentSize =\n" in TEST_F()
3492 " sizeof(int16_t) // DWARF ARange version number\n" in TEST_F()
3493 " + sizeof(int32_t) // Offset of CU in the .debug_info section\n" in TEST_F()
3494 " + sizeof(int8_t) // Pointer Size (in bytes)\n" in TEST_F()
3497 verifyFormat("return boost::fusion::at_c<0>(iiii).second\n" in TEST_F()
3502 verifyFormat("zzzzzzzzzz\n" in TEST_F()
3503 " = bbbbbbbbbbbbbbbbb\n" in TEST_F()
3512 verifyFormat("bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3513 " + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3514 " + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3515 " == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3516 " * bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n" in TEST_F()
3517 " + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n" in TEST_F()
3518 " && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3519 " * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3523 verifyFormat("int aaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3524 " * bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n" in TEST_F()
3527 verifyFormat("int a = aa\n" in TEST_F()
3528 " + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n" in TEST_F()
3533 verifyFormat("return (a > b\n" in TEST_F()
3534 " // comment1\n" in TEST_F()
3535 " // comment2\n" in TEST_F()
3543 verifyFormat("int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n" in TEST_F()
3544 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3553 verifyFormat("Constructor()\n" in TEST_F()
3556 verifyFormat("Constructor()\n" in TEST_F()
3560 verifyFormat("template <typename T>\n" in TEST_F()
3565 "SomeClass::Constructor()\n" in TEST_F()
3569 "SomeClass::Constructor()\n" in TEST_F()
3570 " : aaaaaaaaaaaaa(aaaaaaaaaaaaaa), aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n" in TEST_F()
3573 "SomeClass::Constructor()\n" in TEST_F()
3574 " : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa),\n" in TEST_F()
3576 verifyFormat("Constructor(aaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
3577 " aaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
3580 verifyFormat("Constructor()\n" in TEST_F()
3581 " : aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa),\n" in TEST_F()
3582 " aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
3583 " aaaaaaaaaaaaaaaaaaaaaaaaaaa),\n" in TEST_F()
3586 verifyFormat("Constructor()\n" in TEST_F()
3587 " : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
3590 verifyFormat("Constructor(int Parameter = 0)\n" in TEST_F()
3591 " : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa),\n" in TEST_F()
3593 verifyFormat("Constructor()\n" in TEST_F()
3594 " : aaaaaaaaaaaaaaaaaaaa(a), bbbbbbbbbbbbbbbbbbbbbbbb(b) {\n" in TEST_F()
3597 verifyFormat("Constructor()\n" in TEST_F()
3598 " : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
3603 verifyFormat("Constructor()\n" in TEST_F()
3604 " : aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaa),\n" in TEST_F()
3605 " aaaaaaaaaaa(aaaaaaaaaaa),\n" in TEST_F()
3610 verifyFormat("SomeClass::Constructor()\n" in TEST_F()
3611 " : aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n" in TEST_F()
3612 " aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n" in TEST_F()
3615 verifyFormat("SomeClass::Constructor()\n" in TEST_F()
3616 " : aaaaaaaaaaaaa(aaaaaaaaaaaaaa), // Some comment\n" in TEST_F()
3617 " aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n" in TEST_F()
3620 verifyFormat("MyClass::MyClass(int var)\n" in TEST_F()
3621 " : some_var_(var), // 4 space indent\n" in TEST_F()
3622 " some_other_var_(var + 1) { // lined up\n" in TEST_F()
3625 verifyFormat("Constructor()\n" in TEST_F()
3626 " : aaaaa(aaaaaa),\n" in TEST_F()
3627 " aaaaa(aaaaaa),\n" in TEST_F()
3628 " aaaaa(aaaaaa),\n" in TEST_F()
3629 " aaaaa(aaaaaa),\n" in TEST_F()
3632 verifyFormat("Constructor()\n" in TEST_F()
3633 " : aaaaa(aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
3637 verifyFormat("Constructor()\n" in TEST_F()
3638 " : aaaaaaaaaaaaaaaaaaaa(a),\n" in TEST_F()
3642 EXPECT_EQ("Constructor()\n" in TEST_F()
3643 " : // Comment forcing unwanted break.\n" in TEST_F()
3645 format("Constructor() :\n" in TEST_F()
3646 " // Comment forcing unwanted break.\n" in TEST_F()
3654 "extern CFRunLoopTimerRef\n" in TEST_F()
3655 "CFRunLoopTimerCreate(CFAllocatorRef allocato, CFAbsoluteTime fireDate,\n" in TEST_F()
3656 " CFTimeInterval interval, CFOptionFlags flags,\n" in TEST_F()
3657 " CFIndex order, CFRunLoopTimerCallBack callout,\n" in TEST_F()
3662 "aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(\n" in TEST_F()
3663 " aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(\n" in TEST_F()
3664 " aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(\n" in TEST_F()
3665 " aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(\n" in TEST_F()
3669 "aaaaa(\n" in TEST_F()
3670 " aaaaa,\n" in TEST_F()
3671 " aaaaa(\n" in TEST_F()
3672 " aaaaa,\n" in TEST_F()
3673 " aaaaa(\n" in TEST_F()
3674 " aaaaa,\n" in TEST_F()
3675 " aaaaa(\n" in TEST_F()
3676 " aaaaa,\n" in TEST_F()
3677 " aaaaa(\n" in TEST_F()
3678 " aaaaa,\n" in TEST_F()
3679 " aaaaa(\n" in TEST_F()
3680 " aaaaa,\n" in TEST_F()
3681 " aaaaa(\n" in TEST_F()
3682 " aaaaa,\n" in TEST_F()
3683 " aaaaa(\n" in TEST_F()
3684 " aaaaa,\n" in TEST_F()
3685 " aaaaa(\n" in TEST_F()
3686 " aaaaa,\n" in TEST_F()
3687 " aaaaa(\n" in TEST_F()
3688 " aaaaa,\n" in TEST_F()
3689 " aaaaa(\n" in TEST_F()
3690 " aaaaa,\n" in TEST_F()
3691 " aaaaa(\n" in TEST_F()
3692 " aaaaa,\n" in TEST_F()
3696 "a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(), a), a), a), a),\n" in TEST_F()
3697 " a),\n" in TEST_F()
3698 " a),\n" in TEST_F()
3699 " a),\n" in TEST_F()
3700 " a),\n" in TEST_F()
3701 " a),\n" in TEST_F()
3702 " a),\n" in TEST_F()
3703 " a),\n" in TEST_F()
3704 " a),\n" in TEST_F()
3705 " a),\n" in TEST_F()
3706 " a),\n" in TEST_F()
3707 " a),\n" in TEST_F()
3708 " a),\n" in TEST_F()
3709 " a),\n" in TEST_F()
3710 " a),\n" in TEST_F()
3711 " a),\n" in TEST_F()
3712 " a),\n" in TEST_F()
3720 std::string input = "Constructor()\n" in TEST_F()
3721 " : aaaa(a,\n"; in TEST_F()
3723 input += " a,\n"; in TEST_F()
3731 "void f() {\n" in TEST_F()
3732 " if ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaaaaaaaa) ||\n" in TEST_F()
3733 " (bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && bbbbbbbbbbbbbbbbbbbbbbbbbb))\n" in TEST_F()
3734 " f();\n" in TEST_F()
3736 verifyFormat("if (Intervals[i].getRange().getFirst() <\n" in TEST_F()
3737 " Intervals[i - 1].getRange().getLast()) {\n}"); in TEST_F()
3743 verifyFormat("Aaaaaaaaaaaaaa bbbbbbbbbbbbbb(Cccccccccccccc cccccccccccccc,\n" in TEST_F()
3745 verifyFormat("template <class TemplateIt>\n" in TEST_F()
3746 "SomeReturnType SomeFunction(TemplateIt begin, TemplateIt end,\n" in TEST_F()
3751 "Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3757 "Aaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbb(\n" in TEST_F()
3763 "Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3764 "SomeClasssssssssssssssssssssssssssssssssssssss::\n" in TEST_F()
3772 verifyFormat("Aaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbb(Cccccccccccccc cccccccccc,\n" in TEST_F()
3773 " Cccccccccccccc cccccccccc,\n" in TEST_F()
3774 " Cccccccccccccc cccccccccc,\n" in TEST_F()
3775 " Cccccccccccccc cccccccccc,\n" in TEST_F()
3778 "Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3779 "bbbbbbbbbbb(Cccccccccccccc cccccccccc, Cccccccccccccc cccccccccc,\n" in TEST_F()
3780 " Cccccccccccccc cccccccccc, Cccccccccccccc cccccccccc,\n" in TEST_F()
3784 "Aaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(Cccccccccccccc cccccccccc,\n" in TEST_F()
3785 " Cccccccccccccc cccccccccc,\n" in TEST_F()
3786 " Cccccccccccccc cccccccccc,\n" in TEST_F()
3787 " Cccccccccccccc cccccccccc,\n" in TEST_F()
3788 " Cccccccccccccc cccccccccc,\n" in TEST_F()
3789 " Cccccccccccccc cccccccccc,\n" in TEST_F()
3791 verifyFormat("Aaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(\n" in TEST_F()
3792 " Cccccccccccccc cccccccccc, Cccccccccccccc cccccccccc,\n" in TEST_F()
3793 " Cccccccccccccc cccccccccc, Cccccccccccccc cccccccccc,\n" in TEST_F()
3794 " Cccccccccccccc cccccccccc, Cccccccccccccc cccccccccc,\n" in TEST_F()
3798 verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
3799 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3800 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
3802 verifyFormat("void SomeLoooooooooooongFunction(\n" in TEST_F()
3803 " std::unique_ptr<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>\n" in TEST_F()
3804 " aaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
3808 verifyFormat("SomeLoooooooooooooooooooooooooogType\n" in TEST_F()
3810 verifyFormat("SomeLoooooooooooooooooooooooooogType\n" in TEST_F()
3812 verifyFormat("SomeLoooooooooooooooooooooooooogType\n" in TEST_F()
3815 "SomeLoooooooooooooooooooooooooooooogType operator>>(\n" in TEST_F()
3818 "SomeLoooooooooooooooooooooooooooooogType operator<<(\n" in TEST_F()
3820 verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
3822 verifyFormat("aaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3825 "typename aaaaaaaaaa<aaaaaa>::aaaaaaaaaaa\n" in TEST_F()
3826 "aaaaaaaaaa<aaaaaa>::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
3831 verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
3834 verifyFormat("void aaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*\n" in TEST_F()
3840 verifyFormat("auto foo() -> int;\n"); in TEST_F()
3841 verifyFormat("struct S {\n" in TEST_F()
3842 " auto bar() const -> int;\n" in TEST_F()
3844 verifyFormat("template <size_t Order, typename T>\n" in TEST_F()
3845 "auto load_img(const std::string &filename)\n" in TEST_F()
3847 verifyFormat("auto SomeFunction(A aaaaaaaaaaaaaaaaaaaaa) const\n" in TEST_F()
3850 verifyFormat("template <typename T>\n" in TEST_F()
3851 "auto aaaaaaaaaaaaaaaaaaaaaa(T t)\n" in TEST_F()
3863 verifyFormat("void someLongFunction(\n" in TEST_F()
3864 " int someLoooooooooooooongParameter) const {\n}", in TEST_F()
3866 verifyFormat("LoooooongReturnType\n" in TEST_F()
3869 verifyFormat("LoooooongReturnType someLoooooooongFunction()\n" in TEST_F()
3872 verifyFormat("void SomeFunction(aaaaa aaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
3874 verifyFormat("void SomeFunction(aaaaa aaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
3876 verifyFormat("void SomeFunction(aaaaa aaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
3878 verifyFormat("virtual void aaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaa aaaa,\n" in TEST_F()
3881 "virtual void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()\n" in TEST_F()
3885 verifyFormat("void someLongFunction(\n" in TEST_F()
3888 verifyFormat("void someLongFunction(\n" in TEST_F()
3891 verifyFormat("void someLongFunction(\n" in TEST_F()
3894 verifyFormat("void someLongFunction(\n" in TEST_F()
3897 verifyFormat("void someLongFunction(\n" in TEST_F()
3900 verifyFormat("void someLongFunction(\n" in TEST_F()
3903 verifyFormat("void someLongFunction(\n" in TEST_F()
3908 verifyFormat("void someLongFunction(\n" in TEST_F()
3909 " int someLongParameter) const\n" in TEST_F()
3910 "{\n" in TEST_F()
3915 verifyFormat("void SomeFunction(aaaaaaaaaa aaaaaaaaaaaaaaa,\n" in TEST_F()
3916 " aaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
3921 verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
3923 verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const\n" in TEST_F()
3925 verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const\n" in TEST_F()
3927 verifyGoogleFormat("void aaaaaaaaaaaaaa(aaaaaaaa aaa) override\n" in TEST_F()
3932 "void aaaaaaaaaaaaaaaaaa()\n" in TEST_F()
3933 " __attribute__((aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
3935 verifyFormat("bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3938 "bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3941 "bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3944 "bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(aaaaaaaaaaaa) =\n" in TEST_F()
3947 "bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(aaaaaaaaaaaa) =\n" in TEST_F()
3952 verifyFormat("DEPRECATED(\"Use NewClass::NewFunction instead.\")\n" in TEST_F()
3954 verifyFormat("DEPRECATED(\"Use NewClass::NewFunction instead.\")\n" in TEST_F()
3956 verifyFormat("template <typename T>\n" in TEST_F()
3957 "DEPRECATED(\"Use NewClass::NewFunction instead.\")\n" in TEST_F()
3961 verifyFormat("ASSERT(\"aaaaa\") << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
3963 verifyFormat("TEST_F(ThisIsATestFixtureeeeeeeeeeeee,\n" in TEST_F()
3968 verifyFormat("if (aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa) ||\n" in TEST_F()
3969 " aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa) ||\n" in TEST_F()
3970 " aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa)) {\n}"); in TEST_F()
3971 verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
3972 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)) {\n" in TEST_F()
3976 "aaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
3979 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
3980 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
3984 "aaaaaaaa(aaaaaaaaaaaaa, aaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
3985 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)),\n" in TEST_F()
3986 " aaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
3989 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n" in TEST_F()
3993 "void f() {\n" in TEST_F()
3994 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&\n" in TEST_F()
3995 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);\n" in TEST_F()
3998 "aaaaaa(new Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4001 "aaaaaa(aaa, new Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4003 verifyFormat("aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
4004 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4008 verifyFormat("aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(\n" in TEST_F()
4010 verifyFormat("aaaaaaaaaaa(!bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(\n" in TEST_F()
4012 verifyFormat("aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccc(\n" in TEST_F()
4018 "return aaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaa ||\n" in TEST_F()
4019 " aaaaaaaaaaa(aaaaaaaaa) || aaaaaaaaaaaaaaaaaaaaaaa ||\n" in TEST_F()
4020 " aaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaa ||\n" in TEST_F()
4023 verifyFormat("{\n {\n {\n" in TEST_F()
4024 " Annotation.SpaceRequiredBefore =\n" in TEST_F()
4025 " Line.Tokens[i - 1].Tok.isNot(tok::l_paren) &&\n" in TEST_F()
4026 " Line.Tokens[i - 1].Tok.isNot(tok::l_square);\n" in TEST_F()
4027 " }\n }\n}"); in TEST_F()
4030 EXPECT_EQ("f(g(h(a, // comment\n" in TEST_F()
4031 " b, c),\n" in TEST_F()
4032 " d, e),\n" in TEST_F()
4034 format("f(g(h(a, // comment\n" in TEST_F()
4039 "const int kTrackingOptions = NSTrackingMouseMoved |\n" in TEST_F()
4040 " NSTrackingMouseEnteredAndExited |\n" in TEST_F()
4048 verifyFormat("void f() {\n" in TEST_F()
4049 " f(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4050 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);\n" in TEST_F()
4053 verifyFormat("void f(int aaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4054 " int aaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4063 verifyFormat("f(aaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4064 " aaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4067 verifyFormat("aaaaaaa(aaaaaaaaaaaaa,\n" in TEST_F()
4068 " aaaaaaaaaaaaa,\n" in TEST_F()
4072 "aaaaaaaa(aaaaaaaaaaaaa,\n" in TEST_F()
4073 " aaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4074 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)),\n" in TEST_F()
4075 " aaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4078 verifyFormat("aaaaaaaaaaaaaaa(aaaaaaaaa, aaaaaaaaa, aaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
4081 verifyFormat("void f() {\n" in TEST_F()
4082 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4083 " aaaaaaaaaa, aaaaaaaaaa, aaaaaaaaaa, aaaaaaaaaaa);\n" in TEST_F()
4088 "aaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4089 " aaaaaaaaaaaa,\n" in TEST_F()
4093 "somefunction(someotherFunction(ddddddddddddddddddddddddddddddddddd,\n" in TEST_F()
4094 " ddddddddddddddddddddddddddddd),\n" in TEST_F()
4098 verifyFormat("std::vector<aaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4099 " aaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4100 " aaaaaaaaaaaaaaaaaaaaaaa>\n" in TEST_F()
4103 verifyFormat("a(\"a\"\n" in TEST_F()
4104 " \"a\",\n" in TEST_F()
4108 verifyFormat("void aaaaaaaaaa(aaaaaaaaa,\n" in TEST_F()
4109 " aaaaaaaaa,\n" in TEST_F()
4113 "void f() {\n" in TEST_F()
4114 " aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaa, aaaaaaaaa, aaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
4115 " .aaaaaaa();\n" in TEST_F()
4119 "template <class SomeType, class SomeOtherType>\n" in TEST_F()
4127 EXPECT_EQ("aaa(aaaa,\n" in TEST_F()
4128 " aaaa,\n" in TEST_F()
4129 " aaaa);\n" in TEST_F()
4130 "aaa(aaaa,\n" in TEST_F()
4131 " aaaa,\n" in TEST_F()
4133 format("aaa(aaaa,\n" // one-per-line in TEST_F()
4134 " aaaa,\n" in TEST_F()
4135 " aaaa );\n" in TEST_F()
4138 EXPECT_EQ("aaa(aaaa, aaaa,\n" in TEST_F()
4139 " aaaa);\n" in TEST_F()
4140 "aaa(aaaa, aaaa,\n" in TEST_F()
4142 format("aaa(aaaa, aaaa,\n" // bin-packed in TEST_F()
4143 " aaaa );\n" in TEST_F()
4149 verifyFormat("return llvm::StringSwitch<Reference::Kind>(name)\n" in TEST_F()
4150 " .StartsWith(\".eh_frame_hdr\", ORDER_EH_FRAMEHDR)\n" in TEST_F()
4151 " .StartsWith(\".eh_frame\", ORDER_EH_FRAME)\n" in TEST_F()
4152 " .StartsWith(\".init\", ORDER_INIT)\n" in TEST_F()
4153 " .StartsWith(\".fini\", ORDER_FINI)\n" in TEST_F()
4154 " .StartsWith(\".hash\", ORDER_HASH)\n" in TEST_F()
4155 " .Default(ORDER_TEXT);\n"); in TEST_F()
4157 verifyFormat("return aaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa() <\n" in TEST_F()
4160 "aaaaaaa->aaaaaaa->aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4161 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
4164 "aaaaaaa->aaaaaaa\n" in TEST_F()
4165 " ->aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
4168 "aaaaaaaaaaaaaaaaaaa()->aaaaaa(bbbbb)->aaaaaaaaaaaaaaaaaaa( // break\n" in TEST_F()
4171 "aaaaaaaaaaaaaaaaaaaaaaa *aaaaaaaaa =\n" in TEST_F()
4172 " aaaaaa->aaaaaaaaaaaa()\n" in TEST_F()
4173 " ->aaaaaaaaaaaaaaaa(\n" in TEST_F()
4174 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
4177 "void f() {\n" in TEST_F()
4178 " someo->Add((new util::filetools::Handler(dir))\n" in TEST_F()
4179 " ->OnEvent1(NewPermanentCallback(\n" in TEST_F()
4180 " this, &HandlerHolderClass::EventHandlerCBA))\n" in TEST_F()
4181 " ->OnEvent2(NewPermanentCallback(\n" in TEST_F()
4182 " this, &HandlerHolderClass::EventHandlerCBB))\n" in TEST_F()
4183 " ->OnEvent3(NewPermanentCallback(\n" in TEST_F()
4184 " this, &HandlerHolderClass::EventHandlerCBC))\n" in TEST_F()
4185 " ->OnEvent5(NewPermanentCallback(\n" in TEST_F()
4186 " this, &HandlerHolderClass::EventHandlerCBD))\n" in TEST_F()
4187 " ->OnEvent6(NewPermanentCallback(\n" in TEST_F()
4188 " this, &HandlerHolderClass::EventHandlerCBE)));\n" in TEST_F()
4193 verifyFormat("aaaaaaaaaaaaaaa()\n" in TEST_F()
4194 " .aaaaaaaaaaaaaaa()\n" in TEST_F()
4195 " .aaaaaaaaaaaaaaa()\n" in TEST_F()
4196 " .aaaaaaaaaaaaaaa()\n" in TEST_F()
4198 verifyFormat("aaaaaaaaaaaaaaa.aaaaaaaaaaaaaaa()\n" in TEST_F()
4199 " .aaaaaaaaaaaaaaa()\n" in TEST_F()
4200 " .aaaaaaaaaaaaaaa()\n" in TEST_F()
4202 verifyFormat("aaaaaaaaaaaaaaa.aaaaaaaaaaaaaaa()\n" in TEST_F()
4203 " .aaaaaaaaaaaaaaa.aaaaaaaaaaaaaaa()\n" in TEST_F()
4205 verifyFormat("aaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaaaa()\n" in TEST_F()
4206 " ->aaaaaaaaaaaaaae(0)\n" in TEST_F()
4210 verifyFormat("a().aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()\n" in TEST_F()
4211 " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()\n" in TEST_F()
4213 verifyFormat("aa().aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()\n" in TEST_F()
4214 " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()\n" in TEST_F()
4216 verifyFormat("aaa()\n" in TEST_F()
4217 " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()\n" in TEST_F()
4218 " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()\n" in TEST_F()
4221 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaa()\n" in TEST_F()
4222 " .aaaaaaaaaaaaaaaaaaaaaaaaaa()\n" in TEST_F()
4224 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaa()\n" in TEST_F()
4225 " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<\n" in TEST_F()
4229 verifyFormat("FirstToken->WhitespaceRange.getBegin().getLocWithOffset(\n" in TEST_F()
4234 "return !soooooooooooooome_map\n" in TEST_F()
4235 " .insert(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
4241 "if (aaaaaaaaaaaaaaaaaaaaaaaaa ||\n" in TEST_F()
4242 " bbbbbbbbbbbbbbbbbbbbbbbbb && ccccccccccccccccccccccccc) {\n}"); in TEST_F()
4244 "if (aaaaaaaaaaaaaaaaaaaaaaaaa or\n" in TEST_F()
4245 " bbbbbbbbbbbbbbbbbbbbbbbbb and cccccccccccccccccccccccc) {\n}"); in TEST_F()
4247 verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaa && bbbbbbbbbbbbbbbbbbbbbbbbb ||\n" in TEST_F()
4248 " ccccccccccccccccccccccccc) {\n}"); in TEST_F()
4249 verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaa and bbbbbbbbbbbbbbbbbbbbbbbb or\n" in TEST_F()
4250 " ccccccccccccccccccccccccc) {\n}"); in TEST_F()
4252 verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaa || bbbbbbbbbbbbbbbbbbbbbbbbb ||\n" in TEST_F()
4253 " ccccccccccccccccccccccccc) {\n}"); in TEST_F()
4254 verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaa or bbbbbbbbbbbbbbbbbbbbbbbbb or\n" in TEST_F()
4255 " ccccccccccccccccccccccccc) {\n}"); in TEST_F()
4258 "if ((aaaaaaaaaaaaaaaaaaaaaaaaa || bbbbbbbbbbbbbbbbbbbbbbbbb) &&\n" in TEST_F()
4259 " ccccccccccccccccccccccccc) {\n}"); in TEST_F()
4261 "if ((aaaaaaaaaaaaaaaaaaaaaaaaa or bbbbbbbbbbbbbbbbbbbbbbbbb) and\n" in TEST_F()
4262 " ccccccccccccccccccccccccc) {\n}"); in TEST_F()
4264 verifyFormat("return aaaa & AAAAAAAAAAAAAAAAAAAAAAAAAAAAA ||\n" in TEST_F()
4265 " bbbb & BBBBBBBBBBBBBBBBBBBBBBBBBBBBB ||\n" in TEST_F()
4266 " cccc & CCCCCCCCCCCCCCCCCCCCCCCCCC ||\n" in TEST_F()
4268 verifyFormat("return aaaa & AAAAAAAAAAAAAAAAAAAAAAAAAAAAA or\n" in TEST_F()
4269 " bbbb & BBBBBBBBBBBBBBBBBBBBBBBBBBBBB or\n" in TEST_F()
4270 " cccc & CCCCCCCCCCCCCCCCCCCCCCCCCC or\n" in TEST_F()
4273 verifyFormat("if ((aaaaaaaaaa != aaaaaaaaaaaaaaa ||\n" in TEST_F()
4274 " aaaaaaaaaaaaaaaaaaaaaaaa() >= aaaaaaaaaaaaaaaaaaaa) &&\n" in TEST_F()
4275 " aaaaaaaaaaaaaaa != aa) {\n}"); in TEST_F()
4276 verifyFormat("if ((aaaaaaaaaa != aaaaaaaaaaaaaaa or\n" in TEST_F()
4277 " aaaaaaaaaaaaaaaaaaaaaaaa() >= aaaaaaaaaaaaaaaaaaaa) and\n" in TEST_F()
4278 " aaaaaaaaaaaaaaa != aa) {\n}"); in TEST_F()
4283 "unsigned Cost =\n" in TEST_F()
4284 " TTI.getMemoryOpCost(I->getOpcode(), VectorTy, SI->getAlignment(),\n" in TEST_F()
4285 " SI->getPointerAddressSpaceee());\n"); in TEST_F()
4287 "CharSourceRange LineRange = CharSourceRange::getTokenRange(\n" in TEST_F()
4291 "aaaaaaaaaaaaaaaaaaaaaaaaaa aaaa = aaaaaaaaaaaaaa(0).aaaa().aaaaaaaaa(\n" in TEST_F()
4293 verifyFormat("unsigned OriginalStartColumn =\n" in TEST_F()
4294 " SourceMgr.getSpellingColumnNumber(\n" in TEST_F()
4295 " Current.FormatTok.getStartOfNonWhitespace()) -\n" in TEST_F()
4301 "int Result = aaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
4304 "Result += aaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
4307 "Result >>= aaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
4310 "int Result = (aaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
4313 "double LooooooooooooooooooooooooongResult = aaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
4314 " aaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
4320 "return aaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
4323 "return (aaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
4326 "return aaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >=\n" in TEST_F()
4329 "return (aaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >=\n" in TEST_F()
4331 verifyFormat("return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4333 verifyFormat("return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4334 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) &&\n" in TEST_F()
4336 verifyFormat("return\n" in TEST_F()
4337 " // true if code is one of a or b.\n" in TEST_F()
4343 "void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaa aaaaaaaa,\n" in TEST_F()
4346 "SomeLongVariableName->someVeryLongFunctionName(aaaaaaaaaaa aaaaaaaaa,\n" in TEST_F()
4349 "SomeLongVariableName->someFunction(foooooooo(aaaaaaaaaaaaaaa,\n" in TEST_F()
4353 verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4356 verifyFormat("SomeLongVariableName->someVeryLongFunctionName(\n" in TEST_F()
4359 verifyFormat("SomeLongVariableName->someFunction(\n" in TEST_F()
4363 "void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaa aaaaaaaa,\n" in TEST_F()
4367 "SomeLongVariableName->someVeryLongFunctionName(aaaaaaaaaaa aaaaaaaaa,\n" in TEST_F()
4371 "SomeLongVariableName->someFunction(foooooooo(aaaaaaaaaaaaaaa,\n" in TEST_F()
4378 verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4379 " aaaaaaaaaaa aaaaaaaa,\n" in TEST_F()
4380 " aaaaaaaaa aaaaaaa,\n" in TEST_F()
4383 verifyFormat("SomeLongVariableName->someVeryLongFunctionName(\n" in TEST_F()
4384 " aaaaaaaaaaa aaaaaaaaa,\n" in TEST_F()
4385 " aaaaaaaaaaa aaaaaaaaa,\n" in TEST_F()
4388 verifyFormat("SomeLongVariableName->someFunction(\n" in TEST_F()
4389 " foooooooo(\n" in TEST_F()
4390 " aaaaaaaaaaaaaaa,\n" in TEST_F()
4391 " aaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4398 verifyFormat("int a = f(aaaaaaaaaaaaaaaaaaaaaa &&\n" in TEST_F()
4403 verifyFormat("int a = f(aaaaaaaaaaaaaaaaaaaaaa &&\n" in TEST_F()
4408 verifyFormat("int a = f(aaaaaaaaaaaaaaaaaaaaaa &&\n" in TEST_F()
4413 verifyFormat("int a = f(aaaaaaaaaaaaaaaaaaaaaa &&\n" in TEST_F()
4420 "aaaa(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4421 " ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4424 "aaaa(aaaaaaaaaaaaaaaaaaaa, aaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4427 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa ? aaaa(aaaaaa)\n" in TEST_F()
4430 "aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4431 " aaaaaaaaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4432 " : aaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4435 "aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4436 " aaaaaaaaaaaaaaaa ?: aaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4438 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4439 " ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4440 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
4441 " : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4443 verifyFormat("aaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4444 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4445 " ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4446 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
4447 " : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4448 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa),\n" in TEST_F()
4450 verifyFormat("aaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4451 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4452 " ?: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4453 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa),\n" in TEST_F()
4455 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4456 " ? aaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4458 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaa =\n" in TEST_F()
4459 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4460 " ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4463 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4464 " ? aaaaaaaaaaaaaaa\n" in TEST_F()
4466 verifyFormat("f(aaaaaaaaaaaaaaaa == // force break\n" in TEST_F()
4467 " aaaaaaaaa\n" in TEST_F()
4468 " ? b\n" in TEST_F()
4470 verifyFormat("return aaaa == bbbb\n" in TEST_F()
4471 " // comment\n" in TEST_F()
4472 " ? aaaa\n" in TEST_F()
4474 verifyFormat("unsigned Indent =\n" in TEST_F()
4475 " format(TheLine.First, IndentForLevel[TheLine.Level] >= 0\n" in TEST_F()
4476 " ? IndentForLevel[TheLine.Level]\n" in TEST_F()
4477 " : TheLine * 2,\n" in TEST_F()
4480 verifyFormat("bool aaaaaa = aaaaaaaaaaaaa //\n" in TEST_F()
4481 " ? aaaaaaaaaaaaaaa\n" in TEST_F()
4482 " : bbbbbbbbbbbbbbb //\n" in TEST_F()
4483 " ? ccccccccccccccc\n" in TEST_F()
4485 verifyFormat("bool aaaaaa = aaaaaaaaaaaaa //\n" in TEST_F()
4486 " ? aaaaaaaaaaaaaaa\n" in TEST_F()
4487 " : (bbbbbbbbbbbbbbb //\n" in TEST_F()
4488 " ? ccccccccccccccc\n" in TEST_F()
4491 "int aaaaaaaaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4492 " ? aaaaaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
4493 " aaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
4494 " aaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4497 "aaaaaa = aaaaaaaaaaaa\n" in TEST_F()
4498 " ? aaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4499 " : aaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4505 "void f() {\n" in TEST_F()
4506 " g(aaa,\n" in TEST_F()
4507 " aaaaaaaaaa == aaaaaaaaaa ? aaaa : aaaaa,\n" in TEST_F()
4508 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4509 " ? aaaaaaaaaaaaaaa\n" in TEST_F()
4510 " : aaaaaaaaaaaaaaa);\n" in TEST_F()
4514 "void f() {\n" in TEST_F()
4515 " g(aaa,\n" in TEST_F()
4516 " aaaaaaaaaa == aaaaaaaaaa ? aaaa : aaaaa,\n" in TEST_F()
4517 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4518 " ?: aaaaaaaaaaaaaaa);\n" in TEST_F()
4522 verifyFormat("SomeFunction(aaaaaaaaaaaaaaaaa,\n" in TEST_F()
4523 " // comment.\n" in TEST_F()
4524 " ccccccccccccccccccccccccccccccccccccccc\n" in TEST_F()
4525 " ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4529 verifyFormat("return a != b\n" in TEST_F()
4530 " // comment\n" in TEST_F()
4531 " ? a = b\n" in TEST_F()
4533 verifyFormat("return a != b\n" in TEST_F()
4534 " // comment\n" in TEST_F()
4535 " ? a = a != b\n" in TEST_F()
4536 " // comment\n" in TEST_F()
4537 " ? a = b\n" in TEST_F()
4538 " : a\n" in TEST_F()
4539 " : a;\n"); in TEST_F()
4540 verifyFormat("return a != b\n" in TEST_F()
4541 " // comment\n" in TEST_F()
4542 " ? a\n" in TEST_F()
4543 " : a = a != b\n" in TEST_F()
4544 " // comment\n" in TEST_F()
4545 " ? a = b\n" in TEST_F()
4554 "aaaa(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaa ?\n" in TEST_F()
4555 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa :\n" in TEST_F()
4559 "aaaa(aaaaaaaaaaaaaaaaaaaa, aaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa :\n" in TEST_F()
4563 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa ? aaaa(aaaaaa) :\n" in TEST_F()
4567 "aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4568 " aaaaaaaaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaa :\n" in TEST_F()
4569 " aaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4573 "aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4574 " aaaaaaaaaaaaaaaa ?: aaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4577 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ?\n" in TEST_F()
4578 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4579 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) :\n" in TEST_F()
4580 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4583 verifyFormat("aaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4584 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ?\n" in TEST_F()
4585 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4586 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) :\n" in TEST_F()
4587 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4588 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa),\n" in TEST_F()
4591 verifyFormat("aaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4592 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ?:\n" in TEST_F()
4593 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4594 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa),\n" in TEST_F()
4597 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ?\n" in TEST_F()
4598 " aaaaaaaaaaaaaaaaaaaaaaaaaaa :\n" in TEST_F()
4601 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaa =\n" in TEST_F()
4602 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ?\n" in TEST_F()
4603 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa :\n" in TEST_F()
4607 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ?\n" in TEST_F()
4608 " aaaaaaaaaaaaaaa :\n" in TEST_F()
4611 verifyFormat("f(aaaaaaaaaaaaaaaa == // force break\n" in TEST_F()
4612 " aaaaaaaaa ?\n" in TEST_F()
4613 " b :\n" in TEST_F()
4617 "unsigned Indent =\n" in TEST_F()
4618 " format(TheLine.First, IndentForLevel[TheLine.Level] >= 0 ?\n" in TEST_F()
4619 " IndentForLevel[TheLine.Level] :\n" in TEST_F()
4620 " TheLine * 2,\n" in TEST_F()
4623 verifyFormat("bool aaaaaa = aaaaaaaaaaaaa ? //\n" in TEST_F()
4624 " aaaaaaaaaaaaaaa :\n" in TEST_F()
4625 " bbbbbbbbbbbbbbb ? //\n" in TEST_F()
4626 " ccccccccccccccc :\n" in TEST_F()
4629 verifyFormat("bool aaaaaa = aaaaaaaaaaaaa ? //\n" in TEST_F()
4630 " aaaaaaaaaaaaaaa :\n" in TEST_F()
4631 " (bbbbbbbbbbbbbbb ? //\n" in TEST_F()
4632 " ccccccccccccccc :\n" in TEST_F()
4638 verifyFormat("bool aaaaaaaaaaaaaaaaa = aaaaaa->aaaaaaaaaaaaaaaaa(),\n" in TEST_F()
4642 verifyFormat("bool aaaaaaaaaaaaaaaaaaaaaaaaa =\n" in TEST_F()
4643 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaa),\n" in TEST_F()
4644 " bbbbbbbbbbbbbbbbbbbbbbbbb =\n" in TEST_F()
4647 "bool aaaaaaaaaaaaaaaaaaaaa =\n" in TEST_F()
4648 " bbbbbbbbbbbbbbbbbbbbbbbbbbbb && cccccccccccccccccccccccccccc,\n" in TEST_F()
4650 verifyFormat("aaaaaaaaa a = aaaaaaaaaaaaaaaaaaaa, b = bbbbbbbbbbbbbbbbbbbb,\n" in TEST_F()
4652 verifyFormat("aaaaaaaaa *a = aaaaaaaaaaaaaaaaaaa, *b = bbbbbbbbbbbbbbbbbbb,\n" in TEST_F()
4654 verifyFormat("aaaaaaaaa ***a = aaaaaaaaaaaaaaaaaaa, ***b = bbbbbbbbbbbbbbb,\n" in TEST_F()
4660 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4661 " *aaaaaaaaaaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4664 verifyFormat("aaaaaaaaa *a = aaaaaaaaaaaaaaaaaaa, *b = bbbbbbbbbbbbbbbbbbb,\n" in TEST_F()
4677 verifyFormat("loooooooooooooooooooooooooongFunction(\"short literal \"\n" in TEST_F()
4680 "looooooooooooooooooooooooongFunction(\n" in TEST_F()
4681 " \"short literal\"\n" in TEST_F()
4683 verifyFormat("someFunction(\"Always break between multi-line\"\n" in TEST_F()
4684 " \" string literals\",\n" in TEST_F()
4686 EXPECT_EQ("fun + \"1243\" /* comment */\n" in TEST_F()
4688 format("fun + \"1243\" /* comment */\n" in TEST_F()
4692 "aaaaaa = \"aaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaa \"\n" in TEST_F()
4693 " \"aaaaaaaaaaaaaaaaaaaaa\"\n" in TEST_F()
4699 verifyFormat("a = a + \"a\"\n" in TEST_F()
4700 " \"a\"\n" in TEST_F()
4702 verifyFormat("f(\"a\", \"b\"\n" in TEST_F()
4706 "#define LL_FORMAT \"ll\"\n" in TEST_F()
4707 "printf(\"aaaaa: %d, bbbbbb: %\" LL_FORMAT \"d, cccccccc: %\" LL_FORMAT\n" in TEST_F()
4710 verifyFormat("#define A(X) \\\n" in TEST_F()
4711 " \"aaaaa\" #X \"bbbbbb\" \\\n" in TEST_F()
4714 verifyFormat("#define A \"def\"\n" in TEST_F()
4715 "f(\"abc\" A \"ghi\"\n" in TEST_F()
4718 verifyFormat("f(L\"a\"\n" in TEST_F()
4720 verifyFormat("#define A(X) \\\n" in TEST_F()
4721 " L\"aaaaa\" #X L\"bbbbbb\" \\\n" in TEST_F()
4725 verifyFormat("f(@\"a\"\n" in TEST_F()
4727 verifyFormat("NSString s = @\"a\"\n" in TEST_F()
4728 " @\"b\"\n" in TEST_F()
4730 verifyFormat("NSString s = @\"a\"\n" in TEST_F()
4731 " \"b\"\n" in TEST_F()
4739 verifyFormat("class A {\n" in TEST_F()
4740 " int f() { return 1; }\n" in TEST_F()
4741 " int g();\n" in TEST_F()
4742 "};\n" in TEST_F()
4743 "int f() { return 1; }\n" in TEST_F()
4744 "int g();\n", in TEST_F()
4751 verifyFormat("class E {\n" in TEST_F()
4752 " int\n" in TEST_F()
4753 " f() {\n" in TEST_F()
4754 " return 1;\n" in TEST_F()
4755 " }\n" in TEST_F()
4756 " int\n" in TEST_F()
4757 " g();\n" in TEST_F()
4758 "};\n" in TEST_F()
4759 "int\n" in TEST_F()
4760 "f() {\n" in TEST_F()
4761 " return 1;\n" in TEST_F()
4762 "}\n" in TEST_F()
4763 "int\n" in TEST_F()
4764 "g();\n", in TEST_F()
4770 verifyFormat("class B {\n" in TEST_F()
4771 " int f() { return 1; }\n" in TEST_F()
4772 " int g();\n" in TEST_F()
4773 "};\n" in TEST_F()
4774 "int\n" in TEST_F()
4775 "f() {\n" in TEST_F()
4776 " return 1;\n" in TEST_F()
4777 "}\n" in TEST_F()
4778 "int g();\n", in TEST_F()
4784 verifyFormat("class C {\n" in TEST_F()
4785 " int f() { return 1; }\n" in TEST_F()
4786 " int g();\n" in TEST_F()
4787 "};\n" in TEST_F()
4788 "int\n" in TEST_F()
4789 "f() {\n" in TEST_F()
4790 " return 1;\n" in TEST_F()
4791 "}\n" in TEST_F()
4792 "int\n" in TEST_F()
4793 "g();\n", in TEST_F()
4799 verifyFormat("class D {\n" in TEST_F()
4800 " int\n" in TEST_F()
4801 " f() {\n" in TEST_F()
4802 " return 1;\n" in TEST_F()
4803 " }\n" in TEST_F()
4804 " int g();\n" in TEST_F()
4805 "};\n" in TEST_F()
4806 "int\n" in TEST_F()
4807 "f() {\n" in TEST_F()
4808 " return 1;\n" in TEST_F()
4809 "}\n" in TEST_F()
4810 "int g();\n", in TEST_F()
4812 verifyFormat("const char *\n" in TEST_F()
4813 "f(void) {\n" // Break here. in TEST_F()
4814 " return \"\";\n" in TEST_F()
4815 "}\n" in TEST_F()
4816 "const char *bar(void);\n", // No break here. in TEST_F()
4818 verifyFormat("template <class T>\n" in TEST_F()
4819 "T *\n" in TEST_F()
4820 "f(T &c) {\n" // Break here. in TEST_F()
4821 " return NULL;\n" in TEST_F()
4822 "}\n" in TEST_F()
4823 "template <class T> T *f(T &c);\n", // No break here. in TEST_F()
4825 verifyFormat("class C {\n" in TEST_F()
4826 " int\n" in TEST_F()
4827 " operator+() {\n" in TEST_F()
4828 " return 1;\n" in TEST_F()
4829 " }\n" in TEST_F()
4830 " int\n" in TEST_F()
4831 " operator()() {\n" in TEST_F()
4832 " return 1;\n" in TEST_F()
4833 " }\n" in TEST_F()
4834 "};\n", in TEST_F()
4836 verifyFormat("void\n" in TEST_F()
4837 "A::operator()() {}\n" in TEST_F()
4838 "void\n" in TEST_F()
4839 "A::operator>>() {}\n" in TEST_F()
4840 "void\n" in TEST_F()
4841 "A::operator+() {}\n", in TEST_F()
4845 verifyFormat("void *\n" in TEST_F()
4848 verifyFormat("void *\n" in TEST_F()
4852 verifyFormat("const char *\n" in TEST_F()
4853 "f(void)\n" // Break here. in TEST_F()
4854 "{\n" in TEST_F()
4855 " return \"\";\n" in TEST_F()
4856 "}\n" in TEST_F()
4857 "const char *bar(void);\n", // No break here. in TEST_F()
4859 verifyFormat("template <class T>\n" in TEST_F()
4860 "T *\n" // Problem here: no line break in TEST_F()
4861 "f(T &c)\n" // Break here. in TEST_F()
4862 "{\n" in TEST_F()
4863 " return NULL;\n" in TEST_F()
4864 "}\n" in TEST_F()
4865 "template <class T> T *f(T &c);\n", // No break here. in TEST_F()
4874 verifyFormat("aaaa = \"bbbb\"\n" in TEST_F()
4877 verifyFormat("aaaa =\n" in TEST_F()
4878 " \"bbbb\"\n" in TEST_F()
4881 verifyFormat("aaaa(\"bbbb\"\n" in TEST_F()
4884 verifyFormat("aaaa(\n" in TEST_F()
4885 " \"bbbb\"\n" in TEST_F()
4888 verifyFormat("aaaa(qqq, \"bbbb\"\n" in TEST_F()
4891 verifyFormat("aaaa(qqq,\n" in TEST_F()
4892 " \"bbbb\"\n" in TEST_F()
4895 verifyFormat("aaaa(qqq,\n" in TEST_F()
4896 " L\"bbbb\"\n" in TEST_F()
4899 verifyFormat("aaaaa(aaaaaa, aaaaaaa(\"aaaa\"\n" in TEST_F()
4902 verifyFormat("string s = someFunction(\n" in TEST_F()
4903 " \"abc\"\n" in TEST_F()
4908 verifyFormat("string foo = abc ? \"x\"\n" in TEST_F()
4909 " \"blah blah blah blah blah blah\"\n" in TEST_F()
4914 verifyFormat("f(\"aaaa\"\n" in TEST_F()
4919 EXPECT_EQ("x = \"a\\\n" in TEST_F()
4920 "b\\\n" in TEST_F()
4922 format("x = \"a\\\n" in TEST_F()
4923 "b\\\n" in TEST_F()
4926 EXPECT_EQ("xxxx =\n" in TEST_F()
4927 " \"a\\\n" in TEST_F()
4928 "b\\\n" in TEST_F()
4930 format("xxxx = \"a\\\n" in TEST_F()
4931 "b\\\n" in TEST_F()
4936 EXPECT_EQ("NSString *const kString = @\"aaaa\"\n" in TEST_F()
4938 format("NSString *const kString = @\"aaaa\"\n" in TEST_F()
4948 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4949 " << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4952 "aaaaaaaaaaaaaaaaaaaa << aaaaaaaaaaaaaaaaaaaa << aaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4955 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa << aaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4958 "llvm::outs() << \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n" in TEST_F()
4959 " \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"\n" in TEST_F()
4962 "aaaaaaaa << (aaaaaaaaaaaaaaaaaaa << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
4963 " << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
4965 verifyFormat("llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4966 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
4967 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
4969 verifyFormat("llvm::errs() << \"aaaaaaaaaaaaaaaaaaaaaaa: \"\n" in TEST_F()
4972 "llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
4975 verifyFormat("return out << \"somepacket = {\\n\"\n" in TEST_F()
4976 " << \" aaaaaa = \" << pkt.aaaaaa << \"\\n\"\n" in TEST_F()
4977 " << \" bbbb = \" << pkt.bbbb << \"\\n\"\n" in TEST_F()
4978 " << \" cccccc = \" << pkt.cccccc << \"\\n\"\n" in TEST_F()
4979 " << \" ddd = [\" << pkt.ddd << \"]\\n\"\n" in TEST_F()
4982 verifyFormat("llvm::outs() << \"aaaaaaaaaaaaaaaa: \" << aaaaaaaaaaaaaaaa\n" in TEST_F()
4983 " << \"aaaaaaaaaaaaaaaa: \" << aaaaaaaaaaaaaaaa\n" in TEST_F()
4986 "llvm::outs() << \"aaaaaaaaaaaaaaaaa = \" << aaaaaaaaaaaaaaaaa\n" in TEST_F()
4987 " << \"bbbbbbbbbbbbbbbbb = \" << bbbbbbbbbbbbbbbbb\n" in TEST_F()
4988 " << \"ccccccccccccccccc = \" << ccccccccccccccccc\n" in TEST_F()
4989 " << \"ddddddddddddddddd = \" << ddddddddddddddddd\n" in TEST_F()
4991 verifyFormat("llvm::outs() << aaaaaaaaaaaaaaaaaaaaaaaa << \"=\"\n" in TEST_F()
4994 "void f() {\n" in TEST_F()
4995 " llvm::outs() << \"aaaaaaaaaaaaaaaaaaaa: \"\n" in TEST_F()
4996 " << aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa);\n" in TEST_F()
4998 verifyFormat("llvm::outs() << \"aaaaaaaaaaaaaaaa: \"\n" in TEST_F()
5000 verifyFormat("llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
5001 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
5002 " aaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
5004 verifyFormat("LOG_IF(aaa == //\n" in TEST_F()
5005 " bbb)\n" in TEST_F()
5010 "llvm::errs()\n" in TEST_F()
5011 " << \"aaaaaaaaaaaaaaaaaaa: \" << aaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
5012 " << \"aaaaaaaaaaaaaaaaaaa: \" << aaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
5013 " << \"aaaaaaaaaaaaaaaaaaa: \" << aaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
5016 verifyFormat("llvm::errs() << \"aaaaaaaaaaaaaaaaaaa: \"\n" in TEST_F()
5017 " << aaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
5018 " << \"aaaaaaaaaaaaaaaaaaa: \"\n" in TEST_F()
5019 " << aaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
5020 " << \"aaaaaaaaaaaaaaaaaaa: \"\n" in TEST_F()
5025 verifyFormat("Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa)\n" in TEST_F()
5027 verifyFormat("Diag(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)\n" in TEST_F()
5028 " << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
5030 verifyFormat("SemaRef.Diag(Loc, diag::note_for_range_begin_end)\n" in TEST_F()
5034 "llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
5038 EXPECT_EQ("llvm::errs() << \"\n" in TEST_F()
5040 format("llvm::errs() << \"\n<<a;")); in TEST_F()
5042 verifyFormat("void f() {\n" in TEST_F()
5043 " CHECK_EQ(aaaa, (*bbbbbbbbb)->cccccc)\n" in TEST_F()
5044 " << \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\";\n" in TEST_F()
5048 verifyFormat("llvm::errs() << aaaaaaaaaaaaaaaaaaaaaa << endl\n" in TEST_F()
5055 "aaaaaaaaaaaaaaaaa =\n" in TEST_F()
5058 "if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n" in TEST_F()
5059 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n}"); in TEST_F()
5061 "if (a) {\n" in TEST_F()
5062 " f();\n" in TEST_F()
5063 "} else if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n" in TEST_F()
5064 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n" in TEST_F()
5067 verifyFormat("if (int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n" in TEST_F()
5068 " 100000000 + 10000000) {\n}"); in TEST_F()
5072 verifyFormat("LoooooooooooooooooooooooooooooooooooooongObject\n" in TEST_F()
5075 verifyFormat("LoooooooooooooooooooooooooooooooooooooongObject\n" in TEST_F()
5079 "LooooooooooooooooooooooooooooooooongObject->shortFunction(Parameter1,\n" in TEST_F()
5083 "ShortObject->shortFunction(\n" in TEST_F()
5084 " LooooooooooooooooooooooooooooooooooooooooooooooongParameter1,\n" in TEST_F()
5087 verifyFormat("loooooooooooooongFunction(\n" in TEST_F()
5091 "function(LoooooooooooooooooooooooooooooooooooongObject\n" in TEST_F()
5094 verifyFormat("EXPECT_CALL(SomeObject, SomeFunction(Parameter))\n" in TEST_F()
5096 verifyFormat("void f() {\n" in TEST_F()
5097 " EXPECT_CALL(SomeObject, SomeFunction(Parameter))\n" in TEST_F()
5098 " .Times(2)\n" in TEST_F()
5099 " .WillRepeatedly(Return(SomeValue));\n" in TEST_F()
5101 verifyFormat("SomeMap[std::pair(aaaaaaaaaaaa, bbbbbbbbbbbbbbb)].insert(\n" in TEST_F()
5103 verifyFormat("aaaaa(aaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
5104 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
5105 " .aaaaa(aaaaa),\n" in TEST_F()
5107 verifyFormat("void f() {\n" in TEST_F()
5108 " aaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
5109 " aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa)->aaaaaaaaa());\n" in TEST_F()
5111 verifyFormat("aaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
5112 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
5113 " .aaaaaaaaaaaaaaa(aa(aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
5114 " aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
5116 verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
5117 " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
5118 " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
5119 " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()) {\n" in TEST_F()
5123 verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaa) ||\n" in TEST_F()
5124 " aaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n}"); in TEST_F()
5126 "aaaaaaaaaaa->aaaaaaaaa(\n" in TEST_F()
5127 " aaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
5128 " aaaaaaaaaaaaaaaaaa->aaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa));\n"); in TEST_F()
5131 "aaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
5133 verifyFormat("a->aaaaaa()->aaaaaaaaaaa(aaaaaaaa()->aaaaaa()->aaaaa() *\n" in TEST_F()
5135 verifyFormat("a->aaaaaa()->aaaaaaaaaaa(aaaaaaaa()->aaaaaa()->aaaaa() ||\n" in TEST_F()
5138 verifyFormat("aaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
5139 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
5144 verifyFormat("aaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
5145 " .aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
5146 " .aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
5147 " aaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
5153 "aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
5154 " aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa))\n" in TEST_F()
5157 "aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
5159 verifyFormat("aaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
5160 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
5162 verifyFormat("aaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
5163 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
5168 verifyFormat("template <typename T>\n" in TEST_F()
5170 verifyFormat("template <typename T>\n" in TEST_F()
5171 "// T should be one of {A, B}.\n" in TEST_F()
5174 "template <typename T>\n" in TEST_F()
5176 verifyFormat("template <typename T>\n" in TEST_F()
5177 "void f(int Paaaaaaaaaaaaaaaaaaaaaaaaaaaaaaram1,\n" in TEST_F()
5180 "template <typename T>\n" in TEST_F()
5181 "void looooooooooooooooooooongFunction(int Paaaaaaaaaaaaaaaaaaaaram1,\n" in TEST_F()
5184 "template <typename T>\n" in TEST_F()
5185 "aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaa,\n" in TEST_F()
5186 " aaaaaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaaaaa,\n" in TEST_F()
5188 verifyFormat("template <typename T>\n" in TEST_F()
5189 "void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
5192 "template <typename T1, typename T2 = char, typename T3 = char,\n" in TEST_F()
5193 " typename T4 = char>\n" in TEST_F()
5195 verifyFormat("template <typename aaaaaaaaaaa, typename bbbbbbbbbbbbb,\n" in TEST_F()
5196 " template <typename> class cccccccccccccccccccccc,\n" in TEST_F()
5197 " typename ddddddddddddd>\n" in TEST_F()
5200 "aaaaaaaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa>(\n" in TEST_F()
5203 verifyFormat("void f() {\n" in TEST_F()
5204 " a<aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa>(\n" in TEST_F()
5205 " a(aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa));\n" in TEST_F()
5212 "aaaaaaaaaaaaa<aaaaaaaaaa, aaaaaaaaaaa,\n" in TEST_F()
5213 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
5214 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> *aaaa =\n" in TEST_F()
5215 " new aaaaaaaaaaaaa<aaaaaaaaaa, aaaaaaaaaaa,\n" in TEST_F()
5216 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
5217 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>(\n" in TEST_F()
5220 EXPECT_EQ("static_cast<A< //\n" in TEST_F()
5221 " B> *>(\n" in TEST_F()
5222 "\n" in TEST_F()
5224 format("static_cast<A<//\n" in TEST_F()
5225 " B>*>(\n" in TEST_F()
5226 "\n" in TEST_F()
5228 verifyFormat("int aaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
5236 verifyFormat("void aaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
5237 " bbbbbbbbbbbbbbbbbbbbbbbbbbbb>(\n" in TEST_F()
5239 verifyFormat("template <template <typename> class Fooooooo,\n" in TEST_F()
5240 " template <typename> class Baaaaaaar>\n" in TEST_F()
5243 verifyFormat("template <typename T> // T can be A, B or C.\n" in TEST_F()
5250 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n" in TEST_F()
5253 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n" in TEST_F()
5254 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
5259 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n" in TEST_F()
5260 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n" in TEST_F()
5264 "aaaaaaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb::\n" in TEST_F()
5269 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
5273 "aaaaaaaaaaaaaaaaaa(aaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n" in TEST_F()
5274 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
5278 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n" in TEST_F()
5279 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
5325 verifyFormat("void f() {\n" in TEST_F()
5326 " while (a < b && c > d) {\n" in TEST_F()
5327 " }\n" in TEST_F()
5329 verifyFormat("template <typename... Types>\n" in TEST_F()
5332 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
5349 verifyFormat("void f() {\n" in TEST_F()
5350 " (a->*f)();\n" in TEST_F()
5351 " a->*x;\n" in TEST_F()
5352 " (a.*f)();\n" in TEST_F()
5353 " ((*a).*f)();\n" in TEST_F()
5354 " a.*x;\n" in TEST_F()
5356 verifyFormat("void f() {\n" in TEST_F()
5357 " (a->*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)(\n" in TEST_F()
5358 " aaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);\n" in TEST_F()
5361 "(aaaaaaaaaa->*bbbbbbb)(\n" in TEST_F()
5373 verifyFormat("if (i == -1) {\n}"); in TEST_F()
5374 verifyFormat("if (i != -1) {\n}"); in TEST_F()
5375 verifyFormat("if (i > -1) {\n}"); in TEST_F()
5376 verifyFormat("if (i < -1) {\n}"); in TEST_F()
5381 verifyFormat("if (!(a->f())) {\n}"); in TEST_F()
5385 verifyFormat("n * sizeof char16;"); in TEST_F()
5386 verifyFormat("n * alignof char16;", getGoogleStyle()); in TEST_F()
5391 verifyFormat("switch (a) {\n" in TEST_F()
5392 "case -1:\n" in TEST_F()
5393 " break;\n" in TEST_F()
5407 verifyFormat("if (!aaaaaaaaaa( // break\n" in TEST_F()
5408 " aaaaa)) {\n" in TEST_F()
5410 verifyFormat("aaaaaaaaaa(!aaaaaaaaaa( // break\n" in TEST_F()
5412 verifyFormat("*aaa = aaaaaaa( // break\n" in TEST_F()
5437 verifyFormat("template <typename AAAAAAA, typename BBBBBBB>\n" in TEST_F()
5441 "ostream &operator<<(ostream &OutputStream,\n" in TEST_F()
5443 verifyFormat("bool operator<(const aaaaaaaaaaaaaaaaaaaaa &left,\n" in TEST_F()
5444 " const aaaaaaaaaaaaaaaaaaaaa &right) {\n" in TEST_F()
5445 " return left.group < right.group;\n" in TEST_F()
5455 verifyFormat("inline A operator^(const A &lhs, const A &rhs) {}\n" in TEST_F()
5496 verifyFormat("void f() {\n" in TEST_F()
5497 " A *a = new A;\n" in TEST_F()
5498 " A *a = new (placement) A;\n" in TEST_F()
5499 " delete a;\n" in TEST_F()
5500 " delete (A *)a;\n" in TEST_F()
5502 verifyFormat("new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))\n" in TEST_F()
5504 verifyFormat("auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n" in TEST_F()
5505 " new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))\n" in TEST_F()
5583 verifyFormat("for (char **a = b; *a; ++a) {\n}"); in TEST_F()
5584 verifyFormat("for (; a && b;) {\n}"); in TEST_F()
5588 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
5609 verifyGoogleFormat("template <typename T>\n" in TEST_F()
5615 verifyFormat("for (;; * = b) {\n}", Left); in TEST_F()
5625 "int *MyValues = {\n" in TEST_F()
5626 " *A, // Operator detection might be confused by the '{'\n" in TEST_F()
5627 " *BB // Operator detection might be confused by previous comment\n" in TEST_F()
5639 verifyFormat("void f() {\n" in TEST_F()
5640 " for (const int &v : Values) {\n" in TEST_F()
5641 " }\n" in TEST_F()
5643 verifyFormat("for (int i = a * a; i < 10; ++i) {\n}"); in TEST_F()
5644 verifyFormat("for (int i = 0; i < a * a; ++i) {\n}"); in TEST_F()
5645 verifyGoogleFormat("for (int i = 0; i * 2 < z; i *= 2) {\n}"); in TEST_F()
5648 verifyFormat("#define MACRO \\\n" in TEST_F()
5649 " int *i = a * b; \\\n" in TEST_F()
5679 "template <class T, class = typename std::enable_if<\n" in TEST_F()
5680 " std::is_integral<T>::value &&\n" in TEST_F()
5681 " (sizeof(T) > 1 || sizeof(T) < 8)>::type>\n" in TEST_F()
5685 "template <class T,\n" in TEST_F()
5686 " class = typename ::std::enable_if<\n" in TEST_F()
5687 " ::std::is_array<T>{} && ::std::is_array<T>{}>::type>\n" in TEST_F()
5701 EXPECT_EQ("#define OP(x) \\\n" in TEST_F()
5702 " ostream &operator<<(ostream &s, const A &a) { \\\n" in TEST_F()
5703 " return s << a.DebugString(); \\\n" in TEST_F()
5705 format("#define OP(x) \\\n" in TEST_F()
5706 " ostream &operator<<(ostream &s, const A &a) { \\\n" in TEST_F()
5707 " return s << a.DebugString(); \\\n" in TEST_F()
5732 verifyFormat("string // break\n" in TEST_F()
5734 verifyFormat("string // break\n" in TEST_F()
5736 verifyGoogleFormat("template <typename T>\n" in TEST_F()
5742 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa __attribute__((unused))\n" in TEST_F()
5746 verifyFormat("__attribute__((nodebug)) void\n" in TEST_F()
5747 "foo() {}\n", in TEST_F()
5762 EXPECT_EQ("int *a;\n" in TEST_F()
5763 "int *a;\n" in TEST_F()
5765 format("int *a;\n" in TEST_F()
5766 "int* a;\n" in TEST_F()
5769 EXPECT_EQ("int* a;\n" in TEST_F()
5770 "int* a;\n" in TEST_F()
5772 format("int* a;\n" in TEST_F()
5773 "int* a;\n" in TEST_F()
5776 EXPECT_EQ("int *a;\n" in TEST_F()
5777 "int *a;\n" in TEST_F()
5779 format("int *a;\n" in TEST_F()
5780 "int * a;\n" in TEST_F()
5783 EXPECT_EQ("auto x = [] {\n" in TEST_F()
5784 " int *a;\n" in TEST_F()
5785 " int *a;\n" in TEST_F()
5786 " int *a;\n" in TEST_F()
5788 format("auto x=[]{int *a;\n" in TEST_F()
5789 "int * a;\n" in TEST_F()
5807 verifyFormat("template <bool B, bool C> class A {\n" in TEST_F()
5808 " static_assert(B && C, \"Something is wrong\");\n" in TEST_F()
5816 verifyFormat("void f() {\n" in TEST_F()
5817 " x[aaaaaaaaa -\n" in TEST_F()
5818 " b] = 23;\n" in TEST_F()
5865 verifyFormat("int aaaaaaaaaaaaaaaaaaaaaaaaaaa =\n" in TEST_F()
5866 " (aaaaaaaaaaaaaaaaaaaaaaaaaa *)(aaaaaaaaaaaaaaaaaaaaaa +\n" in TEST_F()
5899 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *foo = (aaaaaaaaaaaaaaaaa *)\n" in TEST_F()
5903 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
5904 " [bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (*cccccccccccccccc)\n" in TEST_F()
5916 verifyFormat("template <class CallbackClass>\n" in TEST_F()
5922 "template <class CallbackClass>\n" in TEST_F()
5938 verifyFormat("LoooooooooooooooooooooooooooooooooooooooongType\n" in TEST_F()
5940 verifyFormat("LoooooooooooooooooooooooooooooooooooooooongType const\n" in TEST_F()
5942 verifyFormat("LoooooooooooooooooooooooooooooooooooooooongType\n" in TEST_F()
5946 verifyFormat("LoooooooooooooooooooooooooooooooooooooooongType\n" in TEST_F()
5948 verifyFormat("LoooooooooooooooooooooooooooooooooooooooongType\n" in TEST_F()
5950 verifyFormat("LoooooooooooooooooooooooooooooooooooooooongType\n" in TEST_F()
5952 verifyFormat("LoooooooooooooooooooooooooooooooooooooooongType\n" in TEST_F()
5957 verifyFormat("typedef LoooooooooooooooooooooooooooooooooooooooongType\n" in TEST_F()
5959 verifyFormat("typedef LongTemplateType<aaaaaaaaaaaaaaaaaaa()>\n" in TEST_F()
5961 verifyFormat("LoooooooooooooooooooooooooooooooooooooooongReturnType\n" in TEST_F()
5963 verifyFormat("LoooooooooooooooooooooooooooooooooooooooongReturnType *\n" in TEST_F()
5965 verifyFormat("LoooooooooooooooooooooooooooooooooooooooongReturnType\n" in TEST_F()
5967 verifyFormat("LoooooooooooooooooooooooooooooooooooooooongReturnType MACRO\n" in TEST_F()
5969 verifyFormat("LoooooooooooooooooooooooooooooooooooooooongReturnType const\n" in TEST_F()
5971 verifyFormat("decltype(LoooooooooooooooooooooooooooooooooooooooongName)\n" in TEST_F()
5975 verifyFormat("LoooooooooooooooooooooooooooooooooooooooongReturnType\n" in TEST_F()
5979 "LoooooooooooooooooooooooooooooooooooooooongReturnType\n" in TEST_F()
5983 "LoooooooooooooooooooooooooooooooooooooooongReturnType const\n" in TEST_F()
5987 "decltype(LoooooooooooooooooooooooooooooooooooooooongName)\n" in TEST_F()
5992 verifyFormat("LoooooooooooooooooooooooooooooooooooooooongType // break\n" in TEST_F()
5996 verifyFormat("int *someFunction(int LoooooooooooooooooooongParam1,\n" in TEST_F()
5999 "TypeSpecDecl *TypeSpecDecl::Create(ASTContext &C, DeclContext *DC,\n" in TEST_F()
6000 " SourceLocation L, IdentifierIn *II,\n" in TEST_F()
6002 verifyFormat("ReallyLongReturnType<TemplateParam1, TemplateParam2>\n" in TEST_F()
6003 "ReallyReaaallyLongFunctionName(\n" in TEST_F()
6004 " const std::string &SomeParameter,\n" in TEST_F()
6005 " const SomeType<string, SomeOtherTemplateParameter>\n" in TEST_F()
6006 " &ReallyReallyLongParameterName,\n" in TEST_F()
6007 " const SomeType<string, SomeOtherTemplateParameter>\n" in TEST_F()
6009 verifyFormat("template <typename A>\n" in TEST_F()
6010 "SomeLoooooooooooooooooooooongType<\n" in TEST_F()
6011 " typename some_namespace::SomeOtherType<A>::Type>\n" in TEST_F()
6015 "aaaaaaaaaaaaaaaa::aaaaaaaaaaaaaaaa<aaaaaaaaaaaaa, aaaaaaaaaaaa>\n" in TEST_F()
6018 "TypeSpecDecl* TypeSpecDecl::Create(ASTContext& C, DeclContext* DC,\n" in TEST_F()
6021 "some_namespace::LongReturnType\n" in TEST_F()
6022 "long_namespace::SomeVeryLongClass::SomeVeryLongFunction(\n" in TEST_F()
6025 verifyGoogleFormat("template <typename T>\n" in TEST_F()
6026 "aaaaaaaa::aaaaa::aaaaaa<T, aaaaaaaaaaaaaaaaaaaaaaaaa>\n" in TEST_F()
6028 verifyGoogleFormat("A<A<A>> aaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
6031 verifyFormat("typedef size_t (*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)(\n" in TEST_F()
6032 " const aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
6034 verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
6035 " vector<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>\n" in TEST_F()
6037 verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
6038 " vector<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<\n" in TEST_F()
6039 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>>\n" in TEST_F()
6044 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaaaaaaaaaaaaaa]\n" in TEST_F()
6046 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
6048 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
6050 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
6051 " [aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]\n" in TEST_F()
6054 "llvm::outs() << \"aaaaaaaaaaaa: \"\n" in TEST_F()
6055 " << (*aaaaaaaiaaaaaaa)[aaaaaaaaaaaaaaaaaaaaaaaaa]\n" in TEST_F()
6058 verifyGoogleFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<int>\n" in TEST_F()
6061 "aaaaaaaaaaa aaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaa->aaaaaaaaa[0]\n" in TEST_F()
6062 " .aaaaaaa[0]\n" in TEST_F()
6074 verifyFormat("#include <string>\n" in TEST_F()
6075 "#include <a/b/c.h>\n" in TEST_F()
6076 "#include \"a/b/string\"\n" in TEST_F()
6077 "#include \"string.h\"\n" in TEST_F()
6078 "#include \"string.h\"\n" in TEST_F()
6079 "#include <a-a>\n" in TEST_F()
6080 "#include < path with space >\n" in TEST_F()
6082 "#include \"abc.h\" // this is included for ABC\n" in TEST_F()
6083 "#include \"some long include\" // with a comment\n" in TEST_F()
6094 verifyFormat("#if __has_include(<strstream>)\n" in TEST_F()
6095 "#include <strstream>\n" in TEST_F()
6110 verifyFormat("import::SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
6121 verifyFormat("void aaaaaaaaaaaaaaaaaa(int level,\n" in TEST_F()
6122 " double *min_x,\n" in TEST_F()
6123 " double *max_x,\n" in TEST_F()
6124 " double *min_y,\n" in TEST_F()
6125 " double *max_y,\n" in TEST_F()
6126 " double *min_z,\n" in TEST_F()
6133 verifyFormat("void f() {\n" in TEST_F()
6134 " if (0)\n" in TEST_F()
6135 " return;\n" in TEST_F()
6136 "}\n" in TEST_F()
6139 verifyFormat("void f() {\n" in TEST_F()
6140 " if (0)\n" in TEST_F()
6141 " return\n" in TEST_F()
6142 "}\n" in TEST_F()
6148 EXPECT_EQ("void f() {\n" in TEST_F()
6149 " if (a)\n" in TEST_F()
6150 " return\n" in TEST_F()
6153 EXPECT_EQ("namespace N {\n" in TEST_F()
6154 "void f()\n" in TEST_F()
6156 format("namespace N { void f() }")); in TEST_F()
6157 EXPECT_EQ("namespace N {\n" in TEST_F()
6158 "void f() {}\n" in TEST_F()
6159 "void g()\n" in TEST_F()
6161 format("namespace N { void f( ) { } void g( ) }")); in TEST_F()
6165 verifyFormat("int aaaaaaaa =\n" in TEST_F()
6166 " // Overlylongcomment\n" in TEST_F()
6169 verifyFormat("function(\n" in TEST_F()
6170 " ShortArgument,\n" in TEST_F()
6171 " LoooooooooooongArgument);\n", in TEST_F()
6177 verifyFormat("class A {\n" in TEST_F()
6178 "public\n" in TEST_F()
6179 " void f() {}\n" in TEST_F()
6181 verifyFormat("public\n" in TEST_F()
6183 verifyFormat("public\n" in TEST_F()
6185 verifyFormat("public\n" in TEST_F()
6187 verifyFormat("public\n" in TEST_F()
6198 verifyFormat("do {\n}"); in TEST_F()
6199 verifyFormat("do {\n}\n" in TEST_F()
6201 verifyFormat("do {\n}\n" in TEST_F()
6203 verifyFormat("do {\n" in TEST_F()
6204 " f();\n" in TEST_F()
6209 verifyFormat("if {\n foo;\n foo();\n}"); in TEST_F()
6210 verifyFormat("switch {\n foo;\n foo();\n}"); in TEST_F()
6211 verifyIncompleteFormat("for {\n foo;\n foo();\n}"); in TEST_F()
6212 verifyFormat("while {\n foo;\n foo();\n}"); in TEST_F()
6213 verifyFormat("do {\n foo;\n foo();\n} while;"); in TEST_F()
6217 verifyIncompleteFormat("namespace {\n" in TEST_F()
6218 "class Foo { Foo (\n" in TEST_F()
6219 "};\n" in TEST_F()
6224 EXPECT_EQ("{\n {}\n", format("{\n{\n}\n")); in TEST_F()
6225 EXPECT_EQ("{\n {}\n", format("{\n {\n}\n")); in TEST_F()
6226 EXPECT_EQ("{\n {}\n", format("{\n {\n }\n")); in TEST_F()
6227 EXPECT_EQ("{\n {}\n}\n}\n", format("{\n {\n }\n }\n}\n")); in TEST_F()
6229 EXPECT_EQ("{\n" in TEST_F()
6230 " {\n" in TEST_F()
6231 " breakme(\n" in TEST_F()
6232 " qwe);\n" in TEST_F()
6233 " }\n", in TEST_F()
6234 format("{\n" in TEST_F()
6235 " {\n" in TEST_F()
6236 " breakme(qwe);\n" in TEST_F()
6237 "}\n", in TEST_F()
6242 verifyFormat("int x = {\n" in TEST_F()
6243 " avariable,\n" in TEST_F()
6254 verifyFormat("vector<int> x{\n" in TEST_F()
6255 " 1, 2, 3, 4,\n" in TEST_F()
6270 verifyFormat("class Class {\n" in TEST_F()
6271 " T member = {arg1, arg2};\n" in TEST_F()
6281 verifyFormat("Node n{1, Node{1000}, //\n" in TEST_F()
6283 verifyFormat("Aaaa aaaaaaa{\n" in TEST_F()
6284 " {\n" in TEST_F()
6285 " aaaa,\n" in TEST_F()
6286 " },\n" in TEST_F()
6288 verifyFormat("class C : public D {\n" in TEST_F()
6289 " SomeClass SC{2};\n" in TEST_F()
6291 verifyFormat("class C : public A {\n" in TEST_F()
6292 " class D : public B {\n" in TEST_F()
6293 " void f() { int i{2}; }\n" in TEST_F()
6294 " };\n" in TEST_F()
6301 verifyFormat("const Aaaaaa aaaaa = {aaaaa,\n" in TEST_F()
6302 " bbbbb,\n" in TEST_F()
6303 " ccccc,\n" in TEST_F()
6304 " ddddd,\n" in TEST_F()
6305 " eeeee,\n" in TEST_F()
6306 " ffffff,\n" in TEST_F()
6307 " ggggg,\n" in TEST_F()
6308 " hhhhhh,\n" in TEST_F()
6309 " iiiiii,\n" in TEST_F()
6310 " jjjjjj,\n" in TEST_F()
6313 verifyFormat("const Aaaaaa aaaaa = {\n" in TEST_F()
6314 " aaaaa,\n" in TEST_F()
6315 " bbbbb,\n" in TEST_F()
6316 " ccccc,\n" in TEST_F()
6317 " ddddd,\n" in TEST_F()
6318 " eeeee,\n" in TEST_F()
6319 " ffffff,\n" in TEST_F()
6320 " ggggg,\n" in TEST_F()
6321 " hhhhhh,\n" in TEST_F()
6322 " iiiiii,\n" in TEST_F()
6323 " jjjjjj,\n" in TEST_F()
6324 " kkkkkk,\n" in TEST_F()
6328 "const Aaaaaa aaaaa = {\n" in TEST_F()
6329 " aaaaa, bbbbb, ccccc, ddddd, eeeee, ffffff, ggggg, hhhhhh,\n" in TEST_F()
6330 " iiiiii, jjjjjj, kkkkkk, aaaaa, bbbbb, ccccc, ddddd, eeeee,\n" in TEST_F()
6331 " ffffff, ggggg, hhhhhh, iiiiii, jjjjjj, kkkkkk,\n" in TEST_F()
6337 verifyFormat("Constructor::Constructor()\n" in TEST_F()
6338 " : some_value{ //\n" in TEST_F()
6339 " aaaaaaa, //\n" in TEST_F()
6345 EXPECT_EQ("function({// First element:\n" in TEST_F()
6346 " 1,\n" in TEST_F()
6347 " // Second element:\n" in TEST_F()
6349 format("function({\n" in TEST_F()
6350 " // First element:\n" in TEST_F()
6351 " 1,\n" in TEST_F()
6352 " // Second element:\n" in TEST_F()
6354 EXPECT_EQ("std::vector<int> MyNumbers{\n" in TEST_F()
6355 " // First element:\n" in TEST_F()
6356 " 1,\n" in TEST_F()
6357 " // Second element:\n" in TEST_F()
6359 format("std::vector<int> MyNumbers{// First element:\n" in TEST_F()
6360 " 1,\n" in TEST_F()
6361 " // Second element:\n" in TEST_F()
6365 EXPECT_EQ("vector<int> SomeVector = {\n" in TEST_F()
6366 " // aaa\n" in TEST_F()
6367 " 1, 2,\n" in TEST_F()
6369 format("vector<int> SomeVector = { // aaa\n" in TEST_F()
6388 verifyFormat("class Class {\n" in TEST_F()
6389 " T member = { arg1, arg2 };\n" in TEST_F()
6393 "foo = aaaaaaaaaaa ? vector<int>{ aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
6394 " aaaaaaaaaaaaaaaaaaaa, aaaaa }\n" in TEST_F()
6395 " : vector<int>{ bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n" in TEST_F()
6402 "someFunction(OtherParam,\n" in TEST_F()
6403 " BracedList{ // comment 1 (Forcing interesting break)\n" in TEST_F()
6404 " param1, param2,\n" in TEST_F()
6405 " // comment 2\n" in TEST_F()
6409 "std::this_thread::sleep_for(\n" in TEST_F()
6412 verifyFormat("std::vector<MyValues> aaaaaaaaaaaaaaaaaaa{\n" in TEST_F()
6413 " aaaaaaa,\n" in TEST_F()
6414 " aaaaaaaaaa,\n" in TEST_F()
6415 " aaaaa,\n" in TEST_F()
6416 " aaaaaaaaaaaaaaa,\n" in TEST_F()
6417 " aaa,\n" in TEST_F()
6418 " aaaaaaaaaa,\n" in TEST_F()
6419 " a,\n" in TEST_F()
6420 " aaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
6421 " aaaaaaaaaaaa,\n" in TEST_F()
6422 " aaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
6423 " aaaaaaa,\n" in TEST_F()
6429 verifyFormat("vector<int> x = {1, 22, 333, 4444, 55555, 666666, 7777777,\n" in TEST_F()
6430 " 1, 22, 333, 4444, 55555, 666666, 7777777,\n" in TEST_F()
6431 " 1, 22, 333, 4444, 55555, 666666, 7777777,\n" in TEST_F()
6432 " 1, 22, 333, 4444, 55555, 666666, 7777777,\n" in TEST_F()
6433 " 1, 22, 333, 4444, 55555, 666666, 7777777,\n" in TEST_F()
6435 verifyFormat("vector<int> x = {1, 22, 333, 4444, 55555, 666666, 7777777, //\n" in TEST_F()
6436 " 1, 22, 333, 4444, 55555, 666666, 7777777,\n" in TEST_F()
6437 " 1, 22, 333, 4444, 55555, //\n" in TEST_F()
6438 " 1, 22, 333, 4444, 55555, 666666, 7777777,\n" in TEST_F()
6441 "vector<int> x = {1, 22, 333, 4444, 55555, 666666, 7777777,\n" in TEST_F()
6442 " 1, 22, 333, 4444, 55555, 666666, 7777777,\n" in TEST_F()
6443 " 1, 22, 333, 4444, 55555, 666666, // comment\n" in TEST_F()
6444 " 7777777, 1, 22, 333, 4444, 55555, 666666,\n" in TEST_F()
6445 " 7777777, 1, 22, 333, 4444, 55555, 666666,\n" in TEST_F()
6446 " 7777777, 1, 22, 333, 4444, 55555, 666666,\n" in TEST_F()
6448 verifyFormat("static const uint16_t CallerSavedRegs64Bittttt[] = {\n" in TEST_F()
6449 " X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,\n" in TEST_F()
6451 verifyFormat("static const uint16_t CallerSavedRegs64Bittttt[] = {\n" in TEST_F()
6452 " X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,\n" in TEST_F()
6453 " // Separating comment.\n" in TEST_F()
6455 verifyFormat("static const uint16_t CallerSavedRegs64Bittttt[] = {\n" in TEST_F()
6456 " // Leading comment\n" in TEST_F()
6457 " X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,\n" in TEST_F()
6459 verifyFormat("vector<int> x = {1, 1, 1, 1,\n" in TEST_F()
6462 verifyFormat("vector<int> x = {1, 1, 1, 1,\n" in TEST_F()
6465 verifyFormat("vector<int> aaaaaaaaaaaaaaaaaaaaaa = {\n" in TEST_F()
6469 "static unsigned SomeValues[10][3] = {\n" in TEST_F()
6470 " {1, 4, 0}, {4, 9, 0}, {4, 5, 9}, {8, 5, 4}, {1, 8, 4},\n" in TEST_F()
6472 verifyFormat("static auto fields = new vector<string>{\n" in TEST_F()
6473 " \"aaaaaaaaaaaaa\",\n" in TEST_F()
6474 " \"aaaaaaaaaaaaa\",\n" in TEST_F()
6475 " \"aaaaaaaaaaaa\",\n" in TEST_F()
6476 " \"aaaaaaaaaaaaaa\",\n" in TEST_F()
6477 " \"aaaaaaaaaaaaaaaaaaaaaaaaa\",\n" in TEST_F()
6478 " \"aaaaaaaaaaaa\",\n" in TEST_F()
6479 " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n" in TEST_F()
6482 verifyFormat("vector<int> x = {1, aaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
6483 " 2, bbbbbbbbbbbbbbbbbbbbbb,\n" in TEST_F()
6488 verifyFormat("vector<int> x = {\n" in TEST_F()
6489 " 1, 1, 1, 1, 1, 1, 1, 1,\n" in TEST_F()
6492 verifyFormat("vector<int> x = {\n" in TEST_F()
6493 " 1, 1, 1, 1, 1, 1, 1, 1, //\n" in TEST_F()
6496 verifyFormat("vector<int> x = {1, 1, 1, 1,\n" in TEST_F()
6497 " 1, 1, 1, 1,\n" in TEST_F()
6502 verifyFormat("vector<int> iiiiiiiiiiiiiii = { //\n" in TEST_F()
6503 " 1111111111, 2222222222, 33333333333, 4444444444, //\n" in TEST_F()
6504 " 111111111, 222222222, 3333333333, 444444444, //\n" in TEST_F()
6507 verifyFormat("int aaaaa[] = {\n" in TEST_F()
6508 " 1, 2, 3, // comment\n" in TEST_F()
6509 " 4, 5, 6 // comment\n" in TEST_F()
6515 verifyFormat("return {{aaaaaaaaaaaaaaaaaaaaa},\n" in TEST_F()
6516 " {aaaaaaaaaaaaaaaaaaa},\n" in TEST_F()
6517 " {aaaaaaaaaaaaaaaaaaaaa},\n" in TEST_F()
6521 "SomeStruct my_struct_array = {\n" in TEST_F()
6522 " {aaaaaa, aaaaaaaa, aaaaaaaaaa, aaaaaaaaa, aaaaaaaaa, aaaaaaaaaa,\n" in TEST_F()
6523 " aaaaaaaaaaaaa, aaaaaaa, aaa},\n" in TEST_F()
6524 " {aaa, aaa},\n" in TEST_F()
6525 " {aaa, aaa},\n" in TEST_F()
6526 " {aaaa, aaaa, aaaa, aaaa, aaaa, aaaa, aaaa, aaa},\n" in TEST_F()
6527 " {aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
6531 verifyFormat("aaaaaaaaaaaaaaa = {aaaaaaaaaaaaaaaaaaaaaaaaaaa, 0, 0,\n" in TEST_F()
6537 verifyFormat("void f() {\n" in TEST_F()
6538 " struct Dummy {};\n" in TEST_F()
6539 " f(v);\n" in TEST_F()
6548 verifyFormat("void f() {\n" in TEST_F()
6549 " return 42;\n" in TEST_F()
6552 verifyFormat("void f() {\n" in TEST_F()
6553 " // Comment\n" in TEST_F()
6555 verifyFormat("{\n" in TEST_F()
6556 "#error {\n" in TEST_F()
6557 " int a;\n" in TEST_F()
6559 verifyFormat("{\n" in TEST_F()
6560 " int a;\n" in TEST_F()
6561 "#error {\n" in TEST_F()
6565 verifyFormat("void f() {\n" in TEST_F()
6568 verifyFormat("void f() {\n" in TEST_F()
6569 " int a;\n" in TEST_F()
6572 verifyFormat("void f() {\n" in TEST_F()
6577 verifyFormat("void f() {\n return 42;\n}", getLLVMStyleWithColumns(22)); in TEST_F()
6580 verifyFormat("void f() {\n}", getLLVMStyleWithColumns(10)); in TEST_F()
6581 verifyFormat("class C {\n" in TEST_F()
6582 " C()\n" in TEST_F()
6583 " : iiiiiiii(nullptr),\n" in TEST_F()
6584 " kkkkkkk(nullptr),\n" in TEST_F()
6585 " mmmmmmm(nullptr),\n" in TEST_F()
6586 " nnnnnnn(nullptr) {}\n" in TEST_F()
6593 EXPECT_EQ("class C {\n" in TEST_F()
6594 " A() : b(0) {}\n" in TEST_F()
6597 EXPECT_EQ("A()\n" in TEST_F()
6598 " : b(0) {\n" in TEST_F()
6600 format("A()\n:b(0)\n{\n}", NoColumnLimit)); in TEST_F()
6605 EXPECT_EQ("A()\n" in TEST_F()
6606 " : b(0) {\n" in TEST_F()
6609 EXPECT_EQ("A()\n" in TEST_F()
6610 " : b(0) {\n" in TEST_F()
6612 format("A()\n:b(0)\n{\n}", DoNotMergeNoColumnLimit)); in TEST_F()
6614 verifyFormat("#define A \\\n" in TEST_F()
6615 " void f() { \\\n" in TEST_F()
6616 " int i; \\\n" in TEST_F()
6619 verifyFormat("#define A \\\n" in TEST_F()
6622 verifyFormat("#define A \\\n" in TEST_F()
6623 " void f() { \\\n" in TEST_F()
6624 " int i; \\\n" in TEST_F()
6625 " } \\\n" in TEST_F()
6628 verifyFormat("#define A \\\n" in TEST_F()
6629 " void f() { int i; } \\\n" in TEST_F()
6637 verifyFormat("class C {\n" in TEST_F()
6638 " int f() { return 42; }\n" in TEST_F()
6641 verifyFormat("int f() {\n" in TEST_F()
6642 " return 42;\n" in TEST_F()
6649 verifyFormat("struct foo a = {bar};\nint n;"); in TEST_F()
6650 verifyFormat("class foo a = {bar};\nint n;"); in TEST_F()
6651 verifyFormat("union foo a = {bar};\nint n;"); in TEST_F()
6654 verifyFormat("struct foo f() {}\nint n;"); in TEST_F()
6655 verifyFormat("class foo f() {}\nint n;"); in TEST_F()
6656 verifyFormat("union foo f() {}\nint n;"); in TEST_F()
6659 verifyFormat("template <class X> void f() {}\nint n;"); in TEST_F()
6660 verifyFormat("template <struct X> void f() {}\nint n;"); in TEST_F()
6661 verifyFormat("template <union X> void f() {}\nint n;"); in TEST_F()
6664 verifyFormat("struct {\n} n;"); in TEST_F()
6666 "template <template <class T, class Y>, class Z> class X {\n} n;"); in TEST_F()
6667 verifyFormat("union Z {\n int n;\n} x;"); in TEST_F()
6668 verifyFormat("class MACRO Z {\n} n;"); in TEST_F()
6669 verifyFormat("class MACRO(X) Z {\n} n;"); in TEST_F()
6670 verifyFormat("class __attribute__(X) Z {\n} n;"); in TEST_F()
6671 verifyFormat("class __declspec(X) Z {\n} n;"); in TEST_F()
6672 verifyFormat("class A##B##C {\n} n;"); in TEST_F()
6673 verifyFormat("class alignas(16) Z {\n} n;"); in TEST_F()
6674 verifyFormat("class MACRO(X) alignas(16) Z {\n} n;"); in TEST_F()
6675 verifyFormat("class MACROA MACRO(X) Z {\n} n;"); in TEST_F()
6678 verifyFormat("class A::B::C {\n} n;"); in TEST_F()
6682 "template <typename F>\n" in TEST_F()
6683 "Matcher(const Matcher<F> &Other,\n" in TEST_F()
6684 " typename enable_if_c<is_base_of<F, T>::value &&\n" in TEST_F()
6685 " !is_same<F, T>::value>::type * = 0)\n" in TEST_F()
6694 // verifyFormat("class A<int> f() {\n}\nint n;"); in TEST_F()
6698 verifyFormat("if (true)\n" in TEST_F()
6699 " class X x;\n" in TEST_F()
6700 "else\n" in TEST_F()
6701 " f();\n"); in TEST_F()
6708 EXPECT_EQ("#error Leave all white!!!!! space* alone!\n", in TEST_F()
6709 format("#error Leave all white!!!!! space* alone!\n")); in TEST_F()
6711 "#warning Leave all white!!!!! space* alone!\n", in TEST_F()
6712 format("#warning Leave all white!!!!! space* alone!\n")); in TEST_F()
6723 "#if !defined(AAAAAAA) && (defined CCCCCC || defined DDDDDD) && \\\n" in TEST_F()
6724 " defined(BBBBBBBB)\n" in TEST_F()
6725 "#elif !defined(AAAAAA) && (defined CCCCC || defined DDDDDD) && \\\n" in TEST_F()
6726 " defined(BBBBBBBB)\n" in TEST_F()
6734 verifyFormat("void f() { f(); }\n#error E", AllowsMergedIf); in TEST_F()
6735 verifyFormat("if (true) return 42;\n#error E", AllowsMergedIf); in TEST_F()
6736 verifyFormat("if (true)\n#error E\n return 42;", AllowsMergedIf); in TEST_F()
6741 verifyFormat("#define A \\\n" in TEST_F()
6744 verifyFormat("#define A \\\n" in TEST_F()
6745 " f(); \\\n" in TEST_F()
6746 " if (true)\n" in TEST_F()
6749 verifyFormat("#define A \\\n" in TEST_F()
6750 " f(); \\\n" in TEST_F()
6751 " if (true)\n" in TEST_F()
6754 verifyFormat("{\n" in TEST_F()
6755 "#ifdef A\n" in TEST_F()
6756 " // Comment\n" in TEST_F()
6757 " if (true) continue;\n" in TEST_F()
6758 "#endif\n" in TEST_F()
6759 " // Comment\n" in TEST_F()
6760 " if (true) continue;\n" in TEST_F()
6764 verifyFormat("#define A \\\n" in TEST_F()
6765 " if (aaaaaaaaaa) return 1; \\\n" in TEST_F()
6769 verifyFormat("#define A \\\n" in TEST_F()
6770 " if (aaaaaaaaaa) \\\n" in TEST_F()
6771 " return 1; \\\n" in TEST_F()
6777 verifyFormat("if (0) /* a comment in a strange place */ {\n" in TEST_F()
6778 " f();\n" in TEST_F()
6780 verifyFormat("if (0) /* a comment in a strange place */ {\n" in TEST_F()
6781 " f();\n" in TEST_F()
6782 "} /* another comment */ else /* comment #3 */ {\n" in TEST_F()
6783 " g();\n" in TEST_F()
6785 verifyFormat("while (0) /* a comment in a strange place */ {\n" in TEST_F()
6786 " f();\n" in TEST_F()
6788 verifyFormat("for (;;) /* a comment in a strange place */ {\n" in TEST_F()
6789 " f();\n" in TEST_F()
6791 verifyFormat("do /* a comment in a strange place */ {\n" in TEST_F()
6792 " f();\n" in TEST_F()
6797 EXPECT_EQ("/* */ /* */ /* */\n/* */ /* */ /* */", in TEST_F()
6798 format("/* *//* */ /* */\n/* *//* */ /* */")); in TEST_F()
6800 EXPECT_EQ("#define A /*123*/ \\\n" in TEST_F()
6801 " b\n" in TEST_F()
6802 "/* */\n" in TEST_F()
6803 "someCall(\n" in TEST_F()
6805 format("#define A /*123*/ b\n" in TEST_F()
6806 "/* */\n" in TEST_F()
6810 EXPECT_EQ("#define A\n" in TEST_F()
6811 "/* */ someCall(\n" in TEST_F()
6813 format("#define A\n" in TEST_F()
6816 EXPECT_EQ("/*\n**\n*/", format("/*\n**\n*/")); in TEST_F()
6817 EXPECT_EQ("/*\n" in TEST_F()
6818 "*\n" in TEST_F()
6819 " * aaaaaa\n" in TEST_F()
6820 " * aaaaaa\n" in TEST_F()
6822 format("/*\n" in TEST_F()
6823 "*\n" in TEST_F()
6824 " * aaaaaa aaaaaa\n" in TEST_F()
6827 EXPECT_EQ("/*\n" in TEST_F()
6828 "**\n" in TEST_F()
6829 "* aaaaaa\n" in TEST_F()
6830 "*aaaaaa\n" in TEST_F()
6832 format("/*\n" in TEST_F()
6833 "**\n" in TEST_F()
6834 "* aaaaaa aaaaaa\n" in TEST_F()
6840 EXPECT_EQ("someFunction(1, /* comment 1 */\n" in TEST_F()
6841 " 2, /* comment 2 */\n" in TEST_F()
6842 " 3, /* comment 3 */\n" in TEST_F()
6843 " aaaa,\n" in TEST_F()
6845 format("someFunction (1, /* comment 1 */\n" in TEST_F()
6846 " 2, /* comment 2 */ \n" in TEST_F()
6847 " 3, /* comment 3 */\n" in TEST_F()
6851 "bool aaaaaaaaaaaaa = /* comment: */ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n" in TEST_F()
6854 "bool aaaaaaaaaaaaa = /* trailing comment */\n" in TEST_F()
6855 " aaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaa ||\n" in TEST_F()
6858 "bool aaaaaaaaaaaaa = /* trailing comment */\n" in TEST_F()
6859 " aaaaaaaaaaaaaaaaaaaaaaaaaaa||aaaaaaaaaaaaaaaaaaaaaaaaa ||\n" in TEST_F()
6862 "int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; /* comment */\n" in TEST_F()
6863 "int bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; /* comment */\n" in TEST_F()
6864 "int cccccccccccccccccccccccccccccc; /* comment */\n", in TEST_F()
6865 format("int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; /* comment */\n" in TEST_F()
6866 "int bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; /* comment */\n" in TEST_F()
6867 "int cccccccccccccccccccccccccccccc; /* comment */\n")); in TEST_F()
6871 EXPECT_EQ("/*\n" in TEST_F()
6872 " **\n" in TEST_F()
6874 format("/*\n" in TEST_F()
6875 " **\n" in TEST_F()
6877 EXPECT_EQ("/*\n" in TEST_F()
6878 " *q\n" in TEST_F()
6880 format("/*\n" in TEST_F()
6881 " *q\n" in TEST_F()
6883 EXPECT_EQ("/*\n" in TEST_F()
6884 " * q\n" in TEST_F()
6886 format("/*\n" in TEST_F()
6887 " * q\n" in TEST_F()
6889 EXPECT_EQ("/*\n" in TEST_F()
6891 format("/*\n" in TEST_F()
6893 EXPECT_EQ("/*\n" in TEST_F()
6895 format("/*\n" in TEST_F()
6900 EXPECT_EQ("#define A \\\n" in TEST_F()
6901 " { \\\n" in TEST_F()
6902 " /* one line */ \\\n" in TEST_F()
6904 format("#define A { \\\n" in TEST_F()
6905 " /* one line */ \\\n" in TEST_F()
6908 EXPECT_EQ("#define A \\\n" in TEST_F()
6909 " { \\\n" in TEST_F()
6910 " /* previous */ \\\n" in TEST_F()
6911 " /* one line */ \\\n" in TEST_F()
6913 format("#define A { \\\n" in TEST_F()
6914 " /* previous */ \\\n" in TEST_F()
6915 " /* one line */ \\\n" in TEST_F()
6921 EXPECT_EQ("a = {\n" in TEST_F()
6922 " 1111 /* */\n" in TEST_F()
6924 format("a = {1111 /* */\n" in TEST_F()
6927 EXPECT_EQ("a = {\n" in TEST_F()
6928 " 1111 /* */\n" in TEST_F()
6930 format("a = {1111 /* */\n" in TEST_F()
6935 EXPECT_EQ("a = {\n" in TEST_F()
6936 " 1111 /* a\n" in TEST_F()
6937 " */\n" in TEST_F()
6939 format("a = {1111 /* a */\n" in TEST_F()
6946 verifyFormat("{\n" in TEST_F()
6954 verifyFormat("class A {\n void f(int *a);\n};"); in TEST_F()
6955 verifyFormat("class A {\n int *a;\n};"); in TEST_F()
6956 verifyFormat("namespace a {\n" in TEST_F()
6957 "namespace b {\n" in TEST_F()
6958 "class A {\n" in TEST_F()
6959 " void f() {}\n" in TEST_F()
6960 " int *a;\n" in TEST_F()
6961 "};\n" in TEST_F()
6962 "}\n" in TEST_F()
6995 verifyFormat("- (void)aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n" in TEST_F()
6997 verifyFormat("- (NSUInteger)indexOfObject:(id)anObject\n" in TEST_F()
6998 " inRange:(NSRange)range\n" in TEST_F()
6999 " outRange:(NSRange)out_range\n" in TEST_F()
7000 " outRange1:(NSRange)out_range1\n" in TEST_F()
7001 " outRange2:(NSRange)out_range2\n" in TEST_F()
7002 " outRange3:(NSRange)out_range3\n" in TEST_F()
7003 " outRange4:(NSRange)out_range4\n" in TEST_F()
7004 " outRange5:(NSRange)out_range5\n" in TEST_F()
7005 " outRange6:(NSRange)out_range6\n" in TEST_F()
7006 " outRange7:(NSRange)out_range7\n" in TEST_F()
7007 " outRange8:(NSRange)out_range8\n" in TEST_F()
7013 verifyFormat("- (SomeLooooooooooooooooooooongType *)\n" in TEST_F()
7014 "veryLooooooooooongName:(NSString)aaaaaaaaaaaaaa\n" in TEST_F()
7015 " anotherName:(NSString)bbbbbbbbbbbbbb {\n" in TEST_F()
7019 verifyFormat("- (SomeLooooooooooooooooooooongType *)\n" in TEST_F()
7020 " veryLooooooooooongName:(NSString)aaaaaaaaaaaaaa\n" in TEST_F()
7021 " anotherName:(NSString)bbbbbbbbbbbbbb {\n" in TEST_F()
7042 verifyFormat("@interface Foo : NSObject <NSSomeDelegate> {\n" in TEST_F()
7043 "@public\n" in TEST_F()
7044 " int field1;\n" in TEST_F()
7045 "@protected\n" in TEST_F()
7046 " int field2;\n" in TEST_F()
7047 "@private\n" in TEST_F()
7048 " int field3;\n" in TEST_F()
7049 "@package\n" in TEST_F()
7050 " int field4;\n" in TEST_F()
7051 "}\n" in TEST_F()
7052 "+ (id)init;\n" in TEST_F()
7055 verifyGoogleFormat("@interface Foo : NSObject<NSSomeDelegate> {\n" in TEST_F()
7056 " @public\n" in TEST_F()
7057 " int field1;\n" in TEST_F()
7058 " @protected\n" in TEST_F()
7059 " int field2;\n" in TEST_F()
7060 " @private\n" in TEST_F()
7061 " int field3;\n" in TEST_F()
7062 " @package\n" in TEST_F()
7063 " int field4;\n" in TEST_F()
7064 "}\n" in TEST_F()
7065 "+ (id)init;\n" in TEST_F()
7068 verifyFormat("@interface /* wait for it */ Foo\n" in TEST_F()
7069 "+ (id)init;\n" in TEST_F()
7070 "// Look, a comment!\n" in TEST_F()
7071 "- (int)answerWith:(int)i;\n" in TEST_F()
7074 verifyFormat("@interface Foo\n" in TEST_F()
7075 "@end\n" in TEST_F()
7076 "@interface Bar\n" in TEST_F()
7079 verifyFormat("@interface Foo : Bar\n" in TEST_F()
7080 "+ (id)init;\n" in TEST_F()
7083 verifyFormat("@interface Foo : /**/ Bar /**/ <Baz, /**/ Quux>\n" in TEST_F()
7084 "+ (id)init;\n" in TEST_F()
7087 verifyGoogleFormat("@interface Foo : Bar<Baz, Quux>\n" in TEST_F()
7088 "+ (id)init;\n" in TEST_F()
7091 verifyFormat("@interface Foo (HackStuff)\n" in TEST_F()
7092 "+ (id)init;\n" in TEST_F()
7095 verifyFormat("@interface Foo ()\n" in TEST_F()
7096 "+ (id)init;\n" in TEST_F()
7099 verifyFormat("@interface Foo (HackStuff) <MyProtocol>\n" in TEST_F()
7100 "+ (id)init;\n" in TEST_F()
7103 verifyGoogleFormat("@interface Foo (HackStuff)<MyProtocol>\n" in TEST_F()
7104 "+ (id)init;\n" in TEST_F()
7107 verifyFormat("@interface Foo {\n" in TEST_F()
7108 " int _i;\n" in TEST_F()
7109 "}\n" in TEST_F()
7110 "+ (id)init;\n" in TEST_F()
7113 verifyFormat("@interface Foo : Bar {\n" in TEST_F()
7114 " int _i;\n" in TEST_F()
7115 "}\n" in TEST_F()
7116 "+ (id)init;\n" in TEST_F()
7119 verifyFormat("@interface Foo : Bar <Baz, Quux> {\n" in TEST_F()
7120 " int _i;\n" in TEST_F()
7121 "}\n" in TEST_F()
7122 "+ (id)init;\n" in TEST_F()
7125 verifyFormat("@interface Foo (HackStuff) {\n" in TEST_F()
7126 " int _i;\n" in TEST_F()
7127 "}\n" in TEST_F()
7128 "+ (id)init;\n" in TEST_F()
7131 verifyFormat("@interface Foo () {\n" in TEST_F()
7132 " int _i;\n" in TEST_F()
7133 "}\n" in TEST_F()
7134 "+ (id)init;\n" in TEST_F()
7137 verifyFormat("@interface Foo (HackStuff) <MyProtocol> {\n" in TEST_F()
7138 " int _i;\n" in TEST_F()
7139 "}\n" in TEST_F()
7140 "+ (id)init;\n" in TEST_F()
7145 verifyFormat("@interface aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ()<\n" in TEST_F()
7146 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
7147 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
7148 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
7149 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> {\n" in TEST_F()
7155 verifyFormat("@implementation Foo : NSObject {\n" in TEST_F()
7156 "@public\n" in TEST_F()
7157 " int field1;\n" in TEST_F()
7158 "@protected\n" in TEST_F()
7159 " int field2;\n" in TEST_F()
7160 "@private\n" in TEST_F()
7161 " int field3;\n" in TEST_F()
7162 "@package\n" in TEST_F()
7163 " int field4;\n" in TEST_F()
7164 "}\n" in TEST_F()
7165 "+ (id)init {\n}\n" in TEST_F()
7168 verifyGoogleFormat("@implementation Foo : NSObject {\n" in TEST_F()
7169 " @public\n" in TEST_F()
7170 " int field1;\n" in TEST_F()
7171 " @protected\n" in TEST_F()
7172 " int field2;\n" in TEST_F()
7173 " @private\n" in TEST_F()
7174 " int field3;\n" in TEST_F()
7175 " @package\n" in TEST_F()
7176 " int field4;\n" in TEST_F()
7177 "}\n" in TEST_F()
7178 "+ (id)init {\n}\n" in TEST_F()
7181 verifyFormat("@implementation Foo\n" in TEST_F()
7182 "+ (id)init {\n" in TEST_F()
7183 " if (true)\n" in TEST_F()
7184 " return nil;\n" in TEST_F()
7185 "}\n" in TEST_F()
7186 "// Look, a comment!\n" in TEST_F()
7187 "- (int)answerWith:(int)i {\n" in TEST_F()
7188 " return i;\n" in TEST_F()
7189 "}\n" in TEST_F()
7190 "+ (int)answerWith:(int)i {\n" in TEST_F()
7191 " return i;\n" in TEST_F()
7192 "}\n" in TEST_F()
7195 verifyFormat("@implementation Foo\n" in TEST_F()
7196 "@end\n" in TEST_F()
7197 "@implementation Bar\n" in TEST_F()
7200 EXPECT_EQ("@implementation Foo : Bar\n" in TEST_F()
7201 "+ (id)init {\n}\n" in TEST_F()
7202 "- (void)foo {\n}\n" in TEST_F()
7204 format("@implementation Foo : Bar\n" in TEST_F()
7205 "+(id)init{}\n" in TEST_F()
7206 "-(void)foo{}\n" in TEST_F()
7209 verifyFormat("@implementation Foo {\n" in TEST_F()
7210 " int _i;\n" in TEST_F()
7211 "}\n" in TEST_F()
7212 "+ (id)init {\n}\n" in TEST_F()
7215 verifyFormat("@implementation Foo : Bar {\n" in TEST_F()
7216 " int _i;\n" in TEST_F()
7217 "}\n" in TEST_F()
7218 "+ (id)init {\n}\n" in TEST_F()
7221 verifyFormat("@implementation Foo (HackStuff)\n" in TEST_F()
7222 "+ (id)init {\n}\n" in TEST_F()
7224 verifyFormat("@implementation ObjcClass\n" in TEST_F()
7225 "- (void)method;\n" in TEST_F()
7226 "{}\n" in TEST_F()
7231 verifyFormat("@protocol Foo\n" in TEST_F()
7232 "@property(weak) id delegate;\n" in TEST_F()
7233 "- (NSUInteger)numberOfThings;\n" in TEST_F()
7236 verifyFormat("@protocol MyProtocol <NSObject>\n" in TEST_F()
7237 "- (NSUInteger)numberOfThings;\n" in TEST_F()
7240 verifyGoogleFormat("@protocol MyProtocol<NSObject>\n" in TEST_F()
7241 "- (NSUInteger)numberOfThings;\n" in TEST_F()
7244 verifyFormat("@protocol Foo;\n" in TEST_F()
7245 "@protocol Bar;\n"); in TEST_F()
7247 verifyFormat("@protocol Foo\n" in TEST_F()
7248 "@end\n" in TEST_F()
7249 "@protocol Bar\n" in TEST_F()
7252 verifyFormat("@protocol myProtocol\n" in TEST_F()
7253 "- (void)mandatoryWithInt:(int)i;\n" in TEST_F()
7254 "@optional\n" in TEST_F()
7255 "- (void)optional;\n" in TEST_F()
7256 "@required\n" in TEST_F()
7257 "- (void)required;\n" in TEST_F()
7258 "@optional\n" in TEST_F()
7259 "@property(assign) int madProp;\n" in TEST_F()
7260 "@end\n"); in TEST_F()
7262 verifyFormat("@property(nonatomic, assign, readonly)\n" in TEST_F()
7263 " int *looooooooooooooooooooooooooooongNumber;\n" in TEST_F()
7264 "@property(nonatomic, assign, readonly)\n" in TEST_F()
7267 verifyFormat("@implementation PR18406\n" in TEST_F()
7268 "}\n" in TEST_F()
7273 verifyFormat("- (void)doSomethingWith:(GTMFoo *)theFoo\n" in TEST_F()
7274 " rect:(NSRect)theRect\n" in TEST_F()
7275 " interval:(float)theInterval {\n" in TEST_F()
7277 verifyFormat("- (void)shortf:(GTMFoo *)theFoo\n" in TEST_F()
7278 " longKeyword:(NSRect)theRect\n" in TEST_F()
7279 " evenLongerKeyword:(float)theInterval\n" in TEST_F()
7280 " error:(NSError **)theError {\n" in TEST_F()
7282 verifyFormat("- (instancetype)initXxxxxx:(id<x>)x\n" in TEST_F()
7283 " y:(id<yyyyyyyyyyyyyyyyyyyy>)y\n" in TEST_F()
7292 verifyFormat("- (void)shortf:(GTMFoo *)theFoo\n" in TEST_F()
7293 " dontAlignNamef:(NSRect)theRect {\n" in TEST_F()
7298 verifyFormat("- (void)shortf:(GTMFoo *)theFoo\n" in TEST_F()
7299 " aShortf:(NSRect)theRect {\n" in TEST_F()
7365 verifyFormat("for (auto v : in[1]) {\n}"); in TEST_F()
7366 verifyFormat("for (int i = 0; i < in[a]; ++i) {\n}"); in TEST_F()
7367 verifyFormat("for (int i = 0; in[a] < i; ++i) {\n}"); in TEST_F()
7368 verifyFormat("for (int i = 0; i < n; ++i, ++in[a]) {\n}"); in TEST_F()
7369 verifyFormat("for (int i = 0; i < n; ++i, in[a]++) {\n}"); in TEST_F()
7370 verifyFormat("for (int i = 0; i < f(in[a]); ++i, in[a]++) {\n}"); in TEST_F()
7371 verifyFormat("for (id foo in [self getStuffFor:bla]) {\n" in TEST_F()
7396 "void f() {\n" in TEST_F()
7397 " if ((self = [super initWithContentRect:contentRect\n" in TEST_F()
7398 " styleMask:styleMask ?: otherMask\n" in TEST_F()
7399 " backing:NSBackingStoreBuffered\n" in TEST_F()
7403 "[foo checkThatBreakingAfterColonWorksOk:\n" in TEST_F()
7406 verifyFormat("[myObj short:arg1 // Force line break\n" in TEST_F()
7407 " longKeyword:arg2 != nil ? arg2 : @\"longKeyword\"\n" in TEST_F()
7408 " evenLongerKeyword:arg3 ?: @\"evenLongerKeyword\"\n" in TEST_F()
7411 "void f() {\n" in TEST_F()
7412 " popup_window_.reset([[RenderWidgetPopupWindow alloc]\n" in TEST_F()
7413 " initWithContentRect:NSMakeRect(origin_global.x, origin_global.y,\n" in TEST_F()
7414 " pos.width(), pos.height())\n" in TEST_F()
7415 " styleMask:NSBorderlessWindowMask\n" in TEST_F()
7416 " backing:NSBackingStoreBuffered\n" in TEST_F()
7417 " defer:NO]);\n" in TEST_F()
7420 "void f() {\n" in TEST_F()
7421 " popup_wdow_.reset([[RenderWidgetPopupWindow alloc]\n" in TEST_F()
7422 " iniithContentRect:NSMakRet(origin_global.x, origin_global.y,\n" in TEST_F()
7423 " pos.width(), pos.height())\n" in TEST_F()
7424 " syeMask:NSBorderlessWindowMask\n" in TEST_F()
7425 " bking:NSBackingStoreBuffered\n" in TEST_F()
7426 " der:NO]);\n" in TEST_F()
7430 "void f() {\n" in TEST_F()
7431 " popup_window_.reset([[RenderWidgetPopupWindow alloc]\n" in TEST_F()
7432 " initWithContentRect:NSMakeRect(origin_global.x, origin_global.y,\n" in TEST_F()
7433 " pos.width(), pos.height())\n" in TEST_F()
7434 " styleMask:NSBorderlessWindowMask\n" in TEST_F()
7435 " backing:NSBackingStoreBuffered\n" in TEST_F()
7436 " defer:NO]);\n" in TEST_F()
7439 verifyFormat("[contentsContainer replaceSubview:[subviews objectAtIndex:0]\n" in TEST_F()
7443 "[pboard addTypes:[NSArray arrayWithObject:kBookmarkButtonDragType]\n" in TEST_F()
7447 "[pboard setData:[NSData dataWithBytes:&button length:sizeof(button)]\n" in TEST_F()
7450 verifyFormat("[defaultCenter addObserver:self\n" in TEST_F()
7451 " selector:@selector(willEnterFullscreen)\n" in TEST_F()
7452 " name:kWillEnterFullscreenNotification\n" in TEST_F()
7454 verifyFormat("[image_rep drawInRect:drawRect\n" in TEST_F()
7455 " fromRect:NSZeroRect\n" in TEST_F()
7456 " operation:NSCompositeCopy\n" in TEST_F()
7457 " fraction:1.0\n" in TEST_F()
7458 " respectFlipped:NO\n" in TEST_F()
7460 verifyFormat("[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
7462 verifyFormat("[aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
7464 verifyFormat("[aaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaa[aaaaaaaaaaaaaaaaaaaaa]\n" in TEST_F()
7466 verifyFormat("[call aaaaaaaa.aaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa\n" in TEST_F()
7471 "scoped_nsobject<NSTextField> message(\n" in TEST_F()
7472 " // The frame will be fixed up when |-setMessageText:| is called.\n" in TEST_F()
7474 verifyFormat("[self aaaaaa:bbbbbbbbbbbbb\n" in TEST_F()
7475 " aaaaaaaaaa:bbbbbbbbbbbbbbbbb\n" in TEST_F()
7476 " aaaaa:bbbbbbbbbbb + bbbbbbbbbbbb\n" in TEST_F()
7478 verifyFormat("[self param:function( //\n" in TEST_F()
7481 "[self aaaaaaaaaa:aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa |\n" in TEST_F()
7482 " aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa |\n" in TEST_F()
7487 "[aaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
7488 " aaaaaaaaaaaaaaaaa:aaaaaaaa\n" in TEST_F()
7496 "[self aaaaaaaaaaaaa:aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa,\n" in TEST_F()
7497 " aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa,\n" in TEST_F()
7499 verifyFormat("[self // break\n" in TEST_F()
7500 " a:a\n" in TEST_F()
7502 verifyFormat("bool a = ([aaaaaaaa aaaaa] == aaaaaaaaaaaaaaaaa ||\n" in TEST_F()
7541 verifyFormat("@autoreleasepool {\n" in TEST_F()
7542 " foo();\n" in TEST_F()
7552 verifyFormat("@synchronized(self) {\n" in TEST_F()
7553 " f();\n" in TEST_F()
7569 verifyFormat("@import foo.bar;\n" in TEST_F()
7574 verifyFormat("- (void)test {\n" in TEST_F()
7575 " for (NSString *n in arrayOfStrings) {\n" in TEST_F()
7576 " foo(n);\n" in TEST_F()
7577 " }\n" in TEST_F()
7579 verifyFormat("- (void)test {\n" in TEST_F()
7580 " for (NSString *n in (__bridge NSArray *)arrayOfStrings) {\n" in TEST_F()
7581 " foo(n);\n" in TEST_F()
7582 " }\n" in TEST_F()
7612 verifyFormat("@{\n" in TEST_F()
7613 " @\"one\" : @{@2 : @1},\n" in TEST_F()
7625 verifyFormat("NSDictionary *d = @{\n" in TEST_F()
7626 " @\"nam\" : NSUserNam(),\n" in TEST_F()
7627 " @\"dte\" : [NSDate date],\n" in TEST_F()
7628 " @\"processInfo\" : [NSProcessInfo processInfo]\n" in TEST_F()
7631 "@{\n" in TEST_F()
7633 "regularFont,\n" in TEST_F()
7636 "@{\n" in TEST_F()
7638 "regularFont,\n" in TEST_F()
7641 "@{\n" in TEST_F()
7642 " NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee :\n" in TEST_F()
7643 " reeeeeeeeeeeeeeeeeeeeeeeegularFont,\n" in TEST_F()
7647 verifyFormat("NSDictionary *d = {\n" in TEST_F()
7648 " @\"nam\" : NSUserNam(),\n" in TEST_F()
7649 " @\"dte\" : [NSDate date],\n" in TEST_F()
7650 " @\"processInfo\" : [NSProcessInfo processInfo]\n" in TEST_F()
7652 verifyFormat("NSMutableDictionary *dictionary =\n" in TEST_F()
7653 " [NSMutableDictionary dictionaryWithDictionary:@{\n" in TEST_F()
7654 " aaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaa,\n" in TEST_F()
7655 " bbbbbbbbbbbbbbbbbb : bbbbb,\n" in TEST_F()
7656 " cccccccccccccccc : ccccccccccccccc\n" in TEST_F()
7661 "NSDictionary *d = @{\n" in TEST_F()
7662 " (aaaaaaaa id)aaaaaaaaa : (aaaaaaaa id)aaaaaaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
7663 " (aaaaaaaa id)aaaaaaaaaaaaaa : (aaaaaaaa id)aaaaaaaaaaaaaa,\n" in TEST_F()
7676 "NSArray *some_variable = @[\n" in TEST_F()
7677 " aaaa == bbbbbbbbbbb ? @\"aaaaaaaaaaaa\" : @\"aaaaaaaaaaaaaa\",\n" in TEST_F()
7678 " @\"aaaaaaaaaaaaaaaaa\",\n" in TEST_F()
7679 " @\"aaaaaaaaaaaaaaaaa\",\n" in TEST_F()
7680 " @\"aaaaaaaaaaaaaaaaa\"\n" in TEST_F()
7682 verifyFormat("NSArray *some_variable = @[\n" in TEST_F()
7683 " @\"aaaaaaaaaaaaaaaaa\",\n" in TEST_F()
7684 " @\"aaaaaaaaaaaaaaaaa\",\n" in TEST_F()
7685 " @\"aaaaaaaaaaaaaaaaa\",\n" in TEST_F()
7686 " @\"aaaaaaaaaaaaaaaaa\",\n" in TEST_F()
7688 verifyGoogleFormat("NSArray *some_variable = @[\n" in TEST_F()
7689 " @\"aaaaaaaaaaaaaaaaa\",\n" in TEST_F()
7690 " @\"aaaaaaaaaaaaaaaaa\",\n" in TEST_F()
7691 " @\"aaaaaaaaaaaaaaaaa\",\n" in TEST_F()
7692 " @\"aaaaaaaaaaaaaaaaa\"\n" in TEST_F()
7694 verifyFormat("NSArray *array = @[\n" in TEST_F()
7695 " @\"a\",\n" in TEST_F()
7696 " @\"a\",\n" // Trailing comma -> one per line. in TEST_F()
7700 verifyFormat("NSArray *some_variable = [\n" in TEST_F()
7701 " @\"aaaaaaaaaaaaaaaaa\",\n" in TEST_F()
7702 " @\"aaaaaaaaaaaaaaaaa\",\n" in TEST_F()
7703 " @\"aaaaaaaaaaaaaaaaa\",\n" in TEST_F()
7704 " @\"aaaaaaaaaaaaaaaaa\",\n" in TEST_F()
7707 "- (NSAttributedString *)attributedStringForSegment:(NSUInteger)segment\n" in TEST_F()
7708 " index:(NSUInteger)index\n" in TEST_F()
7709 " nonDigitAttributes:\n" in TEST_F()
7711 verifyFormat("[someFunction someLooooooooooooongParameter:@[\n" in TEST_F()
7712 " NSBundle.mainBundle.infoDictionary[@\"a\"]\n" in TEST_F()
7717 EXPECT_EQ("\"some text \"\n" in TEST_F()
7720 EXPECT_EQ("\"some text \"\n" in TEST_F()
7722 format("\\\n\"some text other\";", getLLVMStyleWithColumns(12))); in TEST_F()
7724 "#define A \\\n" in TEST_F()
7725 " \"some \" \\\n" in TEST_F()
7726 " \"text \" \\\n" in TEST_F()
7730 "#define A \\\n" in TEST_F()
7731 " \"so \" \\\n" in TEST_F()
7732 " \"text \" \\\n" in TEST_F()
7740 EXPECT_EQ("\"some \"\n" in TEST_F()
7743 EXPECT_EQ("\"some \"\n" in TEST_F()
7746 EXPECT_EQ("\"some\"\n" in TEST_F()
7747 "\" tex\"\n" in TEST_F()
7750 EXPECT_EQ("\"some\"\n" in TEST_F()
7751 "\" tex\"\n" in TEST_F()
7754 EXPECT_EQ("\"some\"\n" in TEST_F()
7755 "\"/tex\"\n" in TEST_F()
7759 EXPECT_EQ("variable =\n" in TEST_F()
7760 " \"long string \"\n" in TEST_F()
7765 EXPECT_EQ("variable = f(\n" in TEST_F()
7766 " \"long string \"\n" in TEST_F()
7767 " \"literal\",\n" in TEST_F()
7768 " short,\n" in TEST_F()
7775 "f(g(\"long string \"\n" in TEST_F()
7776 " \"literal\"),\n" in TEST_F()
7779 EXPECT_EQ("f(g(\"long string \"\n" in TEST_F()
7780 " \"literal\",\n" in TEST_F()
7781 " a),\n" in TEST_F()
7786 "f(\"one two\".split(\n" in TEST_F()
7789 EXPECT_EQ("f(\"one two three four five six \"\n" in TEST_F()
7790 " \"seven\".split(\n" in TEST_F()
7796 EXPECT_EQ("f(\"some \"\n" in TEST_F()
7797 " \"text\",\n" in TEST_F()
7803 "aaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
7804 " aaaaaaaaaaaaaaaaaaaa,\n" in TEST_F()
7807 EXPECT_EQ("\"splitmea\"\n" in TEST_F()
7808 "\"trandomp\"\n" in TEST_F()
7812 EXPECT_EQ("\"split/\"\n" in TEST_F()
7813 "\"pathat/\"\n" in TEST_F()
7817 EXPECT_EQ("\"split/\"\n" in TEST_F()
7818 "\"pathat/\"\n" in TEST_F()
7821 EXPECT_EQ("\"split at \"\n" in TEST_F()
7822 "\"spaces/at/\"\n" in TEST_F()
7823 "\"slashes.at.any$\"\n" in TEST_F()
7824 "\"non-alphanumeric%\"\n" in TEST_F()
7825 "\"1111111111characte\"\n" in TEST_F()
7839 "aaaaaaaaaaaa(\n" in TEST_F()
7840 " \"aaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa \"\n" in TEST_F()
7846 EXPECT_EQ("return \"aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaa \"\n" in TEST_F()
7852 EXPECT_EQ("llvm::outs() << \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \"\n" in TEST_F()
7857 EXPECT_EQ("ffff(\n" in TEST_F()
7858 " {\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \"\n" in TEST_F()
7866 EXPECT_EQ("#define A \\\n" in TEST_F()
7867 " \"some \" \\\n" in TEST_F()
7868 " \"text \" \\\n" in TEST_F()
7877 format("int i=a(\n\n b(\n\n\n )\n\n);", NoEmptyLines)); in TEST_F()
7883 "(\n" in TEST_F()
7892 "u8\"utf8 string \"\n" in TEST_F()
7896 "u\"utf16 string \"\n" in TEST_F()
7900 "U\"utf32 string \"\n" in TEST_F()
7903 EXPECT_EQ("L\"wide string \"\n" in TEST_F()
7906 EXPECT_EQ("@\"NSString \"\n" in TEST_F()
7930 "_T(\"aaaaaaaaaaaaaa\")\n" in TEST_F()
7931 "_T(\"aaaaaaaaaaaaaa\")\n" in TEST_F()
7934 EXPECT_EQ("f(x, _T(\"aaaaaaaaa\")\n" in TEST_F()
7935 " _T(\"aaaaaa\"),\n" in TEST_F()
7940 // EXPECT_EQ("_T(\"aaaaaaaaaaaaa\")\n" in TEST_F()
7941 // "_T(\"aaaaaaaaaaaaa\")\n" in TEST_F()
7942 // "_T(\"aaaaaaaaaaaaa\")\n" in TEST_F()
7949 EXPECT_EQ("f(\n" in TEST_F()
7950 "#if !TEST\n" in TEST_F()
7951 " _T(\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXn\")\n" in TEST_F()
7952 "#endif\n" in TEST_F()
7954 format("f(\n" in TEST_F()
7955 "#if !TEST\n" in TEST_F()
7956 "_T(\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXn\")\n" in TEST_F()
7957 "#endif\n" in TEST_F()
7959 EXPECT_EQ("f(\n" in TEST_F()
7960 "\n" in TEST_F()
7962 format("f(\n" in TEST_F()
7963 "\n" in TEST_F()
7969 "aaaaaaaaaaa = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\\n" in TEST_F()
7970 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\\n" in TEST_F()
7972 format("aaaaaaaaaaa = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\\n" in TEST_F()
7973 " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\\n" in TEST_F()
7980 EXPECT_EQ("fffffffffff(g(R\"x(\n" in TEST_F()
7981 "multiline raw string literal xxxxxxxxxxxxxx\n" in TEST_F()
7982 ")x\",\n" in TEST_F()
7983 " a),\n" in TEST_F()
7985 format("fffffffffff(g(R\"x(\n" in TEST_F()
7986 "multiline raw string literal xxxxxxxxxxxxxx\n" in TEST_F()
7989 EXPECT_EQ("fffffffffff(\n" in TEST_F()
7990 " g(R\"x(qqq\n" in TEST_F()
7991 "multiline raw string literal xxxxxxxxxxxxxx\n" in TEST_F()
7992 ")x\",\n" in TEST_F()
7993 " a),\n" in TEST_F()
7995 format("fffffffffff(g(R\"x(qqq\n" in TEST_F()
7996 "multiline raw string literal xxxxxxxxxxxxxx\n" in TEST_F()
8000 EXPECT_EQ("fffffffffff(R\"x(\n" in TEST_F()
8001 "multiline raw string literal xxxxxxxxxxxxxx\n" in TEST_F()
8003 format("fffffffffff(R\"x(\n" in TEST_F()
8004 "multiline raw string literal xxxxxxxxxxxxxx\n" in TEST_F()
8007 EXPECT_EQ("fffffffffff(R\"x(\n" in TEST_F()
8008 "multiline raw string literal xxxxxxxxxxxxxx\n" in TEST_F()
8010 format("fffffffffff(R\"x(\n" in TEST_F()
8011 "multiline raw string literal xxxxxxxxxxxxxx\n" in TEST_F()
8014 EXPECT_EQ("fffffffffff(\n" in TEST_F()
8015 " R\"x(\n" in TEST_F()
8016 "multiline raw string literal xxxxxxxxxxxxxx\n" in TEST_F()
8017 ")x\" +\n" in TEST_F()
8019 format("fffffffffff(\n" in TEST_F()
8020 " R\"x(\n" in TEST_F()
8021 "multiline raw string literal xxxxxxxxxxxxxx\n" in TEST_F()
8028 EXPECT_EQ("function(\"unterminated,\n" in TEST_F()
8030 format("function( \"unterminated,\n" in TEST_F()
8044 EXPECT_EQ("someFunction(\"aaabbbcccd\"\n" in TEST_F()
8048 EXPECT_EQ("someFunction1234567890(\n" in TEST_F()
8052 EXPECT_EQ("someFunction1234567890(\n" in TEST_F()
8053 " \"aaabbbcccdddeeeff\"\n" in TEST_F()
8057 EXPECT_EQ("someFunction1234567890(\n" in TEST_F()
8058 " \"aaabbbcccdddeeeff\"\n" in TEST_F()
8062 EXPECT_EQ("someFunction(\"aaabbbcc \"\n" in TEST_F()
8063 " \"ddde \"\n" in TEST_F()
8067 EXPECT_EQ("someFunction(\"aaabbbccc \"\n" in TEST_F()
8071 EXPECT_EQ("someFunction1234567890(\n" in TEST_F()
8072 " \"aaabb \"\n" in TEST_F()
8076 EXPECT_EQ("#define A \\\n" in TEST_F()
8077 " string s = \\\n" in TEST_F()
8078 " \"123456789\" \\\n" in TEST_F()
8079 " \"0\"; \\\n" in TEST_F()
8084 EXPECT_EQ("someFunction(\"aaabbbcc \"\n" in TEST_F()
8085 " \"dddeeeff\"\n" in TEST_F()
8094 EXPECT_EQ("\"test\"\n" in TEST_F()
8095 "\"\\n\"", in TEST_F()
8096 format("\"test\\n\"", getLLVMStyleWithColumns(7))); in TEST_F()
8097 EXPECT_EQ("\"tes\\\\\"\n" in TEST_F()
8098 "\"n\"", in TEST_F()
8099 format("\"tes\\\\n\"", getLLVMStyleWithColumns(7))); in TEST_F()
8100 EXPECT_EQ("\"\\\\\\\\\"\n" in TEST_F()
8101 "\"\\n\"", in TEST_F()
8102 format("\"\\\\\\\\\\n\"", getLLVMStyleWithColumns(7))); in TEST_F()
8104 EXPECT_EQ("\"\\uff01\"\n" in TEST_F()
8109 EXPECT_EQ("\"\\x000000000001\"\n" in TEST_F()
8116 EXPECT_EQ("\"test\"\n" in TEST_F()
8117 "\"\\000000\"\n" in TEST_F()
8120 EXPECT_EQ("\"test\\000\"\n" in TEST_F()
8121 "\"00000000\"\n" in TEST_F()
8127 verifyFormat("void f() {\n" in TEST_F()
8128 " return g() {}\n" in TEST_F()
8130 verifyFormat("int a[] = {void forgot_closing_brace(){f();\n" in TEST_F()
8131 "g();\n" in TEST_F()
8141 verifyFormat("class X {\n" in TEST_F()
8142 " void f() {\n" in TEST_F()
8143 " }\n" in TEST_F()
8152 verifyFormat("void f() {\n" in TEST_F()
8153 " someFunction();\n" in TEST_F()
8154 " if (true) {\n" in TEST_F()
8155 " f();\n" in TEST_F()
8156 " }\n" in TEST_F()
8159 verifyFormat("class X {\n" in TEST_F()
8160 " void f() {\n" in TEST_F()
8161 " }\n" in TEST_F()
8164 verifyFormat("int x[] = {\n" in TEST_F()
8165 " call(),\n" in TEST_F()
8171 verifyFormat("double\n" in TEST_F()
8182 EXPECT_EQ("if (aaaaaaaa && // q\n" in TEST_F()
8183 " bb)\t\t// w\n" in TEST_F()
8185 format("if (aaaaaaaa &&// q\n" in TEST_F()
8186 "bb)// w\n" in TEST_F()
8189 EXPECT_EQ("if (aaa && bbb) // w\n" in TEST_F()
8191 format("if(aaa&&bbb)// w\n" in TEST_F()
8195 verifyFormat("class X {\n" in TEST_F()
8196 "\tvoid f() {\n" in TEST_F()
8197 "\t\tsomeFunction(parameter1,\n" in TEST_F()
8198 "\t\t\t parameter2);\n" in TEST_F()
8199 "\t}\n" in TEST_F()
8202 verifyFormat("#define A \\\n" in TEST_F()
8203 "\tvoid f() { \\\n" in TEST_F()
8204 "\t\tsomeFunction( \\\n" in TEST_F()
8205 "\t\t parameter1, \\\n" in TEST_F()
8206 "\t\t parameter2); \\\n" in TEST_F()
8212 verifyFormat("class TabWidth4Indent8 {\n" in TEST_F()
8213 "\t\tvoid f() {\n" in TEST_F()
8214 "\t\t\t\tsomeFunction(parameter1,\n" in TEST_F()
8215 "\t\t\t\t\t\t\t parameter2);\n" in TEST_F()
8216 "\t\t}\n" in TEST_F()
8222 verifyFormat("class TabWidth4Indent4 {\n" in TEST_F()
8223 "\tvoid f() {\n" in TEST_F()
8224 "\t\tsomeFunction(parameter1,\n" in TEST_F()
8225 "\t\t\t\t\t parameter2);\n" in TEST_F()
8226 "\t}\n" in TEST_F()
8232 verifyFormat("class TabWidth8Indent4 {\n" in TEST_F()
8233 " void f() {\n" in TEST_F()
8234 "\tsomeFunction(parameter1,\n" in TEST_F()
8235 "\t\t parameter2);\n" in TEST_F()
8236 " }\n" in TEST_F()
8242 EXPECT_EQ("/*\n" in TEST_F()
8243 "\t a\t\tcomment\n" in TEST_F()
8244 "\t in multiple lines\n" in TEST_F()
8246 format(" /*\t \t \n" in TEST_F()
8247 " \t \t a\t\tcomment\t \t\n" in TEST_F()
8248 " \t \t in multiple lines\t\n" in TEST_F()
8253 verifyFormat("{\n" in TEST_F()
8254 "\taaaaaaaaaaaaaaaaaaaaaaaaaaaa();\n" in TEST_F()
8255 "\taaaaaaaaaaaaaaaaaaaaaaaaaaaa();\n" in TEST_F()
8256 "\taaaaaaaaaaaaaaaaaaaaaaaaaaaa();\n" in TEST_F()
8257 "\taaaaaaaaaaaaaaaaaaaaaaaaaaaa();\n" in TEST_F()
8258 "\taaaaaaaaaaaaaaaaaaaaaaaaaaaa();\n" in TEST_F()
8259 "\taaaaaaaaaaaaaaaaaaaaaaaaaaaa();\n" in TEST_F()
8262 verifyFormat("enum A {\n" in TEST_F()
8263 "\ta1, // Force multiple lines\n" in TEST_F()
8264 "\ta2,\n" in TEST_F()
8265 "\ta3\n" in TEST_F()
8268 EXPECT_EQ("if (aaaaaaaa && // q\n" in TEST_F()
8269 " bb) // w\n" in TEST_F()
8271 format("if (aaaaaaaa &&// q\n" in TEST_F()
8272 "bb)// w\n" in TEST_F()
8275 verifyFormat("class X {\n" in TEST_F()
8276 "\tvoid f() {\n" in TEST_F()
8277 "\t\tsomeFunction(parameter1,\n" in TEST_F()
8278 "\t\t parameter2);\n" in TEST_F()
8279 "\t}\n" in TEST_F()
8282 verifyFormat("{\n" in TEST_F()
8283 "\tQ(\n" in TEST_F()
8284 "\t {\n" in TEST_F()
8285 "\t\t int a;\n" in TEST_F()
8286 "\t\t someFunction(aaaaaaaa,\n" in TEST_F()
8287 "\t\t bbbbbbb);\n" in TEST_F()
8288 "\t },\n" in TEST_F()
8289 "\t p);\n" in TEST_F()
8292 EXPECT_EQ("{\n" in TEST_F()
8293 "\t/* aaaa\n" in TEST_F()
8294 "\t bbbb */\n" in TEST_F()
8296 format("{\n" in TEST_F()
8297 "/* aaaa\n" in TEST_F()
8298 " bbbb */\n" in TEST_F()
8301 EXPECT_EQ("{\n" in TEST_F()
8302 "\t/*\n" in TEST_F()
8303 "\t aaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
8304 "\t bbbbbbbbbbbbb\n" in TEST_F()
8305 "\t*/\n" in TEST_F()
8307 format("{\n" in TEST_F()
8308 "/*\n" in TEST_F()
8309 " aaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbb\n" in TEST_F()
8310 "*/\n" in TEST_F()
8313 EXPECT_EQ("{\n" in TEST_F()
8314 "\t// aaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
8315 "\t// bbbbbbbbbbbbb\n" in TEST_F()
8317 format("{\n" in TEST_F()
8318 "\t// aaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbb\n" in TEST_F()
8321 EXPECT_EQ("{\n" in TEST_F()
8322 "\t/*\n" in TEST_F()
8323 "\t aaaaaaaaaaaaaaaaaaaaaaaaaa\n" in TEST_F()
8324 "\t bbbbbbbbbbbbb\n" in TEST_F()
8325 "\t*/\n" in TEST_F()
8327 format("{\n" in TEST_F()
8328 "\t/*\n" in TEST_F()
8329 "\t aaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbb\n" in TEST_F()
8330 "\t*/\n" in TEST_F()
8333 EXPECT_EQ("{\n" in TEST_F()
8334 "\t/*\n" in TEST_F()
8335 "\n" in TEST_F()
8336 "\t*/\n" in TEST_F()
8338 format("{\n" in TEST_F()
8339 "\t/*\n" in TEST_F()
8340 "\n" in TEST_F()
8341 "\t*/\n" in TEST_F()
8344 EXPECT_EQ("{\n" in TEST_F()
8345 "\t/*\n" in TEST_F()
8346 " asdf\n" in TEST_F()
8347 "\t*/\n" in TEST_F()
8349 format("{\n" in TEST_F()
8350 "\t/*\n" in TEST_F()
8351 " asdf\n" in TEST_F()
8352 "\t*/\n" in TEST_F()
8357 EXPECT_EQ("/*\n" in TEST_F()
8358 " a\t\tcomment\n" in TEST_F()
8359 " in multiple lines\n" in TEST_F()
8361 format(" /*\t \t \n" in TEST_F()
8362 " \t \t a\t\tcomment\t \t\n" in TEST_F()
8363 " \t \t in multiple lines\t\n" in TEST_F()
8366 EXPECT_EQ("/* some\n" in TEST_F()
8368 format(" \t \t /* some\n" in TEST_F()
8371 EXPECT_EQ("int a; /* some\n" in TEST_F()
8373 format(" \t \t int a; /* some\n" in TEST_F()
8377 EXPECT_EQ("int a; /* some\n" in TEST_F()
8379 format(" \t \t int\ta; /* some\n" in TEST_F()
8382 EXPECT_EQ("f(\"\t\t\"); /* some\n" in TEST_F()
8384 format(" \t \t f(\"\t\t\"); /* some\n" in TEST_F()
8387 EXPECT_EQ("{\n" in TEST_F()
8388 " /*\n" in TEST_F()
8389 " * Comment\n" in TEST_F()
8390 " */\n" in TEST_F()
8391 " int i;\n" in TEST_F()
8393 format("{\n" in TEST_F()
8394 "\t/*\n" in TEST_F()
8395 "\t * Comment\n" in TEST_F()
8396 "\t */\n" in TEST_F()
8397 "\t int i;\n" in TEST_F()
8402 EXPECT_EQ("\"qqqqqqqqqqqqqqqqqqqqqqqqqq\\\n" in TEST_F()
8403 "q\"; /* some\n" in TEST_F()
8405 format(" \"qqqqqqqqqqqqqqqqqqqqqqqqqq\\\n" in TEST_F()
8406 "q\"; /* some\n" in TEST_F()
8409 EXPECT_EQ("// qqqqqqqqqqqqqqqqqqqqqqqqqq\n" in TEST_F()
8410 "/* some\n" in TEST_F()
8412 format("// qqqqqqqqqqqqqqqqqqqqqqqqqq\n" in TEST_F()
8413 " /* some\n" in TEST_F()
8416 EXPECT_EQ("// qqqqqqqqqqqqqqqqqqqqqqqqqq\\\n" in TEST_F()
8417 "qqq\n" in TEST_F()
8418 "/* some\n" in TEST_F()
8420 format("// qqqqqqqqqqqqqqqqqqqqqqqqqq\\\n" in TEST_F()
8421 "qqq\n" in TEST_F()
8422 " /* some\n" in TEST_F()
8425 EXPECT_EQ("inttt qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\\\n" in TEST_F()
8426 "wwww; /* some\n" in TEST_F()
8428 format(" inttt qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\\\n" in TEST_F()
8429 "wwww; /* some\n" in TEST_F()
8438 verifyFormat("while(true)\n" in TEST_F()
8441 verifyFormat("for(;;)\n" in TEST_F()
8444 verifyFormat("if(true)\n" in TEST_F()
8445 " f();\n" in TEST_F()
8446 "else if(true)\n" in TEST_F()
8449 verifyFormat("do {\n" in TEST_F()
8450 " do_something();\n" in TEST_F()
8453 verifyFormat("switch(x) {\n" in TEST_F()
8454 "default:\n" in TEST_F()
8455 " break;\n" in TEST_F()
8474 verifyFormat("void f (int a, T b) {\n" in TEST_F()
8475 " while (true)\n" in TEST_F()
8476 " continue;\n" in TEST_F()
8479 verifyFormat("if (true)\n" in TEST_F()
8480 " f ();\n" in TEST_F()
8481 "else if (true)\n" in TEST_F()
8484 verifyFormat("do {\n" in TEST_F()
8485 " do_something ();\n" in TEST_F()
8488 verifyFormat("switch (x) {\n" in TEST_F()
8489 "default:\n" in TEST_F()
8490 " break;\n" in TEST_F()
8495 verifyFormat("*(&a + 1);\n" in TEST_F()
8496 "&((&a)[1]);\n" in TEST_F()
8497 "a[(b + c) * d];\n" in TEST_F()
8502 verifyFormat("#if defined(x)\n" in TEST_F()
8527 verifyFormat("while ( (bool)1 )\n" in TEST_F()
8530 verifyFormat("for ( ;; )\n" in TEST_F()
8533 verifyFormat("if ( true )\n" in TEST_F()
8534 " f();\n" in TEST_F()
8535 "else if ( true )\n" in TEST_F()
8538 verifyFormat("do {\n" in TEST_F()
8539 " do_something( (int)i );\n" in TEST_F()
8542 verifyFormat("switch ( x ) {\n" in TEST_F()
8543 "default:\n" in TEST_F()
8544 " break;\n" in TEST_F()
8564 verifyFormat("while (( bool )1)\n" in TEST_F()
8567 verifyFormat("for (;;)\n" in TEST_F()
8570 verifyFormat("if (true)\n" in TEST_F()
8571 " f( );\n" in TEST_F()
8572 "else if (true)\n" in TEST_F()
8575 verifyFormat("do {\n" in TEST_F()
8576 " do_something(( int )i);\n" in TEST_F()
8579 verifyFormat("switch (x) {\n" in TEST_F()
8580 "default:\n" in TEST_F()
8581 " break;\n" in TEST_F()
8590 verifyFormat("while (( bool ) 1)\n" in TEST_F()
8593 verifyFormat("for (;;)\n" in TEST_F()
8596 verifyFormat("if (true)\n" in TEST_F()
8597 " f( );\n" in TEST_F()
8598 "else if (true)\n" in TEST_F()
8601 verifyFormat("do {\n" in TEST_F()
8602 " do_something(( int ) i);\n" in TEST_F()
8605 verifyFormat("switch (x) {\n" in TEST_F()
8606 "default:\n" in TEST_F()
8607 " break;\n" in TEST_F()
8614 verifyFormat("while ((bool) 1)\n" in TEST_F()
8617 verifyFormat("do {\n" in TEST_F()
8618 " do_something((int) i);\n" in TEST_F()
8630 verifyFormat("int c = []() -> int { return 2; }();\n", Spaces); in TEST_F()
8637 verifyFormat("double &operator[](int i) { return 0; }\n" in TEST_F()
8660 verifyFormat("int a = 5;\n" in TEST_F()
8663 verifyFormat("int a = 5;\n" in TEST_F()
8668 verifyFormat("int a = 5;\n" in TEST_F()
8671 verifyFormat("int a = method();\n" in TEST_F()
8674 verifyFormat("a &= 5;\n" in TEST_F()
8675 "bcd *= 5;\n" in TEST_F()
8676 "ghtyf += 5;\n" in TEST_F()
8677 "dvfvdb -= 5;\n" in TEST_F()
8678 "a /= 5;\n" in TEST_F()
8679 "vdsvsv %= 5;\n" in TEST_F()
8680 "sfdbddfbdfbb ^= 5;\n" in TEST_F()
8681 "dvsdsv |= 5;\n" in TEST_F()
8684 verifyFormat("int i = 1, j = 10;\n" in TEST_F()
8687 verifyFormat("something = 2000;\n" in TEST_F()
8688 "int i = 1, j = 10;\n", in TEST_F()
8690 verifyFormat("something = 2000;\n" in TEST_F()
8691 "another = 911;\n" in TEST_F()
8692 "int i = 1, j = 10;\n" in TEST_F()
8693 "oneMore = 1;\n" in TEST_F()
8696 verifyFormat("int a = 5;\n" in TEST_F()
8697 "int one = 1;\n" in TEST_F()
8698 "method();\n" in TEST_F()
8699 "int oneTwoThree = 123;\n" in TEST_F()
8702 verifyFormat("int oneTwoThree = 123;\n" in TEST_F()
8703 "int oneTwo = 12;\n" in TEST_F()
8704 "method();\n", in TEST_F()
8706 verifyFormat("int oneTwoThree = 123; // comment\n" in TEST_F()
8709 EXPECT_EQ("int a = 5;\n" in TEST_F()
8710 "\n" in TEST_F()
8712 format("int a = 5;\n" in TEST_F()
8713 "\n" in TEST_F()
8716 EXPECT_EQ("int a = 5;\n" in TEST_F()
8717 "int one = 1;\n" in TEST_F()
8718 "\n" in TEST_F()
8720 format("int a = 5;\n" in TEST_F()
8721 "int one = 1;\n" in TEST_F()
8722 "\n" in TEST_F()
8725 EXPECT_EQ("int a = 5;\n" in TEST_F()
8726 "int one = 1;\n" in TEST_F()
8727 "\n" in TEST_F()
8728 "int oneTwoThree = 123;\n" in TEST_F()
8730 format("int a = 5;\n" in TEST_F()
8731 "int one = 1;\n" in TEST_F()
8732 "\n" in TEST_F()
8733 "int oneTwoThree = 123;\n" in TEST_F()
8737 verifyFormat("#define A \\\n" in TEST_F()
8738 " int aaaa = 12; \\\n" in TEST_F()
8739 " int b = 23; \\\n" in TEST_F()
8740 " int ccc = 234; \\\n" in TEST_F()
8745 " \\\n" in TEST_F()
8747 " \\\n" in TEST_F()
8749 " \\\n" in TEST_F()
8751 " \\\n" in TEST_F()
8755 "k = 4, int l = 5,\n" in TEST_F()
8756 " int m = 6) {\n" in TEST_F()
8757 " int j = 10;\n" in TEST_F()
8758 " otherThing = 1;\n" in TEST_F()
8761 verifyFormat("void SomeFunction(int parameter = 0) {\n" in TEST_F()
8762 " int i = 1;\n" in TEST_F()
8763 " int j = 2;\n" in TEST_F()
8764 " int big = 10000;\n" in TEST_F()
8767 verifyFormat("class C {\n" in TEST_F()
8768 "public:\n" in TEST_F()
8769 " int i = 1;\n" in TEST_F()
8770 " virtual void f() = 0;\n" in TEST_F()
8773 verifyFormat("int i = 1;\n" in TEST_F()
8774 "if (SomeType t = getSomething()) {\n" in TEST_F()
8775 "}\n" in TEST_F()
8776 "int j = 2;\n" in TEST_F()
8779 verifyFormat("int j = 7;\n" in TEST_F()
8780 "for (int k = 0; k < N; ++k) {\n" in TEST_F()
8781 "}\n" in TEST_F()
8782 "int j = 2;\n" in TEST_F()
8783 "int big = 10000;\n" in TEST_F()
8787 verifyFormat("int i = 1;\n" in TEST_F()
8788 "LooooooooooongType loooooooooooooooooooooongVariable\n" in TEST_F()
8789 " = someLooooooooooooooooongFunction();\n" in TEST_F()
8793 verifyFormat("int i = 1;\n" in TEST_F()
8794 "LooooooooooongType loooooooooooooooooooooongVariable =\n" in TEST_F()
8795 " someLooooooooooooooooongFunction();\n" in TEST_F()
8799 verifyFormat("auto lambda = []() {\n" in TEST_F()
8800 " auto i = 0;\n" in TEST_F()
8801 " return 0;\n" in TEST_F()
8802 "};\n" in TEST_F()
8803 "int i = 0;\n" in TEST_F()
8804 "auto v = type{\n" in TEST_F()
8805 " i = 1, //\n" in TEST_F()
8806 " (i = 2), //\n" in TEST_F()
8807 " i = 3 //\n" in TEST_F()
8813 "int i = 1;\n" in TEST_F()
8814 "SomeType a = SomeFunction(looooooooooooooooooooooongParameterA,\n" in TEST_F()
8815 " loooooooooooooooooooooongParameterB);\n" in TEST_F()
8819 verifyFormat("template <typename T, typename T_0 = very_long_type_name_0,\n" in TEST_F()
8820 " typename B = very_long_type_name_1,\n" in TEST_F()
8821 " typename T_2 = very_long_type_name_2>\n" in TEST_F()
8822 "auto foo() {}\n", in TEST_F()
8824 verifyFormat("int a, b = 1;\n" in TEST_F()
8825 "int c = 2;\n" in TEST_F()
8826 "int dd = 3;\n", in TEST_F()
8828 verifyFormat("int aa = ((1 > 2) ? 3 : 4);\n" in TEST_F()
8829 "float b[1][] = {{3.f}};\n", in TEST_F()
8836 verifyFormat("float const a = 5;\n" in TEST_F()
8839 verifyFormat("int a = 5;\n" in TEST_F()
8844 verifyFormat("float const a = 5;\n" in TEST_F()
8847 verifyFormat("int a = method();\n" in TEST_F()
8850 verifyFormat("int i = 1, j = 10;\n" in TEST_F()
8853 verifyFormat("something = 2000;\n" in TEST_F()
8854 "int i = 1, j = 10;\n", in TEST_F()
8856 verifyFormat("float something = 2000;\n" in TEST_F()
8857 "double another = 911;\n" in TEST_F()
8858 "int i = 1, j = 10;\n" in TEST_F()
8859 "const int *oneMore = 1;\n" in TEST_F()
8862 verifyFormat("float a = 5;\n" in TEST_F()
8863 "int one = 1;\n" in TEST_F()
8864 "method();\n" in TEST_F()
8865 "const double oneTwoThree = 123;\n" in TEST_F()
8868 verifyFormat("int oneTwoThree{0}; // comment\n" in TEST_F()
8871 EXPECT_EQ("float const a = 5;\n" in TEST_F()
8872 "\n" in TEST_F()
8874 format("float const a = 5;\n" in TEST_F()
8875 "\n" in TEST_F()
8878 EXPECT_EQ("float a = 5;\n" in TEST_F()
8879 "int one = 1;\n" in TEST_F()
8880 "\n" in TEST_F()
8882 format("float a = 5;\n" in TEST_F()
8883 "int one = 1;\n" in TEST_F()
8884 "\n" in TEST_F()
8887 EXPECT_EQ("float a = 5;\n" in TEST_F()
8888 "int one = 1;\n" in TEST_F()
8889 "\n" in TEST_F()
8890 "unsigned oneTwoThree = 123;\n" in TEST_F()
8892 format("float a = 5;\n" in TEST_F()
8893 "int one = 1;\n" in TEST_F()
8894 "\n" in TEST_F()
8895 "unsigned oneTwoThree = 123;\n" in TEST_F()
8899 verifyFormat("float something = 2000;\n" in TEST_F()
8900 "double another = 911;\n" in TEST_F()
8901 "int i = 1, j = 10;\n" in TEST_F()
8902 "const int *oneMore = 1;\n" in TEST_F()
8905 verifyFormat("int oneTwoThree = {0}; // comment\n" in TEST_F()
8908 EXPECT_EQ("void SomeFunction(int parameter = 0) {\n" in TEST_F()
8909 " int const i = 1;\n" in TEST_F()
8910 " int * j = 2;\n" in TEST_F()
8911 " int big = 10000;\n" in TEST_F()
8912 "\n" in TEST_F()
8913 " unsigned oneTwoThree = 123;\n" in TEST_F()
8914 " int oneTwo = 12;\n" in TEST_F()
8915 " method();\n" in TEST_F()
8916 " float k = 2;\n" in TEST_F()
8917 " int ll = 10000;\n" in TEST_F()
8919 format("void SomeFunction(int parameter= 0) {\n" in TEST_F()
8920 " int const i= 1;\n" in TEST_F()
8921 " int *j=2;\n" in TEST_F()
8922 " int big = 10000;\n" in TEST_F()
8923 "\n" in TEST_F()
8924 "unsigned oneTwoThree =123;\n" in TEST_F()
8925 "int oneTwo = 12;\n" in TEST_F()
8926 " method();\n" in TEST_F()
8927 "float k= 2;\n" in TEST_F()
8928 "int ll=10000;\n" in TEST_F()
8933 verifyFormat("#define A \\\n" in TEST_F()
8934 " int aaaa = 12; \\\n" in TEST_F()
8935 " float b = 23; \\\n" in TEST_F()
8936 " const int ccc = 234; \\\n" in TEST_F()
8941 verifyFormat("#define A \\\n" in TEST_F()
8942 " int aaaa = 12; \\\n" in TEST_F()
8943 " float b = 23; \\\n" in TEST_F()
8944 " const int ccc = 234; \\\n" in TEST_F()
8949 "k = 4, int l = 5,\n" in TEST_F()
8950 " int m = 6) {\n" in TEST_F()
8951 " const int j = 10;\n" in TEST_F()
8952 " otherThing = 1;\n" in TEST_F()
8955 verifyFormat("void SomeFunction(int parameter = 0) {\n" in TEST_F()
8956 " int const i = 1;\n" in TEST_F()
8957 " int * j = 2;\n" in TEST_F()
8958 " int big = 10000;\n" in TEST_F()
8961 verifyFormat("class C {\n" in TEST_F()
8962 "public:\n" in TEST_F()
8963 " int i = 1;\n" in TEST_F()
8964 " virtual void f() = 0;\n" in TEST_F()
8967 verifyFormat("float i = 1;\n" in TEST_F()
8968 "if (SomeType t = getSomething()) {\n" in TEST_F()
8969 "}\n" in TEST_F()
8970 "const unsigned j = 2;\n" in TEST_F()
8973 verifyFormat("float j = 7;\n" in TEST_F()
8974 "for (int k = 0; k < N; ++k) {\n" in TEST_F()
8975 "}\n" in TEST_F()
8976 "unsigned j = 2;\n" in TEST_F()
8977 "int big = 10000;\n" in TEST_F()
8981 verifyFormat("float i = 1;\n" in TEST_F()
8982 "LooooooooooongType loooooooooooooooooooooongVariable\n" in TEST_F()
8983 " = someLooooooooooooooooongFunction();\n" in TEST_F()
8987 verifyFormat("int i = 1;\n" in TEST_F()
8988 "LooooooooooongType loooooooooooooooooooooongVariable =\n" in TEST_F()
8989 " someLooooooooooooooooongFunction();\n" in TEST_F()
8994 verifyFormat("auto lambda = []() {\n" in TEST_F()
8995 " auto ii = 0;\n" in TEST_F()
8996 " float j = 0;\n" in TEST_F()
8997 " return 0;\n" in TEST_F()
8998 "};\n" in TEST_F()
8999 "int i = 0;\n" in TEST_F()
9000 "float i2 = 0;\n" in TEST_F()
9001 "auto v = type{\n" in TEST_F()
9002 " i = 1, //\n" in TEST_F()
9003 " (i = 2), //\n" in TEST_F()
9004 " i = 3 //\n" in TEST_F()
9011 "int i = 1;\n" in TEST_F()
9012 "SomeType a = SomeFunction(looooooooooooooooooooooongParameterA,\n" in TEST_F()
9013 " loooooooooooooooooooooongParameterB);\n" in TEST_F()
9023 verifyFormat("float ii = 1;\n" in TEST_F()
9024 "unsigned j = 2;\n" in TEST_F()
9025 "int someVerylongVariable = 1;\n" in TEST_F()
9026 "AnotherLongType ll = 123456;\n" in TEST_F()
9027 "VeryVeryLongType k = 2;\n" in TEST_F()
9034 "template <typename LongTemplate, typename VeryLongTemplateTypeName,\n" in TEST_F()
9035 " typename LongType, typename B>\n" in TEST_F()
9036 "auto foo() {}\n", in TEST_F()
9038 verifyFormat("float a, b = 1;\n" in TEST_F()
9039 "int c = 2;\n" in TEST_F()
9040 "int dd = 3;\n", in TEST_F()
9042 verifyFormat("int aa = ((1 > 2) ? 3 : 4);\n" in TEST_F()
9043 "float b[1][] = {{3.f}};\n", in TEST_F()
9046 verifyFormat("float a, b = 1;\n" in TEST_F()
9047 "int c = 2;\n" in TEST_F()
9048 "int dd = 3;\n", in TEST_F()
9050 verifyFormat("int aa = ((1 > 2) ? 3 : 4);\n" in TEST_F()
9051 "float b[1][] = {{3.f}};\n", in TEST_F()
9057 verifyFormat("void foo(float a,\n" in TEST_F()
9058 " float b,\n" in TEST_F()
9059 " int c,\n" in TEST_F()
9060 " uint32_t *d) {\n" in TEST_F()
9061 " int * e = 0;\n" in TEST_F()
9062 " float f = 0;\n" in TEST_F()
9063 " double g = 0;\n" in TEST_F()
9064 "}\n" in TEST_F()
9065 "void bar(ino_t a,\n" in TEST_F()
9066 " int b,\n" in TEST_F()
9067 " uint32_t *c,\n" in TEST_F()
9068 " bool d) {}\n", in TEST_F()
9077 verifyFormat("namespace a\n" in TEST_F()
9078 "{\n" in TEST_F()
9079 "class A\n" in TEST_F()
9080 "{\n" in TEST_F()
9081 " void f()\n" in TEST_F()
9082 " {\n" in TEST_F()
9083 " if (true) {\n" in TEST_F()
9084 " a();\n" in TEST_F()
9085 " b();\n" in TEST_F()
9086 " } else {\n" in TEST_F()
9087 " a();\n" in TEST_F()
9088 " }\n" in TEST_F()
9089 " }\n" in TEST_F()
9090 " void g() { return; }\n" in TEST_F()
9091 "};\n" in TEST_F()
9092 "struct B {\n" in TEST_F()
9093 " int x;\n" in TEST_F()
9094 "};\n" in TEST_F()
9095 "}\n", in TEST_F()
9097 verifyFormat("enum X {\n" in TEST_F()
9098 " Y = 0,\n" in TEST_F()
9099 "}\n", in TEST_F()
9101 verifyFormat("struct S {\n" in TEST_F()
9102 " int Type;\n" in TEST_F()
9103 " union {\n" in TEST_F()
9104 " int x;\n" in TEST_F()
9105 " double y;\n" in TEST_F()
9106 " } Value;\n" in TEST_F()
9107 " class C\n" in TEST_F()
9108 " {\n" in TEST_F()
9109 " MyFavoriteType Value;\n" in TEST_F()
9110 " } Class;\n" in TEST_F()
9111 "}\n", in TEST_F()
9118 verifyFormat("namespace a {\n" in TEST_F()
9119 "class A\n" in TEST_F()
9120 "{\n" in TEST_F()
9121 " void f()\n" in TEST_F()
9122 " {\n" in TEST_F()
9123 " if (true) {\n" in TEST_F()
9124 " a();\n" in TEST_F()
9125 " b();\n" in TEST_F()
9126 " }\n" in TEST_F()
9127 " }\n" in TEST_F()
9128 " void g() { return; }\n" in TEST_F()
9129 "};\n" in TEST_F()
9130 "enum E\n" in TEST_F()
9131 "{\n" in TEST_F()
9132 " A,\n" in TEST_F()
9133 " // foo\n" in TEST_F()
9134 " B,\n" in TEST_F()
9135 " C\n" in TEST_F()
9136 "};\n" in TEST_F()
9137 "struct B\n" in TEST_F()
9138 "{\n" in TEST_F()
9139 " int x;\n" in TEST_F()
9140 "};\n" in TEST_F()
9141 "}\n", in TEST_F()
9143 verifyFormat("struct S\n" in TEST_F()
9144 "{\n" in TEST_F()
9145 " int Type;\n" in TEST_F()
9146 " union\n" in TEST_F()
9147 " {\n" in TEST_F()
9148 " int x;\n" in TEST_F()
9149 " double y;\n" in TEST_F()
9150 " } Value;\n" in TEST_F()
9151 " class C\n" in TEST_F()
9152 " {\n" in TEST_F()
9153 " MyFavoriteType Value;\n" in TEST_F()
9154 " } Class;\n" in TEST_F()
9155 "}\n", in TEST_F()
9162 verifyFormat("namespace a {\n" in TEST_F()
9163 "class A {\n" in TEST_F()
9164 " void f()\n" in TEST_F()
9165 " {\n" in TEST_F()
9166 " if (true) {\n" in TEST_F()
9167 " a();\n" in TEST_F()
9168 " b();\n" in TEST_F()
9169 " }\n" in TEST_F()
9170 " }\n" in TEST_F()
9171 " void g() { return; }\n" in TEST_F()
9172 "};\n" in TEST_F()
9173 "struct B {\n" in TEST_F()
9174 " int x;\n" in TEST_F()
9175 "};\n" in TEST_F()
9176 "}\n", in TEST_F()
9179 verifyFormat("void foo()\n" in TEST_F()
9180 "{\n" in TEST_F()
9181 " if (a) {\n" in TEST_F()
9182 " a();\n" in TEST_F()
9183 " }\n" in TEST_F()
9184 " else {\n" in TEST_F()
9185 " b();\n" in TEST_F()
9186 " }\n" in TEST_F()
9187 "}\n", in TEST_F()
9190 verifyFormat("#ifdef _DEBUG\n" in TEST_F()
9191 "int foo(int i = 0)\n" in TEST_F()
9192 "#else\n" in TEST_F()
9193 "int foo(int i = 5)\n" in TEST_F()
9194 "#endif\n" in TEST_F()
9195 "{\n" in TEST_F()
9196 " return i;\n" in TEST_F()
9200 verifyFormat("void foo() {}\n" in TEST_F()
9201 "void bar()\n" in TEST_F()
9202 "#ifdef _DEBUG\n" in TEST_F()
9203 "{\n" in TEST_F()
9204 " foo();\n" in TEST_F()
9205 "}\n" in TEST_F()
9206 "#else\n" in TEST_F()
9207 "{\n" in TEST_F()
9208 "}\n" in TEST_F()
9212 verifyFormat("void foobar() { int i = 5; }\n" in TEST_F()
9213 "#ifdef _DEBUG\n" in TEST_F()
9214 "void bar() {}\n" in TEST_F()
9215 "#else\n" in TEST_F()
9216 "void bar() { foobar(); }\n" in TEST_F()
9224 verifyFormat("namespace a\n" in TEST_F()
9225 "{\n" in TEST_F()
9226 "class A\n" in TEST_F()
9227 "{\n" in TEST_F()
9228 " void f()\n" in TEST_F()
9229 " {\n" in TEST_F()
9230 " if (true)\n" in TEST_F()
9231 " {\n" in TEST_F()
9232 " a();\n" in TEST_F()
9233 " b();\n" in TEST_F()
9234 " }\n" in TEST_F()
9235 " }\n" in TEST_F()
9236 " void g() { return; }\n" in TEST_F()
9237 "};\n" in TEST_F()
9238 "struct B\n" in TEST_F()
9239 "{\n" in TEST_F()
9240 " int x;\n" in TEST_F()
9241 "};\n" in TEST_F()
9245 verifyFormat("void f()\n" in TEST_F()
9246 "{\n" in TEST_F()
9247 " if (true)\n" in TEST_F()
9248 " {\n" in TEST_F()
9249 " a();\n" in TEST_F()
9250 " }\n" in TEST_F()
9251 " else if (false)\n" in TEST_F()
9252 " {\n" in TEST_F()
9253 " b();\n" in TEST_F()
9254 " }\n" in TEST_F()
9255 " else\n" in TEST_F()
9256 " {\n" in TEST_F()
9257 " c();\n" in TEST_F()
9258 " }\n" in TEST_F()
9259 "}\n", in TEST_F()
9262 verifyFormat("void f()\n" in TEST_F()
9263 "{\n" in TEST_F()
9264 " for (int i = 0; i < 10; ++i)\n" in TEST_F()
9265 " {\n" in TEST_F()
9266 " a();\n" in TEST_F()
9267 " }\n" in TEST_F()
9268 " while (false)\n" in TEST_F()
9269 " {\n" in TEST_F()
9270 " b();\n" in TEST_F()
9271 " }\n" in TEST_F()
9272 " do\n" in TEST_F()
9273 " {\n" in TEST_F()
9274 " c();\n" in TEST_F()
9275 " } while (false)\n" in TEST_F()
9276 "}\n", in TEST_F()
9279 verifyFormat("void f(int a)\n" in TEST_F()
9280 "{\n" in TEST_F()
9281 " switch (a)\n" in TEST_F()
9282 " {\n" in TEST_F()
9283 " case 0:\n" in TEST_F()
9284 " break;\n" in TEST_F()
9285 " case 1:\n" in TEST_F()
9286 " {\n" in TEST_F()
9287 " break;\n" in TEST_F()
9288 " }\n" in TEST_F()
9289 " case 2:\n" in TEST_F()
9290 " {\n" in TEST_F()
9291 " }\n" in TEST_F()
9292 " break;\n" in TEST_F()
9293 " default:\n" in TEST_F()
9294 " break;\n" in TEST_F()
9295 " }\n" in TEST_F()
9296 "}\n", in TEST_F()
9299 verifyFormat("enum X\n" in TEST_F()
9300 "{\n" in TEST_F()
9301 " Y = 0,\n" in TEST_F()
9302 "}\n", in TEST_F()
9304 verifyFormat("enum X\n" in TEST_F()
9305 "{\n" in TEST_F()
9306 " Y = 0\n" in TEST_F()
9307 "}\n", in TEST_F()
9310 verifyFormat("@interface BSApplicationController ()\n" in TEST_F()
9311 "{\n" in TEST_F()
9312 "@private\n" in TEST_F()
9313 " id _extraIvar;\n" in TEST_F()
9314 "}\n" in TEST_F()
9315 "@end\n", in TEST_F()
9318 verifyFormat("#ifdef _DEBUG\n" in TEST_F()
9319 "int foo(int i = 0)\n" in TEST_F()
9320 "#else\n" in TEST_F()
9321 "int foo(int i = 5)\n" in TEST_F()
9322 "#endif\n" in TEST_F()
9323 "{\n" in TEST_F()
9324 " return i;\n" in TEST_F()
9328 verifyFormat("void foo() {}\n" in TEST_F()
9329 "void bar()\n" in TEST_F()
9330 "#ifdef _DEBUG\n" in TEST_F()
9331 "{\n" in TEST_F()
9332 " foo();\n" in TEST_F()
9333 "}\n" in TEST_F()
9334 "#else\n" in TEST_F()
9335 "{\n" in TEST_F()
9336 "}\n" in TEST_F()
9340 verifyFormat("void foobar() { int i = 5; }\n" in TEST_F()
9341 "#ifdef _DEBUG\n" in TEST_F()
9342 "void bar() {}\n" in TEST_F()
9343 "#else\n" in TEST_F()
9344 "void bar() { foobar(); }\n" in TEST_F()
9349 verifyFormat("[self doSomeThingWithACompletionHandler:^{\n" in TEST_F()
9350 " // ...\n" in TEST_F()
9351 " int i;\n" in TEST_F()
9354 verifyFormat("void (^block)(void) = ^{\n" in TEST_F()
9355 " // ...\n" in TEST_F()
9356 " int i;\n" in TEST_F()
9360 verifyFormat("void f()\n" in TEST_F()
9361 "{\n" in TEST_F()
9362 " [object someMethod:@{ @\"a\" : @\"b\" }];\n" in TEST_F()
9365 verifyFormat("int f()\n" in TEST_F()
9366 "{ // comment\n" in TEST_F()
9367 " return 42;\n" in TEST_F()
9374 verifyFormat("void f()\n" in TEST_F()
9375 "{\n" in TEST_F()
9376 " int i;\n" in TEST_F()
9384 verifyFormat("void f(bool b)\n" in TEST_F()
9385 "{\n" in TEST_F()
9386 " if (b)\n" in TEST_F()
9387 " {\n" in TEST_F()
9388 " return;\n" in TEST_F()
9389 " }\n" in TEST_F()
9390 "}\n", in TEST_F()
9392 verifyFormat("void f(bool b)\n" in TEST_F()
9393 "{\n" in TEST_F()
9394 " if (b) return;\n" in TEST_F()
9395 "}\n", in TEST_F()
9397 verifyFormat("void f(bool b)\n" in TEST_F()
9398 "{\n" in TEST_F()
9399 " while (b)\n" in TEST_F()
9400 " {\n" in TEST_F()
9401 " return;\n" in TEST_F()
9402 " }\n" in TEST_F()
9403 "}\n", in TEST_F()
9410 verifyFormat("namespace a\n" in TEST_F()
9411 "{\n" in TEST_F()
9412 "class A\n" in TEST_F()
9413 "{\n" in TEST_F()
9414 " void f()\n" in TEST_F()
9415 " {\n" in TEST_F()
9416 " int a;\n" in TEST_F()
9417 " {\n" in TEST_F()
9418 " int b;\n" in TEST_F()
9419 " }\n" in TEST_F()
9420 " if (true)\n" in TEST_F()
9421 " {\n" in TEST_F()
9422 " a();\n" in TEST_F()
9423 " b();\n" in TEST_F()
9424 " }\n" in TEST_F()
9425 " }\n" in TEST_F()
9426 " void g() { return; }\n" in TEST_F()
9427 "}\n" in TEST_F()
9431 verifyFormat("void f()\n" in TEST_F()
9432 "{\n" in TEST_F()
9433 " if (true)\n" in TEST_F()
9434 " {\n" in TEST_F()
9435 " a();\n" in TEST_F()
9436 " }\n" in TEST_F()
9437 " else if (false)\n" in TEST_F()
9438 " {\n" in TEST_F()
9439 " b();\n" in TEST_F()
9440 " }\n" in TEST_F()
9441 " else\n" in TEST_F()
9442 " {\n" in TEST_F()
9443 " c();\n" in TEST_F()
9444 " }\n" in TEST_F()
9445 "}\n", in TEST_F()
9448 verifyFormat("void f()\n" in TEST_F()
9449 "{\n" in TEST_F()
9450 " for (int i = 0; i < 10; ++i)\n" in TEST_F()
9451 " {\n" in TEST_F()
9452 " a();\n" in TEST_F()
9453 " }\n" in TEST_F()
9454 " while (false)\n" in TEST_F()
9455 " {\n" in TEST_F()
9456 " b();\n" in TEST_F()
9457 " }\n" in TEST_F()
9458 " do\n" in TEST_F()
9459 " {\n" in TEST_F()
9460 " c();\n" in TEST_F()
9461 " }\n" in TEST_F()
9462 " while (false);\n" in TEST_F()
9463 "}\n", in TEST_F()
9466 verifyFormat("void f(int a)\n" in TEST_F()
9467 "{\n" in TEST_F()
9468 " switch (a)\n" in TEST_F()
9469 " {\n" in TEST_F()
9470 " case 0:\n" in TEST_F()
9471 " break;\n" in TEST_F()
9472 " case 1:\n" in TEST_F()
9473 " {\n" in TEST_F()
9474 " break;\n" in TEST_F()
9475 " }\n" in TEST_F()
9476 " case 2:\n" in TEST_F()
9477 " {\n" in TEST_F()
9478 " }\n" in TEST_F()
9479 " break;\n" in TEST_F()
9480 " default:\n" in TEST_F()
9481 " break;\n" in TEST_F()
9482 " }\n" in TEST_F()
9483 "}\n", in TEST_F()
9486 verifyFormat("enum X\n" in TEST_F()
9487 "{\n" in TEST_F()
9488 " Y = 0,\n" in TEST_F()
9489 "}\n", in TEST_F()
9492 verifyFormat("@interface BSApplicationController ()\n" in TEST_F()
9493 "{\n" in TEST_F()
9494 "@private\n" in TEST_F()
9495 " id _extraIvar;\n" in TEST_F()
9496 "}\n" in TEST_F()
9497 "@end\n", in TEST_F()
9500 verifyFormat("#ifdef _DEBUG\n" in TEST_F()
9501 "int foo(int i = 0)\n" in TEST_F()
9502 "#else\n" in TEST_F()
9503 "int foo(int i = 5)\n" in TEST_F()
9504 "#endif\n" in TEST_F()
9505 "{\n" in TEST_F()
9506 " return i;\n" in TEST_F()
9510 verifyFormat("void foo() {}\n" in TEST_F()
9511 "void bar()\n" in TEST_F()
9512 "#ifdef _DEBUG\n" in TEST_F()
9513 "{\n" in TEST_F()
9514 " foo();\n" in TEST_F()
9515 "}\n" in TEST_F()
9516 "#else\n" in TEST_F()
9517 "{\n" in TEST_F()
9518 "}\n" in TEST_F()
9522 verifyFormat("void foobar() { int i = 5; }\n" in TEST_F()
9523 "#ifdef _DEBUG\n" in TEST_F()
9524 "void bar() {}\n" in TEST_F()
9525 "#else\n" in TEST_F()
9526 "void bar() { foobar(); }\n" in TEST_F()
9534 verifyFormat("namespace a {\n" in TEST_F()
9535 "class A {\n" in TEST_F()
9536 " void f()\n" in TEST_F()
9537 " {\n" in TEST_F()
9538 " if (true) {\n" in TEST_F()
9539 " a();\n" in TEST_F()
9540 " b();\n" in TEST_F()
9541 " }\n" in TEST_F()
9542 " }\n" in TEST_F()
9543 " void g() { return; }\n" in TEST_F()
9544 "};\n" in TEST_F()
9545 "enum E {\n" in TEST_F()
9546 " A,\n" in TEST_F()
9547 " // foo\n" in TEST_F()
9548 " B,\n" in TEST_F()
9549 " C\n" in TEST_F()
9550 "};\n" in TEST_F()
9551 "struct B {\n" in TEST_F()
9552 " int x;\n" in TEST_F()
9553 "};\n" in TEST_F()
9554 "}\n", in TEST_F()
9556 verifyFormat("struct S {\n" in TEST_F()
9557 " int Type;\n" in TEST_F()
9558 " union {\n" in TEST_F()
9559 " int x;\n" in TEST_F()
9560 " double y;\n" in TEST_F()
9561 " } Value;\n" in TEST_F()
9562 " class C {\n" in TEST_F()
9563 " MyFavoriteType Value;\n" in TEST_F()
9564 " } Class;\n" in TEST_F()
9565 "};\n", in TEST_F()
9570 verifyFormat("void f() {\n" in TEST_F()
9571 " try {\n" in TEST_F()
9572 " } catch (const Exception &e) {\n" in TEST_F()
9573 " }\n" in TEST_F()
9574 "}\n", in TEST_F()
9660 EXPECT_EQ(0, parseConfiguration("Language: JavaScript\n" in TEST_F()
9667 EXPECT_EQ(0, parseConfiguration("BasedOnStyle: Google\n" in TEST_F()
9674 EXPECT_EQ(0, parseConfiguration("---\n" in TEST_F()
9675 "BasedOnStyle: LLVM\n" in TEST_F()
9676 "IndentWidth: 123\n" in TEST_F()
9677 "---\n" in TEST_F()
9678 "BasedOnStyle: Google\n" in TEST_F()
9697 parseConfiguration(#STRUCT ":\n " CONFIG_NAME ": true", &Style) \
9701 parseConfiguration(#STRUCT ":\n " CONFIG_NAME ": false", &Style) \
9923 // the first N elements of the list instead of resetting it. in TEST_F()
9937 CHECK_PARSE("IncludeCategories:\n" in TEST_F()
9938 " - Regex: abc/.*\n" in TEST_F()
9939 " Priority: 2\n" in TEST_F()
9940 " - Regex: .*\n" in TEST_F()
9948 CHECK_PARSE("Language: Cpp\n" in TEST_F()
9951 EXPECT_EQ(parseConfiguration("Language: JavaScript\n" in TEST_F()
9960 CHECK_PARSE("Language: JavaScript\n" in TEST_F()
9964 EXPECT_EQ(parseConfiguration("Language: Cpp\n" in TEST_F()
9972 CHECK_PARSE("BasedOnStyle: LLVM\n" in TEST_F()
9976 CHECK_PARSE("---\n" in TEST_F()
9977 "Language: JavaScript\n" in TEST_F()
9978 "IndentWidth: 12\n" in TEST_F()
9979 "---\n" in TEST_F()
9980 "Language: Cpp\n" in TEST_F()
9981 "IndentWidth: 34\n" in TEST_F()
9982 "...\n", in TEST_F()
9986 CHECK_PARSE("---\n" in TEST_F()
9987 "Language: JavaScript\n" in TEST_F()
9988 "IndentWidth: 12\n" in TEST_F()
9989 "---\n" in TEST_F()
9990 "Language: Cpp\n" in TEST_F()
9991 "IndentWidth: 34\n" in TEST_F()
9992 "...\n", in TEST_F()
9994 CHECK_PARSE("---\n" in TEST_F()
9995 "IndentWidth: 78\n" in TEST_F()
9996 "---\n" in TEST_F()
9997 "Language: JavaScript\n" in TEST_F()
9998 "IndentWidth: 56\n" in TEST_F()
9999 "...\n", in TEST_F()
10006 EXPECT_FALSE(parseConfiguration("---\n" in TEST_F()
10007 "IndentWidth: 456\n" in TEST_F()
10008 "BreakBeforeBraces: Allman\n" in TEST_F()
10009 "---\n" in TEST_F()
10010 "Language: JavaScript\n" in TEST_F()
10011 "IndentWidth: 111\n" in TEST_F()
10012 "TabWidth: 111\n" in TEST_F()
10013 "---\n" in TEST_F()
10014 "Language: Cpp\n" in TEST_F()
10015 "BreakBeforeBraces: Stroustrup\n" in TEST_F()
10016 "TabWidth: 789\n" in TEST_F()
10017 "...\n", in TEST_F()
10024 EXPECT_EQ(parseConfiguration("---\n" in TEST_F()
10025 "Language: JavaScript\n" in TEST_F()
10026 "IndentWidth: 56\n" in TEST_F()
10027 "---\n" in TEST_F()
10028 "IndentWidth: 78\n" in TEST_F()
10029 "...\n", in TEST_F()
10032 EXPECT_EQ(parseConfiguration("---\n" in TEST_F()
10033 "Language: JavaScript\n" in TEST_F()
10034 "IndentWidth: 56\n" in TEST_F()
10035 "---\n" in TEST_F()
10036 "Language: JavaScript\n" in TEST_F()
10037 "IndentWidth: 78\n" in TEST_F()
10038 "...\n", in TEST_F()
10055 EXPECT_EQ(0, parseConfiguration("---\n" in TEST_F()
10056 "BasedOnStyle: Google\n" in TEST_F()
10057 "---\n" in TEST_F()
10058 "Language: JavaScript\n" in TEST_F()
10059 "IndentWidth: 76\n" in TEST_F()
10060 "...\n", in TEST_F()
10078 EXPECT_EQ("\"\xce\xe4\xed\xe0\xe6\xe4\xfb \xe2 \"\n" in TEST_F()
10079 "\"\xf1\xf2\xf3\xe4\xb8\xed\xf3\xfe \"\n" in TEST_F()
10080 "\"\xe7\xe8\xec\xed\xfe\xfe \"\n" in TEST_F()
10092 EXPECT_EQ("\xef\xbb\xbf\n#include <iostream>", in TEST_F()
10093 format("\xef\xbb\xbf\n#include <iostream>")); in TEST_F()
10118 EXPECT_EQ("\"aaaaÄ\"\n" in TEST_F()
10121 EXPECT_EQ("\"aaaaaaaÄ\"\n" in TEST_F()
10124 EXPECT_EQ("\"Однажды, в \"\n" in TEST_F()
10125 "\"студёную \"\n" in TEST_F()
10126 "\"зимнюю \"\n" in TEST_F()
10131 "\"一 二 三 \"\n" in TEST_F()
10132 "\"四 五六 \"\n" in TEST_F()
10133 "\"七 八 九 \"\n" in TEST_F()
10136 EXPECT_EQ("\"一\t二 \"\n" in TEST_F()
10137 "\"\t三 \"\n" in TEST_F()
10138 "\"四 五\t六 \"\n" in TEST_F()
10139 "\"\t七 \"\n" in TEST_F()
10145 EXPECT_EQ("\"aaaaaa\"\n" in TEST_F()
10151 EXPECT_EQ("const char *sssss =\n" in TEST_F()
10152 " \"一二三四五六七八\\\n" in TEST_F()
10154 format("const char *sssss = \"一二三四五六七八\\\n" in TEST_F()
10162 EXPECT_EQ("// Я из лесу\n" in TEST_F()
10163 "// вышел; был\n" in TEST_F()
10164 "// сильный\n" in TEST_F()
10168 EXPECT_EQ("// 一二三\n" in TEST_F()
10169 "// 四五六七\n" in TEST_F()
10170 "// 八 九\n" in TEST_F()
10176 EXPECT_EQ("/* Гляжу,\n" in TEST_F()
10177 " * поднимается\n" in TEST_F()
10178 " * медленно в\n" in TEST_F()
10179 " * гору\n" in TEST_F()
10180 " * Лошадка,\n" in TEST_F()
10181 " * везущая\n" in TEST_F()
10182 " * хворосту\n" in TEST_F()
10184 format("/* Гляжу, поднимается медленно в гору\n" in TEST_F()
10188 "/* 一二三\n" in TEST_F()
10189 " * 四五六七\n" in TEST_F()
10190 " * 八 九\n" in TEST_F()
10193 EXPECT_EQ("/* \n" in TEST_F()
10194 " * \n" in TEST_F()
10206 "SomeClass::Constructor()\n" in TEST_F()
10207 " : aaaaaaaaaaaaa(aaaaaaaaaaaaaa), aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n" in TEST_F()
10213 "SomeClass::Constructor()\n" in TEST_F()
10214 " : aaaaaaaaaaaaa(aaaaaaaaaaaaaa), aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n" in TEST_F()
10220 "SomeClass::Constructor()\n" in TEST_F()
10221 ": aaaaaaaaaaaaa(aaaaaaaaaaaaaa), aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n" in TEST_F()
10230 verifyFormat("SomeClass::Constructor()\n" in TEST_F()
10231 " : a(a)\n" in TEST_F()
10232 " , b(b)\n" in TEST_F()
10235 verifyFormat("SomeClass::Constructor()\n" in TEST_F()
10240 verifyFormat("SomeClass::Constructor()\n" in TEST_F()
10243 verifyFormat("SomeClass::Constructor()\n" in TEST_F()
10244 " : a(a)\n" in TEST_F()
10245 " , b(b)\n" in TEST_F()
10248 verifyFormat("SomeClass::Constructor()\n" in TEST_F()
10249 " : a(a) {\n" in TEST_F()
10250 " foo();\n" in TEST_F()
10251 " bar();\n" in TEST_F()
10256 verifyFormat("SomeClass::Constructor()\n" in TEST_F()
10257 " : a(a)\n" in TEST_F()
10258 " , b(b)\n" in TEST_F()
10259 " , c(c) {\n}", in TEST_F()
10261 verifyFormat("SomeClass::Constructor()\n" in TEST_F()
10262 " : a(a) {\n}", in TEST_F()
10268 verifyFormat("SomeClass::Constructor()\n" in TEST_F()
10269 " : a(a)\n" in TEST_F()
10270 " , b(b)\n" in TEST_F()
10275 verifyFormat("SomeClass::Constructor()\n" in TEST_F()
10276 ": a(a)\n" in TEST_F()
10277 ", b(b)\n" in TEST_F()
10285 "SomeClass::Constructor() : aaaaa(aaaaa), aaaaa(aaaaa), aaaaa(aaaaa)\n", in TEST_F()
10288 "SomeClass::Constructor()\n" in TEST_F()
10293 verifyFormat("SomeClass::Constructor()\n" in TEST_F()
10294 " : aaaaaaaa(aaaaaaaa)\n" in TEST_F()
10295 " , aaaaaaaa(aaaaaaaa)\n" in TEST_F()
10309 verifyFormat("namespace outer {\n" in TEST_F()
10310 "int i;\n" in TEST_F()
10311 "namespace inner {\n" in TEST_F()
10312 " int i;\n" in TEST_F()
10313 "} // namespace inner\n" in TEST_F()
10314 "} // namespace outer\n" in TEST_F()
10315 "namespace other_outer {\n" in TEST_F()
10316 "int i;\n" in TEST_F()
10321 verifyFormat("switch (variable) {\n" in TEST_F()
10322 "case 1:\n" in TEST_F()
10323 "case 2:\n" in TEST_F()
10324 " doSomething();\n" in TEST_F()
10325 " break;\n" in TEST_F()
10326 "default:\n" in TEST_F()
10327 " ++variable;\n" in TEST_F()
10332 EXPECT_EQ("void f()\n" in TEST_F()
10333 "{\n" in TEST_F()
10334 " if (aaaaaaaaaaaaaaaa\n" in TEST_F()
10335 " && bbbbbbbbbbbbbbbbbbbbbbbb\n" in TEST_F()
10336 " && (cccccccccccccccccccccccccc || dddddddddddddddddddd))\n" in TEST_F()
10337 " return;\n" in TEST_F()
10339 format("void f() {\n" in TEST_F()
10340 "if (aaaaaaaaaaaaaaaa\n" in TEST_F()
10341 "&& bbbbbbbbbbbbbbbbbbbbbbbb\n" in TEST_F()
10342 "&& (cccccccccccccccccccccccccc || dddddddddddddddddddd))\n" in TEST_F()
10343 "return;\n" in TEST_F()
10352 verifyFormat("Constructor()\n" in TEST_F()
10353 " : aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" in TEST_F()
10354 " , aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaa, // break\n" in TEST_F()
10355 " aaaaaaaaaaaaaa)\n" in TEST_F()
10356 " , aaaaaaaaaaaaaaaaaaaaaaa()\n" in TEST_F()
10357 "{\n" in TEST_F()
10360 verifyFormat("SomeClass::Constructor()\n" in TEST_F()
10361 " : a(a)\n" in TEST_F()
10362 "{\n" in TEST_F()
10365 EXPECT_EQ("SomeClass::Constructor()\n" in TEST_F()
10366 " : a(a)\n" in TEST_F()
10367 "{\n" in TEST_F()
10370 verifyFormat("SomeClass::Constructor()\n" in TEST_F()
10371 " : a(a)\n" in TEST_F()
10372 " , b(b)\n" in TEST_F()
10373 " , c(c)\n" in TEST_F()
10374 "{\n" in TEST_F()
10377 verifyFormat("SomeClass::Constructor()\n" in TEST_F()
10378 " : a(a)\n" in TEST_F()
10379 "{\n" in TEST_F()
10380 " foo();\n" in TEST_F()
10381 " bar();\n" in TEST_F()
10386 verifyFormat("class C {\n" in TEST_F()
10387 "public:\n" in TEST_F()
10388 " int i;\n" in TEST_F()
10393 verifyFormat("int a; // Do not\n" in TEST_F()
10398 EXPECT_EQ("ASSERT(aaaa\n" in TEST_F()
10400 format("ASSERT ( aaaa\n||bbbb);", Style)); in TEST_F()
10403 EXPECT_EQ("if (aaaaaaaaaaaaaaa\n" in TEST_F()
10404 " || bbbbbbbbbbbbbbb) {\n" in TEST_F()
10405 " i++;\n" in TEST_F()
10407 format("if (aaaaaaaaaaaaaaa\n" in TEST_F()
10410 EXPECT_EQ("if (aaaaaaaaaaaaaaa || bbbbbbbbbbbbbbb) {\n" in TEST_F()
10411 " i++;\n" in TEST_F()
10418 EXPECT_EQ("#define aNumber \\\n" in TEST_F()
10420 format("#define aNumber \\\n" in TEST_F()
10425 EXPECT_EQ("NSArray* a = [[NSArray alloc] initWithArray:@[]\n" in TEST_F()
10427 format("NSArray*a=[[NSArray alloc] initWithArray:@[]\n" in TEST_F()
10430 EXPECT_EQ("NSArray* a = [[NSArray alloc] initWithArray:@[ @\"a\" ]\n" in TEST_F()
10432 format("NSArray*a=[[NSArray alloc]initWithArray:@[ @\"a\" ]\n" in TEST_F()
10437 EXPECT_EQ("NSArray* a = [[NSArray alloc] initWithArray:@[\n" in TEST_F()
10438 " @\"a\",\n" in TEST_F()
10439 " @\"a\"\n" in TEST_F()
10440 "]\n" in TEST_F()
10442 format("NSArray* a = [[NSArray alloc] initWithArray:@[\n" in TEST_F()
10443 " @\"a\",\n" in TEST_F()
10444 " @\"a\"\n" in TEST_F()
10445 " ]\n" in TEST_F()
10449 "NSArray* a = [[NSArray alloc] initWithArray:@[ @\"a\", @\"a\" ]\n" in TEST_F()
10451 format("NSArray* a = [[NSArray alloc] initWithArray:@[ @\"a\", @\"a\" ]\n" in TEST_F()
10456 EXPECT_EQ("[self.a b:c\n" in TEST_F()
10458 format("[self.a b:c\n" in TEST_F()
10464 verifyFormat("int c = [b]() mutable { return [&b] { return b++; }(); }();\n"); in TEST_F()
10465 verifyFormat("int c = [&] { [=] { return b++; }(); }();\n"); in TEST_F()
10466 verifyFormat("int c = [&, &a, a] { [=, c, &d] { return b++; }(); }();\n"); in TEST_F()
10467 verifyFormat("int c = [&a, &a, a] { [=, a, b, &c] { return b++; }(); }();\n"); in TEST_F()
10468 verifyFormat("auto c = {[&a, &a, a] { [=, a, b, &c] { return b++; }(); }}\n"); in TEST_F()
10469 verifyFormat("auto c = {[&a, &a, a] { [=, a, b, &c] {}(); }}\n"); in TEST_F()
10470 verifyFormat("void f() {\n" in TEST_F()
10471 " other(x.begin(), x.end(), [&](int, int) { return 1; });\n" in TEST_F()
10472 "}\n"); in TEST_F()
10473 verifyFormat("void f() {\n" in TEST_F()
10474 " other(x.begin(), //\n" in TEST_F()
10475 " x.end(), //\n" in TEST_F()
10476 " [&](int, int) { return 1; });\n" in TEST_F()
10477 "}\n"); in TEST_F()
10478 verifyFormat("SomeFunction([]() { // A cool function...\n" in TEST_F()
10479 " return 43;\n" in TEST_F()
10481 EXPECT_EQ("SomeFunction([]() {\n" in TEST_F()
10482 "#define A a\n" in TEST_F()
10483 " return 43;\n" in TEST_F()
10485 format("SomeFunction([](){\n" in TEST_F()
10486 "#define A a\n" in TEST_F()
10487 "return 43;\n" in TEST_F()
10489 verifyFormat("void f() {\n" in TEST_F()
10490 " SomeFunction([](decltype(x), A *a) {});\n" in TEST_F()
10492 verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
10494 verifyFormat("string abc = SomeFunction(aaaaaaaaaaaaa, aaaaa, []() {\n" in TEST_F()
10495 " SomeOtherFunctioooooooooooooooooooooooooon();\n" in TEST_F()
10497 verifyFormat("Constructor()\n" in TEST_F()
10498 " : Field([] { // comment\n" in TEST_F()
10499 " int i;\n" in TEST_F()
10501 verifyFormat("auto my_lambda = [](const string &some_parameter) {\n" in TEST_F()
10502 " return some_parameter.size();\n" in TEST_F()
10504 verifyFormat("int i = aaaaaa ? 1 //\n" in TEST_F()
10505 " : [] {\n" in TEST_F()
10506 " return 2; //\n" in TEST_F()
10508 verifyFormat("llvm::errs() << \"number of twos is \"\n" in TEST_F()
10509 " << std::count_if(v.begin(), v.end(), [](int x) {\n" in TEST_F()
10510 " return x == 2; // force break\n" in TEST_F()
10512 verifyFormat("return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa([=](\n" in TEST_F()
10513 " int iiiiiiiiiiii) {\n" in TEST_F()
10514 " return aaaaaaaaaaaaaaaaaaaaaaa != aaaaaaaaaaaaaaaaaaaaaaa;\n" in TEST_F()
10517 verifyFormat("SomeFunction({[&] {\n" in TEST_F()
10518 " // comment\n" in TEST_F()
10519 " },\n" in TEST_F()
10520 " [&] {\n" in TEST_F()
10521 " // comment\n" in TEST_F()
10523 verifyFormat("SomeFunction({[&] {\n" in TEST_F()
10524 " // comment\n" in TEST_F()
10526 verifyFormat("virtual aaaaaaaaaaaaaaaa(std::function<bool()> bbbbbbbbbbbb =\n" in TEST_F()
10527 " [&]() { return true; },\n" in TEST_F()
10531 verifyFormat("int c = []() -> int { return 2; }();\n"); in TEST_F()
10532 verifyFormat("int c = []() -> int * { return 2; }();\n"); in TEST_F()
10533 verifyFormat("int c = []() -> vector<int> { return {2}; }();\n"); in TEST_F()
10540 verifyFormat("auto aaaaaaaa = [](int i, // break for some reason\n" in TEST_F()
10541 " int j) -> int {\n" in TEST_F()
10542 " return ffffffffffffffffffffffffffffffffffffffffffff(i * j);\n" in TEST_F()
10545 "aaaaaaaaaaaaaaaaaaaaaa(\n" in TEST_F()
10546 " [](aaaaaaaaaaaaaaaaaaaaaaaaaaa &aaa) -> aaaaaaaaaaaaaaaa {\n" in TEST_F()
10547 " return aaaaaaaaaaaaaaaaa;\n" in TEST_F()
10552 verifyFormat("SomeFunction(\n" in TEST_F()
10553 " []() {\n" in TEST_F()
10554 " int i = 42;\n" in TEST_F()
10555 " return i;\n" in TEST_F()
10556 " },\n" in TEST_F()
10557 " []() {\n" in TEST_F()
10558 " int j = 43;\n" in TEST_F()
10559 " return j;\n" in TEST_F()
10567 verifyFormat("double &operator[](int i) { return 0; }\n" in TEST_F()
10574 verifyFormat("void f() {\n" in TEST_F()
10575 " bar([]() {} // Did not respect SpacesBeforeTrailingComments\n" in TEST_F()
10576 " );\n" in TEST_F()
10580 verifyFormat("void f() {\n" in TEST_F()
10581 " MACRO((const AA &a) { return 1; });\n" in TEST_F()
10584 verifyFormat("if (blah_blah(whatever, whatever, [] {\n" in TEST_F()
10585 " doo_dah();\n" in TEST_F()
10586 " doo_dah();\n" in TEST_F()
10587 " })) {\n" in TEST_F()
10589 verifyFormat("auto lambda = []() {\n" in TEST_F()
10590 " int a = 2\n" in TEST_F()
10591 "#if A\n" in TEST_F()
10592 " + 2\n" in TEST_F()
10593 "#endif\n" in TEST_F()
10594 " ;\n" in TEST_F()
10612 verifyFormat("[operation setCompletionBlock:^{\n" in TEST_F()
10613 " [self onOperationDone];\n" in TEST_F()
10615 verifyFormat("int i = {[operation setCompletionBlock:^{\n" in TEST_F()
10616 " [self onOperationDone];\n" in TEST_F()
10618 verifyFormat("[operation setCompletionBlock:^(int *i) {\n" in TEST_F()
10619 " f();\n" in TEST_F()
10621 verifyFormat("int a = [operation block:^int(int *i) {\n" in TEST_F()
10622 " return 1;\n" in TEST_F()
10624 verifyFormat("[myObject doSomethingWith:arg1\n" in TEST_F()
10625 " aaa:^int(int *a) {\n" in TEST_F()
10626 " return 1;\n" in TEST_F()
10627 " }\n" in TEST_F()
10630 verifyFormat("[operation setCompletionBlock:^{\n" in TEST_F()
10631 " [self.delegate newDataAvailable];\n" in TEST_F()
10634 verifyFormat("dispatch_async(_fileIOQueue, ^{\n" in TEST_F()
10635 " NSString *path = [self sessionFilePath];\n" in TEST_F()
10636 " if (path) {\n" in TEST_F()
10637 " // ...\n" in TEST_F()
10638 " }\n" in TEST_F()
10640 verifyFormat("[[SessionService sharedService]\n" in TEST_F()
10641 " loadWindowWithCompletionBlock:^(SessionWindow *window) {\n" in TEST_F()
10642 " if (window) {\n" in TEST_F()
10643 " [self windowDidLoad:window];\n" in TEST_F()
10644 " } else {\n" in TEST_F()
10645 " [self errorLoadingWindow];\n" in TEST_F()
10646 " }\n" in TEST_F()
10648 verifyFormat("void (^largeBlock)(void) = ^{\n" in TEST_F()
10649 " // ...\n" in TEST_F()
10650 "};\n", in TEST_F()
10652 verifyFormat("[[SessionService sharedService]\n" in TEST_F()
10653 " loadWindowWithCompletionBlock: //\n" in TEST_F()
10654 " ^(SessionWindow *window) {\n" in TEST_F()
10655 " if (window) {\n" in TEST_F()
10656 " [self windowDidLoad:window];\n" in TEST_F()
10657 " } else {\n" in TEST_F()
10658 " [self errorLoadingWindow];\n" in TEST_F()
10659 " }\n" in TEST_F()
10662 verifyFormat("[myObject doSomethingWith:arg1\n" in TEST_F()
10663 " firstBlock:^(Foo *a) {\n" in TEST_F()
10664 " // ...\n" in TEST_F()
10665 " int i;\n" in TEST_F()
10666 " }\n" in TEST_F()
10667 " secondBlock:^(Bar *b) {\n" in TEST_F()
10668 " // ...\n" in TEST_F()
10669 " int i;\n" in TEST_F()
10670 " }\n" in TEST_F()
10671 " thirdBlock:^Foo(Bar *b) {\n" in TEST_F()
10672 " // ...\n" in TEST_F()
10673 " int i;\n" in TEST_F()
10675 verifyFormat("[myObject doSomethingWith:arg1\n" in TEST_F()
10676 " firstBlock:-1\n" in TEST_F()
10677 " secondBlock:^(Bar *b) {\n" in TEST_F()
10678 " // ...\n" in TEST_F()
10679 " int i;\n" in TEST_F()
10682 verifyFormat("f(^{\n" in TEST_F()
10683 " @autoreleasepool {\n" in TEST_F()
10684 " if (a) {\n" in TEST_F()
10685 " g();\n" in TEST_F()
10686 " }\n" in TEST_F()
10687 " }\n" in TEST_F()
10693 verifyFormat("[operation setCompletionBlock:^{\n" in TEST_F()
10694 " [self onOperationDone];\n" in TEST_F()
10704 "loadWindowWithCompletionBlock:^(SessionWindow *window) {\n" in TEST_F()
10705 " if (window) {\n" in TEST_F()
10706 " [self windowDidLoad:window];\n" in TEST_F()
10707 " } else {\n" in TEST_F()
10708 " [self errorLoadingWindow];\n" in TEST_F()
10709 " }\n" in TEST_F()
10712 EXPECT_EQ("[[SessionService sharedService]\n" in TEST_F()
10713 " loadWindowWithCompletionBlock:^(SessionWindow *window) {\n" in TEST_F()
10714 " if (window) {\n" in TEST_F()
10715 " [self windowDidLoad:window];\n" in TEST_F()
10716 " } else {\n" in TEST_F()
10717 " [self errorLoadingWindow];\n" in TEST_F()
10718 " }\n" in TEST_F()
10720 format("[[SessionService sharedService]\n" in TEST_F()
10721 "loadWindowWithCompletionBlock:^(SessionWindow *window) {\n" in TEST_F()
10722 " if (window) {\n" in TEST_F()
10723 " [self windowDidLoad:window];\n" in TEST_F()
10724 " } else {\n" in TEST_F()
10725 " [self errorLoadingWindow];\n" in TEST_F()
10726 " }\n" in TEST_F()
10729 verifyFormat("[myObject doSomethingWith:arg1\n" in TEST_F()
10730 " firstBlock:^(Foo *a) {\n" in TEST_F()
10731 " // ...\n" in TEST_F()
10732 " int i;\n" in TEST_F()
10733 " }\n" in TEST_F()
10734 " secondBlock:^(Bar *b) {\n" in TEST_F()
10735 " // ...\n" in TEST_F()
10736 " int i;\n" in TEST_F()
10737 " }\n" in TEST_F()
10738 " thirdBlock:^Foo(Bar *b) {\n" in TEST_F()
10739 " // ...\n" in TEST_F()
10740 " int i;\n" in TEST_F()
10743 verifyFormat("f(^{\n" in TEST_F()
10744 " @autoreleasepool {\n" in TEST_F()
10745 " if (a) {\n" in TEST_F()
10746 " g();\n" in TEST_F()
10747 " }\n" in TEST_F()
10748 " }\n" in TEST_F()
10751 verifyFormat("void (^largeBlock)(void) = ^{\n" in TEST_F()
10752 " // ...\n" in TEST_F()
10760 EXPECT_EQ("void (^largeBlock)(void) = ^{\n" in TEST_F()
10761 " int i;\n" in TEST_F()
10767 EXPECT_EQ("int a;\r\n" in TEST_F()
10768 "int b;\r\n" in TEST_F()
10769 "int c;\r\n", in TEST_F()
10770 format("int a;\r\n" in TEST_F()
10771 " int b;\r\n" in TEST_F()
10772 " int c;\r\n", in TEST_F()
10774 EXPECT_EQ("int a;\r\n" in TEST_F()
10775 "int b;\r\n" in TEST_F()
10776 "int c;\r\n", in TEST_F()
10777 format("int a;\r\n" in TEST_F()
10778 " int b;\n" in TEST_F()
10779 " int c;\r\n", in TEST_F()
10781 EXPECT_EQ("int a;\n" in TEST_F()
10782 "int b;\n" in TEST_F()
10783 "int c;\n", in TEST_F()
10784 format("int a;\r\n" in TEST_F()
10785 " int b;\n" in TEST_F()
10786 " int c;\n", in TEST_F()
10788 EXPECT_EQ("\"aaaaaaa \"\r\n" in TEST_F()
10789 "\"bbbbbbb\";\r\n", in TEST_F()
10790 format("\"aaaaaaa bbbbbbb\";\r\n", getLLVMStyleWithColumns(10))); in TEST_F()
10791 EXPECT_EQ("#define A \\\r\n" in TEST_F()
10792 " b; \\\r\n" in TEST_F()
10793 " c; \\\r\n" in TEST_F()
10794 " d;\r\n", in TEST_F()
10795 format("#define A \\\r\n" in TEST_F()
10796 " b; \\\r\n" in TEST_F()
10797 " c; d; \r\n", in TEST_F()
10800 EXPECT_EQ("/*\r\n" in TEST_F()
10801 "multi line block comments\r\n" in TEST_F()
10802 "should not introduce\r\n" in TEST_F()
10803 "an extra carriage return\r\n" in TEST_F()
10804 "*/\r\n", in TEST_F()
10805 format("/*\r\n" in TEST_F()
10806 "multi line block comments\r\n" in TEST_F()
10807 "should not introduce\r\n" in TEST_F()
10808 "an extra carriage return\r\n" in TEST_F()
10809 "*/\r\n")); in TEST_F()
10813 verifyFormat("MY_CLASS(C) {\n" in TEST_F()
10814 " int i;\n" in TEST_F()
10815 " int j;\n" in TEST_F()
10823 EXPECT_EQ("int i =\n" in TEST_F()
10824 " longFunction(\n" in TEST_F()
10831 EXPECT_EQ("int i =\n" in TEST_F()
10832 " longFunction(\n" in TEST_F()
10874 "aaaaaaaaaaa<<<\n 1, 1>>>();"); in TEST_F()
10879 EXPECT_EQ("< < <", format("\\\n<<<")); in TEST_F()
10883 "aaaallvm::outs()\n <<"); in TEST_F()
10887 std::string code = "#if A\n" in TEST_F()
10888 "#if B\n" in TEST_F()
10889 "a.\n" in TEST_F()
10890 "#endif\n" in TEST_F()
10891 " a = 1;\n" in TEST_F()
10892 "#else\n" in TEST_F()
10893 "#endif\n" in TEST_F()
10894 "#if C\n" in TEST_F()
10895 "#else\n" in TEST_F()
10896 "#endif\n"; in TEST_F()
10902 EXPECT_EQ("int a;\n" in TEST_F()
10903 "void f() {\n" in TEST_F()
10904 " callme(some(parameter1,\n" in TEST_F()
10905 "<<<<<<< text by the vcs\n" in TEST_F()
10906 " parameter2),\n" in TEST_F()
10907 "||||||| text by the vcs\n" in TEST_F()
10908 " parameter2),\n" in TEST_F()
10909 " parameter3,\n" in TEST_F()
10910 "======= text by the vcs\n" in TEST_F()
10911 " parameter2, parameter3),\n" in TEST_F()
10912 ">>>>>>> text by the vcs\n" in TEST_F()
10913 " otherparameter);\n", in TEST_F()
10914 format("int a;\n" in TEST_F()
10915 "void f() {\n" in TEST_F()
10916 " callme(some(parameter1,\n" in TEST_F()
10917 "<<<<<<< text by the vcs\n" in TEST_F()
10918 " parameter2),\n" in TEST_F()
10919 "||||||| text by the vcs\n" in TEST_F()
10920 " parameter2),\n" in TEST_F()
10921 " parameter3,\n" in TEST_F()
10922 "======= text by the vcs\n" in TEST_F()
10923 " parameter2,\n" in TEST_F()
10924 " parameter3),\n" in TEST_F()
10925 ">>>>>>> text by the vcs\n" in TEST_F()
10926 " otherparameter);\n")); in TEST_F()
10929 EXPECT_EQ("void f() {\n" in TEST_F()
10930 " function(\n" in TEST_F()
10931 ">>>> text by the vcs\n" in TEST_F()
10932 " parameter,\n" in TEST_F()
10933 "==== text by the vcs\n" in TEST_F()
10934 " parameter,\n" in TEST_F()
10935 "==== text by the vcs\n" in TEST_F()
10936 " parameter,\n" in TEST_F()
10937 "<<<< text by the vcs\n" in TEST_F()
10938 " parameter);\n", in TEST_F()
10939 format("void f() {\n" in TEST_F()
10940 " function(\n" in TEST_F()
10941 ">>>> text by the vcs\n" in TEST_F()
10942 " parameter,\n" in TEST_F()
10943 "==== text by the vcs\n" in TEST_F()
10944 " parameter,\n" in TEST_F()
10945 "==== text by the vcs\n" in TEST_F()
10946 " parameter,\n" in TEST_F()
10947 "<<<< text by the vcs\n" in TEST_F()
10948 " parameter);\n")); in TEST_F()
10950 EXPECT_EQ("<<<<<<<\n" in TEST_F()
10951 "|||||||\n" in TEST_F()
10952 "=======\n" in TEST_F()
10954 format("<<<<<<<\n" in TEST_F()
10955 "|||||||\n" in TEST_F()
10956 "=======\n" in TEST_F()
10959 EXPECT_EQ("<<<<<<<\n" in TEST_F()
10960 "|||||||\n" in TEST_F()
10961 "int i;\n" in TEST_F()
10962 "=======\n" in TEST_F()
10964 format("<<<<<<<\n" in TEST_F()
10965 "|||||||\n" in TEST_F()
10966 "int i;\n" in TEST_F()
10967 "=======\n" in TEST_F()
10971 EXPECT_EQ("#define Macro \\\n" in TEST_F()
10972 "<<<<<<<\n" in TEST_F()
10973 "Something \\\n" in TEST_F()
10974 "|||||||\n" in TEST_F()
10975 "Else \\\n" in TEST_F()
10976 "=======\n" in TEST_F()
10977 "Other \\\n" in TEST_F()
10978 ">>>>>>>\n" in TEST_F()
10979 " End int i;\n", in TEST_F()
10980 format("#define Macro \\\n" in TEST_F()
10981 "<<<<<<<\n" in TEST_F()
10982 " Something \\\n" in TEST_F()
10983 "|||||||\n" in TEST_F()
10984 " Else \\\n" in TEST_F()
10985 "=======\n" in TEST_F()
10986 " Other \\\n" in TEST_F()
10987 ">>>>>>>\n" in TEST_F()
10988 " End\n" in TEST_F()
10989 "int i;\n")); in TEST_F()
10993 EXPECT_EQ("int i;\n" in TEST_F()
10994 "// clang-format off\n" in TEST_F()
10995 " int j;\n" in TEST_F()
10996 "// clang-format on\n" in TEST_F()
10998 format(" int i;\n" in TEST_F()
10999 " // clang-format off\n" in TEST_F()
11000 " int j;\n" in TEST_F()
11001 " // clang-format on\n" in TEST_F()
11003 EXPECT_EQ("int i;\n" in TEST_F()
11004 "/* clang-format off */\n" in TEST_F()
11005 " int j;\n" in TEST_F()
11006 "/* clang-format on */\n" in TEST_F()
11008 format(" int i;\n" in TEST_F()
11009 " /* clang-format off */\n" in TEST_F()
11010 " int j;\n" in TEST_F()
11011 " /* clang-format on */\n" in TEST_F()
11017 verifyNoCrash("#define a\\\n /**/}"); in TEST_F()