瀏覽代碼

Update mock int types

Use consistent integer types for mocks.
feature/data-structs
TheoryOfNekomata 2 年之前
父節點
當前提交
1095a92c61
共有 5 個文件被更改,包括 28 次插入24 次删除
  1. +4
    -3
      __mocks__/SDL_joystick.mock.h
  2. +3
    -2
      __mocks__/SDL_keyboard.mock.h
  3. +9
    -8
      __mocks__/SDL_render.mock.h
  4. +1
    -1
      __mocks__/SDL_stdinc.mock.h
  5. +11
    -10
      __mocks__/minIni.mock.h

+ 4
- 3
__mocks__/SDL_joystick.mock.h 查看文件

@@ -1,20 +1,21 @@
#ifndef SDL_JOYSTICK_MOCK_H
#define SDL_JOYSTICK_MOCK_H

#include "../src/packages/game/IZ_common.h"
#include "../src/packages/test/IZ_test.h"

typedef struct _SDL_Joystick {} SDL_Joystick;

mock(SDL_JoystickOpen) SDL_Joystick* SDL_JoystickOpen(int device_index) {
mock(SDL_JoystickOpen) SDL_Joystick* SDL_JoystickOpen(i32 device_index) {
static SDL_Joystick joystick;
mock_return(SDL_JoystickOpen) &joystick;
}

mock(SDL_NumJoysticks) int SDL_NumJoysticks(void) {
mock(SDL_NumJoysticks) i32 SDL_NumJoysticks(void) {
mock_return(SDL_NumJoysticks) 1;
}

mock(SDL_JoystickInstanceID) int SDL_JoystickInstanceID(SDL_Joystick* joystick) {
mock(SDL_JoystickInstanceID) i32 SDL_JoystickInstanceID(SDL_Joystick* joystick) {
mock_return(SDL_JoystickInstanceID) 0;
}



+ 3
- 2
__mocks__/SDL_keyboard.mock.h 查看文件

@@ -1,13 +1,14 @@
#ifndef SDL_KEYBOARD_MOCK_H
#define SDL_KEYBOARD_MOCK_H

#include "../src/packages/game/IZ_common.h"
#include "../src/packages/test/IZ_test.h"

mock(SDL_GetKeyName) const char* SDL_GetKeyName(int key) {
mock(SDL_GetKeyName) const char* SDL_GetKeyName(i32 key) {
mock_return(SDL_GetKeyName) "";
}

mock(SDL_GetKeyFromName) int SDL_GetKeyFromName(const char *name) {
mock(SDL_GetKeyFromName) i32 SDL_GetKeyFromName(const char *name) {
mock_return(SDL_GetKeyFromName) 0;
}



+ 9
- 8
__mocks__/SDL_render.mock.h 查看文件

@@ -1,6 +1,7 @@
#ifndef SDL_RENDER_MOCK_H
#define SDL_RENDER_MOCK_H

#include "../src/packages/game/IZ_common.h"
#include "../src/packages/test/IZ_test.h"

typedef struct SDL_Renderer SDL_Renderer;
@@ -11,34 +12,34 @@ typedef struct SDL_FRect SDL_FRect;

mock(SDL_CreateWindow) SDL_Window* SDL_CreateWindow(
const char *title,
int x, int y, int w,
int h, unsigned int flags
i32 x, i32 y, i32 w,
i32 h, u32 flags
) {
static SDL_Window* window = (SDL_Window*) 1;
mock_return(SDL_CreateWindow) window;
}

mock(SDL_CreateRenderer) SDL_Renderer* SDL_CreateRenderer(SDL_Window* window, int index, unsigned int flags) {
mock(SDL_CreateRenderer) SDL_Renderer* SDL_CreateRenderer(SDL_Window* window, i32 index, u32 flags) {
static SDL_Renderer* renderer = (SDL_Renderer*) 1;
mock_return(SDL_CreateRenderer) renderer;
}

mock(SDL_SetRenderDrawColor) int SDL_SetRenderDrawColor(
mock(SDL_SetRenderDrawColor) i32 SDL_SetRenderDrawColor(
SDL_Renderer* renderer,
unsigned char r, unsigned char g, unsigned char b,
unsigned char a
u8 r, u8 g, u8 b,
u8 a
) {
mock_return(SDL_SetRenderDrawColor) 0;
}

mock(SDL_RenderFillRectF) int SDL_RenderFillRectF(
mock(SDL_RenderFillRectF) i32 SDL_RenderFillRectF(
SDL_Renderer* renderer,
const SDL_FRect* rect
) {
mock_return(SDL_RenderFillRectF) 0;
}

mock(SDL_RenderClear) int SDL_RenderClear(SDL_Renderer* renderer) {
mock(SDL_RenderClear) i32 SDL_RenderClear(SDL_Renderer* renderer) {
mock_return(SDL_RenderClear) 0;
}



+ 1
- 1
__mocks__/SDL_stdinc.mock.h 查看文件

@@ -1,8 +1,8 @@
#ifndef SDL_STDINC_MOCK_H
#define SDL_STDINC_MOCK_H

#include "../src/packages/test/IZ_test.h"
#include <string.h>
#include "../src/packages/test/IZ_test.h"

mock(SDL_memcpy) void* SDL_memcpy(void* dst, const void* src, size_t len) {
mock_return(SDL_memcpy) memcpy(dst, src, len);


+ 11
- 10
__mocks__/minIni.mock.h 查看文件

@@ -1,28 +1,29 @@
#ifndef MININI_MOCK_H
#define MININI_MOCK_H

#include "../src/packages/game/IZ_common.h"
#include "../src/packages/test/IZ_test.h"

mock(ini_getl) long ini_getl(const TCHAR *Section, const TCHAR *Key, long DefValue, const TCHAR *Filename) {
mock(ini_getl) long ini_getl(const char *Section, const char *Key, long DefValue, const char *Filename) {
mock_return(ini_getl) DefValue;
}

mock(ini_putl) int ini_putl(const TCHAR *Section, const TCHAR *Key, long Value, const TCHAR *Filename) {
mock(ini_putl) i32 ini_putl(const char *Section, const char *Key, long Value, const char *Filename) {
mock_return(ini_putl) 1;
}

mock(ini_gets) int ini_gets(
const TCHAR *Section,
const TCHAR *Key,
const TCHAR *DefValue,
TCHAR *Buffer,
int BufferSize,
const TCHAR *Filename
mock(ini_gets) i32 ini_gets(
const char *Section,
const char *Key,
const char *DefValue,
char *Buffer,
i32 BufferSize,
const char *Filename
) {
mock_return(ini_gets) 0;
}

mock(ini_puts) int ini_puts(const TCHAR *Section, const TCHAR *Key, const TCHAR *Value, const TCHAR *Filename) {
mock(ini_puts) i32 ini_puts(const char *Section, const char *Key, const char *Value, const char *Filename) {
mock_return(ini_puts) 1;
}



Loading…
取消
儲存