From 5ddcd765dbb088b3fe8eb09dd38db1252981962c Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Mon, 19 May 2025 01:32:17 -0700 Subject: [clang-format][NFC] Upgrade SortIncludes option to a struct (#140497) This allows adding other suboptions e.g. IgnoreExtension in #137840. --- clang/unittests/Format/ConfigParseTest.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'clang/unittests/Format/ConfigParseTest.cpp') diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp index bd27a9f..5b9055d 100644 --- a/clang/unittests/Format/ConfigParseTest.cpp +++ b/clang/unittests/Format/ConfigParseTest.cpp @@ -257,6 +257,8 @@ TEST(ConfigParseTest, ParsesConfigurationBools) { CHECK_PARSE_NESTED_BOOL(SpacesInParensOptions, InConditionalStatements); CHECK_PARSE_NESTED_BOOL(SpacesInParensOptions, InEmptyParentheses); CHECK_PARSE_NESTED_BOOL(SpacesInParensOptions, Other); + CHECK_PARSE_NESTED_BOOL(SortIncludes, Enabled); + CHECK_PARSE_NESTED_BOOL(SortIncludes, IgnoreCase); } #undef CHECK_PARSE_BOOL @@ -976,15 +978,20 @@ TEST(ConfigParseTest, ParsesConfiguration) { CHECK_PARSE("IncludeIsMainSourceRegex: 'abc$'", IncludeStyle.IncludeIsMainSourceRegex, "abc$"); - Style.SortIncludes = FormatStyle::SI_Never; + Style.SortIncludes = {}; CHECK_PARSE("SortIncludes: true", SortIncludes, - FormatStyle::SI_CaseSensitive); - CHECK_PARSE("SortIncludes: false", SortIncludes, FormatStyle::SI_Never); + FormatStyle::SortIncludesOptions( + {/*Enabled=*/true, /*IgnoreCase=*/false})); + CHECK_PARSE("SortIncludes: false", SortIncludes, + FormatStyle::SortIncludesOptions({})); CHECK_PARSE("SortIncludes: CaseInsensitive", SortIncludes, - FormatStyle::SI_CaseInsensitive); + FormatStyle::SortIncludesOptions( + {/*Enabled=*/true, /*IgnoreCase=*/true})); CHECK_PARSE("SortIncludes: CaseSensitive", SortIncludes, - FormatStyle::SI_CaseSensitive); - CHECK_PARSE("SortIncludes: Never", SortIncludes, FormatStyle::SI_Never); + FormatStyle::SortIncludesOptions( + {/*Enabled=*/true, /*IgnoreCase=*/false})); + CHECK_PARSE("SortIncludes: Never", SortIncludes, + FormatStyle::SortIncludesOptions({})); Style.RawStringFormats.clear(); std::vector ExpectedRawStringFormats = { -- cgit v1.1