src/test/SDL_test_assert.c
changeset 6727 1b5280cd5885
parent 6721 53b71f45a53a
child 6756 398073b195bb
     1.1 --- a/src/test/SDL_test_assert.c	Sat Dec 08 15:33:14 2012 -0500
     1.2 +++ b/src/test/SDL_test_assert.c	Sun Dec 09 17:56:19 2012 -0800
     1.3 @@ -35,6 +35,12 @@
     1.4  /* Assert summary message format */
     1.5  const char *SDLTest_AssertSummaryFmt = "Assert Summary: Total=%d Passed=%d Failed=%d";
     1.6  
     1.7 +/*! \brief counts the failed asserts */
     1.8 +static Uint32 SDLTest_AssertsFailed = 0;
     1.9 +
    1.10 +/*! \brief counts the passed asserts */
    1.11 +static Uint32 SDLTest_AssertsPassed = 0;
    1.12 +
    1.13  /*
    1.14   *  Assert that logs and break execution flow on failures (i.e. for harness errors).
    1.15   */
    1.16 @@ -89,3 +95,19 @@
    1.17  		SDLTest_LogError(fmt, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
    1.18  	}
    1.19  }
    1.20 +
    1.21 +/*
    1.22 + * Converts the current assert state into a test result
    1.23 + */
    1.24 +int SDLTest_AssertSummaryToTestResult()
    1.25 +{
    1.26 +	if (SDLTest_AssertsFailed > 0) {
    1.27 +		return TEST_RESULT_FAILED;
    1.28 +	} else {
    1.29 +		if (SDLTest_AssertsPassed > 0) {
    1.30 +			return TEST_RESULT_PASSED;
    1.31 +		} else {
    1.32 +			return TEST_RESULT_NO_ASSERT;
    1.33 +		}
    1.34 +	}
    1.35 +}