I'm using gtest (google's testing framework), and use the following code for my test fixtures:
#define TEST_NAME test_foo
TEST( TEST_NAME, bar )
{
reset_ports();
/* test body begins here */
}
The function reset_ports is part of some very primitive micro controller hardware emulation code, and I'd like it to be called between every test fixture to ensure a clean state. I tried writing a small macro for doing this for me, but I can't get it to work:
#define BEGIN(x) (TEST((TEST_NAME), (x)) { reset_ports();)
#define END }
BEGIN( bar )
/* test body begins here */
END
The errors I'm getting are:
error: pasting ")" and "_" does not give a valid preprocessing token|
error: pasting "_" and "(" does not give a valid preprocessing token|
error: pasting ")" and "_Test" does not give a valid preprocessing token|
error: pasting ")" and "_" does not give a valid preprocessing token|
error: pasting "_" and "(" does not give a valid preprocessing token|
error: pasting ")" and "_Test" does not give a valid preprocessing token|
error: pasting ")" and "_" does not give a valid preprocessing token|
...
Any help? I've not practiced my preprocessor-voodoo enough to understand what's wrong.