diff options
| author | Daniel Jasper <djasper@google.com> | 2014-09-16 16:22:30 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-09-16 16:22:30 +0000 |
| commit | 0085300a240208b0089eddf7859b5654a3ab3184 (patch) | |
| tree | b7166ed2655c2a614deb14303a18a157da47bc13 /clang/unittests/Format | |
| parent | 4be38d724fbdd74e77ab89eaefc2b5bab73f00af (diff) | |
| download | bcm5719-llvm-0085300a240208b0089eddf7859b5654a3ab3184.tar.gz bcm5719-llvm-0085300a240208b0089eddf7859b5654a3ab3184.zip | |
clang-format: Restructure and add missing tests.
Patch by Jean-Philippe Dufraigne, Thank you!
llvm-svn: 217880
Diffstat (limited to 'clang/unittests/Format')
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 2e358b4a3cb..4b0791d673b 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -8364,6 +8364,11 @@ TEST_F(FormatTest, GetsCorrectBasedOnStyle) { EXPECT_EQ(0, parseConfiguration(#FIELD ": false", &Style).value()); \ EXPECT_FALSE(Style.FIELD); +#define CHECK_PARSE(TEXT, FIELD, VALUE) \ + EXPECT_NE(VALUE, Style.FIELD); \ + EXPECT_EQ(0, parseConfiguration(TEXT, &Style).value()); \ + EXPECT_EQ(VALUE, Style.FIELD) + TEST_F(FormatTest, ParsesConfigurationBools) { FormatStyle Style = {}; Style.Language = FormatStyle::LK_Cpp; @@ -8381,6 +8386,9 @@ TEST_F(FormatTest, ParsesConfigurationBools) { CHECK_PARSE_BOOL(BreakConstructorInitializersBeforeComma); CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine); CHECK_PARSE_BOOL(DerivePointerAlignment); + // For backward compatibility: + CHECK_PARSE("DerivePointerBinding: true", DerivePointerAlignment, true); + CHECK_PARSE("DerivePointerBinding: false", DerivePointerAlignment, false); CHECK_PARSE_BOOL(IndentCaseLabels); CHECK_PARSE_BOOL(IndentWrappedFunctionNames); CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks); @@ -8399,11 +8407,6 @@ TEST_F(FormatTest, ParsesConfigurationBools) { #undef CHECK_PARSE_BOOL -#define CHECK_PARSE(TEXT, FIELD, VALUE) \ - EXPECT_NE(VALUE, Style.FIELD); \ - EXPECT_EQ(0, parseConfiguration(TEXT, &Style).value()); \ - EXPECT_EQ(VALUE, Style.FIELD) - TEST_F(FormatTest, ParsesConfiguration) { FormatStyle Style = {}; Style.Language = FormatStyle::LK_Cpp; @@ -8429,6 +8432,13 @@ TEST_F(FormatTest, ParsesConfiguration) { FormatStyle::PAS_Right); CHECK_PARSE("PointerAlignment: Middle", PointerAlignment, FormatStyle::PAS_Middle); + // For backward compatibility: + CHECK_PARSE("PointerBindsToType: Left", PointerAlignment, + FormatStyle::PAS_Left); + CHECK_PARSE("PointerBindsToType: Right", PointerAlignment, + FormatStyle::PAS_Right); + CHECK_PARSE("PointerBindsToType: Middle", PointerAlignment, + FormatStyle::PAS_Middle); Style.Standard = FormatStyle::LS_Auto; CHECK_PARSE("Standard: Cpp03", Standard, FormatStyle::LS_Cpp03); @@ -8438,35 +8448,38 @@ TEST_F(FormatTest, ParsesConfiguration) { 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); + // For backward compatibility: + CHECK_PARSE("BreakBeforeBinaryOperators: false", BreakBeforeBinaryOperators, + FormatStyle::BOS_None); + CHECK_PARSE("BreakBeforeBinaryOperators: true", 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); CHECK_PARSE("UseTab: Never", UseTab, FormatStyle::UT_Never); CHECK_PARSE("UseTab: ForIndentation", UseTab, FormatStyle::UT_ForIndentation); CHECK_PARSE("UseTab: Always", UseTab, FormatStyle::UT_Always); + // For backward compatibility: + CHECK_PARSE("UseTab: false", UseTab, FormatStyle::UT_Never); + CHECK_PARSE("UseTab: true", UseTab, FormatStyle::UT_Always); Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline; - CHECK_PARSE("AllowShortFunctionsOnASingleLine: false", - AllowShortFunctionsOnASingleLine, FormatStyle::SFS_None); - CHECK_PARSE("AllowShortFunctionsOnASingleLine: true", - AllowShortFunctionsOnASingleLine, FormatStyle::SFS_All); CHECK_PARSE("AllowShortFunctionsOnASingleLine: None", AllowShortFunctionsOnASingleLine, FormatStyle::SFS_None); CHECK_PARSE("AllowShortFunctionsOnASingleLine: Inline", AllowShortFunctionsOnASingleLine, FormatStyle::SFS_Inline); CHECK_PARSE("AllowShortFunctionsOnASingleLine: All", AllowShortFunctionsOnASingleLine, FormatStyle::SFS_All); + // For backward compatibility: + CHECK_PARSE("AllowShortFunctionsOnASingleLine: false", + AllowShortFunctionsOnASingleLine, FormatStyle::SFS_None); + CHECK_PARSE("AllowShortFunctionsOnASingleLine: true", + AllowShortFunctionsOnASingleLine, FormatStyle::SFS_All); Style.SpaceBeforeParens = FormatStyle::SBPO_Always; CHECK_PARSE("SpaceBeforeParens: Never", SpaceBeforeParens, @@ -8791,7 +8804,10 @@ TEST_F(FormatTest, ConstructorInitializerIndentWidth) { ": aaaaaaaaaaaaa(aaaaaaaaaaaaaa), aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n" " aaaaaaaaaaaaa(aaaaaaaaaaaaaa) {}", Style); +} +TEST_F(FormatTest, BreakConstructorInitializersBeforeComma) { + FormatStyle Style = getLLVMStyle(); Style.BreakConstructorInitializersBeforeComma = true; Style.ConstructorInitializerIndentWidth = 4; verifyFormat("SomeClass::Constructor()\n" |

