File src/stic.h changed (mode: 100644) (index 63c7141..e4bc80e) |
... |
... |
struct stic_test_data |
258 |
258 |
int main(int argc, char *argv[]) \ |
int main(int argc, char *argv[]) \ |
259 |
259 |
{ \ |
{ \ |
260 |
260 |
int r; \ |
int r; \ |
261 |
|
if(stic_setup_once_func != NULL) \ |
|
|
261 |
|
const int file_has_tests = (stic_get_fixture_name() != NULL); \ |
|
262 |
|
if(!file_has_tests && stic_setup_once_func != NULL) \ |
262 |
263 |
{ \ |
{ \ |
263 |
264 |
stic_setup_once_func(); \ |
stic_setup_once_func(); \ |
264 |
265 |
} \ |
} \ |
265 |
266 |
r = stic_testrunner(argc, argv, stic_suite, stic_setup_func, stic_teardown_func) == 0; \ |
r = stic_testrunner(argc, argv, stic_suite, stic_setup_func, stic_teardown_func) == 0; \ |
266 |
|
if(stic_teardown_once_func != NULL) \ |
|
|
267 |
|
if(!file_has_tests && stic_teardown_once_func != NULL) \ |
267 |
268 |
{ \ |
{ \ |
268 |
269 |
stic_teardown_once_func(); \ |
stic_teardown_once_func(); \ |
269 |
270 |
} \ |
} \ |
|
... |
... |
static void (*stic_setup_once_func)(void); |
282 |
283 |
static void (*stic_teardown_func)(void); |
static void (*stic_teardown_func)(void); |
283 |
284 |
static void (*stic_teardown_once_func)(void); |
static void (*stic_teardown_once_func)(void); |
284 |
285 |
|
|
|
286 |
|
static struct stic_test_data *const *const stic_test_data[] = { |
|
287 |
|
TEST_DATA_STRUCTS_REF |
|
288 |
|
}; |
|
289 |
|
|
|
290 |
|
static const char * stic_get_fixture_name(void) |
|
291 |
|
{ |
|
292 |
|
size_t i; |
|
293 |
|
for(i = 0U; i < STIC_ARRAY_LEN(stic_test_data); ++i) |
|
294 |
|
{ |
|
295 |
|
if(*stic_test_data[i]) |
|
296 |
|
{ |
|
297 |
|
return (*stic_test_data[i])->f; |
|
298 |
|
} |
|
299 |
|
} |
|
300 |
|
return NULL; |
|
301 |
|
} |
|
302 |
|
|
285 |
303 |
static void stic_fixture(void) |
static void stic_fixture(void) |
286 |
304 |
{ |
{ |
287 |
305 |
extern const char *stic_current_test_name; |
extern const char *stic_current_test_name; |
288 |
306 |
extern stic_void_void stic_current_test; |
extern stic_void_void stic_current_test; |
289 |
307 |
|
|
290 |
|
const char *fixture_name = NULL; |
|
291 |
308 |
size_t i; |
size_t i; |
292 |
|
static struct stic_test_data *const *const test_data[] = { |
|
293 |
|
TEST_DATA_STRUCTS_REF |
|
294 |
|
}; |
|
295 |
309 |
|
|
296 |
|
for(i = 0; i < STIC_ARRAY_LEN(test_data); ++i) |
|
297 |
|
{ |
|
298 |
|
if(*test_data[i]) |
|
299 |
|
{ |
|
300 |
|
fixture_name = (*test_data[i])->f; |
|
301 |
|
break; |
|
302 |
|
} |
|
303 |
|
} |
|
|
310 |
|
const char *fixture_name = stic_get_fixture_name(); |
304 |
311 |
if(fixture_name == NULL) |
if(fixture_name == NULL) |
305 |
312 |
{ |
{ |
306 |
313 |
return; |
return; |
|
... |
... |
static void stic_fixture(void) |
318 |
325 |
stic_setup_once_func(); |
stic_setup_once_func(); |
319 |
326 |
} |
} |
320 |
327 |
|
|
321 |
|
for(i = 0; i < STIC_ARRAY_LEN(test_data); ++i) |
|
|
328 |
|
for(i = 0; i < STIC_ARRAY_LEN(stic_test_data); ++i) |
322 |
329 |
{ |
{ |
323 |
|
struct stic_test_data *td = *test_data[i]; |
|
|
330 |
|
struct stic_test_data *td = *stic_test_data[i]; |
324 |
331 |
if(td == NULL) continue; |
if(td == NULL) continue; |
325 |
332 |
if(td->p != NULL && !td->p()) |
if(td->p != NULL && !td->p()) |
326 |
333 |
{ |
{ |