gpio_ftdi/test/unit/gpio_read.c
2019-07-18 12:08:25 +02:00

41 lines
875 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_read, value_0) {
unsigned int result;
struct gpio gpio_1;
struct ftdi_dev ftdi_obj;
ftdi_obj.status_mask = ~0x08;
gpio_1.pin = 0x08;
gpio_1.ftdi_dev = &ftdi_obj;
ASSERT_EQ(gpio_read(&gpio_1, &result), EXIT_SUCCESS);
result = ((ftdi_obj.status_mask) & (gpio_1.pin)) >> 3;
ASSERT_EQ(result, 0)
}
UTEST(gpio_read, value_1) {
unsigned int result;
struct gpio gpio_1;
struct ftdi_dev ftdi_obj;
ftdi_obj.status_mask = 0x08;
gpio_1.pin = 0x08;
gpio_1.ftdi_dev = &ftdi_obj;
ASSERT_EQ(gpio_read(&gpio_1, &result), EXIT_SUCCESS);
result = ((ftdi_obj.status_mask) & (gpio_1.pin)) >> 3;
ASSERT_EQ(result, 1)
}