🛠️🐜 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.

92 lines
2.4 KiB

  1. /* See COPYING.txt for the full license governing this code. */
  2. /**
  3. * \file variators.c
  4. *
  5. * Source file for the operations that act on variators.
  6. */
  7. #include <SDL_test.h>
  8. #include "SDL_visualtest_variators.h"
  9. int
  10. SDLVisualTest_InitVariator(SDLVisualTest_Variator* variator,
  11. SDLVisualTest_SUTConfig* config,
  12. SDLVisualTest_VariatorType type,
  13. Uint64 seed)
  14. {
  15. if(!variator)
  16. {
  17. SDLTest_LogError("variator argument cannot be NULL");
  18. return 0;
  19. }
  20. if(!config)
  21. {
  22. SDLTest_LogError("config argument cannot be NULL");
  23. return 0;
  24. }
  25. variator->type = type;
  26. switch(type)
  27. {
  28. case SDL_VARIATOR_EXHAUSTIVE:
  29. return SDLVisualTest_InitExhaustiveVariator(&variator->data.exhaustive,
  30. config);
  31. break;
  32. case SDL_VARIATOR_RANDOM:
  33. return SDLVisualTest_InitRandomVariator(&variator->data.random,
  34. config, seed);
  35. break;
  36. default:
  37. SDLTest_LogError("Invalid value for variator type");
  38. return 0;
  39. }
  40. return 0;
  41. }
  42. char*
  43. SDLVisualTest_GetNextVariation(SDLVisualTest_Variator* variator)
  44. {
  45. if(!variator)
  46. {
  47. SDLTest_LogError("variator argument cannot be NULL");
  48. return NULL;
  49. }
  50. switch(variator->type)
  51. {
  52. case SDL_VARIATOR_EXHAUSTIVE:
  53. return SDLVisualTest_GetNextExhaustiveVariation(&variator->data.exhaustive);
  54. break;
  55. case SDL_VARIATOR_RANDOM:
  56. return SDLVisualTest_GetNextRandomVariation(&variator->data.random);
  57. break;
  58. default:
  59. SDLTest_LogError("Invalid value for variator type");
  60. return NULL;
  61. }
  62. return NULL;
  63. }
  64. void SDLVisualTest_FreeVariator(SDLVisualTest_Variator* variator)
  65. {
  66. if(!variator)
  67. {
  68. SDLTest_LogError("variator argument cannot be NULL");
  69. return;
  70. }
  71. switch(variator->type)
  72. {
  73. case SDL_VARIATOR_EXHAUSTIVE:
  74. SDLVisualTest_FreeExhaustiveVariator(&variator->data.exhaustive);
  75. break;
  76. case SDL_VARIATOR_RANDOM:
  77. SDLVisualTest_FreeRandomVariator(&variator->data.random);
  78. break;
  79. default:
  80. SDLTest_LogError("Invalid value for variator type");
  81. }
  82. }