39 lines
739 B
C
39 lines
739 B
C
#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);
|
|
}
|