Browse Source

Define call count type

Use call count type to contextualize call counts.
feature/data-structs
TheoryOfNekomata 2 years ago
parent
commit
093653d1e6
1 changed files with 8 additions and 6 deletions
  1. +8
    -6
      src/packages/game-test/config/IZ_config.c

+ 8
- 6
src/packages/game-test/config/IZ_config.c View File

@@ -1,13 +1,15 @@
#include "bdd-for-c.h" #include "bdd-for-c.h"
#include "../../game/config/IZ_config.h" #include "../../game/config/IZ_config.h"


#define mock(X) static uint8_t calls_##X = 0;
#define mock_call_count_t uint8_t

#define mock(X) static mock_call_count_t calls_##X = 0;


#define mock_return(X) calls_##X += 1; return #define mock_return(X) calls_##X += 1; return


#define mock_reset(X) calls_##X = 0 #define mock_reset(X) calls_##X = 0


#define mock_calls(X) ((uint8_t) (calls_##X))
#define mock_calls(X) ((mock_call_count_t) (calls_##X))


mock(SDL_GetBasePath) char* SDL_GetBasePath() { mock(SDL_GetBasePath) char* SDL_GetBasePath() {
mock_return(SDL_GetBasePath) ""; mock_return(SDL_GetBasePath) "";
@@ -73,7 +75,7 @@ spec("config") {
"SDL_GetBasePath() not called." "SDL_GetBasePath() not called."
); );


static const int expected_calls_ini_getl =
static const mock_call_count_t expected_calls_ini_getl =
3 // video params 3 // video params
+ 1 // input params + 1 // input params
+ (12 * PLAYERS); // joystick controls + (12 * PLAYERS); // joystick controls
@@ -102,7 +104,7 @@ spec("config") {
"Default value for Input.GamepadAxisThreshold is not loaded." "Default value for Input.GamepadAxisThreshold is not loaded."
); );


static const int expected_calls_ini_gets =
static const mock_call_count_t expected_calls_ini_gets =
(16 * PLAYERS); // keyboard controls (16 * PLAYERS); // keyboard controls
check( check(
mock_calls(ini_gets) == expected_calls_ini_gets, mock_calls(ini_gets) == expected_calls_ini_gets,
@@ -111,7 +113,7 @@ spec("config") {
mock_calls(ini_gets) mock_calls(ini_gets)
); );


static const int expected_calls_SDL_GetKeyFromName =
static const mock_call_count_t expected_calls_SDL_GetKeyFromName =
(16 * PLAYERS); // keyboard controls (16 * PLAYERS); // keyboard controls
check( check(
mock_calls(SDL_GetKeyFromName) == expected_calls_SDL_GetKeyFromName, mock_calls(SDL_GetKeyFromName) == expected_calls_SDL_GetKeyFromName,
@@ -120,7 +122,7 @@ spec("config") {
mock_calls(SDL_GetKeyFromName) mock_calls(SDL_GetKeyFromName)
); );


static const int expected_calls_SDL_GetKeyName =
static const mock_call_count_t expected_calls_SDL_GetKeyName =
(16 * PLAYERS); // keyboard controls (16 * PLAYERS); // keyboard controls
check( check(
mock_calls(SDL_GetKeyName) == expected_calls_SDL_GetKeyName, mock_calls(SDL_GetKeyName) == expected_calls_SDL_GetKeyName,


Loading…
Cancel
Save