summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-09-15 11:11:00 +0000
committerDaniel Jasper <djasper@google.com>2014-09-15 11:11:00 +0000
commitac043c900c0a9a8455f5ab96123cb3c8345809e6 (patch)
tree2c8f8c6ab5f23c66505e39c91eba0f0fc2c40e65 /clang/unittests/Format
parent5bfe02c632b118d2c87aae1e08574b321257c820 (diff)
downloadbcm5719-llvm-ac043c900c0a9a8455f5ab96123cb3c8345809e6.tar.gz
bcm5719-llvm-ac043c900c0a9a8455f5ab96123cb3c8345809e6.zip
clang-format: Add option to break before non-assignment operators.
This will allow: int aaaaaaaaaaaaaa = bbbbbbbbbbbbbb + ccccccccccccccc; llvm-svn: 217757
Diffstat (limited to 'clang/unittests/Format')
-rw-r--r--clang/unittests/Format/FormatTest.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index dfa31085a96..2e358b4a3cb 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -3171,7 +3171,7 @@ TEST_F(FormatTest, ExpressionIndentationBreakingBeforeOperators) {
// everything until something with the same indent as the operator is found.
// FIXME: Is this a good system?
FormatStyle Style = getLLVMStyle();
- Style.BreakBeforeBinaryOperators = true;
+ Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
verifyFormat(
"bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
" + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
@@ -3224,6 +3224,15 @@ TEST_F(FormatTest, ExpressionIndentationBreakingBeforeOperators) {
Style);
}
+TEST_F(FormatTest, BreakingBeforeNonAssigmentOperators) {
+ FormatStyle Style = getLLVMStyle();
+ Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
+ verifyFormat("int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
+ " + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;", Style);
+
+}
+
TEST_F(FormatTest, ConstructorInitializers) {
verifyFormat("Constructor() : Initializer(FitsOnTheLine) {}");
verifyFormat("Constructor() : Inttializer(FitsOnTheLine) {}",
@@ -8368,7 +8377,6 @@ TEST_F(FormatTest, ParsesConfigurationBools) {
CHECK_PARSE_BOOL(AlwaysBreakAfterDefinitionReturnType);
CHECK_PARSE_BOOL(AlwaysBreakTemplateDeclarations);
CHECK_PARSE_BOOL(BinPackParameters);
- CHECK_PARSE_BOOL(BreakBeforeBinaryOperators);
CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
CHECK_PARSE_BOOL(BreakConstructorInitializersBeforeComma);
CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine);
@@ -8415,9 +8423,12 @@ TEST_F(FormatTest, ParsesConfiguration) {
CHECK_PARSE("ContinuationIndentWidth: 11", ContinuationIndentWidth, 11u);
Style.PointerAlignment = FormatStyle::PAS_Middle;
- CHECK_PARSE("PointerAlignment: Left", PointerAlignment, FormatStyle::PAS_Left);
- CHECK_PARSE("PointerAlignment: Right", PointerAlignment, FormatStyle::PAS_Right);
- CHECK_PARSE("PointerAlignment: Middle", PointerAlignment, FormatStyle::PAS_Middle);
+ CHECK_PARSE("PointerAlignment: Left", PointerAlignment,
+ FormatStyle::PAS_Left);
+ CHECK_PARSE("PointerAlignment: Right", PointerAlignment,
+ FormatStyle::PAS_Right);
+ CHECK_PARSE("PointerAlignment: Middle", PointerAlignment,
+ FormatStyle::PAS_Middle);
Style.Standard = FormatStyle::LS_Auto;
CHECK_PARSE("Standard: Cpp03", Standard, FormatStyle::LS_Cpp03);
@@ -8426,6 +8437,18 @@ TEST_F(FormatTest, ParsesConfiguration) {
CHECK_PARSE("Standard: C++11", Standard, FormatStyle::LS_Cpp11);
CHECK_PARSE("Standard: Auto", Standard, FormatStyle::LS_Auto);
+ Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
+ CHECK_PARSE("BreakBeforeBinaryOperators: false", BreakBeforeBinaryOperators,
+ FormatStyle::BOS_None);
+ CHECK_PARSE("BreakBeforeBinaryOperators: NonAssignment",
+ BreakBeforeBinaryOperators, FormatStyle::BOS_NonAssignment);
+ CHECK_PARSE("BreakBeforeBinaryOperators: true", BreakBeforeBinaryOperators,
+ FormatStyle::BOS_All);
+ CHECK_PARSE("BreakBeforeBinaryOperators: None", BreakBeforeBinaryOperators,
+ FormatStyle::BOS_None);
+ CHECK_PARSE("BreakBeforeBinaryOperators: All", BreakBeforeBinaryOperators,
+ FormatStyle::BOS_All);
+
Style.UseTab = FormatStyle::UT_ForIndentation;
CHECK_PARSE("UseTab: false", UseTab, FormatStyle::UT_Never);
CHECK_PARSE("UseTab: true", UseTab, FormatStyle::UT_Always);
OpenPOWER on IntegriCloud