diff options
author | Eric Liu <ioeric@google.com> | 2016-09-09 17:50:49 +0000 |
---|---|---|
committer | Eric Liu <ioeric@google.com> | 2016-09-09 17:50:49 +0000 |
commit | 01426ff875419e939f91d959904baac23075084f (patch) | |
tree | e54546adf0175478fcb52f9712a6b300c96a0d7d /clang/unittests/Format/CleanupTest.cpp | |
parent | c6d54da891b5b7f6634d41a1c59eab4d5e226711 (diff) | |
download | bcm5719-llvm-01426ff875419e939f91d959904baac23075084f.tar.gz bcm5719-llvm-01426ff875419e939f91d959904baac23075084f.zip |
Also cleanup comments around redundant colons/commas in format::cleanup.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D24400
llvm-svn: 281064
Diffstat (limited to 'clang/unittests/Format/CleanupTest.cpp')
-rw-r--r-- | clang/unittests/Format/CleanupTest.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/clang/unittests/Format/CleanupTest.cpp b/clang/unittests/Format/CleanupTest.cpp index cb1c742fecb..c2b1ef25586 100644 --- a/clang/unittests/Format/CleanupTest.cpp +++ b/clang/unittests/Format/CleanupTest.cpp @@ -188,39 +188,34 @@ TEST_F(CleanupTest, RedundantCommaNotInAffectedRanges) { EXPECT_EQ(Expected, Result); } -// FIXME: delete comments too. -TEST_F(CleanupTest, CtorInitializationCommentAroundCommas) { - // Remove redundant commas around comment. - std::string Code = "class A {\nA() : x({1}), /* comment */, {} };"; - std::string Expected = "class A {\nA() : x({1}) /* comment */ {} };"; +TEST_F(CleanupTest, RemoveCommentsAroundDeleteCode) { + std::string Code = + "class A {\nA() : x({1}), /* comment */, /* comment */ {} };"; + std::string Expected = "class A {\nA() : x({1}) {} };"; std::vector<tooling::Range> Ranges; Ranges.push_back(tooling::Range(25, 0)); Ranges.push_back(tooling::Range(40, 0)); std::string Result = cleanup(Code, Ranges); EXPECT_EQ(Expected, Result); - // Remove trailing comma and ignore comment. - Code = "class A {\nA() : x({1}), // comment\n{} };"; - Expected = "class A {\nA() : x({1}) // comment\n{} };"; + Code = "class A {\nA() : x({1}), // comment\n {} };"; + Expected = "class A {\nA() : x({1})\n {} };"; Ranges = std::vector<tooling::Range>(1, tooling::Range(25, 0)); Result = cleanup(Code, Ranges); EXPECT_EQ(Expected, Result); - // Remove trailing comma and ignore comment. Code = "class A {\nA() : x({1}), // comment\n , y(1),{} };"; - Expected = "class A {\nA() : x({1}), // comment\n y(1){} };"; + Expected = "class A {\nA() : x({1}), y(1){} };"; Ranges = std::vector<tooling::Range>(1, tooling::Range(38, 0)); Result = cleanup(Code, Ranges); EXPECT_EQ(Expected, Result); - // Remove trailing comma and ignore comment. Code = "class A {\nA() : x({1}), \n/* comment */, y(1),{} };"; - Expected = "class A {\nA() : x({1}), \n/* comment */ y(1){} };"; + Expected = "class A {\nA() : x({1}), \n y(1){} };"; Ranges = std::vector<tooling::Range>(1, tooling::Range(40, 0)); Result = cleanup(Code, Ranges); EXPECT_EQ(Expected, Result); - // Remove trailing comma and ignore comment. Code = "class A {\nA() : , // comment\n y(1),{} };"; Expected = "class A {\nA() : // comment\n y(1){} };"; Ranges = std::vector<tooling::Range>(1, tooling::Range(17, 0)); |