diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2012-07-31 22:37:06 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2012-07-31 22:37:06 +0000 |
commit | 34df220410b36fd6643154d3d6071bac74403da0 (patch) | |
tree | 1f73381a70095ae60f5ab0c1da8d76659f53547f /clang/unittests/AST/CommentParser.cpp | |
parent | 708709c01502e55f6fb49ad45f2c9266fc5eac1b (diff) | |
download | llvm-34df220410b36fd6643154d3d6071bac74403da0.zip llvm-34df220410b36fd6643154d3d6071bac74403da0.tar.gz llvm-34df220410b36fd6643154d3d6071bac74403da0.tar.bz2 |
Comment parsing: add support for \tparam command on all levels.
The only caveat is renumbering CXCommentKind enum for aesthetic reasons -- this
breaks libclang binary compatibility, but should not be a problem since API is
so new.
This also fixes PR13372 as a side-effect.
llvm-svn: 161087
Diffstat (limited to 'clang/unittests/AST/CommentParser.cpp')
-rw-r--r-- | clang/unittests/AST/CommentParser.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/clang/unittests/AST/CommentParser.cpp b/clang/unittests/AST/CommentParser.cpp index faf11b2..c6d809f 100644 --- a/clang/unittests/AST/CommentParser.cpp +++ b/clang/unittests/AST/CommentParser.cpp @@ -221,6 +221,39 @@ template <typename T> return ::testing::AssertionSuccess(); } +::testing::AssertionResult HasTParamCommandAt( + const Comment *C, + size_t Idx, + TParamCommandComment *&TPCC, + StringRef CommandName, + StringRef ParamName, + ParagraphComment *&Paragraph) { + ::testing::AssertionResult AR = GetChildAt(C, Idx, TPCC); + if (!AR) + return AR; + + StringRef ActualCommandName = TPCC->getCommandName(); + if (ActualCommandName != CommandName) + return ::testing::AssertionFailure() + << "TParamCommandComment has name \"" << ActualCommandName.str() << "\", " + "expected \"" << CommandName.str() << "\""; + + if (!TPCC->hasParamName()) + return ::testing::AssertionFailure() + << "TParamCommandComment has no parameter name"; + + StringRef ActualParamName = TPCC->getParamName(); + if (ActualParamName != ParamName) + return ::testing::AssertionFailure() + << "TParamCommandComment has parameter name \"" << ActualParamName.str() + << "\", " + "expected \"" << ParamName.str() << "\""; + + Paragraph = TPCC->getParagraph(); + + return ::testing::AssertionSuccess(); +} + ::testing::AssertionResult HasInlineCommandAt(const Comment *C, size_t Idx, InlineCommandComment *&ICC, @@ -838,6 +871,33 @@ TEST_F(CommentParserTest, ParamCommand6) { } } +TEST_F(CommentParserTest, TParamCommand1) { + const char *Sources[] = { + "// \\tparam aaa Bbb\n", + "// \\tparam\n" + "// aaa Bbb\n", + "// \\tparam \n" + "// aaa Bbb\n", + "// \\tparam aaa\n" + "// Bbb\n" + }; + + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + FullComment *FC = parseString(Sources[i]); + ASSERT_TRUE(HasChildCount(FC, 2)); + + ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " ")); + { + TParamCommandComment *TPCC; + ParagraphComment *PC; + ASSERT_TRUE(HasTParamCommandAt(FC, 1, TPCC, "tparam", + "aaa", PC)); + ASSERT_TRUE(HasChildCount(TPCC, 1)); + ASSERT_TRUE(HasParagraphCommentAt(TPCC, 0, " Bbb")); + } + } +} + TEST_F(CommentParserTest, InlineCommand1) { const char *Source = "// \\c"; |