diff options
author | MyDeveloperDay <mydeveloperday@gmail.com> | 2024-01-12 08:30:53 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-12 08:30:53 +0000 |
commit | c65b939fb795ce4688d33531341d460a47d16664 (patch) | |
tree | 8a4f6b76f560273d5c1cb9e1ec4f31ee910b4f5f /clang/unittests/Format/FormatTestJava.cpp | |
parent | ef156f91262e960eea5ca93f95dd6111cfa3c5cc (diff) | |
download | llvm-c65b939fb795ce4688d33531341d460a47d16664.zip llvm-c65b939fb795ce4688d33531341d460a47d16664.tar.gz llvm-c65b939fb795ce4688d33531341d460a47d16664.tar.bz2 |
[clang-format] SpacesInSquareBrackets not working for Java (#77833)
spaces in [] needs to be handled the same in Java the same as C#.
Co-authored-by: paul_hoad <paul_hoad@amat.com>
Diffstat (limited to 'clang/unittests/Format/FormatTestJava.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestJava.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp index 202d603..6da5f4f 100644 --- a/clang/unittests/Format/FormatTestJava.cpp +++ b/clang/unittests/Format/FormatTestJava.cpp @@ -603,6 +603,21 @@ TEST_F(FormatTestJava, ShortFunctions) { Style); } +TEST_F(FormatTestJava, ConfigurableSpacesInSquareBrackets) { + FormatStyle Spaces = getLLVMStyle(FormatStyle::LK_Java); + + verifyFormat("Object[] arguments", Spaces); + verifyFormat("final Class<?>[] types = new Class<?>[numElements];", Spaces); + verifyFormat("types[i] = arguments[i].getClass();", Spaces); + + Spaces.SpacesInSquareBrackets = true; + + verifyFormat("Object[ ] arguments", Spaces); + verifyFormat("final Class<?>[ ] types = new Class<?>[ numElements ];", + Spaces); + verifyFormat("types[ i ] = arguments[ i ].getClass();", Spaces); +} + } // namespace } // namespace test } // namespace format |