You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of exporting the defined name as a bare function, export a
struct that has a pointer to the function, but also its name, file and
line number where it is defined.
Store that information into a new `struct TTest`.
After this commit, START_TEST(<testname>) will create three definitions:
- <testname>_fn: The actual function;
- <testname>_ttest: A `struct TTest` with the information about it;
- <testname>: A pointer to <testname>_ttest.
Functions `tcase_add_test()` and friends are updated to take a `TTest *`
argument rather than a `TFun` and separate name. The runners are updated
to find that information inside the linked `tc->ttest`. The call to
`tcase_fn_start()` is moved from the defined functions to the runners
(both the "fork" and the "nofork" one) which call it just before
invoking the test function.
A nice side-effect is that END_TEST is now optional, though the empty
`#define` is kept for backwards compability.
v2: Initialize the struct TTest by position to be compatible with older
compilers that do not recognize named fields (e.g. VS 2010, VS 2012.)
Tested:
- `make check` still passes.
- Removing END_TEST from test cases still produces valid code that
builds and passes tests.
0 commit comments