[cfe-dev] gtest and AST matchers

Jesper Eskilson jesper.eskilson at iar.com
Tue Nov 19 00:53:26 PST 2013


On 11/18/2013 02:37 PM, Manuel Klimek wrote:
> On Mon, Nov 18, 2013 at 11:14 AM, Jesper Eskilson
> <jesper.eskilson at iar.com <mailto:jesper.eskilson at iar.com>> wrote:
>
>
>     Hi,
>
>     I'm trying to use gtest to write tests for stuff that goes on inside
>     an AST matcher, but it seems like any gtest assertions made inside a
>     AST matcher callback are silently ignored.
>
>     For example, in the following program, the "FAIL" in the callback is
>     silently ignored, but the TEST in the test-method succeeds.
>
>
> Yep, this generally doesn't work - just set a variable from the
> callback, and check that from the test...
>

Apparently it does work. The problem was that my matcher matched on 
expr(), but there is no expression in the code, so the matcher callback 
was never invoked. Duh. Changing "expr()" to "varDecl()" solved the 
problem :D

/J

-- 
*Jesper Eskilson* /Development Engineer/
IAR Systems AB
Box 23051, Strandbodgatan 1
SE-750 23 Uppsala, SWEDEN
E-mail: jesper.eskilson at iar.com <mailto:jesper.eskilson at iar.com>
Website: www.iar.com
<http://www.iar.com> Twitter: www.twitter.com/iarsystems
<http://www.twitter.com/iarsystems>



More information about the cfe-dev mailing list