grassator/bdd-for-c

Add __LINE__ and __FILE__ to check error output

Closed this issue · 2 comments

While it is possible to use __FILE__ and __LINE__ with printf extra arguments to the check macro, it would be much more convenient if something like "%s:%d: ", __FILE__, __LINE__ was prefixed to the error output. The formatting would be cleaner and more controlled too (like starting at the beginning of a line instead of the middle of the error message).

This is really useful when running the tests as part of a make run from an editor or other dev environment to automatically position at the failing test.

Might also be a good idea to control this with a #define or a env var.

Here is an example

example

@dalepsmith I've added the location and it works great, at least in CLion, thanks for the idea, although I've kept the indentation, as I believe it adds to readability.

Works great in emacs! I'm happy now.