[cfe-commits] r160649 - /cfe/trunk/unittests/AST/CommentParser.cpp
Dmitri Gribenko
gribozavr at gmail.com
Mon Jul 23 16:37:11 PDT 2012
Author: gribozavr
Date: Mon Jul 23 18:37:11 2012
New Revision: 160649
URL: http://llvm.org/viewvc/llvm-project?rev=160649&view=rev
Log:
Comment parser unit tests: split a huge test case
Modified:
cfe/trunk/unittests/AST/CommentParser.cpp
Modified: cfe/trunk/unittests/AST/CommentParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/CommentParser.cpp?rev=160649&r1=160648&r2=160649&view=diff
==============================================================================
--- cfe/trunk/unittests/AST/CommentParser.cpp (original)
+++ cfe/trunk/unittests/AST/CommentParser.cpp Mon Jul 23 18:37:11 2012
@@ -673,14 +673,10 @@
TEST_F(CommentParserTest, ParamCommand1) {
const char *Source =
- "// \\param aaa\n"
- "// \\param [in] aaa\n"
- "// \\param [out] aaa\n"
- "// \\param [in,out] aaa\n"
- "// \\param [in, out] aaa\n";
+ "// \\param aaa Bbb\n";
FullComment *FC = parseString(Source);
- ASSERT_TRUE(HasChildCount(FC, 6));
+ ASSERT_TRUE(HasChildCount(FC, 2));
ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " "));
{
@@ -691,54 +687,75 @@
/* IsDirectionExplicit = */ false,
"aaa", PC));
ASSERT_TRUE(HasChildCount(PCC, 1));
- ASSERT_TRUE(HasChildCount(PC, 1));
- ASSERT_TRUE(HasTextAt(PC, 0, " "));
+ ASSERT_TRUE(HasParagraphCommentAt(PCC, 0, " Bbb"));
}
+}
+
+TEST_F(CommentParserTest, ParamCommand2) {
+ const char *Source =
+ "// \\param [in] aaa Bbb\n";
+
+ FullComment *FC = parseString(Source);
+ ASSERT_TRUE(HasChildCount(FC, 2));
+
+ ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " "));
{
ParamCommandComment *PCC;
ParagraphComment *PC;
- ASSERT_TRUE(HasParamCommandAt(FC, 2, PCC, "param",
+ ASSERT_TRUE(HasParamCommandAt(FC, 1, PCC, "param",
ParamCommandComment::In,
/* IsDirectionExplicit = */ true,
"aaa", PC));
ASSERT_TRUE(HasChildCount(PCC, 1));
- ASSERT_TRUE(HasChildCount(PC, 1));
- ASSERT_TRUE(HasTextAt(PC, 0, " "));
+ ASSERT_TRUE(HasParagraphCommentAt(PCC, 0, " Bbb"));
}
+}
+
+TEST_F(CommentParserTest, ParamCommand3) {
+ const char *Source =
+ "// \\param [out] aaa Bbb\n";
+
+ FullComment *FC = parseString(Source);
+ ASSERT_TRUE(HasChildCount(FC, 2));
+
+ ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " "));
{
ParamCommandComment *PCC;
ParagraphComment *PC;
- ASSERT_TRUE(HasParamCommandAt(FC, 3, PCC, "param",
+ ASSERT_TRUE(HasParamCommandAt(FC, 1, PCC, "param",
ParamCommandComment::Out,
/* IsDirectionExplicit = */ true,
"aaa", PC));
ASSERT_TRUE(HasChildCount(PCC, 1));
- ASSERT_TRUE(HasChildCount(PC, 1));
- ASSERT_TRUE(HasTextAt(PC, 0, " "));
- }
- {
- ParamCommandComment *PCC;
- ParagraphComment *PC;
- ASSERT_TRUE(HasParamCommandAt(FC, 4, PCC, "param",
- ParamCommandComment::InOut,
- /* IsDirectionExplicit = */ true,
- "aaa", PC));
- ASSERT_TRUE(HasChildCount(PCC, 1));
- ASSERT_TRUE(HasChildCount(PC, 1));
- ASSERT_TRUE(HasTextAt(PC, 0, " "));
+ ASSERT_TRUE(HasParagraphCommentAt(PCC, 0, " Bbb"));
}
- {
- ParamCommandComment *PCC;
- ParagraphComment *PC;
- ASSERT_TRUE(HasParamCommandAt(FC, 5, PCC, "param",
- ParamCommandComment::InOut,
- /* IsDirectionExplicit = */ true,
- "aaa", PC));
- ASSERT_TRUE(HasChildCount(PCC, 1));
- ASSERT_TRUE(HasChildCount(PC, 0));
+}
+
+TEST_F(CommentParserTest, ParamCommand4) {
+ const char *Sources[] = {
+ "// \\param [in,out] aaa Bbb\n",
+ "// \\param [in, out] aaa 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, " "));
+ {
+ ParamCommandComment *PCC;
+ ParagraphComment *PC;
+ ASSERT_TRUE(HasParamCommandAt(FC, 1, PCC, "param",
+ ParamCommandComment::InOut,
+ /* IsDirectionExplicit = */ true,
+ "aaa", PC));
+ ASSERT_TRUE(HasChildCount(PCC, 1));
+ ASSERT_TRUE(HasParagraphCommentAt(PCC, 0, " Bbb"));
+ }
}
}
+
TEST_F(CommentParserTest, InlineCommand1) {
const char *Source = "// \\c";
More information about the cfe-commits
mailing list