SDL_test_compare.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2025 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. * Comparison function of SDL test framework.
  20. *
  21. * This code is a part of the SDL test library, not the main SDL library.
  22. */
  23. /*
  24. Defines comparison functions (i.e. for surfaces).
  25. */
  26. #ifndef SDL_test_compare_h_
  27. #define SDL_test_compare_h_
  28. #include <SDL3/SDL.h>
  29. #include <SDL3/SDL_begin_code.h>
  30. /* Set up for C function definitions, even when using C++ */
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /**
  35. * Compares a surface and with reference image data for equality
  36. *
  37. * \param surface Surface used in comparison
  38. * \param referenceSurface Test Surface used in comparison
  39. * \param allowable_error Allowable difference (=sum of squared difference for each RGB component) in blending accuracy.
  40. *
  41. * \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ.
  42. */
  43. int SDLCALL SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error);
  44. /**
  45. * Compares 2 memory blocks for equality
  46. *
  47. * \param actual Memory used in comparison, displayed on the left
  48. * \param size_actual Size of actual in bytes
  49. * \param reference Reference memory, displayed on the right
  50. * \param size_reference Size of reference in bytes
  51. *
  52. * \returns 0 if the left and right memory block are equal, non-zero if they are non-equal.
  53. *
  54. * \since This function is available since SDL 3.2.0.
  55. */
  56. int SDLCALL SDLTest_CompareMemory(const void *actual, size_t size_actual, const void *reference, size_t size_reference);
  57. /* Ends C function definitions when using C++ */
  58. #ifdef __cplusplus
  59. }
  60. #endif
  61. #include <SDL3/SDL_close_code.h>
  62. #endif /* SDL_test_compare_h_ */