[clang-format][NFC] Remove CRs at EOLs introduced in 617277e7cbda
authorOwen Pan <owenpiano@gmail.com>
Tue, 3 Jan 2023 03:06:00 +0000 (19:06 -0800)
committerOwen Pan <owenpiano@gmail.com>
Tue, 3 Jan 2023 03:13:51 +0000 (19:13 -0800)
clang/unittests/Format/ConfigParseTest.cpp

index 777b2c2..d1c9093 100644 (file)
-//===- unittest/Format/ConfigParseTest.cpp - Config parsing unit tests ----===//\r
-//\r
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\r
-// See https://llvm.org/LICENSE.txt for license information.\r
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\r
-//\r
-//===----------------------------------------------------------------------===//\r
-\r
-#include "clang/Format/Format.h"\r
-\r
-#include "llvm/Support/VirtualFileSystem.h"\r
-#include "gtest/gtest.h"\r
-\r
-namespace clang {\r
-namespace format {\r
-namespace {\r
-\r
-FormatStyle getGoogleStyle() { return getGoogleStyle(FormatStyle::LK_Cpp); }\r
-\r
-#define EXPECT_ALL_STYLES_EQUAL(Styles)                                        \\r
-  for (size_t i = 1; i < Styles.size(); ++i)                                   \\r
-  EXPECT_EQ(Styles[0], Styles[i])                                              \\r
-      << "Style #" << i << " of " << Styles.size() << " differs from Style #0"\r
-\r
-TEST(ConfigParseTest, GetsPredefinedStyleByName) {\r
-  SmallVector<FormatStyle, 3> Styles;\r
-  Styles.resize(3);\r
-\r
-  Styles[0] = getLLVMStyle();\r
-  EXPECT_TRUE(getPredefinedStyle("LLVM", FormatStyle::LK_Cpp, &Styles[1]));\r
-  EXPECT_TRUE(getPredefinedStyle("lLvM", FormatStyle::LK_Cpp, &Styles[2]));\r
-  EXPECT_ALL_STYLES_EQUAL(Styles);\r
-\r
-  Styles[0] = getGoogleStyle();\r
-  EXPECT_TRUE(getPredefinedStyle("Google", FormatStyle::LK_Cpp, &Styles[1]));\r
-  EXPECT_TRUE(getPredefinedStyle("gOOgle", FormatStyle::LK_Cpp, &Styles[2]));\r
-  EXPECT_ALL_STYLES_EQUAL(Styles);\r
-\r
-  Styles[0] = getGoogleStyle(FormatStyle::LK_JavaScript);\r
-  EXPECT_TRUE(\r
-      getPredefinedStyle("Google", FormatStyle::LK_JavaScript, &Styles[1]));\r
-  EXPECT_TRUE(\r
-      getPredefinedStyle("gOOgle", FormatStyle::LK_JavaScript, &Styles[2]));\r
-  EXPECT_ALL_STYLES_EQUAL(Styles);\r
-\r
-  Styles[0] = getChromiumStyle(FormatStyle::LK_Cpp);\r
-  EXPECT_TRUE(getPredefinedStyle("Chromium", FormatStyle::LK_Cpp, &Styles[1]));\r
-  EXPECT_TRUE(getPredefinedStyle("cHRoMiUM", FormatStyle::LK_Cpp, &Styles[2]));\r
-  EXPECT_ALL_STYLES_EQUAL(Styles);\r
-\r
-  Styles[0] = getMozillaStyle();\r
-  EXPECT_TRUE(getPredefinedStyle("Mozilla", FormatStyle::LK_Cpp, &Styles[1]));\r
-  EXPECT_TRUE(getPredefinedStyle("moZILla", FormatStyle::LK_Cpp, &Styles[2]));\r
-  EXPECT_ALL_STYLES_EQUAL(Styles);\r
-\r
-  Styles[0] = getWebKitStyle();\r
-  EXPECT_TRUE(getPredefinedStyle("WebKit", FormatStyle::LK_Cpp, &Styles[1]));\r
-  EXPECT_TRUE(getPredefinedStyle("wEbKit", FormatStyle::LK_Cpp, &Styles[2]));\r
-  EXPECT_ALL_STYLES_EQUAL(Styles);\r
-\r
-  Styles[0] = getGNUStyle();\r
-  EXPECT_TRUE(getPredefinedStyle("GNU", FormatStyle::LK_Cpp, &Styles[1]));\r
-  EXPECT_TRUE(getPredefinedStyle("gnU", FormatStyle::LK_Cpp, &Styles[2]));\r
-  EXPECT_ALL_STYLES_EQUAL(Styles);\r
-\r
-  EXPECT_FALSE(getPredefinedStyle("qwerty", FormatStyle::LK_Cpp, &Styles[0]));\r
-}\r
-\r
-TEST(ConfigParseTest, GetsCorrectBasedOnStyle) {\r
-  SmallVector<FormatStyle, 8> Styles;\r
-  Styles.resize(2);\r
-\r
-  Styles[0] = getGoogleStyle();\r
-  Styles[1] = getLLVMStyle();\r
-  EXPECT_EQ(0, parseConfiguration("BasedOnStyle: Google", &Styles[1]).value());\r
-  EXPECT_ALL_STYLES_EQUAL(Styles);\r
-\r
-  Styles.resize(5);\r
-  Styles[0] = getGoogleStyle(FormatStyle::LK_JavaScript);\r
-  Styles[1] = getLLVMStyle();\r
-  Styles[1].Language = FormatStyle::LK_JavaScript;\r
-  EXPECT_EQ(0, parseConfiguration("BasedOnStyle: Google", &Styles[1]).value());\r
-\r
-  Styles[2] = getLLVMStyle();\r
-  Styles[2].Language = FormatStyle::LK_JavaScript;\r
-  EXPECT_EQ(0, parseConfiguration("Language: JavaScript\n"\r
-                                  "BasedOnStyle: Google",\r
-                                  &Styles[2])\r
-                   .value());\r
-\r
-  Styles[3] = getLLVMStyle();\r
-  Styles[3].Language = FormatStyle::LK_JavaScript;\r
-  EXPECT_EQ(0, parseConfiguration("BasedOnStyle: Google\n"\r
-                                  "Language: JavaScript",\r
-                                  &Styles[3])\r
-                   .value());\r
-\r
-  Styles[4] = getLLVMStyle();\r
-  Styles[4].Language = FormatStyle::LK_JavaScript;\r
-  EXPECT_EQ(0, parseConfiguration("---\n"\r
-                                  "BasedOnStyle: LLVM\n"\r
-                                  "IndentWidth: 123\n"\r
-                                  "---\n"\r
-                                  "BasedOnStyle: Google\n"\r
-                                  "Language: JavaScript",\r
-                                  &Styles[4])\r
-                   .value());\r
-  EXPECT_ALL_STYLES_EQUAL(Styles);\r
-}\r
-\r
-#define CHECK_PARSE_BOOL_FIELD(FIELD, CONFIG_NAME)                             \\r
-  Style.FIELD = false;                                                         \\r
-  EXPECT_EQ(0, parseConfiguration(CONFIG_NAME ": true", &Style).value());      \\r
-  EXPECT_TRUE(Style.FIELD);                                                    \\r
-  EXPECT_EQ(0, parseConfiguration(CONFIG_NAME ": false", &Style).value());     \\r
-  EXPECT_FALSE(Style.FIELD)\r
-\r
-#define CHECK_PARSE_BOOL(FIELD) CHECK_PARSE_BOOL_FIELD(FIELD, #FIELD)\r
-\r
-#define CHECK_PARSE_NESTED_BOOL_FIELD(STRUCT, FIELD, CONFIG_NAME)              \\r
-  Style.STRUCT.FIELD = false;                                                  \\r
-  EXPECT_EQ(0,                                                                 \\r
-            parseConfiguration(#STRUCT ":\n  " CONFIG_NAME ": true", &Style)   \\r
-                .value());                                                     \\r
-  EXPECT_TRUE(Style.STRUCT.FIELD);                                             \\r
-  EXPECT_EQ(0,                                                                 \\r
-            parseConfiguration(#STRUCT ":\n  " CONFIG_NAME ": false", &Style)  \\r
-                .value());                                                     \\r
-  EXPECT_FALSE(Style.STRUCT.FIELD)\r
-\r
-#define CHECK_PARSE_NESTED_BOOL(STRUCT, FIELD)                                 \\r
-  CHECK_PARSE_NESTED_BOOL_FIELD(STRUCT, FIELD, #FIELD)\r
-\r
-#define CHECK_PARSE(TEXT, FIELD, VALUE)                                        \\r
-  EXPECT_NE(VALUE, Style.FIELD) << "Initial value already the same!";          \\r
-  EXPECT_EQ(0, parseConfiguration(TEXT, &Style).value());                      \\r
-  EXPECT_EQ(VALUE, Style.FIELD) << "Unexpected value after parsing!"\r
-\r
-#define CHECK_PARSE_NESTED_VALUE(TEXT, STRUCT, FIELD, VALUE)                   \\r
-  EXPECT_NE(VALUE, Style.STRUCT.FIELD) << "Initial value already the same!";   \\r
-  EXPECT_EQ(0, parseConfiguration(#STRUCT ":\n  " TEXT, &Style).value());      \\r
-  EXPECT_EQ(VALUE, Style.STRUCT.FIELD) << "Unexpected value after parsing!"\r
-\r
-TEST(ConfigParseTest, ParsesConfigurationBools) {\r
-  FormatStyle Style = {};\r
-  Style.Language = FormatStyle::LK_Cpp;\r
-  CHECK_PARSE_BOOL(AllowAllArgumentsOnNextLine);\r
-  CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);\r
-  CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);\r
-  CHECK_PARSE_BOOL(AllowShortEnumsOnASingleLine);\r
-  CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);\r
-  CHECK_PARSE_BOOL(BinPackArguments);\r
-  CHECK_PARSE_BOOL(BinPackParameters);\r
-  CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);\r
-  CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);\r
-  CHECK_PARSE_BOOL(BreakStringLiterals);\r
-  CHECK_PARSE_BOOL(CompactNamespaces);\r
-  CHECK_PARSE_BOOL(DeriveLineEnding);\r
-  CHECK_PARSE_BOOL(DerivePointerAlignment);\r
-  CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding");\r
-  CHECK_PARSE_BOOL(DisableFormat);\r
-  CHECK_PARSE_BOOL(IndentAccessModifiers);\r
-  CHECK_PARSE_BOOL(IndentCaseLabels);\r
-  CHECK_PARSE_BOOL(IndentCaseBlocks);\r
-  CHECK_PARSE_BOOL(IndentGotoLabels);\r
-  CHECK_PARSE_BOOL_FIELD(IndentRequiresClause, "IndentRequires");\r
-  CHECK_PARSE_BOOL(IndentRequiresClause);\r
-  CHECK_PARSE_BOOL(IndentWrappedFunctionNames);\r
-  CHECK_PARSE_BOOL(InsertBraces);\r
-  CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);\r
-  CHECK_PARSE_BOOL(ObjCSpaceAfterProperty);\r
-  CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);\r
-  CHECK_PARSE_BOOL(Cpp11BracedListStyle);\r
-  CHECK_PARSE_BOOL(ReflowComments);\r
-  CHECK_PARSE_BOOL(RemoveBracesLLVM);\r
-  CHECK_PARSE_BOOL(RemoveSemicolon);\r
-  CHECK_PARSE_BOOL(SortUsingDeclarations);\r
-  CHECK_PARSE_BOOL(SpacesInParentheses);\r
-  CHECK_PARSE_BOOL(SpacesInSquareBrackets);\r
-  CHECK_PARSE_BOOL(SpacesInConditionalStatement);\r
-  CHECK_PARSE_BOOL(SpaceInEmptyBlock);\r
-  CHECK_PARSE_BOOL(SpaceInEmptyParentheses);\r
-  CHECK_PARSE_BOOL(SpacesInContainerLiterals);\r
-  CHECK_PARSE_BOOL(SpacesInCStyleCastParentheses);\r
-  CHECK_PARSE_BOOL(SpaceAfterCStyleCast);\r
-  CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);\r
-  CHECK_PARSE_BOOL(SpaceAfterLogicalNot);\r
-  CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);\r
-  CHECK_PARSE_BOOL(SpaceBeforeCaseColon);\r
-  CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList);\r
-  CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);\r
-  CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);\r
-  CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);\r
-  CHECK_PARSE_BOOL(SpaceBeforeSquareBrackets);\r
-  CHECK_PARSE_BOOL(UseCRLF);\r
-\r
-  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterCaseLabel);\r
-  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterClass);\r
-  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterEnum);\r
-  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterFunction);\r
-  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterNamespace);\r
-  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterObjCDeclaration);\r
-  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterStruct);\r
-  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterUnion);\r
-  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterExternBlock);\r
-  CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeCatch);\r
-  CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeElse);\r
-  CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeLambdaBody);\r
-  CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeWhile);\r
-  CHECK_PARSE_NESTED_BOOL(BraceWrapping, IndentBraces);\r
-  CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyFunction);\r
-  CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyRecord);\r
-  CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyNamespace);\r
-  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterControlStatements);\r
-  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterForeachMacros);\r
-  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions,\r
-                          AfterFunctionDeclarationName);\r
-  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions,\r
-                          AfterFunctionDefinitionName);\r
-  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterIfMacros);\r
-  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterOverloadedOperator);\r
-  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, BeforeNonEmptyParentheses);\r
-}\r
-\r
-#undef CHECK_PARSE_BOOL\r
-\r
-TEST(ConfigParseTest, ParsesConfiguration) {\r
-  FormatStyle Style = {};\r
-  Style.Language = FormatStyle::LK_Cpp;\r
-  CHECK_PARSE("AccessModifierOffset: -1234", AccessModifierOffset, -1234);\r
-  CHECK_PARSE("ConstructorInitializerIndentWidth: 1234",\r
-              ConstructorInitializerIndentWidth, 1234u);\r
-  CHECK_PARSE("ObjCBlockIndentWidth: 1234", ObjCBlockIndentWidth, 1234u);\r
-  CHECK_PARSE("ColumnLimit: 1234", ColumnLimit, 1234u);\r
-  CHECK_PARSE("MaxEmptyLinesToKeep: 1234", MaxEmptyLinesToKeep, 1234u);\r
-  CHECK_PARSE("PenaltyBreakAssignment: 1234", PenaltyBreakAssignment, 1234u);\r
-  CHECK_PARSE("PenaltyBreakBeforeFirstCallParameter: 1234",\r
-              PenaltyBreakBeforeFirstCallParameter, 1234u);\r
-  CHECK_PARSE("PenaltyBreakTemplateDeclaration: 1234",\r
-              PenaltyBreakTemplateDeclaration, 1234u);\r
-  CHECK_PARSE("PenaltyBreakOpenParenthesis: 1234", PenaltyBreakOpenParenthesis,\r
-              1234u);\r
-  CHECK_PARSE("PenaltyExcessCharacter: 1234", PenaltyExcessCharacter, 1234u);\r
-  CHECK_PARSE("PenaltyReturnTypeOnItsOwnLine: 1234",\r
-              PenaltyReturnTypeOnItsOwnLine, 1234u);\r
-  CHECK_PARSE("SpacesBeforeTrailingComments: 1234",\r
-              SpacesBeforeTrailingComments, 1234u);\r
-  CHECK_PARSE("IndentWidth: 32", IndentWidth, 32u);\r
-  CHECK_PARSE("ContinuationIndentWidth: 11", ContinuationIndentWidth, 11u);\r
-  CHECK_PARSE("CommentPragmas: '// abc$'", CommentPragmas, "// abc$");\r
-\r
-  Style.QualifierAlignment = FormatStyle::QAS_Right;\r
-  CHECK_PARSE("QualifierAlignment: Leave", QualifierAlignment,\r
-              FormatStyle::QAS_Leave);\r
-  CHECK_PARSE("QualifierAlignment: Right", QualifierAlignment,\r
-              FormatStyle::QAS_Right);\r
-  CHECK_PARSE("QualifierAlignment: Left", QualifierAlignment,\r
-              FormatStyle::QAS_Left);\r
-  CHECK_PARSE("QualifierAlignment: Custom", QualifierAlignment,\r
-              FormatStyle::QAS_Custom);\r
-\r
-  Style.QualifierOrder.clear();\r
-  CHECK_PARSE("QualifierOrder: [ const, volatile, type ]", QualifierOrder,\r
-              std::vector<std::string>({"const", "volatile", "type"}));\r
-  Style.QualifierOrder.clear();\r
-  CHECK_PARSE("QualifierOrder: [const, type]", QualifierOrder,\r
-              std::vector<std::string>({"const", "type"}));\r
-  Style.QualifierOrder.clear();\r
-  CHECK_PARSE("QualifierOrder: [volatile, type]", QualifierOrder,\r
-              std::vector<std::string>({"volatile", "type"}));\r
-\r
-#define CHECK_ALIGN_CONSECUTIVE(FIELD)                                         \\r
-  do {                                                                         \\r
-    Style.FIELD.Enabled = true;                                                \\r
-    CHECK_PARSE(#FIELD ": None", FIELD,                                        \\r
-                FormatStyle::AlignConsecutiveStyle(                            \\r
-                    {/*Enabled=*/false, /*AcrossEmptyLines=*/false,            \\r
-                     /*AcrossComments=*/false, /*AlignCompound=*/false,        \\r
-                     /*PadOperators=*/true}));                                 \\r
-    CHECK_PARSE(#FIELD ": Consecutive", FIELD,                                 \\r
-                FormatStyle::AlignConsecutiveStyle(                            \\r
-                    {/*Enabled=*/true, /*AcrossEmptyLines=*/false,             \\r
-                     /*AcrossComments=*/false, /*AlignCompound=*/false,        \\r
-                     /*PadOperators=*/true}));                                 \\r
-    CHECK_PARSE(#FIELD ": AcrossEmptyLines", FIELD,                            \\r
-                FormatStyle::AlignConsecutiveStyle(                            \\r
-                    {/*Enabled=*/true, /*AcrossEmptyLines=*/true,              \\r
-                     /*AcrossComments=*/false, /*AlignCompound=*/false,        \\r
-                     /*PadOperators=*/true}));                                 \\r
-    CHECK_PARSE(#FIELD ": AcrossEmptyLinesAndComments", FIELD,                 \\r
-                FormatStyle::AlignConsecutiveStyle(                            \\r
-                    {/*Enabled=*/true, /*AcrossEmptyLines=*/true,              \\r
-                     /*AcrossComments=*/true, /*AlignCompound=*/false,         \\r
-                     /*PadOperators=*/true}));                                 \\r
-    /* For backwards compability, false / true should still parse */           \\r
-    CHECK_PARSE(#FIELD ": false", FIELD,                                       \\r
-                FormatStyle::AlignConsecutiveStyle(                            \\r
-                    {/*Enabled=*/false, /*AcrossEmptyLines=*/false,            \\r
-                     /*AcrossComments=*/false, /*AlignCompound=*/false,        \\r
-                     /*PadOperators=*/true}));                                 \\r
-    CHECK_PARSE(#FIELD ": true", FIELD,                                        \\r
-                FormatStyle::AlignConsecutiveStyle(                            \\r
-                    {/*Enabled=*/true, /*AcrossEmptyLines=*/false,             \\r
-                     /*AcrossComments=*/false, /*AlignCompound=*/false,        \\r
-                     /*PadOperators=*/true}));                                 \\r
-                                                                               \\r
-    CHECK_PARSE_NESTED_BOOL(FIELD, Enabled);                                   \\r
-    CHECK_PARSE_NESTED_BOOL(FIELD, AcrossEmptyLines);                          \\r
-    CHECK_PARSE_NESTED_BOOL(FIELD, AcrossComments);                            \\r
-    CHECK_PARSE_NESTED_BOOL(FIELD, AlignCompound);                             \\r
-    CHECK_PARSE_NESTED_BOOL(FIELD, PadOperators);                              \\r
-  } while (false)\r
-\r
-  CHECK_ALIGN_CONSECUTIVE(AlignConsecutiveAssignments);\r
-  CHECK_ALIGN_CONSECUTIVE(AlignConsecutiveBitFields);\r
-  CHECK_ALIGN_CONSECUTIVE(AlignConsecutiveMacros);\r
-  CHECK_ALIGN_CONSECUTIVE(AlignConsecutiveDeclarations);\r
-\r
-#undef CHECK_ALIGN_CONSECUTIVE\r
-\r
-  Style.PointerAlignment = FormatStyle::PAS_Middle;\r
-  CHECK_PARSE("PointerAlignment: Left", PointerAlignment,\r
-              FormatStyle::PAS_Left);\r
-  CHECK_PARSE("PointerAlignment: Right", PointerAlignment,\r
-              FormatStyle::PAS_Right);\r
-  CHECK_PARSE("PointerAlignment: Middle", PointerAlignment,\r
-              FormatStyle::PAS_Middle);\r
-  Style.ReferenceAlignment = FormatStyle::RAS_Middle;\r
-  CHECK_PARSE("ReferenceAlignment: Pointer", ReferenceAlignment,\r
-              FormatStyle::RAS_Pointer);\r
-  CHECK_PARSE("ReferenceAlignment: Left", ReferenceAlignment,\r
-              FormatStyle::RAS_Left);\r
-  CHECK_PARSE("ReferenceAlignment: Right", ReferenceAlignment,\r
-              FormatStyle::RAS_Right);\r
-  CHECK_PARSE("ReferenceAlignment: Middle", ReferenceAlignment,\r
-              FormatStyle::RAS_Middle);\r
-  // For backward compatibility:\r
-  CHECK_PARSE("PointerBindsToType: Left", PointerAlignment,\r
-              FormatStyle::PAS_Left);\r
-  CHECK_PARSE("PointerBindsToType: Right", PointerAlignment,\r
-              FormatStyle::PAS_Right);\r
-  CHECK_PARSE("PointerBindsToType: Middle", PointerAlignment,\r
-              FormatStyle::PAS_Middle);\r
-\r
-  Style.Standard = FormatStyle::LS_Auto;\r
-  CHECK_PARSE("Standard: c++03", Standard, FormatStyle::LS_Cpp03);\r
-  CHECK_PARSE("Standard: c++11", Standard, FormatStyle::LS_Cpp11);\r
-  CHECK_PARSE("Standard: c++14", Standard, FormatStyle::LS_Cpp14);\r
-  CHECK_PARSE("Standard: c++17", Standard, FormatStyle::LS_Cpp17);\r
-  CHECK_PARSE("Standard: c++20", Standard, FormatStyle::LS_Cpp20);\r
-  CHECK_PARSE("Standard: Auto", Standard, FormatStyle::LS_Auto);\r
-  CHECK_PARSE("Standard: Latest", Standard, FormatStyle::LS_Latest);\r
-  // Legacy aliases:\r
-  CHECK_PARSE("Standard: Cpp03", Standard, FormatStyle::LS_Cpp03);\r
-  CHECK_PARSE("Standard: Cpp11", Standard, FormatStyle::LS_Latest);\r
-  CHECK_PARSE("Standard: C++03", Standard, FormatStyle::LS_Cpp03);\r
-  CHECK_PARSE("Standard: C++11", Standard, FormatStyle::LS_Cpp11);\r
-\r
-  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;\r
-  CHECK_PARSE("BreakBeforeBinaryOperators: NonAssignment",\r
-              BreakBeforeBinaryOperators, FormatStyle::BOS_NonAssignment);\r
-  CHECK_PARSE("BreakBeforeBinaryOperators: None", BreakBeforeBinaryOperators,\r
-              FormatStyle::BOS_None);\r
-  CHECK_PARSE("BreakBeforeBinaryOperators: All", BreakBeforeBinaryOperators,\r
-              FormatStyle::BOS_All);\r
-  // For backward compatibility:\r
-  CHECK_PARSE("BreakBeforeBinaryOperators: false", BreakBeforeBinaryOperators,\r
-              FormatStyle::BOS_None);\r
-  CHECK_PARSE("BreakBeforeBinaryOperators: true", BreakBeforeBinaryOperators,\r
-              FormatStyle::BOS_All);\r
-\r
-  Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeColon;\r
-  CHECK_PARSE("BreakConstructorInitializers: BeforeComma",\r
-              BreakConstructorInitializers, FormatStyle::BCIS_BeforeComma);\r
-  CHECK_PARSE("BreakConstructorInitializers: AfterColon",\r
-              BreakConstructorInitializers, FormatStyle::BCIS_AfterColon);\r
-  CHECK_PARSE("BreakConstructorInitializers: BeforeColon",\r
-              BreakConstructorInitializers, FormatStyle::BCIS_BeforeColon);\r
-  // For backward compatibility:\r
-  CHECK_PARSE("BreakConstructorInitializersBeforeComma: true",\r
-              BreakConstructorInitializers, FormatStyle::BCIS_BeforeComma);\r
-\r
-  Style.BreakInheritanceList = FormatStyle::BILS_BeforeColon;\r
-  CHECK_PARSE("BreakInheritanceList: AfterComma", BreakInheritanceList,\r
-              FormatStyle::BILS_AfterComma);\r
-  CHECK_PARSE("BreakInheritanceList: BeforeComma", BreakInheritanceList,\r
-              FormatStyle::BILS_BeforeComma);\r
-  CHECK_PARSE("BreakInheritanceList: AfterColon", BreakInheritanceList,\r
-              FormatStyle::BILS_AfterColon);\r
-  CHECK_PARSE("BreakInheritanceList: BeforeColon", BreakInheritanceList,\r
-              FormatStyle::BILS_BeforeColon);\r
-  // For backward compatibility:\r
-  CHECK_PARSE("BreakBeforeInheritanceComma: true", BreakInheritanceList,\r
-              FormatStyle::BILS_BeforeComma);\r
-\r
-  Style.PackConstructorInitializers = FormatStyle::PCIS_BinPack;\r
-  CHECK_PARSE("PackConstructorInitializers: Never", PackConstructorInitializers,\r
-              FormatStyle::PCIS_Never);\r
-  CHECK_PARSE("PackConstructorInitializers: BinPack",\r
-              PackConstructorInitializers, FormatStyle::PCIS_BinPack);\r
-  CHECK_PARSE("PackConstructorInitializers: CurrentLine",\r
-              PackConstructorInitializers, FormatStyle::PCIS_CurrentLine);\r
-  CHECK_PARSE("PackConstructorInitializers: NextLine",\r
-              PackConstructorInitializers, FormatStyle::PCIS_NextLine);\r
-  // For backward compatibility:\r
-  CHECK_PARSE("BasedOnStyle: Google\n"\r
-              "ConstructorInitializerAllOnOneLineOrOnePerLine: true\n"\r
-              "AllowAllConstructorInitializersOnNextLine: false",\r
-              PackConstructorInitializers, FormatStyle::PCIS_CurrentLine);\r
-  Style.PackConstructorInitializers = FormatStyle::PCIS_NextLine;\r
-  CHECK_PARSE("BasedOnStyle: Google\n"\r
-              "ConstructorInitializerAllOnOneLineOrOnePerLine: false",\r
-              PackConstructorInitializers, FormatStyle::PCIS_BinPack);\r
-  CHECK_PARSE("ConstructorInitializerAllOnOneLineOrOnePerLine: true\n"\r
-              "AllowAllConstructorInitializersOnNextLine: true",\r
-              PackConstructorInitializers, FormatStyle::PCIS_NextLine);\r
-  Style.PackConstructorInitializers = FormatStyle::PCIS_BinPack;\r
-  CHECK_PARSE("ConstructorInitializerAllOnOneLineOrOnePerLine: true\n"\r
-              "AllowAllConstructorInitializersOnNextLine: false",\r
-              PackConstructorInitializers, FormatStyle::PCIS_CurrentLine);\r
-\r
-  Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_LogicalBlock;\r
-  CHECK_PARSE("EmptyLineBeforeAccessModifier: Never",\r
-              EmptyLineBeforeAccessModifier, FormatStyle::ELBAMS_Never);\r
-  CHECK_PARSE("EmptyLineBeforeAccessModifier: Leave",\r
-              EmptyLineBeforeAccessModifier, FormatStyle::ELBAMS_Leave);\r
-  CHECK_PARSE("EmptyLineBeforeAccessModifier: LogicalBlock",\r
-              EmptyLineBeforeAccessModifier, FormatStyle::ELBAMS_LogicalBlock);\r
-  CHECK_PARSE("EmptyLineBeforeAccessModifier: Always",\r
-              EmptyLineBeforeAccessModifier, FormatStyle::ELBAMS_Always);\r
-\r
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;\r
-  CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket,\r
-              FormatStyle::BAS_Align);\r
-  CHECK_PARSE("AlignAfterOpenBracket: DontAlign", AlignAfterOpenBracket,\r
-              FormatStyle::BAS_DontAlign);\r
-  CHECK_PARSE("AlignAfterOpenBracket: AlwaysBreak", AlignAfterOpenBracket,\r
-              FormatStyle::BAS_AlwaysBreak);\r
-  CHECK_PARSE("AlignAfterOpenBracket: BlockIndent", AlignAfterOpenBracket,\r
-              FormatStyle::BAS_BlockIndent);\r
-  // For backward compatibility:\r
-  CHECK_PARSE("AlignAfterOpenBracket: false", AlignAfterOpenBracket,\r
-              FormatStyle::BAS_DontAlign);\r
-  CHECK_PARSE("AlignAfterOpenBracket: true", AlignAfterOpenBracket,\r
-              FormatStyle::BAS_Align);\r
-\r
-  Style.AlignEscapedNewlines = FormatStyle::ENAS_Left;\r
-  CHECK_PARSE("AlignEscapedNewlines: DontAlign", AlignEscapedNewlines,\r
-              FormatStyle::ENAS_DontAlign);\r
-  CHECK_PARSE("AlignEscapedNewlines: Left", AlignEscapedNewlines,\r
-              FormatStyle::ENAS_Left);\r
-  CHECK_PARSE("AlignEscapedNewlines: Right", AlignEscapedNewlines,\r
-              FormatStyle::ENAS_Right);\r
-  // For backward compatibility:\r
-  CHECK_PARSE("AlignEscapedNewlinesLeft: true", AlignEscapedNewlines,\r
-              FormatStyle::ENAS_Left);\r
-  CHECK_PARSE("AlignEscapedNewlinesLeft: false", AlignEscapedNewlines,\r
-              FormatStyle::ENAS_Right);\r
-\r
-  Style.AlignOperands = FormatStyle::OAS_Align;\r
-  CHECK_PARSE("AlignOperands: DontAlign", AlignOperands,\r
-              FormatStyle::OAS_DontAlign);\r
-  CHECK_PARSE("AlignOperands: Align", AlignOperands, FormatStyle::OAS_Align);\r
-  CHECK_PARSE("AlignOperands: AlignAfterOperator", AlignOperands,\r
-              FormatStyle::OAS_AlignAfterOperator);\r
-  // For backward compatibility:\r
-  CHECK_PARSE("AlignOperands: false", AlignOperands,\r
-              FormatStyle::OAS_DontAlign);\r
-  CHECK_PARSE("AlignOperands: true", AlignOperands, FormatStyle::OAS_Align);\r
-\r
-  CHECK_PARSE("AlignTrailingComments: Leave", AlignTrailingComments,\r
-              FormatStyle::TrailingCommentsAlignmentStyle(\r
-                  {FormatStyle::TCAS_Leave, 1}));\r
-  CHECK_PARSE("AlignTrailingComments: Always", AlignTrailingComments,\r
-              FormatStyle::TrailingCommentsAlignmentStyle(\r
-                  {FormatStyle::TCAS_Always, 1}));\r
-  CHECK_PARSE("AlignTrailingComments: Never", AlignTrailingComments,\r
-              FormatStyle::TrailingCommentsAlignmentStyle(\r
-                  {FormatStyle::TCAS_Never, 1}));\r
-  // For backwards compatibility\r
-  CHECK_PARSE("AlignTrailingComments: true", AlignTrailingComments,\r
-              FormatStyle::TrailingCommentsAlignmentStyle(\r
-                  {FormatStyle::TCAS_Always, 1}));\r
-  CHECK_PARSE("AlignTrailingComments: false", AlignTrailingComments,\r
-              FormatStyle::TrailingCommentsAlignmentStyle(\r
-                  {FormatStyle::TCAS_Never, 1}));\r
-  CHECK_PARSE_NESTED_VALUE("Kind: Always", AlignTrailingComments, Kind,\r
-                           FormatStyle::TCAS_Always);\r
-  CHECK_PARSE_NESTED_VALUE("Kind: Never", AlignTrailingComments, Kind,\r
-                           FormatStyle::TCAS_Never);\r
-  CHECK_PARSE_NESTED_VALUE("Kind: Leave", AlignTrailingComments, Kind,\r
-                           FormatStyle::TCAS_Leave);\r
-  CHECK_PARSE_NESTED_VALUE("OverEmptyLines: 1234", AlignTrailingComments,\r
-                           OverEmptyLines, 1234u);\r
-\r
-  Style.UseTab = FormatStyle::UT_ForIndentation;\r
-  CHECK_PARSE("UseTab: Never", UseTab, FormatStyle::UT_Never);\r
-  CHECK_PARSE("UseTab: ForIndentation", UseTab, FormatStyle::UT_ForIndentation);\r
-  CHECK_PARSE("UseTab: Always", UseTab, FormatStyle::UT_Always);\r
-  CHECK_PARSE("UseTab: ForContinuationAndIndentation", UseTab,\r
-              FormatStyle::UT_ForContinuationAndIndentation);\r
-  CHECK_PARSE("UseTab: AlignWithSpaces", UseTab,\r
-              FormatStyle::UT_AlignWithSpaces);\r
-  // For backward compatibility:\r
-  CHECK_PARSE("UseTab: false", UseTab, FormatStyle::UT_Never);\r
-  CHECK_PARSE("UseTab: true", UseTab, FormatStyle::UT_Always);\r
-\r
-  Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Empty;\r
-  CHECK_PARSE("AllowShortBlocksOnASingleLine: Never",\r
-              AllowShortBlocksOnASingleLine, FormatStyle::SBS_Never);\r
-  CHECK_PARSE("AllowShortBlocksOnASingleLine: Empty",\r
-              AllowShortBlocksOnASingleLine, FormatStyle::SBS_Empty);\r
-  CHECK_PARSE("AllowShortBlocksOnASingleLine: Always",\r
-              AllowShortBlocksOnASingleLine, FormatStyle::SBS_Always);\r
-  // For backward compatibility:\r
-  CHECK_PARSE("AllowShortBlocksOnASingleLine: false",\r
-              AllowShortBlocksOnASingleLine, FormatStyle::SBS_Never);\r
-  CHECK_PARSE("AllowShortBlocksOnASingleLine: true",\r
-              AllowShortBlocksOnASingleLine, FormatStyle::SBS_Always);\r
-\r
-  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;\r
-  CHECK_PARSE("AllowShortFunctionsOnASingleLine: None",\r
-              AllowShortFunctionsOnASingleLine, FormatStyle::SFS_None);\r
-  CHECK_PARSE("AllowShortFunctionsOnASingleLine: Inline",\r
-              AllowShortFunctionsOnASingleLine, FormatStyle::SFS_Inline);\r
-  CHECK_PARSE("AllowShortFunctionsOnASingleLine: Empty",\r
-              AllowShortFunctionsOnASingleLine, FormatStyle::SFS_Empty);\r
-  CHECK_PARSE("AllowShortFunctionsOnASingleLine: All",\r
-              AllowShortFunctionsOnASingleLine, FormatStyle::SFS_All);\r
-  // For backward compatibility:\r
-  CHECK_PARSE("AllowShortFunctionsOnASingleLine: false",\r
-              AllowShortFunctionsOnASingleLine, FormatStyle::SFS_None);\r
-  CHECK_PARSE("AllowShortFunctionsOnASingleLine: true",\r
-              AllowShortFunctionsOnASingleLine, FormatStyle::SFS_All);\r
-\r
-  Style.AllowShortLambdasOnASingleLine = FormatStyle::SLS_All;\r
-  CHECK_PARSE("AllowShortLambdasOnASingleLine: None",\r
-              AllowShortLambdasOnASingleLine, FormatStyle::SLS_None);\r
-  CHECK_PARSE("AllowShortLambdasOnASingleLine: Empty",\r
-              AllowShortLambdasOnASingleLine, FormatStyle::SLS_Empty);\r
-  CHECK_PARSE("AllowShortLambdasOnASingleLine: Inline",\r
-              AllowShortLambdasOnASingleLine, FormatStyle::SLS_Inline);\r
-  CHECK_PARSE("AllowShortLambdasOnASingleLine: All",\r
-              AllowShortLambdasOnASingleLine, FormatStyle::SLS_All);\r
-  // For backward compatibility:\r
-  CHECK_PARSE("AllowShortLambdasOnASingleLine: false",\r
-              AllowShortLambdasOnASingleLine, FormatStyle::SLS_None);\r
-  CHECK_PARSE("AllowShortLambdasOnASingleLine: true",\r
-              AllowShortLambdasOnASingleLine, FormatStyle::SLS_All);\r
-\r
-  Style.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Both;\r
-  CHECK_PARSE("SpaceAroundPointerQualifiers: Default",\r
-              SpaceAroundPointerQualifiers, FormatStyle::SAPQ_Default);\r
-  CHECK_PARSE("SpaceAroundPointerQualifiers: Before",\r
-              SpaceAroundPointerQualifiers, FormatStyle::SAPQ_Before);\r
-  CHECK_PARSE("SpaceAroundPointerQualifiers: After",\r
-              SpaceAroundPointerQualifiers, FormatStyle::SAPQ_After);\r
-  CHECK_PARSE("SpaceAroundPointerQualifiers: Both",\r
-              SpaceAroundPointerQualifiers, FormatStyle::SAPQ_Both);\r
-\r
-  Style.SpaceBeforeParens = FormatStyle::SBPO_Always;\r
-  CHECK_PARSE("SpaceBeforeParens: Never", SpaceBeforeParens,\r
-              FormatStyle::SBPO_Never);\r
-  CHECK_PARSE("SpaceBeforeParens: Always", SpaceBeforeParens,\r
-              FormatStyle::SBPO_Always);\r
-  CHECK_PARSE("SpaceBeforeParens: ControlStatements", SpaceBeforeParens,\r
-              FormatStyle::SBPO_ControlStatements);\r
-  CHECK_PARSE("SpaceBeforeParens: ControlStatementsExceptControlMacros",\r
-              SpaceBeforeParens,\r
-              FormatStyle::SBPO_ControlStatementsExceptControlMacros);\r
-  CHECK_PARSE("SpaceBeforeParens: NonEmptyParentheses", SpaceBeforeParens,\r
-              FormatStyle::SBPO_NonEmptyParentheses);\r
-  CHECK_PARSE("SpaceBeforeParens: Custom", SpaceBeforeParens,\r
-              FormatStyle::SBPO_Custom);\r
-  // For backward compatibility:\r
-  CHECK_PARSE("SpaceAfterControlStatementKeyword: false", SpaceBeforeParens,\r
-              FormatStyle::SBPO_Never);\r
-  CHECK_PARSE("SpaceAfterControlStatementKeyword: true", SpaceBeforeParens,\r
-              FormatStyle::SBPO_ControlStatements);\r
-  CHECK_PARSE("SpaceBeforeParens: ControlStatementsExceptForEachMacros",\r
-              SpaceBeforeParens,\r
-              FormatStyle::SBPO_ControlStatementsExceptControlMacros);\r
-\r
-  Style.ColumnLimit = 123;\r
-  FormatStyle BaseStyle = getLLVMStyle();\r
-  CHECK_PARSE("BasedOnStyle: LLVM", ColumnLimit, BaseStyle.ColumnLimit);\r
-  CHECK_PARSE("BasedOnStyle: LLVM\nColumnLimit: 1234", ColumnLimit, 1234u);\r
-\r
-  Style.BreakBeforeBraces = FormatStyle::BS_Stroustrup;\r
-  CHECK_PARSE("BreakBeforeBraces: Attach", BreakBeforeBraces,\r
-              FormatStyle::BS_Attach);\r
-  CHECK_PARSE("BreakBeforeBraces: Linux", BreakBeforeBraces,\r
-              FormatStyle::BS_Linux);\r
-  CHECK_PARSE("BreakBeforeBraces: Mozilla", BreakBeforeBraces,\r
-              FormatStyle::BS_Mozilla);\r
-  CHECK_PARSE("BreakBeforeBraces: Stroustrup", BreakBeforeBraces,\r
-              FormatStyle::BS_Stroustrup);\r
-  CHECK_PARSE("BreakBeforeBraces: Allman", BreakBeforeBraces,\r
-              FormatStyle::BS_Allman);\r
-  CHECK_PARSE("BreakBeforeBraces: Whitesmiths", BreakBeforeBraces,\r
-              FormatStyle::BS_Whitesmiths);\r
-  CHECK_PARSE("BreakBeforeBraces: GNU", BreakBeforeBraces, FormatStyle::BS_GNU);\r
-  CHECK_PARSE("BreakBeforeBraces: WebKit", BreakBeforeBraces,\r
-              FormatStyle::BS_WebKit);\r
-  CHECK_PARSE("BreakBeforeBraces: Custom", BreakBeforeBraces,\r
-              FormatStyle::BS_Custom);\r
-\r
-  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Never;\r
-  CHECK_PARSE("BraceWrapping:\n"\r
-              "  AfterControlStatement: MultiLine",\r
-              BraceWrapping.AfterControlStatement,\r
-              FormatStyle::BWACS_MultiLine);\r
-  CHECK_PARSE("BraceWrapping:\n"\r
-              "  AfterControlStatement: Always",\r
-              BraceWrapping.AfterControlStatement, FormatStyle::BWACS_Always);\r
-  CHECK_PARSE("BraceWrapping:\n"\r
-              "  AfterControlStatement: Never",\r
-              BraceWrapping.AfterControlStatement, FormatStyle::BWACS_Never);\r
-  // For backward compatibility:\r
-  CHECK_PARSE("BraceWrapping:\n"\r
-              "  AfterControlStatement: true",\r
-              BraceWrapping.AfterControlStatement, FormatStyle::BWACS_Always);\r
-  CHECK_PARSE("BraceWrapping:\n"\r
-              "  AfterControlStatement: false",\r
-              BraceWrapping.AfterControlStatement, FormatStyle::BWACS_Never);\r
-\r
-  Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_All;\r
-  CHECK_PARSE("AlwaysBreakAfterReturnType: None", AlwaysBreakAfterReturnType,\r
-              FormatStyle::RTBS_None);\r
-  CHECK_PARSE("AlwaysBreakAfterReturnType: All", AlwaysBreakAfterReturnType,\r
-              FormatStyle::RTBS_All);\r
-  CHECK_PARSE("AlwaysBreakAfterReturnType: TopLevel",\r
-              AlwaysBreakAfterReturnType, FormatStyle::RTBS_TopLevel);\r
-  CHECK_PARSE("AlwaysBreakAfterReturnType: AllDefinitions",\r
-              AlwaysBreakAfterReturnType, FormatStyle::RTBS_AllDefinitions);\r
-  CHECK_PARSE("AlwaysBreakAfterReturnType: TopLevelDefinitions",\r
-              AlwaysBreakAfterReturnType,\r
-              FormatStyle::RTBS_TopLevelDefinitions);\r
-\r
-  Style.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;\r
-  CHECK_PARSE("AlwaysBreakTemplateDeclarations: No",\r
-              AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_No);\r
-  CHECK_PARSE("AlwaysBreakTemplateDeclarations: MultiLine",\r
-              AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_MultiLine);\r
-  CHECK_PARSE("AlwaysBreakTemplateDeclarations: Yes",\r
-              AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_Yes);\r
-  CHECK_PARSE("AlwaysBreakTemplateDeclarations: false",\r
-              AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_MultiLine);\r
-  CHECK_PARSE("AlwaysBreakTemplateDeclarations: true",\r
-              AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_Yes);\r
-\r
-  Style.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All;\r
-  CHECK_PARSE("AlwaysBreakAfterDefinitionReturnType: None",\r
-              AlwaysBreakAfterDefinitionReturnType, FormatStyle::DRTBS_None);\r
-  CHECK_PARSE("AlwaysBreakAfterDefinitionReturnType: All",\r
-              AlwaysBreakAfterDefinitionReturnType, FormatStyle::DRTBS_All);\r
-  CHECK_PARSE("AlwaysBreakAfterDefinitionReturnType: TopLevel",\r
-              AlwaysBreakAfterDefinitionReturnType,\r
-              FormatStyle::DRTBS_TopLevel);\r
-\r
-  Style.NamespaceIndentation = FormatStyle::NI_All;\r
-  CHECK_PARSE("NamespaceIndentation: None", NamespaceIndentation,\r
-              FormatStyle::NI_None);\r
-  CHECK_PARSE("NamespaceIndentation: Inner", NamespaceIndentation,\r
-              FormatStyle::NI_Inner);\r
-  CHECK_PARSE("NamespaceIndentation: All", NamespaceIndentation,\r
-              FormatStyle::NI_All);\r
-\r
-  Style.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_OnlyFirstIf;\r
-  CHECK_PARSE("AllowShortIfStatementsOnASingleLine: Never",\r
-              AllowShortIfStatementsOnASingleLine, FormatStyle::SIS_Never);\r
-  CHECK_PARSE("AllowShortIfStatementsOnASingleLine: WithoutElse",\r
-              AllowShortIfStatementsOnASingleLine,\r
-              FormatStyle::SIS_WithoutElse);\r
-  CHECK_PARSE("AllowShortIfStatementsOnASingleLine: OnlyFirstIf",\r
-              AllowShortIfStatementsOnASingleLine,\r
-              FormatStyle::SIS_OnlyFirstIf);\r
-  CHECK_PARSE("AllowShortIfStatementsOnASingleLine: AllIfsAndElse",\r
-              AllowShortIfStatementsOnASingleLine,\r
-              FormatStyle::SIS_AllIfsAndElse);\r
-  CHECK_PARSE("AllowShortIfStatementsOnASingleLine: Always",\r
-              AllowShortIfStatementsOnASingleLine,\r
-              FormatStyle::SIS_OnlyFirstIf);\r
-  CHECK_PARSE("AllowShortIfStatementsOnASingleLine: false",\r
-              AllowShortIfStatementsOnASingleLine, FormatStyle::SIS_Never);\r
-  CHECK_PARSE("AllowShortIfStatementsOnASingleLine: true",\r
-              AllowShortIfStatementsOnASingleLine,\r
-              FormatStyle::SIS_WithoutElse);\r
-\r
-  Style.IndentExternBlock = FormatStyle::IEBS_NoIndent;\r
-  CHECK_PARSE("IndentExternBlock: AfterExternBlock", IndentExternBlock,\r
-              FormatStyle::IEBS_AfterExternBlock);\r
-  CHECK_PARSE("IndentExternBlock: Indent", IndentExternBlock,\r
-              FormatStyle::IEBS_Indent);\r
-  CHECK_PARSE("IndentExternBlock: NoIndent", IndentExternBlock,\r
-              FormatStyle::IEBS_NoIndent);\r
-  CHECK_PARSE("IndentExternBlock: true", IndentExternBlock,\r
-              FormatStyle::IEBS_Indent);\r
-  CHECK_PARSE("IndentExternBlock: false", IndentExternBlock,\r
-              FormatStyle::IEBS_NoIndent);\r
-\r
-  Style.BitFieldColonSpacing = FormatStyle::BFCS_None;\r
-  CHECK_PARSE("BitFieldColonSpacing: Both", BitFieldColonSpacing,\r
-              FormatStyle::BFCS_Both);\r
-  CHECK_PARSE("BitFieldColonSpacing: None", BitFieldColonSpacing,\r
-              FormatStyle::BFCS_None);\r
-  CHECK_PARSE("BitFieldColonSpacing: Before", BitFieldColonSpacing,\r
-              FormatStyle::BFCS_Before);\r
-  CHECK_PARSE("BitFieldColonSpacing: After", BitFieldColonSpacing,\r
-              FormatStyle::BFCS_After);\r
-\r
-  Style.SortJavaStaticImport = FormatStyle::SJSIO_Before;\r
-  CHECK_PARSE("SortJavaStaticImport: After", SortJavaStaticImport,\r
-              FormatStyle::SJSIO_After);\r
-  CHECK_PARSE("SortJavaStaticImport: Before", SortJavaStaticImport,\r
-              FormatStyle::SJSIO_Before);\r
-\r
-  // FIXME: This is required because parsing a configuration simply overwrites\r
-  // the first N elements of the list instead of resetting it.\r
-  Style.ForEachMacros.clear();\r
-  std::vector<std::string> BoostForeach;\r
-  BoostForeach.push_back("BOOST_FOREACH");\r
-  CHECK_PARSE("ForEachMacros: [BOOST_FOREACH]", ForEachMacros, BoostForeach);\r
-  std::vector<std::string> BoostAndQForeach;\r
-  BoostAndQForeach.push_back("BOOST_FOREACH");\r
-  BoostAndQForeach.push_back("Q_FOREACH");\r
-  CHECK_PARSE("ForEachMacros: [BOOST_FOREACH, Q_FOREACH]", ForEachMacros,\r
-              BoostAndQForeach);\r
-\r
-  Style.IfMacros.clear();\r
-  std::vector<std::string> CustomIfs;\r
-  CustomIfs.push_back("MYIF");\r
-  CHECK_PARSE("IfMacros: [MYIF]", IfMacros, CustomIfs);\r
-\r
-  Style.AttributeMacros.clear();\r
-  CHECK_PARSE("BasedOnStyle: LLVM", AttributeMacros,\r
-              std::vector<std::string>{"__capability"});\r
-  CHECK_PARSE("AttributeMacros: [attr1, attr2]", AttributeMacros,\r
-              std::vector<std::string>({"attr1", "attr2"}));\r
-\r
-  Style.StatementAttributeLikeMacros.clear();\r
-  CHECK_PARSE("StatementAttributeLikeMacros: [emit,Q_EMIT]",\r
-              StatementAttributeLikeMacros,\r
-              std::vector<std::string>({"emit", "Q_EMIT"}));\r
-\r
-  Style.StatementMacros.clear();\r
-  CHECK_PARSE("StatementMacros: [QUNUSED]", StatementMacros,\r
-              std::vector<std::string>{"QUNUSED"});\r
-  CHECK_PARSE("StatementMacros: [QUNUSED, QT_REQUIRE_VERSION]", StatementMacros,\r
-              std::vector<std::string>({"QUNUSED", "QT_REQUIRE_VERSION"}));\r
-\r
-  Style.NamespaceMacros.clear();\r
-  CHECK_PARSE("NamespaceMacros: [TESTSUITE]", NamespaceMacros,\r
-              std::vector<std::string>{"TESTSUITE"});\r
-  CHECK_PARSE("NamespaceMacros: [TESTSUITE, SUITE]", NamespaceMacros,\r
-              std::vector<std::string>({"TESTSUITE", "SUITE"}));\r
-\r
-  Style.WhitespaceSensitiveMacros.clear();\r
-  CHECK_PARSE("WhitespaceSensitiveMacros: [STRINGIZE]",\r
-              WhitespaceSensitiveMacros, std::vector<std::string>{"STRINGIZE"});\r
-  CHECK_PARSE("WhitespaceSensitiveMacros: [STRINGIZE, ASSERT]",\r
-              WhitespaceSensitiveMacros,\r
-              std::vector<std::string>({"STRINGIZE", "ASSERT"}));\r
-  Style.WhitespaceSensitiveMacros.clear();\r
-  CHECK_PARSE("WhitespaceSensitiveMacros: ['STRINGIZE']",\r
-              WhitespaceSensitiveMacros, std::vector<std::string>{"STRINGIZE"});\r
-  CHECK_PARSE("WhitespaceSensitiveMacros: ['STRINGIZE', 'ASSERT']",\r
-              WhitespaceSensitiveMacros,\r
-              std::vector<std::string>({"STRINGIZE", "ASSERT"}));\r
-\r
-  Style.IncludeStyle.IncludeCategories.clear();\r
-  std::vector<tooling::IncludeStyle::IncludeCategory> ExpectedCategories = {\r
-      {"abc/.*", 2, 0, false}, {".*", 1, 0, true}};\r
-  CHECK_PARSE("IncludeCategories:\n"\r
-              "  - Regex: abc/.*\n"\r
-              "    Priority: 2\n"\r
-              "  - Regex: .*\n"\r
-              "    Priority: 1\n"\r
-              "    CaseSensitive: true\n",\r
-              IncludeStyle.IncludeCategories, ExpectedCategories);\r
-  CHECK_PARSE("IncludeIsMainRegex: 'abc$'", IncludeStyle.IncludeIsMainRegex,\r
-              "abc$");\r
-  CHECK_PARSE("IncludeIsMainSourceRegex: 'abc$'",\r
-              IncludeStyle.IncludeIsMainSourceRegex, "abc$");\r
-\r
-  Style.SortIncludes = FormatStyle::SI_Never;\r
-  CHECK_PARSE("SortIncludes: true", SortIncludes,\r
-              FormatStyle::SI_CaseSensitive);\r
-  CHECK_PARSE("SortIncludes: false", SortIncludes, FormatStyle::SI_Never);\r
-  CHECK_PARSE("SortIncludes: CaseInsensitive", SortIncludes,\r
-              FormatStyle::SI_CaseInsensitive);\r
-  CHECK_PARSE("SortIncludes: CaseSensitive", SortIncludes,\r
-              FormatStyle::SI_CaseSensitive);\r
-  CHECK_PARSE("SortIncludes: Never", SortIncludes, FormatStyle::SI_Never);\r
-\r
-  Style.RawStringFormats.clear();\r
-  std::vector<FormatStyle::RawStringFormat> ExpectedRawStringFormats = {\r
-      {\r
-          FormatStyle::LK_TextProto,\r
-          {"pb", "proto"},\r
-          {"PARSE_TEXT_PROTO"},\r
-          /*CanonicalDelimiter=*/"",\r
-          "llvm",\r
-      },\r
-      {\r
-          FormatStyle::LK_Cpp,\r
-          {"cc", "cpp"},\r
-          {"C_CODEBLOCK", "CPPEVAL"},\r
-          /*CanonicalDelimiter=*/"cc",\r
-          /*BasedOnStyle=*/"",\r
-      },\r
-  };\r
-\r
-  CHECK_PARSE("RawStringFormats:\n"\r
-              "  - Language: TextProto\n"\r
-              "    Delimiters:\n"\r
-              "      - 'pb'\n"\r
-              "      - 'proto'\n"\r
-              "    EnclosingFunctions:\n"\r
-              "      - 'PARSE_TEXT_PROTO'\n"\r
-              "    BasedOnStyle: llvm\n"\r
-              "  - Language: Cpp\n"\r
-              "    Delimiters:\n"\r
-              "      - 'cc'\n"\r
-              "      - 'cpp'\n"\r
-              "    EnclosingFunctions:\n"\r
-              "      - 'C_CODEBLOCK'\n"\r
-              "      - 'CPPEVAL'\n"\r
-              "    CanonicalDelimiter: 'cc'",\r
-              RawStringFormats, ExpectedRawStringFormats);\r
-\r
-  CHECK_PARSE("SpacesInLineCommentPrefix:\n"\r
-              "  Minimum: 0\n"\r
-              "  Maximum: 0",\r
-              SpacesInLineCommentPrefix.Minimum, 0u);\r
-  EXPECT_EQ(Style.SpacesInLineCommentPrefix.Maximum, 0u);\r
-  Style.SpacesInLineCommentPrefix.Minimum = 1;\r
-  CHECK_PARSE("SpacesInLineCommentPrefix:\n"\r
-              "  Minimum: 2",\r
-              SpacesInLineCommentPrefix.Minimum, 0u);\r
-  CHECK_PARSE("SpacesInLineCommentPrefix:\n"\r
-              "  Maximum: -1",\r
-              SpacesInLineCommentPrefix.Maximum, -1u);\r
-  CHECK_PARSE("SpacesInLineCommentPrefix:\n"\r
-              "  Minimum: 2",\r
-              SpacesInLineCommentPrefix.Minimum, 2u);\r
-  CHECK_PARSE("SpacesInLineCommentPrefix:\n"\r
-              "  Maximum: 1",\r
-              SpacesInLineCommentPrefix.Maximum, 1u);\r
-  EXPECT_EQ(Style.SpacesInLineCommentPrefix.Minimum, 1u);\r
-\r
-  Style.SpacesInAngles = FormatStyle::SIAS_Always;\r
-  CHECK_PARSE("SpacesInAngles: Never", SpacesInAngles, FormatStyle::SIAS_Never);\r
-  CHECK_PARSE("SpacesInAngles: Always", SpacesInAngles,\r
-              FormatStyle::SIAS_Always);\r
-  CHECK_PARSE("SpacesInAngles: Leave", SpacesInAngles, FormatStyle::SIAS_Leave);\r
-  // For backward compatibility:\r
-  CHECK_PARSE("SpacesInAngles: false", SpacesInAngles, FormatStyle::SIAS_Never);\r
-  CHECK_PARSE("SpacesInAngles: true", SpacesInAngles, FormatStyle::SIAS_Always);\r
-\r
-  CHECK_PARSE("RequiresClausePosition: WithPreceding", RequiresClausePosition,\r
-              FormatStyle::RCPS_WithPreceding);\r
-  CHECK_PARSE("RequiresClausePosition: WithFollowing", RequiresClausePosition,\r
-              FormatStyle::RCPS_WithFollowing);\r
-  CHECK_PARSE("RequiresClausePosition: SingleLine", RequiresClausePosition,\r
-              FormatStyle::RCPS_SingleLine);\r
-  CHECK_PARSE("RequiresClausePosition: OwnLine", RequiresClausePosition,\r
-              FormatStyle::RCPS_OwnLine);\r
-\r
-  CHECK_PARSE("BreakBeforeConceptDeclarations: Never",\r
-              BreakBeforeConceptDeclarations, FormatStyle::BBCDS_Never);\r
-  CHECK_PARSE("BreakBeforeConceptDeclarations: Always",\r
-              BreakBeforeConceptDeclarations, FormatStyle::BBCDS_Always);\r
-  CHECK_PARSE("BreakBeforeConceptDeclarations: Allowed",\r
-              BreakBeforeConceptDeclarations, FormatStyle::BBCDS_Allowed);\r
-  // For backward compatibility:\r
-  CHECK_PARSE("BreakBeforeConceptDeclarations: true",\r
-              BreakBeforeConceptDeclarations, FormatStyle::BBCDS_Always);\r
-  CHECK_PARSE("BreakBeforeConceptDeclarations: false",\r
-              BreakBeforeConceptDeclarations, FormatStyle::BBCDS_Allowed);\r
-}\r
-\r
-TEST(ConfigParseTest, ParsesConfigurationWithLanguages) {\r
-  FormatStyle Style = {};\r
-  Style.Language = FormatStyle::LK_Cpp;\r
-  CHECK_PARSE("Language: Cpp\n"\r
-              "IndentWidth: 12",\r
-              IndentWidth, 12u);\r
-  EXPECT_EQ(parseConfiguration("Language: JavaScript\n"\r
-                               "IndentWidth: 34",\r
-                               &Style),\r
-            ParseError::Unsuitable);\r
-  FormatStyle BinPackedTCS = {};\r
-  BinPackedTCS.Language = FormatStyle::LK_JavaScript;\r
-  EXPECT_EQ(parseConfiguration("BinPackArguments: true\n"\r
-                               "InsertTrailingCommas: Wrapped",\r
-                               &BinPackedTCS),\r
-            ParseError::BinPackTrailingCommaConflict);\r
-  EXPECT_EQ(12u, Style.IndentWidth);\r
-  CHECK_PARSE("IndentWidth: 56", IndentWidth, 56u);\r
-  EXPECT_EQ(FormatStyle::LK_Cpp, Style.Language);\r
-\r
-  Style.Language = FormatStyle::LK_JavaScript;\r
-  CHECK_PARSE("Language: JavaScript\n"\r
-              "IndentWidth: 12",\r
-              IndentWidth, 12u);\r
-  CHECK_PARSE("IndentWidth: 23", IndentWidth, 23u);\r
-  EXPECT_EQ(parseConfiguration("Language: Cpp\n"\r
-                               "IndentWidth: 34",\r
-                               &Style),\r
-            ParseError::Unsuitable);\r
-  EXPECT_EQ(23u, Style.IndentWidth);\r
-  CHECK_PARSE("IndentWidth: 56", IndentWidth, 56u);\r
-  EXPECT_EQ(FormatStyle::LK_JavaScript, Style.Language);\r
-\r
-  CHECK_PARSE("BasedOnStyle: LLVM\n"\r
-              "IndentWidth: 67",\r
-              IndentWidth, 67u);\r
-\r
-  CHECK_PARSE("---\n"\r
-              "Language: JavaScript\n"\r
-              "IndentWidth: 12\n"\r
-              "---\n"\r
-              "Language: Cpp\n"\r
-              "IndentWidth: 34\n"\r
-              "...\n",\r
-              IndentWidth, 12u);\r
-\r
-  Style.Language = FormatStyle::LK_Cpp;\r
-  CHECK_PARSE("---\n"\r
-              "Language: JavaScript\n"\r
-              "IndentWidth: 12\n"\r
-              "---\n"\r
-              "Language: Cpp\n"\r
-              "IndentWidth: 34\n"\r
-              "...\n",\r
-              IndentWidth, 34u);\r
-  CHECK_PARSE("---\n"\r
-              "IndentWidth: 78\n"\r
-              "---\n"\r
-              "Language: JavaScript\n"\r
-              "IndentWidth: 56\n"\r
-              "...\n",\r
-              IndentWidth, 78u);\r
-\r
-  Style.ColumnLimit = 123;\r
-  Style.IndentWidth = 234;\r
-  Style.BreakBeforeBraces = FormatStyle::BS_Linux;\r
-  Style.TabWidth = 345;\r
-  EXPECT_FALSE(parseConfiguration("---\n"\r
-                                  "IndentWidth: 456\n"\r
-                                  "BreakBeforeBraces: Allman\n"\r
-                                  "---\n"\r
-                                  "Language: JavaScript\n"\r
-                                  "IndentWidth: 111\n"\r
-                                  "TabWidth: 111\n"\r
-                                  "---\n"\r
-                                  "Language: Cpp\n"\r
-                                  "BreakBeforeBraces: Stroustrup\n"\r
-                                  "TabWidth: 789\n"\r
-                                  "...\n",\r
-                                  &Style));\r
-  EXPECT_EQ(123u, Style.ColumnLimit);\r
-  EXPECT_EQ(456u, Style.IndentWidth);\r
-  EXPECT_EQ(FormatStyle::BS_Stroustrup, Style.BreakBeforeBraces);\r
-  EXPECT_EQ(789u, Style.TabWidth);\r
-\r
-  EXPECT_EQ(parseConfiguration("---\n"\r
-                               "Language: JavaScript\n"\r
-                               "IndentWidth: 56\n"\r
-                               "---\n"\r
-                               "IndentWidth: 78\n"\r
-                               "...\n",\r
-                               &Style),\r
-            ParseError::Error);\r
-  EXPECT_EQ(parseConfiguration("---\n"\r
-                               "Language: JavaScript\n"\r
-                               "IndentWidth: 56\n"\r
-                               "---\n"\r
-                               "Language: JavaScript\n"\r
-                               "IndentWidth: 78\n"\r
-                               "...\n",\r
-                               &Style),\r
-            ParseError::Error);\r
-\r
-  EXPECT_EQ(FormatStyle::LK_Cpp, Style.Language);\r
-}\r
-\r
-TEST(ConfigParseTest, UsesLanguageForBasedOnStyle) {\r
-  FormatStyle Style = {};\r
-  Style.Language = FormatStyle::LK_JavaScript;\r
-  Style.BreakBeforeTernaryOperators = true;\r
-  EXPECT_EQ(0, parseConfiguration("BasedOnStyle: Google", &Style).value());\r
-  EXPECT_FALSE(Style.BreakBeforeTernaryOperators);\r
-\r
-  Style.BreakBeforeTernaryOperators = true;\r
-  EXPECT_EQ(0, parseConfiguration("---\n"\r
-                                  "BasedOnStyle: Google\n"\r
-                                  "---\n"\r
-                                  "Language: JavaScript\n"\r
-                                  "IndentWidth: 76\n"\r
-                                  "...\n",\r
-                                  &Style)\r
-                   .value());\r
-  EXPECT_FALSE(Style.BreakBeforeTernaryOperators);\r
-  EXPECT_EQ(76u, Style.IndentWidth);\r
-  EXPECT_EQ(FormatStyle::LK_JavaScript, Style.Language);\r
-}\r
-\r
-TEST(ConfigParseTest, ConfigurationRoundTripTest) {\r
-  FormatStyle Style = getLLVMStyle();\r
-  std::string YAML = configurationAsText(Style);\r
-  FormatStyle ParsedStyle = {};\r
-  ParsedStyle.Language = FormatStyle::LK_Cpp;\r
-  EXPECT_EQ(0, parseConfiguration(YAML, &ParsedStyle).value());\r
-  EXPECT_EQ(Style, ParsedStyle);\r
-}\r
-\r
-TEST(ConfigParseTest, GetStyleWithEmptyFileName) {\r
-  llvm::vfs::InMemoryFileSystem FS;\r
-  auto Style1 = getStyle("file", "", "Google", "", &FS);\r
-  ASSERT_TRUE((bool)Style1);\r
-  ASSERT_EQ(*Style1, getGoogleStyle());\r
-}\r
-\r
-TEST(ConfigParseTest, GetStyleOfFile) {\r
-  llvm::vfs::InMemoryFileSystem FS;\r
-  // Test 1: format file in the same directory.\r
-  ASSERT_TRUE(\r
-      FS.addFile("/a/.clang-format", 0,\r
-                 llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM")));\r
-  ASSERT_TRUE(\r
-      FS.addFile("/a/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));\r
-  auto Style1 = getStyle("file", "/a/.clang-format", "Google", "", &FS);\r
-  ASSERT_TRUE((bool)Style1);\r
-  ASSERT_EQ(*Style1, getLLVMStyle());\r
-\r
-  // Test 2.1: fallback to default.\r
-  ASSERT_TRUE(\r
-      FS.addFile("/b/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));\r
-  auto Style2 = getStyle("file", "/b/test.cpp", "Mozilla", "", &FS);\r
-  ASSERT_TRUE((bool)Style2);\r
-  ASSERT_EQ(*Style2, getMozillaStyle());\r
-\r
-  // Test 2.2: no format on 'none' fallback style.\r
-  Style2 = getStyle("file", "/b/test.cpp", "none", "", &FS);\r
-  ASSERT_TRUE((bool)Style2);\r
-  ASSERT_EQ(*Style2, getNoStyle());\r
-\r
-  // Test 2.3: format if config is found with no based style while fallback is\r
-  // 'none'.\r
-  ASSERT_TRUE(FS.addFile("/b/.clang-format", 0,\r
-                         llvm::MemoryBuffer::getMemBuffer("IndentWidth: 2")));\r
-  Style2 = getStyle("file", "/b/test.cpp", "none", "", &FS);\r
-  ASSERT_TRUE((bool)Style2);\r
-  ASSERT_EQ(*Style2, getLLVMStyle());\r
-\r
-  // Test 2.4: format if yaml with no based style, while fallback is 'none'.\r
-  Style2 = getStyle("{}", "a.h", "none", "", &FS);\r
-  ASSERT_TRUE((bool)Style2);\r
-  ASSERT_EQ(*Style2, getLLVMStyle());\r
-\r
-  // Test 3: format file in parent directory.\r
-  ASSERT_TRUE(\r
-      FS.addFile("/c/.clang-format", 0,\r
-                 llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));\r
-  ASSERT_TRUE(FS.addFile("/c/sub/sub/sub/test.cpp", 0,\r
-                         llvm::MemoryBuffer::getMemBuffer("int i;")));\r
-  auto Style3 = getStyle("file", "/c/sub/sub/sub/test.cpp", "LLVM", "", &FS);\r
-  ASSERT_TRUE((bool)Style3);\r
-  ASSERT_EQ(*Style3, getGoogleStyle());\r
-\r
-  // Test 4: error on invalid fallback style\r
-  auto Style4 = getStyle("file", "a.h", "KungFu", "", &FS);\r
-  ASSERT_FALSE((bool)Style4);\r
-  llvm::consumeError(Style4.takeError());\r
-\r
-  // Test 5: error on invalid yaml on command line\r
-  auto Style5 = getStyle("{invalid_key=invalid_value}", "a.h", "LLVM", "", &FS);\r
-  ASSERT_FALSE((bool)Style5);\r
-  llvm::consumeError(Style5.takeError());\r
-\r
-  // Test 6: error on invalid style\r
-  auto Style6 = getStyle("KungFu", "a.h", "LLVM", "", &FS);\r
-  ASSERT_FALSE((bool)Style6);\r
-  llvm::consumeError(Style6.takeError());\r
-\r
-  // Test 7: found config file, error on parsing it\r
-  ASSERT_TRUE(\r
-      FS.addFile("/d/.clang-format", 0,\r
-                 llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM\n"\r
-                                                  "InvalidKey: InvalidValue")));\r
-  ASSERT_TRUE(\r
-      FS.addFile("/d/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));\r
-  auto Style7a = getStyle("file", "/d/.clang-format", "LLVM", "", &FS);\r
-  ASSERT_FALSE((bool)Style7a);\r
-  llvm::consumeError(Style7a.takeError());\r
-\r
-  auto Style7b = getStyle("file", "/d/.clang-format", "LLVM", "", &FS, true);\r
-  ASSERT_TRUE((bool)Style7b);\r
-\r
-  // Test 8: inferred per-language defaults apply.\r
-  auto StyleTd = getStyle("file", "x.td", "llvm", "", &FS);\r
-  ASSERT_TRUE((bool)StyleTd);\r
-  ASSERT_EQ(*StyleTd, getLLVMStyle(FormatStyle::LK_TableGen));\r
-\r
-  // Test 9.1.1: overwriting a file style, when no parent file exists with no\r
-  // fallback style.\r
-  ASSERT_TRUE(FS.addFile(\r
-      "/e/sub/.clang-format", 0,\r
-      llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: InheritParentConfig\n"\r
-                                       "ColumnLimit: 20")));\r
-  ASSERT_TRUE(FS.addFile("/e/sub/code.cpp", 0,\r
-                         llvm::MemoryBuffer::getMemBuffer("int i;")));\r
-  auto Style9 = getStyle("file", "/e/sub/code.cpp", "none", "", &FS);\r
-  ASSERT_TRUE(static_cast<bool>(Style9));\r
-  ASSERT_EQ(*Style9, [] {\r
-    auto Style = getNoStyle();\r
-    Style.ColumnLimit = 20;\r
-    return Style;\r
-  }());\r
-\r
-  // Test 9.1.2: propagate more than one level with no parent file.\r
-  ASSERT_TRUE(FS.addFile("/e/sub/sub/code.cpp", 0,\r
-                         llvm::MemoryBuffer::getMemBuffer("int i;")));\r
-  ASSERT_TRUE(FS.addFile("/e/sub/sub/.clang-format", 0,\r
-                         llvm::MemoryBuffer::getMemBuffer(\r
-                             "BasedOnStyle: InheritParentConfig\n"\r
-                             "WhitespaceSensitiveMacros: ['FOO', 'BAR']")));\r
-  std::vector<std::string> NonDefaultWhiteSpaceMacros =\r
-      Style9->WhitespaceSensitiveMacros;\r
-  NonDefaultWhiteSpaceMacros[0] = "FOO";\r
-  NonDefaultWhiteSpaceMacros[1] = "BAR";\r
-\r
-  ASSERT_NE(Style9->WhitespaceSensitiveMacros, NonDefaultWhiteSpaceMacros);\r
-  Style9 = getStyle("file", "/e/sub/sub/code.cpp", "none", "", &FS);\r
-  ASSERT_TRUE(static_cast<bool>(Style9));\r
-  ASSERT_EQ(*Style9, [&NonDefaultWhiteSpaceMacros] {\r
-    auto Style = getNoStyle();\r
-    Style.ColumnLimit = 20;\r
-    Style.WhitespaceSensitiveMacros = NonDefaultWhiteSpaceMacros;\r
-    return Style;\r
-  }());\r
-\r
-  // Test 9.2: with LLVM fallback style\r
-  Style9 = getStyle("file", "/e/sub/code.cpp", "LLVM", "", &FS);\r
-  ASSERT_TRUE(static_cast<bool>(Style9));\r
-  ASSERT_EQ(*Style9, [] {\r
-    auto Style = getLLVMStyle();\r
-    Style.ColumnLimit = 20;\r
-    return Style;\r
-  }());\r
-\r
-  // Test 9.3: with a parent file\r
-  ASSERT_TRUE(\r
-      FS.addFile("/e/.clang-format", 0,\r
-                 llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google\n"\r
-                                                  "UseTab: Always")));\r
-  Style9 = getStyle("file", "/e/sub/code.cpp", "none", "", &FS);\r
-  ASSERT_TRUE(static_cast<bool>(Style9));\r
-  ASSERT_EQ(*Style9, [] {\r
-    auto Style = getGoogleStyle();\r
-    Style.ColumnLimit = 20;\r
-    Style.UseTab = FormatStyle::UT_Always;\r
-    return Style;\r
-  }());\r
-\r
-  // Test 9.4: propagate more than one level with a parent file.\r
-  const auto SubSubStyle = [&NonDefaultWhiteSpaceMacros] {\r
-    auto Style = getGoogleStyle();\r
-    Style.ColumnLimit = 20;\r
-    Style.UseTab = FormatStyle::UT_Always;\r
-    Style.WhitespaceSensitiveMacros = NonDefaultWhiteSpaceMacros;\r
-    return Style;\r
-  }();\r
-\r
-  ASSERT_NE(Style9->WhitespaceSensitiveMacros, NonDefaultWhiteSpaceMacros);\r
-  Style9 = getStyle("file", "/e/sub/sub/code.cpp", "none", "", &FS);\r
-  ASSERT_TRUE(static_cast<bool>(Style9));\r
-  ASSERT_EQ(*Style9, SubSubStyle);\r
-\r
-  // Test 9.5: use InheritParentConfig as style name\r
-  Style9 =\r
-      getStyle("inheritparentconfig", "/e/sub/sub/code.cpp", "none", "", &FS);\r
-  ASSERT_TRUE(static_cast<bool>(Style9));\r
-  ASSERT_EQ(*Style9, SubSubStyle);\r
-\r
-  // Test 9.6: use command line style with inheritance\r
-  Style9 = getStyle("{BasedOnStyle: InheritParentConfig}",\r
-                    "/e/sub/sub/code.cpp", "none", "", &FS);\r
-  ASSERT_TRUE(static_cast<bool>(Style9));\r
-  ASSERT_EQ(*Style9, SubSubStyle);\r
-\r
-  // Test 9.7: use command line style with inheritance and own config\r
-  Style9 = getStyle("{BasedOnStyle: InheritParentConfig, "\r
-                    "WhitespaceSensitiveMacros: ['FOO', 'BAR']}",\r
-                    "/e/sub/code.cpp", "none", "", &FS);\r
-  ASSERT_TRUE(static_cast<bool>(Style9));\r
-  ASSERT_EQ(*Style9, SubSubStyle);\r
-\r
-  // Test 9.8: use inheritance from a file without BasedOnStyle\r
-  ASSERT_TRUE(FS.addFile("/e/withoutbase/.clang-format", 0,\r
-                         llvm::MemoryBuffer::getMemBuffer("ColumnLimit: 123")));\r
-  ASSERT_TRUE(\r
-      FS.addFile("/e/withoutbase/sub/.clang-format", 0,\r
-                 llvm::MemoryBuffer::getMemBuffer(\r
-                     "BasedOnStyle: InheritParentConfig\nIndentWidth: 7")));\r
-  // Make sure we do not use the fallback style\r
-  Style9 = getStyle("file", "/e/withoutbase/code.cpp", "google", "", &FS);\r
-  ASSERT_TRUE(static_cast<bool>(Style9));\r
-  ASSERT_EQ(*Style9, [] {\r
-    auto Style = getLLVMStyle();\r
-    Style.ColumnLimit = 123;\r
-    return Style;\r
-  }());\r
-\r
-  Style9 = getStyle("file", "/e/withoutbase/sub/code.cpp", "google", "", &FS);\r
-  ASSERT_TRUE(static_cast<bool>(Style9));\r
-  ASSERT_EQ(*Style9, [] {\r
-    auto Style = getLLVMStyle();\r
-    Style.ColumnLimit = 123;\r
-    Style.IndentWidth = 7;\r
-    return Style;\r
-  }());\r
-\r
-  // Test 9.9: use inheritance from a specific config file.\r
-  Style9 = getStyle("file:/e/sub/sub/.clang-format", "/e/sub/sub/code.cpp",\r
-                    "none", "", &FS);\r
-  ASSERT_TRUE(static_cast<bool>(Style9));\r
-  ASSERT_EQ(*Style9, SubSubStyle);\r
-}\r
-\r
-TEST(ConfigParseTest, GetStyleOfSpecificFile) {\r
-  llvm::vfs::InMemoryFileSystem FS;\r
-  // Specify absolute path to a format file in a parent directory.\r
-  ASSERT_TRUE(\r
-      FS.addFile("/e/.clang-format", 0,\r
-                 llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM")));\r
-  ASSERT_TRUE(\r
-      FS.addFile("/e/explicit.clang-format", 0,\r
-                 llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));\r
-  ASSERT_TRUE(FS.addFile("/e/sub/sub/sub/test.cpp", 0,\r
-                         llvm::MemoryBuffer::getMemBuffer("int i;")));\r
-  auto Style = getStyle("file:/e/explicit.clang-format",\r
-                        "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);\r
-  ASSERT_TRUE(static_cast<bool>(Style));\r
-  ASSERT_EQ(*Style, getGoogleStyle());\r
-\r
-  // Specify relative path to a format file.\r
-  ASSERT_TRUE(\r
-      FS.addFile("../../e/explicit.clang-format", 0,\r
-                 llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));\r
-  Style = getStyle("file:../../e/explicit.clang-format",\r
-                   "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);\r
-  ASSERT_TRUE(static_cast<bool>(Style));\r
-  ASSERT_EQ(*Style, getGoogleStyle());\r
-\r
-  // Specify path to a format file that does not exist.\r
-  Style = getStyle("file:/e/missing.clang-format", "/e/sub/sub/sub/test.cpp",\r
-                   "LLVM", "", &FS);\r
-  ASSERT_FALSE(static_cast<bool>(Style));\r
-  llvm::consumeError(Style.takeError());\r
-\r
-  // Specify path to a file on the filesystem.\r
-  SmallString<128> FormatFilePath;\r
-  std::error_code ECF = llvm::sys::fs::createTemporaryFile(\r
-      "FormatFileTest", "tpl", FormatFilePath);\r
-  EXPECT_FALSE((bool)ECF);\r
-  llvm::raw_fd_ostream FormatFileTest(FormatFilePath, ECF);\r
-  EXPECT_FALSE((bool)ECF);\r
-  FormatFileTest << "BasedOnStyle: Google\n";\r
-  FormatFileTest.close();\r
-\r
-  SmallString<128> TestFilePath;\r
-  std::error_code ECT =\r
-      llvm::sys::fs::createTemporaryFile("CodeFileTest", "cc", TestFilePath);\r
-  EXPECT_FALSE((bool)ECT);\r
-  llvm::raw_fd_ostream CodeFileTest(TestFilePath, ECT);\r
-  CodeFileTest << "int i;\n";\r
-  CodeFileTest.close();\r
-\r
-  std::string format_file_arg = std::string("file:") + FormatFilePath.c_str();\r
-  Style = getStyle(format_file_arg, TestFilePath, "LLVM", "", nullptr);\r
-\r
-  llvm::sys::fs::remove(FormatFilePath.c_str());\r
-  llvm::sys::fs::remove(TestFilePath.c_str());\r
-  ASSERT_TRUE(static_cast<bool>(Style));\r
-  ASSERT_EQ(*Style, getGoogleStyle());\r
-}\r
-\r
-} // namespace\r
-} // namespace format\r
-} // namespace clang\r
+//===- unittest/Format/ConfigParseTest.cpp - Config parsing unit tests ----===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Format/Format.h"
+
+#include "llvm/Support/VirtualFileSystem.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace format {
+namespace {
+
+FormatStyle getGoogleStyle() { return getGoogleStyle(FormatStyle::LK_Cpp); }
+
+#define EXPECT_ALL_STYLES_EQUAL(Styles)                                        \
+  for (size_t i = 1; i < Styles.size(); ++i)                                   \
+  EXPECT_EQ(Styles[0], Styles[i])                                              \
+      << "Style #" << i << " of " << Styles.size() << " differs from Style #0"
+
+TEST(ConfigParseTest, GetsPredefinedStyleByName) {
+  SmallVector<FormatStyle, 3> Styles;
+  Styles.resize(3);
+
+  Styles[0] = getLLVMStyle();
+  EXPECT_TRUE(getPredefinedStyle("LLVM", FormatStyle::LK_Cpp, &Styles[1]));
+  EXPECT_TRUE(getPredefinedStyle("lLvM", FormatStyle::LK_Cpp, &Styles[2]));
+  EXPECT_ALL_STYLES_EQUAL(Styles);
+
+  Styles[0] = getGoogleStyle();
+  EXPECT_TRUE(getPredefinedStyle("Google", FormatStyle::LK_Cpp, &Styles[1]));
+  EXPECT_TRUE(getPredefinedStyle("gOOgle", FormatStyle::LK_Cpp, &Styles[2]));
+  EXPECT_ALL_STYLES_EQUAL(Styles);
+
+  Styles[0] = getGoogleStyle(FormatStyle::LK_JavaScript);
+  EXPECT_TRUE(
+      getPredefinedStyle("Google", FormatStyle::LK_JavaScript, &Styles[1]));
+  EXPECT_TRUE(
+      getPredefinedStyle("gOOgle", FormatStyle::LK_JavaScript, &Styles[2]));
+  EXPECT_ALL_STYLES_EQUAL(Styles);
+
+  Styles[0] = getChromiumStyle(FormatStyle::LK_Cpp);
+  EXPECT_TRUE(getPredefinedStyle("Chromium", FormatStyle::LK_Cpp, &Styles[1]));
+  EXPECT_TRUE(getPredefinedStyle("cHRoMiUM", FormatStyle::LK_Cpp, &Styles[2]));
+  EXPECT_ALL_STYLES_EQUAL(Styles);
+
+  Styles[0] = getMozillaStyle();
+  EXPECT_TRUE(getPredefinedStyle("Mozilla", FormatStyle::LK_Cpp, &Styles[1]));
+  EXPECT_TRUE(getPredefinedStyle("moZILla", FormatStyle::LK_Cpp, &Styles[2]));
+  EXPECT_ALL_STYLES_EQUAL(Styles);
+
+  Styles[0] = getWebKitStyle();
+  EXPECT_TRUE(getPredefinedStyle("WebKit", FormatStyle::LK_Cpp, &Styles[1]));
+  EXPECT_TRUE(getPredefinedStyle("wEbKit", FormatStyle::LK_Cpp, &Styles[2]));
+  EXPECT_ALL_STYLES_EQUAL(Styles);
+
+  Styles[0] = getGNUStyle();
+  EXPECT_TRUE(getPredefinedStyle("GNU", FormatStyle::LK_Cpp, &Styles[1]));
+  EXPECT_TRUE(getPredefinedStyle("gnU", FormatStyle::LK_Cpp, &Styles[2]));
+  EXPECT_ALL_STYLES_EQUAL(Styles);
+
+  EXPECT_FALSE(getPredefinedStyle("qwerty", FormatStyle::LK_Cpp, &Styles[0]));
+}
+
+TEST(ConfigParseTest, GetsCorrectBasedOnStyle) {
+  SmallVector<FormatStyle, 8> Styles;
+  Styles.resize(2);
+
+  Styles[0] = getGoogleStyle();
+  Styles[1] = getLLVMStyle();
+  EXPECT_EQ(0, parseConfiguration("BasedOnStyle: Google", &Styles[1]).value());
+  EXPECT_ALL_STYLES_EQUAL(Styles);
+
+  Styles.resize(5);
+  Styles[0] = getGoogleStyle(FormatStyle::LK_JavaScript);
+  Styles[1] = getLLVMStyle();
+  Styles[1].Language = FormatStyle::LK_JavaScript;
+  EXPECT_EQ(0, parseConfiguration("BasedOnStyle: Google", &Styles[1]).value());
+
+  Styles[2] = getLLVMStyle();
+  Styles[2].Language = FormatStyle::LK_JavaScript;
+  EXPECT_EQ(0, parseConfiguration("Language: JavaScript\n"
+                                  "BasedOnStyle: Google",
+                                  &Styles[2])
+                   .value());
+
+  Styles[3] = getLLVMStyle();
+  Styles[3].Language = FormatStyle::LK_JavaScript;
+  EXPECT_EQ(0, parseConfiguration("BasedOnStyle: Google\n"
+                                  "Language: JavaScript",
+                                  &Styles[3])
+                   .value());
+
+  Styles[4] = getLLVMStyle();
+  Styles[4].Language = FormatStyle::LK_JavaScript;
+  EXPECT_EQ(0, parseConfiguration("---\n"
+                                  "BasedOnStyle: LLVM\n"
+                                  "IndentWidth: 123\n"
+                                  "---\n"
+                                  "BasedOnStyle: Google\n"
+                                  "Language: JavaScript",
+                                  &Styles[4])
+                   .value());
+  EXPECT_ALL_STYLES_EQUAL(Styles);
+}
+
+#define CHECK_PARSE_BOOL_FIELD(FIELD, CONFIG_NAME)                             \
+  Style.FIELD = false;                                                         \
+  EXPECT_EQ(0, parseConfiguration(CONFIG_NAME ": true", &Style).value());      \
+  EXPECT_TRUE(Style.FIELD);                                                    \
+  EXPECT_EQ(0, parseConfiguration(CONFIG_NAME ": false", &Style).value());     \
+  EXPECT_FALSE(Style.FIELD)
+
+#define CHECK_PARSE_BOOL(FIELD) CHECK_PARSE_BOOL_FIELD(FIELD, #FIELD)
+
+#define CHECK_PARSE_NESTED_BOOL_FIELD(STRUCT, FIELD, CONFIG_NAME)              \
+  Style.STRUCT.FIELD = false;                                                  \
+  EXPECT_EQ(0,                                                                 \
+            parseConfiguration(#STRUCT ":\n  " CONFIG_NAME ": true", &Style)   \
+                .value());                                                     \
+  EXPECT_TRUE(Style.STRUCT.FIELD);                                             \
+  EXPECT_EQ(0,                                                                 \
+            parseConfiguration(#STRUCT ":\n  " CONFIG_NAME ": false", &Style)  \
+                .value());                                                     \
+  EXPECT_FALSE(Style.STRUCT.FIELD)
+
+#define CHECK_PARSE_NESTED_BOOL(STRUCT, FIELD)                                 \
+  CHECK_PARSE_NESTED_BOOL_FIELD(STRUCT, FIELD, #FIELD)
+
+#define CHECK_PARSE(TEXT, FIELD, VALUE)                                        \
+  EXPECT_NE(VALUE, Style.FIELD) << "Initial value already the same!";          \
+  EXPECT_EQ(0, parseConfiguration(TEXT, &Style).value());                      \
+  EXPECT_EQ(VALUE, Style.FIELD) << "Unexpected value after parsing!"
+
+#define CHECK_PARSE_NESTED_VALUE(TEXT, STRUCT, FIELD, VALUE)                   \
+  EXPECT_NE(VALUE, Style.STRUCT.FIELD) << "Initial value already the same!";   \
+  EXPECT_EQ(0, parseConfiguration(#STRUCT ":\n  " TEXT, &Style).value());      \
+  EXPECT_EQ(VALUE, Style.STRUCT.FIELD) << "Unexpected value after parsing!"
+
+TEST(ConfigParseTest, ParsesConfigurationBools) {
+  FormatStyle Style = {};
+  Style.Language = FormatStyle::LK_Cpp;
+  CHECK_PARSE_BOOL(AllowAllArgumentsOnNextLine);
+  CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
+  CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
+  CHECK_PARSE_BOOL(AllowShortEnumsOnASingleLine);
+  CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
+  CHECK_PARSE_BOOL(BinPackArguments);
+  CHECK_PARSE_BOOL(BinPackParameters);
+  CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
+  CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
+  CHECK_PARSE_BOOL(BreakStringLiterals);
+  CHECK_PARSE_BOOL(CompactNamespaces);
+  CHECK_PARSE_BOOL(DeriveLineEnding);
+  CHECK_PARSE_BOOL(DerivePointerAlignment);
+  CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding");
+  CHECK_PARSE_BOOL(DisableFormat);
+  CHECK_PARSE_BOOL(IndentAccessModifiers);
+  CHECK_PARSE_BOOL(IndentCaseLabels);
+  CHECK_PARSE_BOOL(IndentCaseBlocks);
+  CHECK_PARSE_BOOL(IndentGotoLabels);
+  CHECK_PARSE_BOOL_FIELD(IndentRequiresClause, "IndentRequires");
+  CHECK_PARSE_BOOL(IndentRequiresClause);
+  CHECK_PARSE_BOOL(IndentWrappedFunctionNames);
+  CHECK_PARSE_BOOL(InsertBraces);
+  CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);
+  CHECK_PARSE_BOOL(ObjCSpaceAfterProperty);
+  CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
+  CHECK_PARSE_BOOL(Cpp11BracedListStyle);
+  CHECK_PARSE_BOOL(ReflowComments);
+  CHECK_PARSE_BOOL(RemoveBracesLLVM);
+  CHECK_PARSE_BOOL(RemoveSemicolon);
+  CHECK_PARSE_BOOL(SortUsingDeclarations);
+  CHECK_PARSE_BOOL(SpacesInParentheses);
+  CHECK_PARSE_BOOL(SpacesInSquareBrackets);
+  CHECK_PARSE_BOOL(SpacesInConditionalStatement);
+  CHECK_PARSE_BOOL(SpaceInEmptyBlock);
+  CHECK_PARSE_BOOL(SpaceInEmptyParentheses);
+  CHECK_PARSE_BOOL(SpacesInContainerLiterals);
+  CHECK_PARSE_BOOL(SpacesInCStyleCastParentheses);
+  CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
+  CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
+  CHECK_PARSE_BOOL(SpaceAfterLogicalNot);
+  CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
+  CHECK_PARSE_BOOL(SpaceBeforeCaseColon);
+  CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList);
+  CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
+  CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);
+  CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);
+  CHECK_PARSE_BOOL(SpaceBeforeSquareBrackets);
+  CHECK_PARSE_BOOL(UseCRLF);
+
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterCaseLabel);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterClass);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterEnum);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterFunction);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterNamespace);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterObjCDeclaration);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterStruct);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterUnion);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterExternBlock);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeCatch);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeElse);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeLambdaBody);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeWhile);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, IndentBraces);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyFunction);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyRecord);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyNamespace);
+  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterControlStatements);
+  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterForeachMacros);
+  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions,
+                          AfterFunctionDeclarationName);
+  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions,
+                          AfterFunctionDefinitionName);
+  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterIfMacros);
+  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterOverloadedOperator);
+  CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, BeforeNonEmptyParentheses);
+}
+
+#undef CHECK_PARSE_BOOL
+
+TEST(ConfigParseTest, ParsesConfiguration) {
+  FormatStyle Style = {};
+  Style.Language = FormatStyle::LK_Cpp;
+  CHECK_PARSE("AccessModifierOffset: -1234", AccessModifierOffset, -1234);
+  CHECK_PARSE("ConstructorInitializerIndentWidth: 1234",
+              ConstructorInitializerIndentWidth, 1234u);
+  CHECK_PARSE("ObjCBlockIndentWidth: 1234", ObjCBlockIndentWidth, 1234u);
+  CHECK_PARSE("ColumnLimit: 1234", ColumnLimit, 1234u);
+  CHECK_PARSE("MaxEmptyLinesToKeep: 1234", MaxEmptyLinesToKeep, 1234u);
+  CHECK_PARSE("PenaltyBreakAssignment: 1234", PenaltyBreakAssignment, 1234u);
+  CHECK_PARSE("PenaltyBreakBeforeFirstCallParameter: 1234",
+              PenaltyBreakBeforeFirstCallParameter, 1234u);
+  CHECK_PARSE("PenaltyBreakTemplateDeclaration: 1234",
+              PenaltyBreakTemplateDeclaration, 1234u);
+  CHECK_PARSE("PenaltyBreakOpenParenthesis: 1234", PenaltyBreakOpenParenthesis,
+              1234u);
+  CHECK_PARSE("PenaltyExcessCharacter: 1234", PenaltyExcessCharacter, 1234u);
+  CHECK_PARSE("PenaltyReturnTypeOnItsOwnLine: 1234",
+              PenaltyReturnTypeOnItsOwnLine, 1234u);
+  CHECK_PARSE("SpacesBeforeTrailingComments: 1234",
+              SpacesBeforeTrailingComments, 1234u);
+  CHECK_PARSE("IndentWidth: 32", IndentWidth, 32u);
+  CHECK_PARSE("ContinuationIndentWidth: 11", ContinuationIndentWidth, 11u);
+  CHECK_PARSE("CommentPragmas: '// abc$'", CommentPragmas, "// abc$");
+
+  Style.QualifierAlignment = FormatStyle::QAS_Right;
+  CHECK_PARSE("QualifierAlignment: Leave", QualifierAlignment,
+              FormatStyle::QAS_Leave);
+  CHECK_PARSE("QualifierAlignment: Right", QualifierAlignment,
+              FormatStyle::QAS_Right);
+  CHECK_PARSE("QualifierAlignment: Left", QualifierAlignment,
+              FormatStyle::QAS_Left);
+  CHECK_PARSE("QualifierAlignment: Custom", QualifierAlignment,
+              FormatStyle::QAS_Custom);
+
+  Style.QualifierOrder.clear();
+  CHECK_PARSE("QualifierOrder: [ const, volatile, type ]", QualifierOrder,
+              std::vector<std::string>({"const", "volatile", "type"}));
+  Style.QualifierOrder.clear();
+  CHECK_PARSE("QualifierOrder: [const, type]", QualifierOrder,
+              std::vector<std::string>({"const", "type"}));
+  Style.QualifierOrder.clear();
+  CHECK_PARSE("QualifierOrder: [volatile, type]", QualifierOrder,
+              std::vector<std::string>({"volatile", "type"}));
+
+#define CHECK_ALIGN_CONSECUTIVE(FIELD)                                         \
+  do {                                                                         \
+    Style.FIELD.Enabled = true;                                                \
+    CHECK_PARSE(#FIELD ": None", FIELD,                                        \
+                FormatStyle::AlignConsecutiveStyle(                            \
+                    {/*Enabled=*/false, /*AcrossEmptyLines=*/false,            \
+                     /*AcrossComments=*/false, /*AlignCompound=*/false,        \
+                     /*PadOperators=*/true}));                                 \
+    CHECK_PARSE(#FIELD ": Consecutive", FIELD,                                 \
+                FormatStyle::AlignConsecutiveStyle(                            \
+                    {/*Enabled=*/true, /*AcrossEmptyLines=*/false,             \
+                     /*AcrossComments=*/false, /*AlignCompound=*/false,        \
+                     /*PadOperators=*/true}));                                 \
+    CHECK_PARSE(#FIELD ": AcrossEmptyLines", FIELD,                            \
+                FormatStyle::AlignConsecutiveStyle(                            \
+                    {/*Enabled=*/true, /*AcrossEmptyLines=*/true,              \
+                     /*AcrossComments=*/false, /*AlignCompound=*/false,        \
+                     /*PadOperators=*/true}));                                 \
+    CHECK_PARSE(#FIELD ": AcrossEmptyLinesAndComments", FIELD,                 \
+                FormatStyle::AlignConsecutiveStyle(                            \
+                    {/*Enabled=*/true, /*AcrossEmptyLines=*/true,              \
+                     /*AcrossComments=*/true, /*AlignCompound=*/false,         \
+                     /*PadOperators=*/true}));                                 \
+    /* For backwards compability, false / true should still parse */           \
+    CHECK_PARSE(#FIELD ": false", FIELD,                                       \
+                FormatStyle::AlignConsecutiveStyle(                            \
+                    {/*Enabled=*/false, /*AcrossEmptyLines=*/false,            \
+                     /*AcrossComments=*/false, /*AlignCompound=*/false,        \
+                     /*PadOperators=*/true}));                                 \
+    CHECK_PARSE(#FIELD ": true", FIELD,                                        \
+                FormatStyle::AlignConsecutiveStyle(                            \
+                    {/*Enabled=*/true, /*AcrossEmptyLines=*/false,             \
+                     /*AcrossComments=*/false, /*AlignCompound=*/false,        \
+                     /*PadOperators=*/true}));                                 \
+                                                                               \
+    CHECK_PARSE_NESTED_BOOL(FIELD, Enabled);                                   \
+    CHECK_PARSE_NESTED_BOOL(FIELD, AcrossEmptyLines);                          \
+    CHECK_PARSE_NESTED_BOOL(FIELD, AcrossComments);                            \
+    CHECK_PARSE_NESTED_BOOL(FIELD, AlignCompound);                             \
+    CHECK_PARSE_NESTED_BOOL(FIELD, PadOperators);                              \
+  } while (false)
+
+  CHECK_ALIGN_CONSECUTIVE(AlignConsecutiveAssignments);
+  CHECK_ALIGN_CONSECUTIVE(AlignConsecutiveBitFields);
+  CHECK_ALIGN_CONSECUTIVE(AlignConsecutiveMacros);
+  CHECK_ALIGN_CONSECUTIVE(AlignConsecutiveDeclarations);
+
+#undef CHECK_ALIGN_CONSECUTIVE
+
+  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);
+  Style.ReferenceAlignment = FormatStyle::RAS_Middle;
+  CHECK_PARSE("ReferenceAlignment: Pointer", ReferenceAlignment,
+              FormatStyle::RAS_Pointer);
+  CHECK_PARSE("ReferenceAlignment: Left", ReferenceAlignment,
+              FormatStyle::RAS_Left);
+  CHECK_PARSE("ReferenceAlignment: Right", ReferenceAlignment,
+              FormatStyle::RAS_Right);
+  CHECK_PARSE("ReferenceAlignment: Middle", ReferenceAlignment,
+              FormatStyle::RAS_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: c++03", Standard, FormatStyle::LS_Cpp03);
+  CHECK_PARSE("Standard: c++11", Standard, FormatStyle::LS_Cpp11);
+  CHECK_PARSE("Standard: c++14", Standard, FormatStyle::LS_Cpp14);
+  CHECK_PARSE("Standard: c++17", Standard, FormatStyle::LS_Cpp17);
+  CHECK_PARSE("Standard: c++20", Standard, FormatStyle::LS_Cpp20);
+  CHECK_PARSE("Standard: Auto", Standard, FormatStyle::LS_Auto);
+  CHECK_PARSE("Standard: Latest", Standard, FormatStyle::LS_Latest);
+  // Legacy aliases:
+  CHECK_PARSE("Standard: Cpp03", Standard, FormatStyle::LS_Cpp03);
+  CHECK_PARSE("Standard: Cpp11", Standard, FormatStyle::LS_Latest);
+  CHECK_PARSE("Standard: C++03", Standard, FormatStyle::LS_Cpp03);
+  CHECK_PARSE("Standard: C++11", Standard, FormatStyle::LS_Cpp11);
+
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
+  CHECK_PARSE("BreakBeforeBinaryOperators: NonAssignment",
+              BreakBeforeBinaryOperators, FormatStyle::BOS_NonAssignment);
+  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.BreakConstructorInitializers = FormatStyle::BCIS_BeforeColon;
+  CHECK_PARSE("BreakConstructorInitializers: BeforeComma",
+              BreakConstructorInitializers, FormatStyle::BCIS_BeforeComma);
+  CHECK_PARSE("BreakConstructorInitializers: AfterColon",
+              BreakConstructorInitializers, FormatStyle::BCIS_AfterColon);
+  CHECK_PARSE("BreakConstructorInitializers: BeforeColon",
+              BreakConstructorInitializers, FormatStyle::BCIS_BeforeColon);
+  // For backward compatibility:
+  CHECK_PARSE("BreakConstructorInitializersBeforeComma: true",
+              BreakConstructorInitializers, FormatStyle::BCIS_BeforeComma);
+
+  Style.BreakInheritanceList = FormatStyle::BILS_BeforeColon;
+  CHECK_PARSE("BreakInheritanceList: AfterComma", BreakInheritanceList,
+              FormatStyle::BILS_AfterComma);
+  CHECK_PARSE("BreakInheritanceList: BeforeComma", BreakInheritanceList,
+              FormatStyle::BILS_BeforeComma);
+  CHECK_PARSE("BreakInheritanceList: AfterColon", BreakInheritanceList,
+              FormatStyle::BILS_AfterColon);
+  CHECK_PARSE("BreakInheritanceList: BeforeColon", BreakInheritanceList,
+              FormatStyle::BILS_BeforeColon);
+  // For backward compatibility:
+  CHECK_PARSE("BreakBeforeInheritanceComma: true", BreakInheritanceList,
+              FormatStyle::BILS_BeforeComma);
+
+  Style.PackConstructorInitializers = FormatStyle::PCIS_BinPack;
+  CHECK_PARSE("PackConstructorInitializers: Never", PackConstructorInitializers,
+              FormatStyle::PCIS_Never);
+  CHECK_PARSE("PackConstructorInitializers: BinPack",
+              PackConstructorInitializers, FormatStyle::PCIS_BinPack);
+  CHECK_PARSE("PackConstructorInitializers: CurrentLine",
+              PackConstructorInitializers, FormatStyle::PCIS_CurrentLine);
+  CHECK_PARSE("PackConstructorInitializers: NextLine",
+              PackConstructorInitializers, FormatStyle::PCIS_NextLine);
+  // For backward compatibility:
+  CHECK_PARSE("BasedOnStyle: Google\n"
+              "ConstructorInitializerAllOnOneLineOrOnePerLine: true\n"
+              "AllowAllConstructorInitializersOnNextLine: false",
+              PackConstructorInitializers, FormatStyle::PCIS_CurrentLine);
+  Style.PackConstructorInitializers = FormatStyle::PCIS_NextLine;
+  CHECK_PARSE("BasedOnStyle: Google\n"
+              "ConstructorInitializerAllOnOneLineOrOnePerLine: false",
+              PackConstructorInitializers, FormatStyle::PCIS_BinPack);
+  CHECK_PARSE("ConstructorInitializerAllOnOneLineOrOnePerLine: true\n"
+              "AllowAllConstructorInitializersOnNextLine: true",
+              PackConstructorInitializers, FormatStyle::PCIS_NextLine);
+  Style.PackConstructorInitializers = FormatStyle::PCIS_BinPack;
+  CHECK_PARSE("ConstructorInitializerAllOnOneLineOrOnePerLine: true\n"
+              "AllowAllConstructorInitializersOnNextLine: false",
+              PackConstructorInitializers, FormatStyle::PCIS_CurrentLine);
+
+  Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_LogicalBlock;
+  CHECK_PARSE("EmptyLineBeforeAccessModifier: Never",
+              EmptyLineBeforeAccessModifier, FormatStyle::ELBAMS_Never);
+  CHECK_PARSE("EmptyLineBeforeAccessModifier: Leave",
+              EmptyLineBeforeAccessModifier, FormatStyle::ELBAMS_Leave);
+  CHECK_PARSE("EmptyLineBeforeAccessModifier: LogicalBlock",
+              EmptyLineBeforeAccessModifier, FormatStyle::ELBAMS_LogicalBlock);
+  CHECK_PARSE("EmptyLineBeforeAccessModifier: Always",
+              EmptyLineBeforeAccessModifier, FormatStyle::ELBAMS_Always);
+
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket,
+              FormatStyle::BAS_Align);
+  CHECK_PARSE("AlignAfterOpenBracket: DontAlign", AlignAfterOpenBracket,
+              FormatStyle::BAS_DontAlign);
+  CHECK_PARSE("AlignAfterOpenBracket: AlwaysBreak", AlignAfterOpenBracket,
+              FormatStyle::BAS_AlwaysBreak);
+  CHECK_PARSE("AlignAfterOpenBracket: BlockIndent", AlignAfterOpenBracket,
+              FormatStyle::BAS_BlockIndent);
+  // For backward compatibility:
+  CHECK_PARSE("AlignAfterOpenBracket: false", AlignAfterOpenBracket,
+              FormatStyle::BAS_DontAlign);
+  CHECK_PARSE("AlignAfterOpenBracket: true", AlignAfterOpenBracket,
+              FormatStyle::BAS_Align);
+
+  Style.AlignEscapedNewlines = FormatStyle::ENAS_Left;
+  CHECK_PARSE("AlignEscapedNewlines: DontAlign", AlignEscapedNewlines,
+              FormatStyle::ENAS_DontAlign);
+  CHECK_PARSE("AlignEscapedNewlines: Left", AlignEscapedNewlines,
+              FormatStyle::ENAS_Left);
+  CHECK_PARSE("AlignEscapedNewlines: Right", AlignEscapedNewlines,
+              FormatStyle::ENAS_Right);
+  // For backward compatibility:
+  CHECK_PARSE("AlignEscapedNewlinesLeft: true", AlignEscapedNewlines,
+              FormatStyle::ENAS_Left);
+  CHECK_PARSE("AlignEscapedNewlinesLeft: false", AlignEscapedNewlines,
+              FormatStyle::ENAS_Right);
+
+  Style.AlignOperands = FormatStyle::OAS_Align;
+  CHECK_PARSE("AlignOperands: DontAlign", AlignOperands,
+              FormatStyle::OAS_DontAlign);
+  CHECK_PARSE("AlignOperands: Align", AlignOperands, FormatStyle::OAS_Align);
+  CHECK_PARSE("AlignOperands: AlignAfterOperator", AlignOperands,
+              FormatStyle::OAS_AlignAfterOperator);
+  // For backward compatibility:
+  CHECK_PARSE("AlignOperands: false", AlignOperands,
+              FormatStyle::OAS_DontAlign);
+  CHECK_PARSE("AlignOperands: true", AlignOperands, FormatStyle::OAS_Align);
+
+  CHECK_PARSE("AlignTrailingComments: Leave", AlignTrailingComments,
+              FormatStyle::TrailingCommentsAlignmentStyle(
+                  {FormatStyle::TCAS_Leave, 1}));
+  CHECK_PARSE("AlignTrailingComments: Always", AlignTrailingComments,
+              FormatStyle::TrailingCommentsAlignmentStyle(
+                  {FormatStyle::TCAS_Always, 1}));
+  CHECK_PARSE("AlignTrailingComments: Never", AlignTrailingComments,
+              FormatStyle::TrailingCommentsAlignmentStyle(
+                  {FormatStyle::TCAS_Never, 1}));
+  // For backwards compatibility
+  CHECK_PARSE("AlignTrailingComments: true", AlignTrailingComments,
+              FormatStyle::TrailingCommentsAlignmentStyle(
+                  {FormatStyle::TCAS_Always, 1}));
+  CHECK_PARSE("AlignTrailingComments: false", AlignTrailingComments,
+              FormatStyle::TrailingCommentsAlignmentStyle(
+                  {FormatStyle::TCAS_Never, 1}));
+  CHECK_PARSE_NESTED_VALUE("Kind: Always", AlignTrailingComments, Kind,
+                           FormatStyle::TCAS_Always);
+  CHECK_PARSE_NESTED_VALUE("Kind: Never", AlignTrailingComments, Kind,
+                           FormatStyle::TCAS_Never);
+  CHECK_PARSE_NESTED_VALUE("Kind: Leave", AlignTrailingComments, Kind,
+                           FormatStyle::TCAS_Leave);
+  CHECK_PARSE_NESTED_VALUE("OverEmptyLines: 1234", AlignTrailingComments,
+                           OverEmptyLines, 1234u);
+
+  Style.UseTab = FormatStyle::UT_ForIndentation;
+  CHECK_PARSE("UseTab: Never", UseTab, FormatStyle::UT_Never);
+  CHECK_PARSE("UseTab: ForIndentation", UseTab, FormatStyle::UT_ForIndentation);
+  CHECK_PARSE("UseTab: Always", UseTab, FormatStyle::UT_Always);
+  CHECK_PARSE("UseTab: ForContinuationAndIndentation", UseTab,
+              FormatStyle::UT_ForContinuationAndIndentation);
+  CHECK_PARSE("UseTab: AlignWithSpaces", UseTab,
+              FormatStyle::UT_AlignWithSpaces);
+  // For backward compatibility:
+  CHECK_PARSE("UseTab: false", UseTab, FormatStyle::UT_Never);
+  CHECK_PARSE("UseTab: true", UseTab, FormatStyle::UT_Always);
+
+  Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Empty;
+  CHECK_PARSE("AllowShortBlocksOnASingleLine: Never",
+              AllowShortBlocksOnASingleLine, FormatStyle::SBS_Never);
+  CHECK_PARSE("AllowShortBlocksOnASingleLine: Empty",
+              AllowShortBlocksOnASingleLine, FormatStyle::SBS_Empty);
+  CHECK_PARSE("AllowShortBlocksOnASingleLine: Always",
+              AllowShortBlocksOnASingleLine, FormatStyle::SBS_Always);
+  // For backward compatibility:
+  CHECK_PARSE("AllowShortBlocksOnASingleLine: false",
+              AllowShortBlocksOnASingleLine, FormatStyle::SBS_Never);
+  CHECK_PARSE("AllowShortBlocksOnASingleLine: true",
+              AllowShortBlocksOnASingleLine, FormatStyle::SBS_Always);
+
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
+  CHECK_PARSE("AllowShortFunctionsOnASingleLine: None",
+              AllowShortFunctionsOnASingleLine, FormatStyle::SFS_None);
+  CHECK_PARSE("AllowShortFunctionsOnASingleLine: Inline",
+              AllowShortFunctionsOnASingleLine, FormatStyle::SFS_Inline);
+  CHECK_PARSE("AllowShortFunctionsOnASingleLine: Empty",
+              AllowShortFunctionsOnASingleLine, FormatStyle::SFS_Empty);
+  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.AllowShortLambdasOnASingleLine = FormatStyle::SLS_All;
+  CHECK_PARSE("AllowShortLambdasOnASingleLine: None",
+              AllowShortLambdasOnASingleLine, FormatStyle::SLS_None);
+  CHECK_PARSE("AllowShortLambdasOnASingleLine: Empty",
+              AllowShortLambdasOnASingleLine, FormatStyle::SLS_Empty);
+  CHECK_PARSE("AllowShortLambdasOnASingleLine: Inline",
+              AllowShortLambdasOnASingleLine, FormatStyle::SLS_Inline);
+  CHECK_PARSE("AllowShortLambdasOnASingleLine: All",
+              AllowShortLambdasOnASingleLine, FormatStyle::SLS_All);
+  // For backward compatibility:
+  CHECK_PARSE("AllowShortLambdasOnASingleLine: false",
+              AllowShortLambdasOnASingleLine, FormatStyle::SLS_None);
+  CHECK_PARSE("AllowShortLambdasOnASingleLine: true",
+              AllowShortLambdasOnASingleLine, FormatStyle::SLS_All);
+
+  Style.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Both;
+  CHECK_PARSE("SpaceAroundPointerQualifiers: Default",
+              SpaceAroundPointerQualifiers, FormatStyle::SAPQ_Default);
+  CHECK_PARSE("SpaceAroundPointerQualifiers: Before",
+              SpaceAroundPointerQualifiers, FormatStyle::SAPQ_Before);
+  CHECK_PARSE("SpaceAroundPointerQualifiers: After",
+              SpaceAroundPointerQualifiers, FormatStyle::SAPQ_After);
+  CHECK_PARSE("SpaceAroundPointerQualifiers: Both",
+              SpaceAroundPointerQualifiers, FormatStyle::SAPQ_Both);
+
+  Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
+  CHECK_PARSE("SpaceBeforeParens: Never", SpaceBeforeParens,
+              FormatStyle::SBPO_Never);
+  CHECK_PARSE("SpaceBeforeParens: Always", SpaceBeforeParens,
+              FormatStyle::SBPO_Always);
+  CHECK_PARSE("SpaceBeforeParens: ControlStatements", SpaceBeforeParens,
+              FormatStyle::SBPO_ControlStatements);
+  CHECK_PARSE("SpaceBeforeParens: ControlStatementsExceptControlMacros",
+              SpaceBeforeParens,
+              FormatStyle::SBPO_ControlStatementsExceptControlMacros);
+  CHECK_PARSE("SpaceBeforeParens: NonEmptyParentheses", SpaceBeforeParens,
+              FormatStyle::SBPO_NonEmptyParentheses);
+  CHECK_PARSE("SpaceBeforeParens: Custom", SpaceBeforeParens,
+              FormatStyle::SBPO_Custom);
+  // For backward compatibility:
+  CHECK_PARSE("SpaceAfterControlStatementKeyword: false", SpaceBeforeParens,
+              FormatStyle::SBPO_Never);
+  CHECK_PARSE("SpaceAfterControlStatementKeyword: true", SpaceBeforeParens,
+              FormatStyle::SBPO_ControlStatements);
+  CHECK_PARSE("SpaceBeforeParens: ControlStatementsExceptForEachMacros",
+              SpaceBeforeParens,
+              FormatStyle::SBPO_ControlStatementsExceptControlMacros);
+
+  Style.ColumnLimit = 123;
+  FormatStyle BaseStyle = getLLVMStyle();
+  CHECK_PARSE("BasedOnStyle: LLVM", ColumnLimit, BaseStyle.ColumnLimit);
+  CHECK_PARSE("BasedOnStyle: LLVM\nColumnLimit: 1234", ColumnLimit, 1234u);
+
+  Style.BreakBeforeBraces = FormatStyle::BS_Stroustrup;
+  CHECK_PARSE("BreakBeforeBraces: Attach", BreakBeforeBraces,
+              FormatStyle::BS_Attach);
+  CHECK_PARSE("BreakBeforeBraces: Linux", BreakBeforeBraces,
+              FormatStyle::BS_Linux);
+  CHECK_PARSE("BreakBeforeBraces: Mozilla", BreakBeforeBraces,
+              FormatStyle::BS_Mozilla);
+  CHECK_PARSE("BreakBeforeBraces: Stroustrup", BreakBeforeBraces,
+              FormatStyle::BS_Stroustrup);
+  CHECK_PARSE("BreakBeforeBraces: Allman", BreakBeforeBraces,
+              FormatStyle::BS_Allman);
+  CHECK_PARSE("BreakBeforeBraces: Whitesmiths", BreakBeforeBraces,
+              FormatStyle::BS_Whitesmiths);
+  CHECK_PARSE("BreakBeforeBraces: GNU", BreakBeforeBraces, FormatStyle::BS_GNU);
+  CHECK_PARSE("BreakBeforeBraces: WebKit", BreakBeforeBraces,
+              FormatStyle::BS_WebKit);
+  CHECK_PARSE("BreakBeforeBraces: Custom", BreakBeforeBraces,
+              FormatStyle::BS_Custom);
+
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Never;
+  CHECK_PARSE("BraceWrapping:\n"
+              "  AfterControlStatement: MultiLine",
+              BraceWrapping.AfterControlStatement,
+              FormatStyle::BWACS_MultiLine);
+  CHECK_PARSE("BraceWrapping:\n"
+              "  AfterControlStatement: Always",
+              BraceWrapping.AfterControlStatement, FormatStyle::BWACS_Always);
+  CHECK_PARSE("BraceWrapping:\n"
+              "  AfterControlStatement: Never",
+              BraceWrapping.AfterControlStatement, FormatStyle::BWACS_Never);
+  // For backward compatibility:
+  CHECK_PARSE("BraceWrapping:\n"
+              "  AfterControlStatement: true",
+              BraceWrapping.AfterControlStatement, FormatStyle::BWACS_Always);
+  CHECK_PARSE("BraceWrapping:\n"
+              "  AfterControlStatement: false",
+              BraceWrapping.AfterControlStatement, FormatStyle::BWACS_Never);
+
+  Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_All;
+  CHECK_PARSE("AlwaysBreakAfterReturnType: None", AlwaysBreakAfterReturnType,
+              FormatStyle::RTBS_None);
+  CHECK_PARSE("AlwaysBreakAfterReturnType: All", AlwaysBreakAfterReturnType,
+              FormatStyle::RTBS_All);
+  CHECK_PARSE("AlwaysBreakAfterReturnType: TopLevel",
+              AlwaysBreakAfterReturnType, FormatStyle::RTBS_TopLevel);
+  CHECK_PARSE("AlwaysBreakAfterReturnType: AllDefinitions",
+              AlwaysBreakAfterReturnType, FormatStyle::RTBS_AllDefinitions);
+  CHECK_PARSE("AlwaysBreakAfterReturnType: TopLevelDefinitions",
+              AlwaysBreakAfterReturnType,
+              FormatStyle::RTBS_TopLevelDefinitions);
+
+  Style.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
+  CHECK_PARSE("AlwaysBreakTemplateDeclarations: No",
+              AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_No);
+  CHECK_PARSE("AlwaysBreakTemplateDeclarations: MultiLine",
+              AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_MultiLine);
+  CHECK_PARSE("AlwaysBreakTemplateDeclarations: Yes",
+              AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_Yes);
+  CHECK_PARSE("AlwaysBreakTemplateDeclarations: false",
+              AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_MultiLine);
+  CHECK_PARSE("AlwaysBreakTemplateDeclarations: true",
+              AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_Yes);
+
+  Style.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All;
+  CHECK_PARSE("AlwaysBreakAfterDefinitionReturnType: None",
+              AlwaysBreakAfterDefinitionReturnType, FormatStyle::DRTBS_None);
+  CHECK_PARSE("AlwaysBreakAfterDefinitionReturnType: All",
+              AlwaysBreakAfterDefinitionReturnType, FormatStyle::DRTBS_All);
+  CHECK_PARSE("AlwaysBreakAfterDefinitionReturnType: TopLevel",
+              AlwaysBreakAfterDefinitionReturnType,
+              FormatStyle::DRTBS_TopLevel);
+
+  Style.NamespaceIndentation = FormatStyle::NI_All;
+  CHECK_PARSE("NamespaceIndentation: None", NamespaceIndentation,
+              FormatStyle::NI_None);
+  CHECK_PARSE("NamespaceIndentation: Inner", NamespaceIndentation,
+              FormatStyle::NI_Inner);
+  CHECK_PARSE("NamespaceIndentation: All", NamespaceIndentation,
+              FormatStyle::NI_All);
+
+  Style.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_OnlyFirstIf;
+  CHECK_PARSE("AllowShortIfStatementsOnASingleLine: Never",
+              AllowShortIfStatementsOnASingleLine, FormatStyle::SIS_Never);
+  CHECK_PARSE("AllowShortIfStatementsOnASingleLine: WithoutElse",
+              AllowShortIfStatementsOnASingleLine,
+              FormatStyle::SIS_WithoutElse);
+  CHECK_PARSE("AllowShortIfStatementsOnASingleLine: OnlyFirstIf",
+              AllowShortIfStatementsOnASingleLine,
+              FormatStyle::SIS_OnlyFirstIf);
+  CHECK_PARSE("AllowShortIfStatementsOnASingleLine: AllIfsAndElse",
+              AllowShortIfStatementsOnASingleLine,
+              FormatStyle::SIS_AllIfsAndElse);
+  CHECK_PARSE("AllowShortIfStatementsOnASingleLine: Always",
+              AllowShortIfStatementsOnASingleLine,
+              FormatStyle::SIS_OnlyFirstIf);
+  CHECK_PARSE("AllowShortIfStatementsOnASingleLine: false",
+              AllowShortIfStatementsOnASingleLine, FormatStyle::SIS_Never);
+  CHECK_PARSE("AllowShortIfStatementsOnASingleLine: true",
+              AllowShortIfStatementsOnASingleLine,
+              FormatStyle::SIS_WithoutElse);
+
+  Style.IndentExternBlock = FormatStyle::IEBS_NoIndent;
+  CHECK_PARSE("IndentExternBlock: AfterExternBlock", IndentExternBlock,
+              FormatStyle::IEBS_AfterExternBlock);
+  CHECK_PARSE("IndentExternBlock: Indent", IndentExternBlock,
+              FormatStyle::IEBS_Indent);
+  CHECK_PARSE("IndentExternBlock: NoIndent", IndentExternBlock,
+              FormatStyle::IEBS_NoIndent);
+  CHECK_PARSE("IndentExternBlock: true", IndentExternBlock,
+              FormatStyle::IEBS_Indent);
+  CHECK_PARSE("IndentExternBlock: false", IndentExternBlock,
+              FormatStyle::IEBS_NoIndent);
+
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_None;
+  CHECK_PARSE("BitFieldColonSpacing: Both", BitFieldColonSpacing,
+              FormatStyle::BFCS_Both);
+  CHECK_PARSE("BitFieldColonSpacing: None", BitFieldColonSpacing,
+              FormatStyle::BFCS_None);
+  CHECK_PARSE("BitFieldColonSpacing: Before", BitFieldColonSpacing,
+              FormatStyle::BFCS_Before);
+  CHECK_PARSE("BitFieldColonSpacing: After", BitFieldColonSpacing,
+              FormatStyle::BFCS_After);
+
+  Style.SortJavaStaticImport = FormatStyle::SJSIO_Before;
+  CHECK_PARSE("SortJavaStaticImport: After", SortJavaStaticImport,
+              FormatStyle::SJSIO_After);
+  CHECK_PARSE("SortJavaStaticImport: Before", SortJavaStaticImport,
+              FormatStyle::SJSIO_Before);
+
+  // FIXME: This is required because parsing a configuration simply overwrites
+  // the first N elements of the list instead of resetting it.
+  Style.ForEachMacros.clear();
+  std::vector<std::string> BoostForeach;
+  BoostForeach.push_back("BOOST_FOREACH");
+  CHECK_PARSE("ForEachMacros: [BOOST_FOREACH]", ForEachMacros, BoostForeach);
+  std::vector<std::string> BoostAndQForeach;
+  BoostAndQForeach.push_back("BOOST_FOREACH");
+  BoostAndQForeach.push_back("Q_FOREACH");
+  CHECK_PARSE("ForEachMacros: [BOOST_FOREACH, Q_FOREACH]", ForEachMacros,
+              BoostAndQForeach);
+
+  Style.IfMacros.clear();
+  std::vector<std::string> CustomIfs;
+  CustomIfs.push_back("MYIF");
+  CHECK_PARSE("IfMacros: [MYIF]", IfMacros, CustomIfs);
+
+  Style.AttributeMacros.clear();
+  CHECK_PARSE("BasedOnStyle: LLVM", AttributeMacros,
+              std::vector<std::string>{"__capability"});
+  CHECK_PARSE("AttributeMacros: [attr1, attr2]", AttributeMacros,
+              std::vector<std::string>({"attr1", "attr2"}));
+
+  Style.StatementAttributeLikeMacros.clear();
+  CHECK_PARSE("StatementAttributeLikeMacros: [emit,Q_EMIT]",
+              StatementAttributeLikeMacros,
+              std::vector<std::string>({"emit", "Q_EMIT"}));
+
+  Style.StatementMacros.clear();
+  CHECK_PARSE("StatementMacros: [QUNUSED]", StatementMacros,
+              std::vector<std::string>{"QUNUSED"});
+  CHECK_PARSE("StatementMacros: [QUNUSED, QT_REQUIRE_VERSION]", StatementMacros,
+              std::vector<std::string>({"QUNUSED", "QT_REQUIRE_VERSION"}));
+
+  Style.NamespaceMacros.clear();
+  CHECK_PARSE("NamespaceMacros: [TESTSUITE]", NamespaceMacros,
+              std::vector<std::string>{"TESTSUITE"});
+  CHECK_PARSE("NamespaceMacros: [TESTSUITE, SUITE]", NamespaceMacros,
+              std::vector<std::string>({"TESTSUITE", "SUITE"}));
+
+  Style.WhitespaceSensitiveMacros.clear();
+  CHECK_PARSE("WhitespaceSensitiveMacros: [STRINGIZE]",
+              WhitespaceSensitiveMacros, std::vector<std::string>{"STRINGIZE"});
+  CHECK_PARSE("WhitespaceSensitiveMacros: [STRINGIZE, ASSERT]",
+              WhitespaceSensitiveMacros,
+              std::vector<std::string>({"STRINGIZE", "ASSERT"}));
+  Style.WhitespaceSensitiveMacros.clear();
+  CHECK_PARSE("WhitespaceSensitiveMacros: ['STRINGIZE']",
+              WhitespaceSensitiveMacros, std::vector<std::string>{"STRINGIZE"});
+  CHECK_PARSE("WhitespaceSensitiveMacros: ['STRINGIZE', 'ASSERT']",
+              WhitespaceSensitiveMacros,
+              std::vector<std::string>({"STRINGIZE", "ASSERT"}));
+
+  Style.IncludeStyle.IncludeCategories.clear();
+  std::vector<tooling::IncludeStyle::IncludeCategory> ExpectedCategories = {
+      {"abc/.*", 2, 0, false}, {".*", 1, 0, true}};
+  CHECK_PARSE("IncludeCategories:\n"
+              "  - Regex: abc/.*\n"
+              "    Priority: 2\n"
+              "  - Regex: .*\n"
+              "    Priority: 1\n"
+              "    CaseSensitive: true\n",
+              IncludeStyle.IncludeCategories, ExpectedCategories);
+  CHECK_PARSE("IncludeIsMainRegex: 'abc$'", IncludeStyle.IncludeIsMainRegex,
+              "abc$");
+  CHECK_PARSE("IncludeIsMainSourceRegex: 'abc$'",
+              IncludeStyle.IncludeIsMainSourceRegex, "abc$");
+
+  Style.SortIncludes = FormatStyle::SI_Never;
+  CHECK_PARSE("SortIncludes: true", SortIncludes,
+              FormatStyle::SI_CaseSensitive);
+  CHECK_PARSE("SortIncludes: false", SortIncludes, FormatStyle::SI_Never);
+  CHECK_PARSE("SortIncludes: CaseInsensitive", SortIncludes,
+              FormatStyle::SI_CaseInsensitive);
+  CHECK_PARSE("SortIncludes: CaseSensitive", SortIncludes,
+              FormatStyle::SI_CaseSensitive);
+  CHECK_PARSE("SortIncludes: Never", SortIncludes, FormatStyle::SI_Never);
+
+  Style.RawStringFormats.clear();
+  std::vector<FormatStyle::RawStringFormat> ExpectedRawStringFormats = {
+      {
+          FormatStyle::LK_TextProto,
+          {"pb", "proto"},
+          {"PARSE_TEXT_PROTO"},
+          /*CanonicalDelimiter=*/"",
+          "llvm",
+      },
+      {
+          FormatStyle::LK_Cpp,
+          {"cc", "cpp"},
+          {"C_CODEBLOCK", "CPPEVAL"},
+          /*CanonicalDelimiter=*/"cc",
+          /*BasedOnStyle=*/"",
+      },
+  };
+
+  CHECK_PARSE("RawStringFormats:\n"
+              "  - Language: TextProto\n"
+              "    Delimiters:\n"
+              "      - 'pb'\n"
+              "      - 'proto'\n"
+              "    EnclosingFunctions:\n"
+              "      - 'PARSE_TEXT_PROTO'\n"
+              "    BasedOnStyle: llvm\n"
+              "  - Language: Cpp\n"
+              "    Delimiters:\n"
+              "      - 'cc'\n"
+              "      - 'cpp'\n"
+              "    EnclosingFunctions:\n"
+              "      - 'C_CODEBLOCK'\n"
+              "      - 'CPPEVAL'\n"
+              "    CanonicalDelimiter: 'cc'",
+              RawStringFormats, ExpectedRawStringFormats);
+
+  CHECK_PARSE("SpacesInLineCommentPrefix:\n"
+              "  Minimum: 0\n"
+              "  Maximum: 0",
+              SpacesInLineCommentPrefix.Minimum, 0u);
+  EXPECT_EQ(Style.SpacesInLineCommentPrefix.Maximum, 0u);
+  Style.SpacesInLineCommentPrefix.Minimum = 1;
+  CHECK_PARSE("SpacesInLineCommentPrefix:\n"
+              "  Minimum: 2",
+              SpacesInLineCommentPrefix.Minimum, 0u);
+  CHECK_PARSE("SpacesInLineCommentPrefix:\n"
+              "  Maximum: -1",
+              SpacesInLineCommentPrefix.Maximum, -1u);
+  CHECK_PARSE("SpacesInLineCommentPrefix:\n"
+              "  Minimum: 2",
+              SpacesInLineCommentPrefix.Minimum, 2u);
+  CHECK_PARSE("SpacesInLineCommentPrefix:\n"
+              "  Maximum: 1",
+              SpacesInLineCommentPrefix.Maximum, 1u);
+  EXPECT_EQ(Style.SpacesInLineCommentPrefix.Minimum, 1u);
+
+  Style.SpacesInAngles = FormatStyle::SIAS_Always;
+  CHECK_PARSE("SpacesInAngles: Never", SpacesInAngles, FormatStyle::SIAS_Never);
+  CHECK_PARSE("SpacesInAngles: Always", SpacesInAngles,
+              FormatStyle::SIAS_Always);
+  CHECK_PARSE("SpacesInAngles: Leave", SpacesInAngles, FormatStyle::SIAS_Leave);
+  // For backward compatibility:
+  CHECK_PARSE("SpacesInAngles: false", SpacesInAngles, FormatStyle::SIAS_Never);
+  CHECK_PARSE("SpacesInAngles: true", SpacesInAngles, FormatStyle::SIAS_Always);
+
+  CHECK_PARSE("RequiresClausePosition: WithPreceding", RequiresClausePosition,
+              FormatStyle::RCPS_WithPreceding);
+  CHECK_PARSE("RequiresClausePosition: WithFollowing", RequiresClausePosition,
+              FormatStyle::RCPS_WithFollowing);
+  CHECK_PARSE("RequiresClausePosition: SingleLine", RequiresClausePosition,
+              FormatStyle::RCPS_SingleLine);
+  CHECK_PARSE("RequiresClausePosition: OwnLine", RequiresClausePosition,
+              FormatStyle::RCPS_OwnLine);
+
+  CHECK_PARSE("BreakBeforeConceptDeclarations: Never",
+              BreakBeforeConceptDeclarations, FormatStyle::BBCDS_Never);
+  CHECK_PARSE("BreakBeforeConceptDeclarations: Always",
+              BreakBeforeConceptDeclarations, FormatStyle::BBCDS_Always);
+  CHECK_PARSE("BreakBeforeConceptDeclarations: Allowed",
+              BreakBeforeConceptDeclarations, FormatStyle::BBCDS_Allowed);
+  // For backward compatibility:
+  CHECK_PARSE("BreakBeforeConceptDeclarations: true",
+              BreakBeforeConceptDeclarations, FormatStyle::BBCDS_Always);
+  CHECK_PARSE("BreakBeforeConceptDeclarations: false",
+              BreakBeforeConceptDeclarations, FormatStyle::BBCDS_Allowed);
+}
+
+TEST(ConfigParseTest, ParsesConfigurationWithLanguages) {
+  FormatStyle Style = {};
+  Style.Language = FormatStyle::LK_Cpp;
+  CHECK_PARSE("Language: Cpp\n"
+              "IndentWidth: 12",
+              IndentWidth, 12u);
+  EXPECT_EQ(parseConfiguration("Language: JavaScript\n"
+                               "IndentWidth: 34",
+                               &Style),
+            ParseError::Unsuitable);
+  FormatStyle BinPackedTCS = {};
+  BinPackedTCS.Language = FormatStyle::LK_JavaScript;
+  EXPECT_EQ(parseConfiguration("BinPackArguments: true\n"
+                               "InsertTrailingCommas: Wrapped",
+                               &BinPackedTCS),
+            ParseError::BinPackTrailingCommaConflict);
+  EXPECT_EQ(12u, Style.IndentWidth);
+  CHECK_PARSE("IndentWidth: 56", IndentWidth, 56u);
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style.Language);
+
+  Style.Language = FormatStyle::LK_JavaScript;
+  CHECK_PARSE("Language: JavaScript\n"
+              "IndentWidth: 12",
+              IndentWidth, 12u);
+  CHECK_PARSE("IndentWidth: 23", IndentWidth, 23u);
+  EXPECT_EQ(parseConfiguration("Language: Cpp\n"
+                               "IndentWidth: 34",
+                               &Style),
+            ParseError::Unsuitable);
+  EXPECT_EQ(23u, Style.IndentWidth);
+  CHECK_PARSE("IndentWidth: 56", IndentWidth, 56u);
+  EXPECT_EQ(FormatStyle::LK_JavaScript, Style.Language);
+
+  CHECK_PARSE("BasedOnStyle: LLVM\n"
+              "IndentWidth: 67",
+              IndentWidth, 67u);
+
+  CHECK_PARSE("---\n"
+              "Language: JavaScript\n"
+              "IndentWidth: 12\n"
+              "---\n"
+              "Language: Cpp\n"
+              "IndentWidth: 34\n"
+              "...\n",
+              IndentWidth, 12u);
+
+  Style.Language = FormatStyle::LK_Cpp;
+  CHECK_PARSE("---\n"
+              "Language: JavaScript\n"
+              "IndentWidth: 12\n"
+              "---\n"
+              "Language: Cpp\n"
+              "IndentWidth: 34\n"
+              "...\n",
+              IndentWidth, 34u);
+  CHECK_PARSE("---\n"
+              "IndentWidth: 78\n"
+              "---\n"
+              "Language: JavaScript\n"
+              "IndentWidth: 56\n"
+              "...\n",
+              IndentWidth, 78u);
+
+  Style.ColumnLimit = 123;
+  Style.IndentWidth = 234;
+  Style.BreakBeforeBraces = FormatStyle::BS_Linux;
+  Style.TabWidth = 345;
+  EXPECT_FALSE(parseConfiguration("---\n"
+                                  "IndentWidth: 456\n"
+                                  "BreakBeforeBraces: Allman\n"
+                                  "---\n"
+                                  "Language: JavaScript\n"
+                                  "IndentWidth: 111\n"
+                                  "TabWidth: 111\n"
+                                  "---\n"
+                                  "Language: Cpp\n"
+                                  "BreakBeforeBraces: Stroustrup\n"
+                                  "TabWidth: 789\n"
+                                  "...\n",
+                                  &Style));
+  EXPECT_EQ(123u, Style.ColumnLimit);
+  EXPECT_EQ(456u, Style.IndentWidth);
+  EXPECT_EQ(FormatStyle::BS_Stroustrup, Style.BreakBeforeBraces);
+  EXPECT_EQ(789u, Style.TabWidth);
+
+  EXPECT_EQ(parseConfiguration("---\n"
+                               "Language: JavaScript\n"
+                               "IndentWidth: 56\n"
+                               "---\n"
+                               "IndentWidth: 78\n"
+                               "...\n",
+                               &Style),
+            ParseError::Error);
+  EXPECT_EQ(parseConfiguration("---\n"
+                               "Language: JavaScript\n"
+                               "IndentWidth: 56\n"
+                               "---\n"
+                               "Language: JavaScript\n"
+                               "IndentWidth: 78\n"
+                               "...\n",
+                               &Style),
+            ParseError::Error);
+
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style.Language);
+}
+
+TEST(ConfigParseTest, UsesLanguageForBasedOnStyle) {
+  FormatStyle Style = {};
+  Style.Language = FormatStyle::LK_JavaScript;
+  Style.BreakBeforeTernaryOperators = true;
+  EXPECT_EQ(0, parseConfiguration("BasedOnStyle: Google", &Style).value());
+  EXPECT_FALSE(Style.BreakBeforeTernaryOperators);
+
+  Style.BreakBeforeTernaryOperators = true;
+  EXPECT_EQ(0, parseConfiguration("---\n"
+                                  "BasedOnStyle: Google\n"
+                                  "---\n"
+                                  "Language: JavaScript\n"
+                                  "IndentWidth: 76\n"
+                                  "...\n",
+                                  &Style)
+                   .value());
+  EXPECT_FALSE(Style.BreakBeforeTernaryOperators);
+  EXPECT_EQ(76u, Style.IndentWidth);
+  EXPECT_EQ(FormatStyle::LK_JavaScript, Style.Language);
+}
+
+TEST(ConfigParseTest, ConfigurationRoundTripTest) {
+  FormatStyle Style = getLLVMStyle();
+  std::string YAML = configurationAsText(Style);
+  FormatStyle ParsedStyle = {};
+  ParsedStyle.Language = FormatStyle::LK_Cpp;
+  EXPECT_EQ(0, parseConfiguration(YAML, &ParsedStyle).value());
+  EXPECT_EQ(Style, ParsedStyle);
+}
+
+TEST(ConfigParseTest, GetStyleWithEmptyFileName) {
+  llvm::vfs::InMemoryFileSystem FS;
+  auto Style1 = getStyle("file", "", "Google", "", &FS);
+  ASSERT_TRUE((bool)Style1);
+  ASSERT_EQ(*Style1, getGoogleStyle());
+}
+
+TEST(ConfigParseTest, GetStyleOfFile) {
+  llvm::vfs::InMemoryFileSystem FS;
+  // Test 1: format file in the same directory.
+  ASSERT_TRUE(
+      FS.addFile("/a/.clang-format", 0,
+                 llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM")));
+  ASSERT_TRUE(
+      FS.addFile("/a/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style1 = getStyle("file", "/a/.clang-format", "Google", "", &FS);
+  ASSERT_TRUE((bool)Style1);
+  ASSERT_EQ(*Style1, getLLVMStyle());
+
+  // Test 2.1: fallback to default.
+  ASSERT_TRUE(
+      FS.addFile("/b/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style2 = getStyle("file", "/b/test.cpp", "Mozilla", "", &FS);
+  ASSERT_TRUE((bool)Style2);
+  ASSERT_EQ(*Style2, getMozillaStyle());
+
+  // Test 2.2: no format on 'none' fallback style.
+  Style2 = getStyle("file", "/b/test.cpp", "none", "", &FS);
+  ASSERT_TRUE((bool)Style2);
+  ASSERT_EQ(*Style2, getNoStyle());
+
+  // Test 2.3: format if config is found with no based style while fallback is
+  // 'none'.
+  ASSERT_TRUE(FS.addFile("/b/.clang-format", 0,
+                         llvm::MemoryBuffer::getMemBuffer("IndentWidth: 2")));
+  Style2 = getStyle("file", "/b/test.cpp", "none", "", &FS);
+  ASSERT_TRUE((bool)Style2);
+  ASSERT_EQ(*Style2, getLLVMStyle());
+
+  // Test 2.4: format if yaml with no based style, while fallback is 'none'.
+  Style2 = getStyle("{}", "a.h", "none", "", &FS);
+  ASSERT_TRUE((bool)Style2);
+  ASSERT_EQ(*Style2, getLLVMStyle());
+
+  // Test 3: format file in parent directory.
+  ASSERT_TRUE(
+      FS.addFile("/c/.clang-format", 0,
+                 llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  ASSERT_TRUE(FS.addFile("/c/sub/sub/sub/test.cpp", 0,
+                         llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style3 = getStyle("file", "/c/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_TRUE((bool)Style3);
+  ASSERT_EQ(*Style3, getGoogleStyle());
+
+  // Test 4: error on invalid fallback style
+  auto Style4 = getStyle("file", "a.h", "KungFu", "", &FS);
+  ASSERT_FALSE((bool)Style4);
+  llvm::consumeError(Style4.takeError());
+
+  // Test 5: error on invalid yaml on command line
+  auto Style5 = getStyle("{invalid_key=invalid_value}", "a.h", "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style5);
+  llvm::consumeError(Style5.takeError());
+
+  // Test 6: error on invalid style
+  auto Style6 = getStyle("KungFu", "a.h", "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style6);
+  llvm::consumeError(Style6.takeError());
+
+  // Test 7: found config file, error on parsing it
+  ASSERT_TRUE(
+      FS.addFile("/d/.clang-format", 0,
+                 llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM\n"
+                                                  "InvalidKey: InvalidValue")));
+  ASSERT_TRUE(
+      FS.addFile("/d/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style7a = getStyle("file", "/d/.clang-format", "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style7a);
+  llvm::consumeError(Style7a.takeError());
+
+  auto Style7b = getStyle("file", "/d/.clang-format", "LLVM", "", &FS, true);
+  ASSERT_TRUE((bool)Style7b);
+
+  // Test 8: inferred per-language defaults apply.
+  auto StyleTd = getStyle("file", "x.td", "llvm", "", &FS);
+  ASSERT_TRUE((bool)StyleTd);
+  ASSERT_EQ(*StyleTd, getLLVMStyle(FormatStyle::LK_TableGen));
+
+  // Test 9.1.1: overwriting a file style, when no parent file exists with no
+  // fallback style.
+  ASSERT_TRUE(FS.addFile(
+      "/e/sub/.clang-format", 0,
+      llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: InheritParentConfig\n"
+                                       "ColumnLimit: 20")));
+  ASSERT_TRUE(FS.addFile("/e/sub/code.cpp", 0,
+                         llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style9 = getStyle("file", "/e/sub/code.cpp", "none", "", &FS);
+  ASSERT_TRUE(static_cast<bool>(Style9));
+  ASSERT_EQ(*Style9, [] {
+    auto Style = getNoStyle();
+    Style.ColumnLimit = 20;
+    return Style;
+  }());
+
+  // Test 9.1.2: propagate more than one level with no parent file.
+  ASSERT_TRUE(FS.addFile("/e/sub/sub/code.cpp", 0,
+                         llvm::MemoryBuffer::getMemBuffer("int i;")));
+  ASSERT_TRUE(FS.addFile("/e/sub/sub/.clang-format", 0,
+                         llvm::MemoryBuffer::getMemBuffer(
+                             "BasedOnStyle: InheritParentConfig\n"
+                             "WhitespaceSensitiveMacros: ['FOO', 'BAR']")));
+  std::vector<std::string> NonDefaultWhiteSpaceMacros =
+      Style9->WhitespaceSensitiveMacros;
+  NonDefaultWhiteSpaceMacros[0] = "FOO";
+  NonDefaultWhiteSpaceMacros[1] = "BAR";
+
+  ASSERT_NE(Style9->WhitespaceSensitiveMacros, NonDefaultWhiteSpaceMacros);
+  Style9 = getStyle("file", "/e/sub/sub/code.cpp", "none", "", &FS);
+  ASSERT_TRUE(static_cast<bool>(Style9));
+  ASSERT_EQ(*Style9, [&NonDefaultWhiteSpaceMacros] {
+    auto Style = getNoStyle();
+    Style.ColumnLimit = 20;
+    Style.WhitespaceSensitiveMacros = NonDefaultWhiteSpaceMacros;
+    return Style;
+  }());
+
+  // Test 9.2: with LLVM fallback style
+  Style9 = getStyle("file", "/e/sub/code.cpp", "LLVM", "", &FS);
+  ASSERT_TRUE(static_cast<bool>(Style9));
+  ASSERT_EQ(*Style9, [] {
+    auto Style = getLLVMStyle();
+    Style.ColumnLimit = 20;
+    return Style;
+  }());
+
+  // Test 9.3: with a parent file
+  ASSERT_TRUE(
+      FS.addFile("/e/.clang-format", 0,
+                 llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google\n"
+                                                  "UseTab: Always")));
+  Style9 = getStyle("file", "/e/sub/code.cpp", "none", "", &FS);
+  ASSERT_TRUE(static_cast<bool>(Style9));
+  ASSERT_EQ(*Style9, [] {
+    auto Style = getGoogleStyle();
+    Style.ColumnLimit = 20;
+    Style.UseTab = FormatStyle::UT_Always;
+    return Style;
+  }());
+
+  // Test 9.4: propagate more than one level with a parent file.
+  const auto SubSubStyle = [&NonDefaultWhiteSpaceMacros] {
+    auto Style = getGoogleStyle();
+    Style.ColumnLimit = 20;
+    Style.UseTab = FormatStyle::UT_Always;
+    Style.WhitespaceSensitiveMacros = NonDefaultWhiteSpaceMacros;
+    return Style;
+  }();
+
+  ASSERT_NE(Style9->WhitespaceSensitiveMacros, NonDefaultWhiteSpaceMacros);
+  Style9 = getStyle("file", "/e/sub/sub/code.cpp", "none", "", &FS);
+  ASSERT_TRUE(static_cast<bool>(Style9));
+  ASSERT_EQ(*Style9, SubSubStyle);
+
+  // Test 9.5: use InheritParentConfig as style name
+  Style9 =
+      getStyle("inheritparentconfig", "/e/sub/sub/code.cpp", "none", "", &FS);
+  ASSERT_TRUE(static_cast<bool>(Style9));
+  ASSERT_EQ(*Style9, SubSubStyle);
+
+  // Test 9.6: use command line style with inheritance
+  Style9 = getStyle("{BasedOnStyle: InheritParentConfig}",
+                    "/e/sub/sub/code.cpp", "none", "", &FS);
+  ASSERT_TRUE(static_cast<bool>(Style9));
+  ASSERT_EQ(*Style9, SubSubStyle);
+
+  // Test 9.7: use command line style with inheritance and own config
+  Style9 = getStyle("{BasedOnStyle: InheritParentConfig, "
+                    "WhitespaceSensitiveMacros: ['FOO', 'BAR']}",
+                    "/e/sub/code.cpp", "none", "", &FS);
+  ASSERT_TRUE(static_cast<bool>(Style9));
+  ASSERT_EQ(*Style9, SubSubStyle);
+
+  // Test 9.8: use inheritance from a file without BasedOnStyle
+  ASSERT_TRUE(FS.addFile("/e/withoutbase/.clang-format", 0,
+                         llvm::MemoryBuffer::getMemBuffer("ColumnLimit: 123")));
+  ASSERT_TRUE(
+      FS.addFile("/e/withoutbase/sub/.clang-format", 0,
+                 llvm::MemoryBuffer::getMemBuffer(
+                     "BasedOnStyle: InheritParentConfig\nIndentWidth: 7")));
+  // Make sure we do not use the fallback style
+  Style9 = getStyle("file", "/e/withoutbase/code.cpp", "google", "", &FS);
+  ASSERT_TRUE(static_cast<bool>(Style9));
+  ASSERT_EQ(*Style9, [] {
+    auto Style = getLLVMStyle();
+    Style.ColumnLimit = 123;
+    return Style;
+  }());
+
+  Style9 = getStyle("file", "/e/withoutbase/sub/code.cpp", "google", "", &FS);
+  ASSERT_TRUE(static_cast<bool>(Style9));
+  ASSERT_EQ(*Style9, [] {
+    auto Style = getLLVMStyle();
+    Style.ColumnLimit = 123;
+    Style.IndentWidth = 7;
+    return Style;
+  }());
+
+  // Test 9.9: use inheritance from a specific config file.
+  Style9 = getStyle("file:/e/sub/sub/.clang-format", "/e/sub/sub/code.cpp",
+                    "none", "", &FS);
+  ASSERT_TRUE(static_cast<bool>(Style9));
+  ASSERT_EQ(*Style9, SubSubStyle);
+}
+
+TEST(ConfigParseTest, GetStyleOfSpecificFile) {
+  llvm::vfs::InMemoryFileSystem FS;
+  // Specify absolute path to a format file in a parent directory.
+  ASSERT_TRUE(
+      FS.addFile("/e/.clang-format", 0,
+                 llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM")));
+  ASSERT_TRUE(
+      FS.addFile("/e/explicit.clang-format", 0,
+                 llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  ASSERT_TRUE(FS.addFile("/e/sub/sub/sub/test.cpp", 0,
+                         llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style = getStyle("file:/e/explicit.clang-format",
+                        "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_TRUE(static_cast<bool>(Style));
+  ASSERT_EQ(*Style, getGoogleStyle());
+
+  // Specify relative path to a format file.
+  ASSERT_TRUE(
+      FS.addFile("../../e/explicit.clang-format", 0,
+                 llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  Style = getStyle("file:../../e/explicit.clang-format",
+                   "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_TRUE(static_cast<bool>(Style));
+  ASSERT_EQ(*Style, getGoogleStyle());
+
+  // Specify path to a format file that does not exist.
+  Style = getStyle("file:/e/missing.clang-format", "/e/sub/sub/sub/test.cpp",
+                   "LLVM", "", &FS);
+  ASSERT_FALSE(static_cast<bool>(Style));
+  llvm::consumeError(Style.takeError());
+
+  // Specify path to a file on the filesystem.
+  SmallString<128> FormatFilePath;
+  std::error_code ECF = llvm::sys::fs::createTemporaryFile(
+      "FormatFileTest", "tpl", FormatFilePath);
+  EXPECT_FALSE((bool)ECF);
+  llvm::raw_fd_ostream FormatFileTest(FormatFilePath, ECF);
+  EXPECT_FALSE((bool)ECF);
+  FormatFileTest << "BasedOnStyle: Google\n";
+  FormatFileTest.close();
+
+  SmallString<128> TestFilePath;
+  std::error_code ECT =
+      llvm::sys::fs::createTemporaryFile("CodeFileTest", "cc", TestFilePath);
+  EXPECT_FALSE((bool)ECT);
+  llvm::raw_fd_ostream CodeFileTest(TestFilePath, ECT);
+  CodeFileTest << "int i;\n";
+  CodeFileTest.close();
+
+  std::string format_file_arg = std::string("file:") + FormatFilePath.c_str();
+  Style = getStyle(format_file_arg, TestFilePath, "LLVM", "", nullptr);
+
+  llvm::sys::fs::remove(FormatFilePath.c_str());
+  llvm::sys::fs::remove(TestFilePath.c_str());
+  ASSERT_TRUE(static_cast<bool>(Style));
+  ASSERT_EQ(*Style, getGoogleStyle());
+}
+
+} // namespace
+} // namespace format
+} // namespace clang