forked from OSchip/llvm-project
Comment parser unit tests: reduce code duplication
llvm-svn: 160647
This commit is contained in:
parent
45fbfc7f11
commit
89630bce27
|
@ -385,6 +385,32 @@ struct NoAttrs {};
|
|||
return ::testing::AssertionSuccess();
|
||||
}
|
||||
|
||||
::testing::AssertionResult HasParagraphCommentAt(const Comment *C,
|
||||
size_t Idx,
|
||||
StringRef Text) {
|
||||
ParagraphComment *PC;
|
||||
|
||||
{
|
||||
::testing::AssertionResult AR = GetChildAt(C, Idx, PC);
|
||||
if (!AR)
|
||||
return AR;
|
||||
}
|
||||
|
||||
{
|
||||
::testing::AssertionResult AR = HasChildCount(PC, 1);
|
||||
if (!AR)
|
||||
return AR;
|
||||
}
|
||||
|
||||
{
|
||||
::testing::AssertionResult AR = HasTextAt(PC, 0, Text);
|
||||
if (!AR)
|
||||
return AR;
|
||||
}
|
||||
|
||||
return ::testing::AssertionSuccess();
|
||||
}
|
||||
|
||||
::testing::AssertionResult HasVerbatimBlockAt(const Comment *C,
|
||||
size_t Idx,
|
||||
VerbatimBlockComment *&VBC,
|
||||
|
@ -529,13 +555,7 @@ TEST_F(CommentParserTest, Basic2) {
|
|||
FullComment *FC = parseString(Source);
|
||||
ASSERT_TRUE(HasChildCount(FC, 1));
|
||||
|
||||
{
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(GetChildAt(FC, 0, PC));
|
||||
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " Meow"));
|
||||
}
|
||||
ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " Meow"));
|
||||
}
|
||||
|
||||
TEST_F(CommentParserTest, Basic3) {
|
||||
|
@ -573,20 +593,8 @@ TEST_F(CommentParserTest, Paragraph1) {
|
|||
FullComment *FC = parseString(Sources[i]);
|
||||
ASSERT_TRUE(HasChildCount(FC, 2));
|
||||
|
||||
{
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(GetChildAt(FC, 0, PC));
|
||||
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " Aaa"));
|
||||
}
|
||||
{
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(GetChildAt(FC, 1, PC));
|
||||
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " Bbb"));
|
||||
}
|
||||
ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " Aaa"));
|
||||
ASSERT_TRUE(HasParagraphCommentAt(FC, 1, " Bbb"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -599,30 +607,15 @@ TEST_F(CommentParserTest, Paragraph2) {
|
|||
FullComment *FC = parseString(Source);
|
||||
ASSERT_TRUE(HasChildCount(FC, 3));
|
||||
|
||||
{
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(GetChildAt(FC, 0, PC));
|
||||
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " "));
|
||||
}
|
||||
ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " "));
|
||||
{
|
||||
BlockCommandComment *BCC;
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(HasBlockCommandAt(FC, 1, BCC, "brief", PC));
|
||||
|
||||
ASSERT_TRUE(GetChildAt(BCC, 0, PC));
|
||||
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " Aaa"));
|
||||
}
|
||||
{
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(GetChildAt(FC, 2, PC));
|
||||
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " Bbb"));
|
||||
ASSERT_TRUE(HasParagraphCommentAt(BCC, 0, " Aaa"));
|
||||
}
|
||||
ASSERT_TRUE(HasParagraphCommentAt(FC, 2, " Bbb"));
|
||||
}
|
||||
|
||||
TEST_F(CommentParserTest, Paragraph3) {
|
||||
|
@ -631,21 +624,13 @@ TEST_F(CommentParserTest, Paragraph3) {
|
|||
FullComment *FC = parseString(Source);
|
||||
ASSERT_TRUE(HasChildCount(FC, 3));
|
||||
|
||||
{
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(GetChildAt(FC, 0, PC));
|
||||
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " "));
|
||||
}
|
||||
ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " "));
|
||||
{
|
||||
BlockCommandComment *BCC;
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(HasBlockCommandAt(FC, 1, BCC, "brief", PC));
|
||||
|
||||
ASSERT_TRUE(GetChildAt(BCC, 0, PC));
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " "));
|
||||
ASSERT_TRUE(HasParagraphCommentAt(BCC, 0, " "));
|
||||
}
|
||||
{
|
||||
BlockCommandComment *BCC;
|
||||
|
@ -666,13 +651,7 @@ TEST_F(CommentParserTest, Paragraph4) {
|
|||
FullComment *FC = parseString(Source);
|
||||
ASSERT_TRUE(HasChildCount(FC, 3));
|
||||
|
||||
{
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(GetChildAt(FC, 0, PC));
|
||||
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " "));
|
||||
}
|
||||
ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " "));
|
||||
{
|
||||
BlockCommandComment *BCC;
|
||||
ParagraphComment *PC;
|
||||
|
@ -688,9 +667,7 @@ TEST_F(CommentParserTest, Paragraph4) {
|
|||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(HasBlockCommandAt(FC, 2, BCC, "author", PC));
|
||||
|
||||
ASSERT_TRUE(GetChildAt(BCC, 0, PC));
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " Ccc"));
|
||||
ASSERT_TRUE(HasParagraphCommentAt(BCC, 0, " Ccc"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -705,13 +682,7 @@ TEST_F(CommentParserTest, ParamCommand1) {
|
|||
FullComment *FC = parseString(Source);
|
||||
ASSERT_TRUE(HasChildCount(FC, 6));
|
||||
|
||||
{
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(GetChildAt(FC, 0, PC));
|
||||
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " "));
|
||||
}
|
||||
ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " "));
|
||||
{
|
||||
ParamCommandComment *PCC;
|
||||
ParagraphComment *PC;
|
||||
|
@ -1002,13 +973,7 @@ TEST_F(CommentParserTest, VerbatimBlock1) {
|
|||
FullComment *FC = parseString(Source);
|
||||
ASSERT_TRUE(HasChildCount(FC, 2));
|
||||
|
||||
{
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(GetChildAt(FC, 0, PC));
|
||||
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " "));
|
||||
}
|
||||
ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " "));
|
||||
{
|
||||
VerbatimBlockComment *VCC;
|
||||
ASSERT_TRUE(HasVerbatimBlockAt(FC, 1, VCC, "verbatim", "endverbatim",
|
||||
|
@ -1022,13 +987,7 @@ TEST_F(CommentParserTest, VerbatimBlock2) {
|
|||
FullComment *FC = parseString(Source);
|
||||
ASSERT_TRUE(HasChildCount(FC, 2));
|
||||
|
||||
{
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(GetChildAt(FC, 0, PC));
|
||||
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " "));
|
||||
}
|
||||
ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " "));
|
||||
{
|
||||
VerbatimBlockComment *VBC;
|
||||
ASSERT_TRUE(HasVerbatimBlockAt(FC, 1, VBC, "verbatim", "endverbatim",
|
||||
|
@ -1042,13 +1001,7 @@ TEST_F(CommentParserTest, VerbatimBlock3) {
|
|||
FullComment *FC = parseString(Source);
|
||||
ASSERT_TRUE(HasChildCount(FC, 2));
|
||||
|
||||
{
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(GetChildAt(FC, 0, PC));
|
||||
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " "));
|
||||
}
|
||||
ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " "));
|
||||
{
|
||||
VerbatimBlockComment *VBC;
|
||||
ASSERT_TRUE(HasVerbatimBlockAt(FC, 1, VBC, "verbatim", "",
|
||||
|
@ -1109,13 +1062,7 @@ TEST_F(CommentParserTest, VerbatimBlock6) {
|
|||
FullComment *FC = parseString(Sources[i]);
|
||||
ASSERT_TRUE(HasChildCount(FC, 2));
|
||||
|
||||
{
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(GetChildAt(FC, 0, PC));
|
||||
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " "));
|
||||
}
|
||||
ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " "));
|
||||
{
|
||||
VerbatimBlockComment *VBC;
|
||||
ASSERT_TRUE(HasVerbatimBlockAt(FC, 1, VBC, "verbatim", "endverbatim",
|
||||
|
@ -1141,13 +1088,7 @@ TEST_F(CommentParserTest, VerbatimBlock7) {
|
|||
FullComment *FC = parseString(Sources[i]);
|
||||
ASSERT_TRUE(HasChildCount(FC, 2));
|
||||
|
||||
{
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(GetChildAt(FC, 0, PC));
|
||||
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " "));
|
||||
}
|
||||
ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " "));
|
||||
{
|
||||
VerbatimBlockComment *VBC;
|
||||
ASSERT_TRUE(HasVerbatimBlockAt(FC, 1, VBC, "verbatim", "endverbatim",
|
||||
|
@ -1174,13 +1115,7 @@ TEST_F(CommentParserTest, VerbatimBlock8) {
|
|||
FullComment *FC = parseString(Sources[i]);
|
||||
ASSERT_TRUE(HasChildCount(FC, 2));
|
||||
|
||||
{
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(GetChildAt(FC, 0, PC));
|
||||
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " "));
|
||||
}
|
||||
ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " "));
|
||||
{
|
||||
VerbatimBlockComment *VBC;
|
||||
ASSERT_TRUE(HasVerbatimBlockAt(FC, 1, VBC, "verbatim", "endverbatim"));
|
||||
|
@ -1202,13 +1137,7 @@ TEST_F(CommentParserTest, VerbatimLine1) {
|
|||
FullComment *FC = parseString(Sources[i]);
|
||||
ASSERT_TRUE(HasChildCount(FC, 2));
|
||||
|
||||
{
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(GetChildAt(FC, 0, PC));
|
||||
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " "));
|
||||
}
|
||||
ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " "));
|
||||
{
|
||||
VerbatimLineComment *VLC;
|
||||
ASSERT_TRUE(HasVerbatimLineAt(FC, 1, VLC, "fn", ""));
|
||||
|
@ -1226,13 +1155,7 @@ TEST_F(CommentParserTest, VerbatimLine2) {
|
|||
FullComment *FC = parseString(Sources[i]);
|
||||
ASSERT_TRUE(HasChildCount(FC, 2));
|
||||
|
||||
{
|
||||
ParagraphComment *PC;
|
||||
ASSERT_TRUE(GetChildAt(FC, 0, PC));
|
||||
|
||||
ASSERT_TRUE(HasChildCount(PC, 1));
|
||||
ASSERT_TRUE(HasTextAt(PC, 0, " "));
|
||||
}
|
||||
ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " "));
|
||||
{
|
||||
VerbatimLineComment *VLC;
|
||||
ASSERT_TRUE(HasVerbatimLineAt(FC, 1, VLC, "fn",
|
||||
|
|
Loading…
Reference in New Issue