diff options
author | Owen Pan <owenpiano@gmail.com> | 2023-06-16 00:00:43 -0700 |
---|---|---|
committer | Owen Pan <owenpiano@gmail.com> | 2023-06-16 16:03:19 -0700 |
commit | 20b4df1ed611517d2c964dbade3e61aff4be2e87 (patch) | |
tree | b540e8fd7c1d024d9cf632ac81831bb5ce670529 /clang/unittests/Format/FormatTestJS.cpp | |
parent | 12c12c5fe0f0ec55086bbd1609c847db6c269cdf (diff) | |
download | llvm-20b4df1ed611517d2c964dbade3e61aff4be2e87.zip llvm-20b4df1ed611517d2c964dbade3e61aff4be2e87.tar.gz llvm-20b4df1ed611517d2c964dbade3e61aff4be2e87.tar.bz2 |
[clang-format][NFC] Clean up unit tests
This patch adds a verifyNoChange macro to verify code that won't
change after being formatted. (The code will not be messed up before
being formatted.) It then replaces EXPECT_EQ with verifyFormat
wherever applicable so that the code will be messed up before being
formatted. When the replacement fails the unit test, verifyFormat is
replaced with verifyNoChange.
Differential Revision: https://reviews.llvm.org/D153109
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index ce81bd5..1df7859 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -116,12 +116,10 @@ TEST_F(FormatTestJS, JSDocComments) { " */", getGoogleJSStyleWithColumns(20))); // Don't break the first line of a short single line jsdoc comment. - EXPECT_EQ("/** jsdoc line 1 */", - format("/** jsdoc line 1 */", getGoogleJSStyleWithColumns(20))); + verifyFormat("/** jsdoc line 1 */", getGoogleJSStyleWithColumns(20)); // Don't break the first line of a single line jsdoc comment if it just fits // the column limit. - EXPECT_EQ("/** jsdoc line 12 */", - format("/** jsdoc line 12 */", getGoogleJSStyleWithColumns(20))); + verifyFormat("/** jsdoc line 12 */", getGoogleJSStyleWithColumns(20)); // Don't break after '/**' and before '*/' if there is no space between // '/**' and the content. EXPECT_EQ( @@ -183,8 +181,7 @@ TEST_F(FormatTestJS, JSDocComments) { getGoogleJSStyleWithColumns(20))); // Don't break the first line of a single line short jsdoc comment pragma. - EXPECT_EQ("/** @returns j */", - format("/** @returns j */", getGoogleJSStyleWithColumns(20))); + verifyFormat("/** @returns j */", getGoogleJSStyleWithColumns(20)); // Break a single line long jsdoc comment pragma. EXPECT_EQ("/**\n" |