|
Simple XUnit test library / objects in plain C Snapshot
|
#include "vtest.h"#include "vtestrunner.h"#include "vtestcui.h"#include <stdio.h>#include <string.h>#include <stdarg.h>Go to the source code of this file.
Functions | |
| static void | MSG (const char *format,...) |
| void | VTEST_CUI_set_debug_output_hook (PFN_DEBUG_FUNCTION debug_output_hook_) |
| void | CUI_report_suite_start (const char *suite_name) |
| void | CUI_report_test_start (const char *suite_name, const char *test_name, int iteration, int maxiteration) |
| void | CUI_report_results (VTEST_STATUS status, const char *suite_name, const char *test_name, struct timeval *duration, const char *fail_cond, const char *fail_file, int fail_line) |
| void | CUI_report_wrapup (int suitesinitfailed, int suitesteardownfailed, int tests_passed, int tests_failed, int testnotrun) |
| int | VTEST_CUI_test_runner (VTEST_TEST_SUITE *suite) |
| int | VTEST_CUI_test_runner_cmdline (VTEST_TEST_SUITE *suite, int argc, char *argv[]) |
| void | VTEST_CUI_list_suite (VTEST_TEST_SUITE *suite) |
| int | VTEST_CUI_list_tests_of_suite (VTEST_TEST_SUITE *suite, const char *suite_name) |
Variables | |
| static PFN_DEBUG_FUNCTION | debug_output_hook = 0 |
| void CUI_report_results | ( | VTEST_STATUS | status, |
| const char * | suite_name, | ||
| const char * | test_name, | ||
| struct timeval * | duration, | ||
| const char * | fail_cond, | ||
| const char * | fail_file, | ||
| int | fail_line | ||
| ) |
Definition at line 65 of file cuitestrunner.c.
{
(void) (test_name);
switch(status) {
case VTEST_TEST_OK: {
#ifdef TIME_TEST_GETTIMEOFDAY
char msg[100];
char *ptr;
size_t size;
ptr = msg;
size = sizeof(msg);
strcpy(msg, " Status: Ok" );
size -= strlen(msg);
ptr += strlen(msg);
format_time( ptr, size, duration );
MSG( msg );
#else
(void) (duration);
MSG( " Status: Ok\n");
#endif
}
break;
case VTEST_TEST_FAILED:
MSG( " Status: Failed - %s at %s:%d\n",
fail_cond, fail_file, fail_line);
break;
case VTEST_SUITE_SETUP_FAILED:
MSG( "Suite %s setup failed - %s at %s:%d\n",
suite_name, fail_cond, fail_file, fail_line);
break;
case VTEST_SUITE_TEARDOWN_FAILED:
MSG( "Suite %s teardown failed - %s at %s:%d\n",
suite_name, fail_cond, fail_file, fail_line);
break;
default: {
}
}
}
| void CUI_report_suite_start | ( | const char * | suite_name | ) |
Definition at line 37 of file cuitestrunner.c.
{
MSG( "Suite %s\n", suite_name );
}
| void CUI_report_test_start | ( | const char * | suite_name, |
| const char * | test_name, | ||
| int | iteration, | ||
| int | maxiteration | ||
| ) |
Definition at line 42 of file cuitestrunner.c.
| void CUI_report_wrapup | ( | int | suitesinitfailed, |
| int | suitesteardownfailed, | ||
| int | tests_passed, | ||
| int | tests_failed, | ||
| int | testnotrun | ||
| ) |
Definition at line 116 of file cuitestrunner.c.
{
MSG( "\nTest summary\n"
" Tests passed: %d\n"
" Tests failed: %d\n"
" Tests not run: %d (due to suite setup failure)\n"
" Suites setup failed: %d\n"
" Suites teardown failed: %d\n",
tests_passed, tests_failed, testnotrun,
suitesinitfailed, suitesteardownfailed);
if (!suitesinitfailed && !suitesteardownfailed &&
!tests_failed && !testnotrun) {
MSG( "\nALL TESTS PASSED\n");
} else {
MSG( "\n***YOU HAVE TESTS TO FIX***\n");
}
}
| static void MSG | ( | const char * | format, |
| ... | |||
| ) | [static] |
Definition at line 15 of file cuitestrunner.c.
{
va_list ap;
va_start(ap, format);
if (!debug_output_hook) {
vfprintf( stdout, format, ap );
} else {
char big_buf[ 32 * 1024 ];
vsnprintf( big_buf, sizeof( big_buf ), format, ap );
debug_output_hook( big_buf );
fputs( big_buf, stdout );
}
va_end(ap);
}
| void VTEST_CUI_list_suite | ( | VTEST_TEST_SUITE * | suite | ) |
Definition at line 168 of file cuitestrunner.c.
{
for(;suite; suite = suite->next_suite) {
MSG( "%s ",suite->name);
}
}
| int VTEST_CUI_list_tests_of_suite | ( | VTEST_TEST_SUITE * | suite, |
| const char * | suite_name | ||
| ) |
Definition at line 175 of file cuitestrunner.c.
{
int ret = 0;
VTEST_TEST *test;
for(;suite; suite = suite->next_suite) {
if (strcmp(suite->name,suite_name) == 0) {
ret = 1;
for(test = suite->test_cases; test->name != 0; test++) {
MSG( "%s ",test->name);
}
}
}
return ret;
}
| void VTEST_CUI_set_debug_output_hook | ( | PFN_DEBUG_FUNCTION | debug_output_hook_ | ) |
Definition at line 33 of file cuitestrunner.c.
{
debug_output_hook = debug_output_hook_;
}
| int VTEST_CUI_test_runner | ( | VTEST_TEST_SUITE * | suite | ) |
Definition at line 142 of file cuitestrunner.c.
{
VTEST_RUNNER_IMPL impl;
impl.suite_start = CUI_report_suite_start;
impl.test_start = CUI_report_test_start;
impl.results = CUI_report_results;
impl.wrapup = CUI_report_wrapup;
return VTEST_test_runner( suite, &impl );
}
| int VTEST_CUI_test_runner_cmdline | ( | VTEST_TEST_SUITE * | suite, |
| int | argc, | ||
| char * | argv[] | ||
| ) |
Definition at line 155 of file cuitestrunner.c.
{
VTEST_RUNNER_IMPL impl;
impl.suite_start = CUI_report_suite_start;
impl.test_start = CUI_report_test_start;
impl.results = CUI_report_results;
impl.wrapup = CUI_report_wrapup;
return VTEST_test_runner_cmdline( suite, &impl, argc, argv);
}
PFN_DEBUG_FUNCTION debug_output_hook = 0 [static] |
Definition at line 12 of file cuitestrunner.c.
1.7.4