Menu

#16 cgreen can't handle functions #define

1.0.0beta5
open
nobody
None
1.0alpha3
5
2014-08-21
2014-08-21
Arik
No

I know I found it on an old version, but I looked at the current source code, and it seems that the problem still exists.

Currently, the cgreen unittest framework can't handle a function definition.
For example:

#define foo bar

Unittest code:

expect(foo);

-> This yields an error: Call was not made to function [foo)]

This is because expect() is actually a macro which takes the name of the function as a string:

#define expect(f, ...) \
    expect_(#f)

The name to string conversion happens before the fed to amf #define conversion.

This is how I solved it in my project:

#define TO_STRING(x) #x

#define expect(f, ...) \
    expect_(TO_STRING(f))

Of course there is a need to change all the functions that use "#", not just the expect.
Sorry I didn't submit a patch...

Discussion


Log in to post a comment.

Auth0 Logo