🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.2 KiB

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * \file SDL_test_assert.h
  20. *
  21. * Include file for SDL test framework.
  22. *
  23. * This code is a part of the SDL2_test library, not the main SDL library.
  24. */
  25. /*
  26. *
  27. * Assert API for test code and test cases
  28. *
  29. */
  30. #ifndef SDL_test_assert_h_
  31. #define SDL_test_assert_h_
  32. #include "begin_code.h"
  33. /* Set up for C function definitions, even when using C++ */
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. /**
  38. * \brief Fails the assert.
  39. */
  40. #define ASSERT_FAIL 0
  41. /**
  42. * \brief Passes the assert.
  43. */
  44. #define ASSERT_PASS 1
  45. /**
  46. * \brief Assert that logs and break execution flow on failures.
  47. *
  48. * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
  49. * \param assertDescription Message to log with the assert describing it.
  50. */
  51. void SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2);
  52. /**
  53. * \brief Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters.
  54. *
  55. * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
  56. * \param assertDescription Message to log with the assert describing it.
  57. *
  58. * \returns Returns the assertCondition so it can be used to externally to break execution flow if desired.
  59. */
  60. int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2);
  61. /**
  62. * \brief Explicitly pass without checking an assertion condition. Updates assertion counter.
  63. *
  64. * \param assertDescription Message to log with the assert describing it.
  65. */
  66. void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(1);
  67. /**
  68. * \brief Resets the assert summary counters to zero.
  69. */
  70. void SDLTest_ResetAssertSummary(void);
  71. /**
  72. * \brief Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR.
  73. */
  74. void SDLTest_LogAssertSummary(void);
  75. /**
  76. * \brief Converts the current assert summary state to a test result.
  77. *
  78. * \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT
  79. */
  80. int SDLTest_AssertSummaryToTestResult(void);
  81. #ifdef __cplusplus
  82. }
  83. #endif
  84. #include "close_code.h"
  85. #endif /* SDL_test_assert_h_ */
  86. /* vi: set ts=4 sw=4 expandtab: */