char _data;
FCT_SUITE_BGN(xxx) {
FCT_SETUP_BGN() {
data = malloc(sizeof(char)_N);
}FCT_SETUP_END();
FCT_TEARDOWN_BGN() {
free(data);
} FCT_TEARDOWN_END();
FCT_TEST_BGN() { /* do test */ } FCT_TEST_END();
FCT_SUITE_END();
is akward. It is especially akward when the "data" is a C++ object that lacks a default constructor. Perhaps you have an object you would like to do a one-time initialization on, for instance:
Those "add" commands can't be in the "global" space, but you don't really want to call them over and over again with the setup/teardown. Its a config object that is read-only for the test suite for example.
Sometimes the following pattern,
char _data; FCT_SUITE_BGN(xxx) { FCT_SETUP_BGN() { data = malloc(sizeof(char)_N); }FCT_SETUP_END(); FCT_TEARDOWN_BGN() { free(data); } FCT_TEARDOWN_END(); FCT_TEST_BGN() { /* do test */ } FCT_TEST_END(); FCT_SUITE_END();
is akward. It is especially akward when the "data" is a C++ object that lacks a default constructor. Perhaps you have an object you would like to do a one-time initialization on, for instance:
Those "add" commands can't be in the "global" space, but you don't really want to call them over and over again with the setup/teardown. Its a config object that is read-only for the test suite for example.