Commit b107ae17 authored by Nicolas Michon's avatar Nicolas Michon

Add public tester function to get failed asserts

parent 7cb24206
......@@ -101,10 +101,12 @@ BCTBX_PUBLIC const char * bc_tester_current_suite_name(void);
BCTBX_PUBLIC const char * bc_tester_current_test_name(void);
BCTBX_PUBLIC const char ** bc_tester_current_test_tags(void);
BCTBX_PUBLIC char* bc_sprintfva(const char* format, va_list args);
BCTBX_PUBLIC char* bc_sprintf(const char* format, ...);
BCTBX_PUBLIC void bc_free(void *ptr);
BCTBX_PUBLIC char * bc_tester_get_failed_asserts(void);
BCTBX_PUBLIC unsigned int bc_get_number_of_failures(void);
BCTBX_PUBLIC void bc_set_trace_handler(void(*handler)(int, const char*, va_list));
......
......@@ -289,6 +289,29 @@ void bc_tester_list_tests(const char *suite_name) {
}
}
char *bc_tester_get_failed_asserts(void) {
int i;
CU_pFailureRecord pFailure = NULL;
char *buffer = "";
pFailure = CU_get_failure_list();
if (pFailure) {
for (i = 1; (NULL != pFailure); pFailure = pFailure->pNext, i++) {
buffer = bc_sprintf("%s\n %d. %s:%u - %s",
buffer,
i,
(NULL != pFailure->strFileName) ? pFailure->strFileName : "",
pFailure->uiLineNumber,
(NULL != pFailure->strCondition) ? pFailure->strCondition : "");
if (i != 1) {
free(buffer);
}
}
}
return buffer;
}
static void all_complete_message_handler(const CU_pFailureRecord pFailure) {
#ifdef HAVE_CU_GET_SUITE
char * results = CU_get_run_results_string();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment