During extracting FOV and raycasting routines in libchthon I ran into a need of testing a number of data using same test flow. Each case consisted of some original map and a map with expected calculated FOV. Basically, I needed some way to describe repeatable tests with different names but the same value types and testing code and ONLY ONE instance of actual testing code.
The solution was to declare a test function separately from the test itself and define it when the actual code is started:
Thanks to that, each test case working with data can be easily declared with define looking like this:
Data sets could be differentiated using corresponding names of run() function. One more possible impovement is to declare two values: one for input and one for expected output. Final version of macro looks like this:
Actual example of usage (taken from documentation):