[clang-format] add config parse test for short lambda
authorBackl1ght <backlight.zzk@gmail.com>
Fri, 16 Dec 2022 12:53:58 +0000 (20:53 +0800)
committerBackl1ght <backlight.zzk@gmail.com>
Fri, 16 Dec 2022 13:36:07 +0000 (21:36 +0800)
Reviewed By: HazardyKnusperkeks, MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D140105

clang/unittests/Format/ConfigParseTest.cpp

index a65fffc..777b2c2 100644 (file)
@@ -533,6 +533,21 @@ TEST(ConfigParseTest, ParsesConfiguration) {
   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