gtest and AST matchers

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.

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 :smiley:

/J

In article <528B2706.9050706@iar.com>,
    Jesper Eskilson <jesper.eskilson@iar.com> writes:

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 :smiley:

Unit Tests FTW!