summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2012-07-31 22:37:06 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2012-07-31 22:37:06 +0000
commit96b098674908eaa59a9128f3305cda6fbbdad563 (patch)
treed57eea0d73104b14e3bd09e070657d2af8a29edd /unittests
parent3c394c54511b27be0ff6968f159bba3521ab3c3e (diff)
downloadclang-96b098674908eaa59a9128f3305cda6fbbdad563.tar.gz
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161087 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/AST/CommentParser.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/unittests/AST/CommentParser.cpp b/unittests/AST/CommentParser.cpp
index faf11b28fd..c6d809ff40 100644
--- a/unittests/AST/CommentParser.cpp
+++ b/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";