summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index ce79a1c97b9..9624ac92240 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -4037,6 +4037,42 @@ TEST_F(FormatTest, ConfigurableUseOfTab) {
Tab);
}
+TEST_F(FormatTest, LinuxBraceBreaking) {
+ FormatStyle BreakBeforeBrace = getLLVMStyle();
+ BreakBeforeBrace.BreakBeforeBraces = FormatStyle::BS_Linux;
+ verifyFormat("namespace a\n"
+ "{\n"
+ "class A\n"
+ "{\n"
+ " void f()\n"
+ " {\n"
+ " if (true) {\n"
+ " a();\n"
+ " b();\n"
+ " }\n"
+ " }\n"
+ "}\n"
+ "}",
+ BreakBeforeBrace);
+}
+
+TEST_F(FormatTest, StroustrupBraceBreaking) {
+ FormatStyle BreakBeforeBrace = getLLVMStyle();
+ BreakBeforeBrace.BreakBeforeBraces = FormatStyle::BS_Stroustrup;
+ verifyFormat("namespace a {\n"
+ "class A {\n"
+ " void f()\n"
+ " {\n"
+ " if (true) {\n"
+ " a();\n"
+ " b();\n"
+ " }\n"
+ " }\n"
+ "}\n"
+ "}",
+ BreakBeforeBrace);
+}
+
bool allStylesEqual(ArrayRef<FormatStyle> Styles) {
for (size_t i = 1; i < Styles.size(); ++i)
if (!(Styles[0] == Styles[i]))
@@ -4113,6 +4149,14 @@ TEST_F(FormatTest, ParsesConfiguration) {
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: Stroustrup", BreakBeforeBraces,
+ FormatStyle::BS_Stroustrup);
+
#undef CHECK_PARSE
#undef CHECK_PARSE_BOOL
}
OpenPOWER on IntegriCloud