SDL standard library

Dependents:   H261_encoder

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SDL_test_assert.h Source File

SDL_test_assert.h

Go to the documentation of this file.
00001 /*
00002   Simple DirectMedia Layer
00003   Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
00004 
00005   This software is provided 'as-is', without any express or implied
00006   warranty.  In no event will the authors be held liable for any damages
00007   arising from the use of this software.
00008 
00009   Permission is granted to anyone to use this software for any purpose,
00010   including commercial applications, and to alter it and redistribute it
00011   freely, subject to the following restrictions:
00012 
00013   1. The origin of this software must not be misrepresented; you must not
00014      claim that you wrote the original software. If you use this software
00015      in a product, an acknowledgment in the product documentation would be
00016      appreciated but is not required.
00017   2. Altered source versions must be plainly marked as such, and must not be
00018      misrepresented as being the original software.
00019   3. This notice may not be removed or altered from any source distribution.
00020 */
00021 
00022 /**
00023  *  \file SDL_test_assert.h
00024  *
00025  *  Include file for SDL test framework.
00026  *
00027  *  This code is a part of the SDL2_test library, not the main SDL library.
00028  */
00029 
00030 /*
00031  *
00032  * Assert API for test code and test cases
00033  *
00034  */
00035 
00036 #ifndef _SDL_test_assert_h
00037 #define _SDL_test_assert_h
00038 
00039 #include "begin_code.h"
00040 /* Set up for C function definitions, even when using C++ */
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044 
00045 /**
00046  * \brief Fails the assert.
00047  */
00048 #define ASSERT_FAIL     0
00049 
00050 /**
00051  * \brief Passes the assert.
00052  */
00053 #define ASSERT_PASS     1
00054 
00055 /**
00056  * \brief Assert that logs and break execution flow on failures.
00057  *
00058  * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
00059  * \param assertDescription Message to log with the assert describing it.
00060  */
00061 void SDLTest_Assert(int assertCondition, const char *assertDescription, ...);
00062 
00063 /**
00064  * \brief Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters.
00065  *
00066  * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
00067  * \param assertDescription Message to log with the assert describing it.
00068  *
00069  * \returns Returns the assertCondition so it can be used to externally to break execution flow if desired.
00070  */
00071 int SDLTest_AssertCheck(int assertCondition, const char *assertDescription, ...);
00072 
00073 /**
00074  * \brief Explicitely pass without checking an assertion condition. Updates assertion counter.
00075  *
00076  * \param assertDescription Message to log with the assert describing it.
00077  */
00078 void SDLTest_AssertPass(const char *assertDescription, ...);
00079 
00080 /**
00081  * \brief Resets the assert summary counters to zero.
00082  */
00083 void SDLTest_ResetAssertSummary();
00084 
00085 /**
00086  * \brief Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR.
00087  */
00088 void SDLTest_LogAssertSummary();
00089 
00090 
00091 /**
00092  * \brief Converts the current assert summary state to a test result.
00093  *
00094  * \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT
00095  */
00096 int SDLTest_AssertSummaryToTestResult();
00097 
00098 #ifdef __cplusplus
00099 }
00100 #endif
00101 #include "close_code.h"
00102 
00103 #endif /* _SDL_test_assert_h */
00104 
00105 /* vi: set ts=4 sw=4 expandtab: */