Add mock objects for unit testing

This commit is contained in:
Thomas Klaehn 2019-07-29 16:25:35 +02:00
parent f0c3514884
commit 12cf5c9bae
2 changed files with 22 additions and 0 deletions

13
test/inc/mock_i2c.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef __MOCK_I2C_H__
#define __MOCK_I2C_H__
#include <fff.h>
DEFINE_FFF_GLOBALS;
DECLARE_FAKE_VALUE_FUNC(int, i2c_open, const struct i2c_bb *);
DECLARE_FAKE_VALUE_FUNC(int, i2c_close, const struct i2c_bb *);
DECLARE_FAKE_VALUE_FUNC(int, i2c_read, const struct i2c_bb *, uint8_t, char *, unsigned int);
DECLARE_FAKE_VALUE_FUNC(int, i2c_write, const struct i2c_bb *, uint8_t, const char *, unsigned int);
#endif

9
test/unit/mock_i2c.c Normal file
View File

@ -0,0 +1,9 @@
#include <stdint.h>
#include <mock_i2c.h>
DEFINE_FFF_GLOBALS;
DEFINE_FAKE_VALUE_FUNC(int, i2c_open, const struct i2c_bb *);
DEFINE_FAKE_VALUE_FUNC(int, i2c_close, const struct i2c_bb *);
DEFINE_FAKE_VALUE_FUNC(int, i2c_read, const struct i2c_bb *, uint8_t, char *, unsigned int);
DEFINE_FAKE_VALUE_FUNC(int, i2c_write, const struct i2c_bb *, uint8_t, const char *, unsigned int);