Skip to content

Commit 3a1c901

Browse files
committed
FormatTest: fix and add test cases for ExceptDoubleParentheses
1 parent 5cbcc79 commit 3a1c901

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

clang/unittests/Format/FormatTest.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17375,6 +17375,8 @@ TEST_F(FormatTest, ConfigurableSpacesInParens) {
1737517375
verifyFormat("int x __attribute__( ( aligned( 16 ) ) ) = 0;", Spaces);
1737617376
verifyFormat("class __declspec( dllimport ) X {};", Spaces);
1737717377
verifyFormat("class __declspec( ( dllimport ) ) X {};", Spaces);
17378+
verifyFormat("int x = ( ( a - 1 ) * 3 );", Spaces);
17379+
verifyFormat("int x = ( 3 * ( a - 1 ) );", Spaces);
1737817380

1737917381
Spaces.SpacesInParensOptions.ExceptDoubleParentheses = true;
1738017382
verifyFormat("SomeType *__attribute__(( attr )) *a = NULL;", Spaces);
@@ -17384,6 +17386,8 @@ TEST_F(FormatTest, ConfigurableSpacesInParens) {
1738417386
verifyFormat("int x __attribute__(( aligned( 16 ) )) = 0;", Spaces);
1738517387
verifyFormat("class __declspec( dllimport ) X {};", Spaces);
1738617388
verifyFormat("class __declspec(( dllimport )) X {};", Spaces);
17389+
verifyFormat("int x = ( ( a - 1 ) * 3 );", Spaces);
17390+
verifyFormat("int x = ( 3 * ( a - 1 ) );", Spaces);
1738717391

1738817392
Spaces.SpacesInParensOptions.Other = false;
1738917393
verifyFormat("SomeType *__attribute__((attr)) *a = NULL;", Spaces);
@@ -17559,10 +17563,10 @@ TEST_F(FormatTest, ConfigurableSpacesInParens) {
1755917563
verifyFormat("decltype( ( foo() ) ) a = foo();", Spaces);
1756017564
verifyFormat("decltype( ( bar( 10 ) ) ) a = bar( 11 );", Spaces);
1756117565
verifyFormat("decltype( ( foo->bar ) ) baz;", Spaces);
17562-
verifyFormat("if (( i = j ))\n"
17566+
verifyFormat("if ( ( i = j ) )\n"
1756317567
" do_something( i );",
1756417568
Spaces);
17565-
verifyFormat("if constexpr (( a = b ))\n"
17569+
verifyFormat("if constexpr ( ( a = b ) )\n"
1756617570
" c;",
1756717571
Spaces);
1756817572

0 commit comments

Comments
 (0)