changeset 3752:f47658c8f87a gsoc2009_unit_tests

Better error handling.
author Edgar Simo <bobbens@gmail.com>
date Wed, 05 Aug 2009 18:56:56 +0000
parents 4a58821c9c98
children 5b48a529fd8a
files test/automated/SDL_at.c
diffstat 1 files changed, 27 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/test/automated/SDL_at.c	Wed Aug 05 18:45:55 2009 +0000
+++ b/test/automated/SDL_at.c	Wed Aug 05 18:56:56 2009 +0000
@@ -31,6 +31,14 @@
 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.
  */
@@ -193,16 +201,29 @@
 
 
 /**
+ * @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;
 }
@@ -222,10 +243,8 @@
       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;
 }