diff options
author | Owen Pan <owenpiano@gmail.com> | 2025-05-28 19:10:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-28 19:10:20 -0700 |
commit | 7e1a88b9d1431e263258e3ff0f729c1fdce342d3 (patch) | |
tree | 0b3a128656c01979dee35ef9b854336fc88667be /clang/unittests/Format/ConfigParseTest.cpp | |
parent | 7b074fc9362a4a6a5f172dd8936a22fb25eff96b (diff) | |
download | llvm-7e1a88b9d1431e263258e3ff0f729c1fdce342d3.zip llvm-7e1a88b9d1431e263258e3ff0f729c1fdce342d3.tar.gz llvm-7e1a88b9d1431e263258e3ff0f729c1fdce342d3.tar.bz2 |
[clang-format] Handle .h files for LK_C and LK_ObjC (#141714)
Fix #137792
Diffstat (limited to 'clang/unittests/Format/ConfigParseTest.cpp')
-rw-r--r-- | clang/unittests/Format/ConfigParseTest.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp index 5b9055d..aedfdd1 100644 --- a/clang/unittests/Format/ConfigParseTest.cpp +++ b/clang/unittests/Format/ConfigParseTest.cpp @@ -1267,6 +1267,24 @@ TEST(ConfigParseTest, AllowCppForC) { ParseError::Success); } +TEST(ConfigParseTest, HandleNonCppDotHFile) { + FormatStyle Style = {}; + Style.Language = FormatStyle::LK_Cpp; + EXPECT_EQ(parseConfiguration("Language: C", &Style, + /*AllowUnknownOptions=*/false, + /*IsDotHFile=*/true), + ParseError::Success); + EXPECT_EQ(Style.Language, FormatStyle::LK_C); + + Style = {}; + Style.Language = FormatStyle::LK_Cpp; + EXPECT_EQ(parseConfiguration("Language: ObjC", &Style, + /*AllowUnknownOptions=*/false, + /*IsDotHFile=*/true), + ParseError::Success); + EXPECT_EQ(Style.Language, FormatStyle::LK_ObjC); +} + TEST(ConfigParseTest, UsesLanguageForBasedOnStyle) { FormatStyle Style = {}; Style.Language = FormatStyle::LK_JavaScript; |