Skip to content

Commit

Permalink
Increase test coverage of ExpressionNode and SubexpressionNode
Browse files Browse the repository at this point in the history
Add tests to verify the behaviour of the overloaded accept method
in the ExpressionNode and SubexpressionNode classes.
  • Loading branch information
robertmrk committed Jan 22, 2016
1 parent 3fdcb85 commit a404e3a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/expressionnode_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,16 @@ TEST_CASE("ExpressionNode")
REQUIRE(expression.expression == literal);
}
}

SECTION("accepts visitor")
{
ExpressionNode node{IdentifierNode{}};
Mock<AbstractVisitor> visitor;
When(OverloadedMethod(visitor, visit, void(IdentifierNode*)))
.AlwaysReturn();

node.accept(&visitor.get());

Verify(OverloadedMethod(visitor, visit, void(IdentifierNode*))).Once();
}
}
15 changes: 15 additions & 0 deletions test/subexpressionnode_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,19 @@ TEST_CASE("SubexpressionNode")
REQUIRE(node1 == node2);
REQUIRE(node1 == node1);
}

SECTION("accepts visitor")
{
ExpressionNode expression{IdentifierNode{}};
IdentifierNode identifier;
SubexpressionNode node{expression, identifier};
Mock<AbstractVisitor> visitor;
When(OverloadedMethod(visitor, visit, void(IdentifierNode*)))
.AlwaysReturn();

node.accept(&visitor.get());

Verify(OverloadedMethod(visitor, visit, void(IdentifierNode*)))
.Exactly(2);
}
}

0 comments on commit a404e3a

Please sign in to comment.