Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Better error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbens committed Aug 5, 2009
1 parent 59ea8ec commit 99b4336
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions test/automated/SDL_at.c
Expand Up @@ -31,6 +31,14 @@ static int at_verbose = 0; /**< Verbosity. */
static int at_quiet = 0; /**< Quietness. */


/*
* Prototypes.
*/
static void SDL_ATcleanup (void);
static void SDL_ATendWith( int success );
static void SDL_ATassertFailed( const char *msg );


/**
* @brief Cleans up the automated testsuite state.
*/
Expand Down Expand Up @@ -192,17 +200,30 @@ static void SDL_ATendWith( int success )
}


/**
* @brief Display failed assert message.
*/
static void SDL_ATassertFailed( const char *msg )
{
/* Print. */
SDL_ATprintErr( "Assert Failed!\n" );
SDL_ATprintErr( " %s\n", msg );
SDL_ATprintErr( " Test Case '%s'\n", at_test_msg );
SDL_ATprintErr( " Test Suite '%s'\n", at_suite_msg );
/* End. */
SDL_ATendWith(0);
}


/**
* @brief Testcase test.
*/
int SDL_ATassert( const char *msg, int condition )
{
/* Condition failed. */
if (!condition) {
/* Print. */
SDL_ATprintErr( "%s [%s] : %s\n", at_suite_msg, at_test_msg, msg );
/* End. */
SDL_ATendWith(0);
/* Failed message. */
SDL_ATassertFailed(msg);
}
return !condition;
}
Expand All @@ -222,10 +243,8 @@ int SDL_ATvassert( int condition, const char *msg, ... )
va_start( args, msg );
vsnprintf( buf, sizeof(buf), msg, args );
va_end( args );
/* Print. */
SDL_ATprintErr( "%s [%s] : %s\n", at_suite_msg, at_test_msg, buf );
/* End. */
SDL_ATendWith(0);
/* Failed message. */
SDL_ATassertFailed( buf );
}
return !condition;
}
Expand Down

0 comments on commit 99b4336

Please sign in to comment.