aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Format
diff options
context:
space:
mode:
authorrmarker <37921131+rmarker@users.noreply.github.com>2024-01-15 06:25:44 +1030
committerGitHub <noreply@github.com>2024-01-14 20:55:44 +0100
commit60a9874f54922a0fd9bfca9a028c32473f7ef85f (patch)
treefb675245fae942260694fe2162d944c859560b19 /clang/unittests/Format
parent7f1d757fb40f06cc1c6b134d770987b340286996 (diff)
downloadllvm-60a9874f54922a0fd9bfca9a028c32473f7ef85f.zip
llvm-60a9874f54922a0fd9bfca9a028c32473f7ef85f.tar.gz
llvm-60a9874f54922a0fd9bfca9a028c32473f7ef85f.tar.bz2
[clang-format] Add PenaltyBreakScopeResolution option. (#78015)
Resolves #78014
Diffstat (limited to 'clang/unittests/Format')
-rw-r--r--clang/unittests/Format/ConfigParseTest.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp13
2 files changed, 15 insertions, 0 deletions
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index 18ecba2..6c0f9dd 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -255,6 +255,8 @@ TEST(ConfigParseTest, ParsesConfiguration) {
PenaltyBreakTemplateDeclaration, 1234u);
CHECK_PARSE("PenaltyBreakOpenParenthesis: 1234", PenaltyBreakOpenParenthesis,
1234u);
+ CHECK_PARSE("PenaltyBreakScopeResolution: 1234", PenaltyBreakScopeResolution,
+ 1234u);
CHECK_PARSE("PenaltyExcessCharacter: 1234", PenaltyExcessCharacter, 1234u);
CHECK_PARSE("PenaltyReturnTypeOnItsOwnLine: 1234",
PenaltyReturnTypeOnItsOwnLine, 1234u);
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 340ae39..263bbed 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -21567,6 +21567,19 @@ TEST_F(FormatTest, BreakPenaltyAfterForLoopLParen) {
Style);
}
+TEST_F(FormatTest, BreakPenaltyScopeResolution) {
+ FormatStyle Style = getLLVMStyle();
+ Style.ColumnLimit = 20;
+ Style.PenaltyExcessCharacter = 100;
+ verifyFormat("unsigned long\n"
+ "foo::bar();",
+ Style);
+ Style.PenaltyBreakScopeResolution = 10;
+ verifyFormat("unsigned long foo::\n"
+ " bar();",
+ Style);
+}
+
TEST_F(FormatTest, WorksFor8bitEncodings) {
// FIXME: unstable test case
EXPECT_EQ("\"\xce\xe4\xed\xe0\xe6\xe4\xfb \xe2 \"\n"