From 12cf5c9baece0b91d8e9c0d4984f19459a364946 Mon Sep 17 00:00:00 2001 From: Thomas Klaehn Date: Mon, 29 Jul 2019 16:25:35 +0200 Subject: [PATCH] Add mock objects for unit testing --- test/inc/mock_i2c.h | 13 +++++++++++++ test/unit/mock_i2c.c | 9 +++++++++ 2 files changed, 22 insertions(+) create mode 100644 test/inc/mock_i2c.h create mode 100644 test/unit/mock_i2c.c diff --git a/test/inc/mock_i2c.h b/test/inc/mock_i2c.h new file mode 100644 index 0000000..1c37d99 --- /dev/null +++ b/test/inc/mock_i2c.h @@ -0,0 +1,13 @@ +#ifndef __MOCK_I2C_H__ +#define __MOCK_I2C_H__ + +#include + +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 diff --git a/test/unit/mock_i2c.c b/test/unit/mock_i2c.c new file mode 100644 index 0000000..52c6879 --- /dev/null +++ b/test/unit/mock_i2c.c @@ -0,0 +1,9 @@ +#include +#include + +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);