本文整理汇总了C++中Suite::setup方法的典型用法代码示例。如果您正苦于以下问题:C++ Suite::setup方法的具体用法?C++ Suite::setup怎么用?C++ Suite::setup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Suite
的用法示例。
在下文中一共展示了Suite::setup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: suite_run
int suite_run()
{
int i, stage;
char *extra;
void (*func)();
passed = failed = 0;
printf("Starting suite %s (%d tests)\n",suite.name, suite.num_tests);
for ( i = 0; i < suite.num_tests; i++ ) {
if ( setjmp(jmpbuf) == 0 ) {
#ifndef NO_LOG_RUNNING
printf("Running test %s..",suite.testnames[i]);
#endif
failed_message = NULL;
stage = 0;
if ( suite.setup ) {
suite.setup();
}
func = suite.tests[i];
stage++;
func();
stage++;
if ( suite.teardown ) {
suite.teardown();
}
#ifndef NO_LOG_PASSED
#ifdef NO_LOG_RUNNING
printf("Running test %s..",suite.testnames[i]);
#endif
printf("...passed\n");
#endif
passed++;
} else {
extra = "";
switch ( stage ) {
case 0:
extra = "(in setup)";
/* Fall through */
case 1:
/* Protect ourselves against teardown failing */
if ( setjmp(jmpbuf) == 0 ) {
if ( suite.teardown() ) {
suite.teardown();
}
} else {
stage = 3;
}
break;
case 2:
extra = "(in teardown) ";
break;
}
#ifdef NO_LOG_RUNNING
printf("Running test %s..",suite.testnames[i]);
#endif
printf("...failed %s%s:%d (%s)%s\n",extra,failed_file, failed_line, failed_message,stage == 3 ? " (and in teardown)" : "");
failed++;
}
}
printf("%d run, %d passed, %d failed\n", suite.num_tests, passed, failed);
return failed != 0;
}