gpio_ftdi/test/unit/gpio_toggle.c

39 lines
739 B
C
Raw Permalink Normal View History

2019-07-16 14:40:42 +00:00
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#include <sys/syscall.h>
#include <utest.h>
#include <mock_ftdi.h>
#include <ftdi_dev.h>
#include <gpio.h>
#include <stdio.h>
UTEST(gpio_toggle, ftdi_write_data_fails) {
struct gpio gpio_1;
struct ftdi_dev ftdi_obj;
ftdi_obj.status_mask = 0;
gpio_1.pin = 0x08;
gpio_1.ftdi_dev = &ftdi_obj;
ftdi_write_data_fake.return_val = -1;
ASSERT_EQ(gpio_toggle(&gpio_1), EXIT_FAILURE);
}
UTEST(gpio_toggle, success) {
struct gpio gpio_1;
struct ftdi_dev ftdi_obj;
ftdi_obj.status_mask = 0;
gpio_1.pin = 0x08;
gpio_1.ftdi_dev = &ftdi_obj;
ftdi_write_data_fake.return_val = 0;
ASSERT_EQ(gpio_toggle(&gpio_1), EXIT_SUCCESS);
}