2015-06-21 23:33:46 +08:00
|
|
|
/*
|
|
|
|
Simple DirectMedia Layer
|
2024-01-02 05:15:26 +08:00
|
|
|
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
2015-06-21 23:33:46 +08:00
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
appreciated but is not required.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2023-11-06 23:26:06 +08:00
|
|
|
* Assertion functions of SDL test framework.
|
2015-06-21 23:33:46 +08:00
|
|
|
*
|
2022-11-22 12:28:58 +08:00
|
|
|
* This code is a part of the SDL test library, not the main SDL library.
|
2015-06-21 23:33:46 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Assert API for test code and test cases
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-11-21 13:34:54 +08:00
|
|
|
#ifndef SDL_test_assert_h_
|
|
|
|
#define SDL_test_assert_h_
|
2015-06-21 23:33:46 +08:00
|
|
|
|
2024-09-01 02:27:01 +08:00
|
|
|
#include <SDL3/SDL_stdinc.h>
|
|
|
|
|
2022-12-23 00:38:59 +08:00
|
|
|
#include <SDL3/SDL_begin_code.h>
|
2015-06-21 23:33:46 +08:00
|
|
|
/* Set up for C function definitions, even when using C++ */
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2024-04-09 10:36:57 +08:00
|
|
|
/* Fails the assert. */
|
2015-06-21 23:33:46 +08:00
|
|
|
#define ASSERT_FAIL 0
|
|
|
|
|
2024-04-09 10:36:57 +08:00
|
|
|
/* Passes the assert. */
|
2015-06-21 23:33:46 +08:00
|
|
|
#define ASSERT_PASS 1
|
|
|
|
|
2024-04-09 10:36:57 +08:00
|
|
|
/*
|
2023-11-06 23:26:06 +08:00
|
|
|
* Assert that logs and break execution flow on failures.
|
2015-06-21 23:33:46 +08:00
|
|
|
*
|
|
|
|
* \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
|
|
|
|
* \param assertDescription Message to log with the assert describing it.
|
|
|
|
*/
|
2024-09-06 09:21:13 +08:00
|
|
|
void SDLCALL SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2);
|
2015-06-21 23:33:46 +08:00
|
|
|
|
2024-04-09 10:36:57 +08:00
|
|
|
/*
|
2023-11-06 23:26:06 +08:00
|
|
|
* Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters.
|
2015-06-21 23:33:46 +08:00
|
|
|
*
|
|
|
|
* \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
|
|
|
|
* \param assertDescription Message to log with the assert describing it.
|
|
|
|
*
|
2021-07-15 02:15:30 +08:00
|
|
|
* \returns the assertCondition so it can be used to externally to break execution flow if desired.
|
2015-06-21 23:33:46 +08:00
|
|
|
*/
|
2024-09-06 09:21:13 +08:00
|
|
|
int SDLCALL SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2);
|
2015-06-21 23:33:46 +08:00
|
|
|
|
2024-04-09 10:36:57 +08:00
|
|
|
/*
|
2023-11-06 23:26:06 +08:00
|
|
|
* Explicitly pass without checking an assertion condition. Updates assertion counter.
|
2015-06-21 23:33:46 +08:00
|
|
|
*
|
|
|
|
* \param assertDescription Message to log with the assert describing it.
|
|
|
|
*/
|
2024-09-06 09:21:13 +08:00
|
|
|
void SDLCALL SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(1);
|
2015-06-21 23:33:46 +08:00
|
|
|
|
2024-04-09 10:36:57 +08:00
|
|
|
/*
|
2023-11-06 23:26:06 +08:00
|
|
|
* Resets the assert summary counters to zero.
|
2015-06-21 23:33:46 +08:00
|
|
|
*/
|
2024-09-06 09:21:13 +08:00
|
|
|
void SDLCALL SDLTest_ResetAssertSummary(void);
|
2015-06-21 23:33:46 +08:00
|
|
|
|
2024-04-09 10:36:57 +08:00
|
|
|
/*
|
2023-11-06 23:26:06 +08:00
|
|
|
* Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR.
|
2015-06-21 23:33:46 +08:00
|
|
|
*/
|
2024-09-06 09:21:13 +08:00
|
|
|
void SDLCALL SDLTest_LogAssertSummary(void);
|
2015-06-21 23:33:46 +08:00
|
|
|
|
2024-04-09 10:36:57 +08:00
|
|
|
/*
|
2023-11-06 23:26:06 +08:00
|
|
|
* Converts the current assert summary state to a test result.
|
2015-06-21 23:33:46 +08:00
|
|
|
*
|
|
|
|
* \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT
|
|
|
|
*/
|
2024-09-06 09:21:13 +08:00
|
|
|
int SDLCALL SDLTest_AssertSummaryToTestResult(void);
|
2015-06-21 23:33:46 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2022-12-23 00:38:59 +08:00
|
|
|
#include <SDL3/SDL_close_code.h>
|
2015-06-21 23:33:46 +08:00
|
|
|
|
2016-11-21 13:34:54 +08:00
|
|
|
#endif /* SDL_test_assert_h_ */
|