Initial commit.

This commit is contained in:
Thomas Klaehn
2019-07-18 16:26:03 +02:00
commit 629d95f346
14 changed files with 7891 additions and 0 deletions

25
test/unit/i2c_close.c Normal file
View File

@@ -0,0 +1,25 @@
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#include <sys/syscall.h>
#include <utest.h>
#include <mock_ftdi.h>
#include <i2c_bb.h>
UTEST(i2c_close, success)
{
struct i2c_bb i2x_obj;
gpio_close_fake.return_val = EXIT_SUCCESS;
ASSERT_EQ(i2c_close(&i2x_obj), EXIT_SUCCESS);
}
UTEST(i2c_close, failure)
{
struct i2c_bb i2x_obj;
gpio_close_fake.return_val = EXIT_FAILURE;
ASSERT_EQ(i2c_close(&i2x_obj), EXIT_FAILURE);
}

25
test/unit/i2c_open.c Normal file
View File

@@ -0,0 +1,25 @@
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#include <sys/syscall.h>
#include <utest.h>
#include <mock_ftdi.h>
#include <i2c_bb.h>
UTEST(i2c_open, success)
{
struct i2c_bb i2x_obj;
gpio_open_fake.return_val = EXIT_SUCCESS;
ASSERT_EQ(i2c_open(&i2x_obj), EXIT_SUCCESS);
}
UTEST(i2c_open, failure)
{
struct i2c_bb i2x_obj;
gpio_open_fake.return_val = EXIT_FAILURE;
ASSERT_EQ(i2c_open(&i2x_obj), EXIT_FAILURE);
}

8
test/unit/main.c Normal file
View File

@@ -0,0 +1,8 @@
#include <stdlib.h>
#include <time.h>
#include <sys/syscall.h>
#include <utest.h>
UTEST_MAIN();

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

@@ -0,0 +1,9 @@
#include <mock_ftdi.h>
DEFINE_FFF_GLOBALS;
DEFINE_FAKE_VALUE_FUNC(int, gpio_open, const struct gpio *);
DEFINE_FAKE_VALUE_FUNC(int, gpio_close, const struct gpio *);
DEFINE_FAKE_VALUE_FUNC(int, gpio_read, const struct gpio *, unsigned int *);
DEFINE_FAKE_VALUE_FUNC(int, gpio_write, const struct gpio *, unsigned int);
DEFINE_FAKE_VALUE_FUNC(int, gpio_toggle, const struct gpio *);